diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2005-11-04 17:18:33 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2005-11-04 17:18:33 +0100 |
commit | 92af12daac8a33db8be0b33335bd79330ced9463 (patch) | |
tree | 32416d5ef4b5f96d09905d40c076a368fd275097 | |
parent | 903e929a85945567e9433b93f03567fe2f3b98fc (diff) | |
download | vdr-92af12daac8a33db8be0b33335bd79330ced9463.tar.gz vdr-92af12daac8a33db8be0b33335bd79330ced9463.tar.bz2 |
cReadLine now dynamically allocates its buffer; changed cConfig::Load() to use cReadLine instead of a fixed buffer
-rw-r--r-- | CONTRIBUTORS | 1 | ||||
-rw-r--r-- | HISTORY | 5 | ||||
-rw-r--r-- | config.h | 15 | ||||
-rw-r--r-- | tools.c | 22 | ||||
-rw-r--r-- | tools.h | 7 |
5 files changed, 36 insertions, 14 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 39eaed5e..491a0fd2 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -857,6 +857,7 @@ Christian Jacobsen <christian.jacobsen@stageholding.de> Andreas Mair <Andreas.Mair@linogate.com> for reporting a short display of the main menu if a plugin displays its own OSD and is started through a user defined key macro + for reporting a problem with extremely long summary fields in timers Olivier Jacques <jacquesolivier@hotmail.com>) for translating OSD texts to the French language @@ -3924,3 +3924,8 @@ Video Disk Recorder Revision History Sascha Volkenandt). - Fixed a memory leak in cString::operator=() (reported by Sascha Volkenandt). - Updated the Dutch OSD texts (thanks to Maarten Wisse). +- cReadLine now dynamically allocates its buffer, so that it can handle lines + of any length. +- Changed cConfig::Load() to use cReadLine instead of a fixed buffer (thanks + to Andreas Mair for reporting a problem with extremely long summary fields + in timers). @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: config.h 1.233 2005/11/04 14:18:59 kls Exp $ + * $Id: config.h 1.234 2005/11/04 15:55:05 kls Exp $ */ #ifndef __CONFIG_H @@ -102,20 +102,21 @@ public: isyslog("loading %s", fileName); FILE *f = fopen(fileName, "r"); if (f) { + char *s; int line = 0; - char buffer[MAXPARSEBUFFER]; + cReadLine ReadLine; result = true; - while (fgets(buffer, sizeof(buffer), f) > 0) { + while ((s = ReadLine.Read(f)) != NULL) { line++; if (allowComments) { - char *p = strchr(buffer, '#'); + char *p = strchr(s, '#'); if (p) *p = 0; } - stripspace(buffer); - if (!isempty(buffer)) { + stripspace(s); + if (!isempty(s)) { T *l = new T; - if (l->Parse(buffer)) + if (l->Parse(s)) Add(l); else { esyslog("ERROR: error in %s, line %d", fileName, line); @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.c 1.102 2005/11/04 14:26:39 kls Exp $ + * $Id: tools.c 1.103 2005/11/04 16:33:18 kls Exp $ */ #include "tools.h" @@ -610,12 +610,24 @@ cString TimeString(time_t t) // --- cReadLine ------------------------------------------------------------- +cReadLine::cReadLine(void) +{ + size = 0; + buffer = NULL; +} + +cReadLine::~cReadLine() +{ + free(buffer); +} + char *cReadLine::Read(FILE *f) { - if (fgets(buffer, sizeof(buffer), f) > 0) { - int l = strlen(buffer) - 1; - if (l >= 0 && buffer[l] == '\n') - buffer[l] = 0; + int n = getline(&buffer, &size, f); + if (n > 0) { + n--; + if (buffer[n] == '\n') + buffer[n] = 0; return buffer; } return NULL; @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: tools.h 1.81 2005/10/31 12:54:36 kls Exp $ + * $Id: tools.h 1.82 2005/11/04 17:05:35 kls Exp $ */ #ifndef __TOOLS_H @@ -135,8 +135,11 @@ public: class cReadLine { private: - char buffer[MAXPARSEBUFFER]; + size_t size; + char *buffer; public: + cReadLine(void); + ~cReadLine(); char *Read(FILE *f); }; |