mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
cReadLine now dynamically allocates its buffer; changed cConfig::Load() to use cReadLine instead of a fixed buffer
This commit is contained in:
parent
903e929a85
commit
92af12daac
@ -857,6 +857,7 @@ Christian Jacobsen <christian.jacobsen@stageholding.de>
|
|||||||
Andreas Mair <Andreas.Mair@linogate.com>
|
Andreas Mair <Andreas.Mair@linogate.com>
|
||||||
for reporting a short display of the main menu if a plugin displays its own OSD and
|
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
|
is started through a user defined key macro
|
||||||
|
for reporting a problem with extremely long summary fields in timers
|
||||||
|
|
||||||
Olivier Jacques <jacquesolivier@hotmail.com>)
|
Olivier Jacques <jacquesolivier@hotmail.com>)
|
||||||
for translating OSD texts to the French language
|
for translating OSD texts to the French language
|
||||||
|
5
HISTORY
5
HISTORY
@ -3924,3 +3924,8 @@ Video Disk Recorder Revision History
|
|||||||
Sascha Volkenandt).
|
Sascha Volkenandt).
|
||||||
- Fixed a memory leak in cString::operator=() (reported by Sascha Volkenandt).
|
- Fixed a memory leak in cString::operator=() (reported by Sascha Volkenandt).
|
||||||
- Updated the Dutch OSD texts (thanks to Maarten Wisse).
|
- 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).
|
||||||
|
15
config.h
15
config.h
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* 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
|
#ifndef __CONFIG_H
|
||||||
@ -102,20 +102,21 @@ public:
|
|||||||
isyslog("loading %s", fileName);
|
isyslog("loading %s", fileName);
|
||||||
FILE *f = fopen(fileName, "r");
|
FILE *f = fopen(fileName, "r");
|
||||||
if (f) {
|
if (f) {
|
||||||
|
char *s;
|
||||||
int line = 0;
|
int line = 0;
|
||||||
char buffer[MAXPARSEBUFFER];
|
cReadLine ReadLine;
|
||||||
result = true;
|
result = true;
|
||||||
while (fgets(buffer, sizeof(buffer), f) > 0) {
|
while ((s = ReadLine.Read(f)) != NULL) {
|
||||||
line++;
|
line++;
|
||||||
if (allowComments) {
|
if (allowComments) {
|
||||||
char *p = strchr(buffer, '#');
|
char *p = strchr(s, '#');
|
||||||
if (p)
|
if (p)
|
||||||
*p = 0;
|
*p = 0;
|
||||||
}
|
}
|
||||||
stripspace(buffer);
|
stripspace(s);
|
||||||
if (!isempty(buffer)) {
|
if (!isempty(s)) {
|
||||||
T *l = new T;
|
T *l = new T;
|
||||||
if (l->Parse(buffer))
|
if (l->Parse(s))
|
||||||
Add(l);
|
Add(l);
|
||||||
else {
|
else {
|
||||||
esyslog("ERROR: error in %s, line %d", fileName, line);
|
esyslog("ERROR: error in %s, line %d", fileName, line);
|
||||||
|
22
tools.c
22
tools.c
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* 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"
|
#include "tools.h"
|
||||||
@ -610,12 +610,24 @@ cString TimeString(time_t t)
|
|||||||
|
|
||||||
// --- cReadLine -------------------------------------------------------------
|
// --- cReadLine -------------------------------------------------------------
|
||||||
|
|
||||||
|
cReadLine::cReadLine(void)
|
||||||
|
{
|
||||||
|
size = 0;
|
||||||
|
buffer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
cReadLine::~cReadLine()
|
||||||
|
{
|
||||||
|
free(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
char *cReadLine::Read(FILE *f)
|
char *cReadLine::Read(FILE *f)
|
||||||
{
|
{
|
||||||
if (fgets(buffer, sizeof(buffer), f) > 0) {
|
int n = getline(&buffer, &size, f);
|
||||||
int l = strlen(buffer) - 1;
|
if (n > 0) {
|
||||||
if (l >= 0 && buffer[l] == '\n')
|
n--;
|
||||||
buffer[l] = 0;
|
if (buffer[n] == '\n')
|
||||||
|
buffer[n] = 0;
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
7
tools.h
7
tools.h
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* 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
|
#ifndef __TOOLS_H
|
||||||
@ -135,8 +135,11 @@ public:
|
|||||||
|
|
||||||
class cReadLine {
|
class cReadLine {
|
||||||
private:
|
private:
|
||||||
char buffer[MAXPARSEBUFFER];
|
size_t size;
|
||||||
|
char *buffer;
|
||||||
public:
|
public:
|
||||||
|
cReadLine(void);
|
||||||
|
~cReadLine();
|
||||||
char *Read(FILE *f);
|
char *Read(FILE *f);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user