1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Empty lines in config files no longer cause error messages

This commit is contained in:
Klaus Schmidinger 2001-04-01 14:44:40 +02:00
parent ab626eecd3
commit eb8bd1e754
3 changed files with 47 additions and 41 deletions

View File

@ -449,4 +449,4 @@ Video Disk Recorder Revision History
of terminating with 'abort()' (which caused a core dump). of terminating with 'abort()' (which caused a core dump).
- SVDRP now also works with clients that don't do line buffering (like the - SVDRP now also works with clients that don't do line buffering (like the
Windows 'telnet'). Windows 'telnet').
- Empty lines in config files no longer cause error messages.

View File

@ -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.c 1.43 2001/02/24 13:20:18 kls Exp $ * $Id: config.c 1.44 2001/04/01 14:32:22 kls Exp $
*/ */
#include "config.h" #include "config.h"
@ -75,37 +75,39 @@ bool cKeys::Load(const char *FileName)
result = true; result = true;
while (fgets(buffer, sizeof(buffer), f) > 0) { while (fgets(buffer, sizeof(buffer), f) > 0) {
line++; line++;
char *Name = buffer; if (!isempty(buffer)) {
char *p = strpbrk(Name, " \t"); char *Name = buffer;
if (p) { char *p = strpbrk(Name, " \t");
*p = 0; // terminates 'Name' if (p) {
while (*++p && isspace(*p)) *p = 0; // terminates 'Name'
; while (*++p && isspace(*p))
if (*p) { ;
if (strcasecmp(Name, "Code") == 0) if (*p) {
code = *p; if (strcasecmp(Name, "Code") == 0)
else if (strcasecmp(Name, "Address") == 0) code = *p;
address = strtol(p, NULL, 16); else if (strcasecmp(Name, "Address") == 0)
else { address = strtol(p, NULL, 16);
for (tKey *k = keys; k->type != kNone; k++) { else {
if (strcasecmp(Name, k->name) == 0) { for (tKey *k = keys; k->type != kNone; k++) {
k->code = strtol(p, NULL, 16); if (strcasecmp(Name, k->name) == 0) {
Name = NULL; // to indicate that we found it k->code = strtol(p, NULL, 16);
Name = NULL; // to indicate that we found it
break;
}
}
if (Name) {
esyslog(LOG_ERR, "unknown key in %s, line %d\n", fileName, line);
result = false;
break; break;
} }
} }
if (Name) { }
esyslog(LOG_ERR, "unknown key in %s, line %d\n", fileName, line); continue;
result = false;
break;
}
}
} }
continue; esyslog(LOG_ERR, "error in %s, line %d\n", fileName, line);
result = false;
break;
} }
esyslog(LOG_ERR, "error in %s, line %d\n", fileName, line);
result = false;
break;
} }
fclose(f); fclose(f);
} }
@ -782,10 +784,12 @@ bool cSetup::Load(const char *FileName)
bool result = true; bool result = true;
while (fgets(buffer, sizeof(buffer), f) > 0) { while (fgets(buffer, sizeof(buffer), f) > 0) {
line++; line++;
if (*buffer != '#' && !Parse(buffer)) { if (!isempty(buffer)) {
esyslog(LOG_ERR, "error in %s, line %d\n", fileName, line); if (*buffer != '#' && !Parse(buffer)) {
result = false; esyslog(LOG_ERR, "error in %s, line %d\n", fileName, line);
break; result = false;
break;
}
} }
} }
fclose(f); fclose(f);

View File

@ -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.43 2001/03/18 16:47:00 kls Exp $ * $Id: config.h 1.44 2001/04/01 14:44:40 kls Exp $
*/ */
#ifndef __CONFIG_H #ifndef __CONFIG_H
@ -184,14 +184,16 @@ public:
result = true; result = true;
while (fgets(buffer, sizeof(buffer), f) > 0) { while (fgets(buffer, sizeof(buffer), f) > 0) {
line++; line++;
T *l = new T; if (!isempty(buffer)) {
if (l->Parse(buffer)) T *l = new T;
Add(l); if (l->Parse(buffer))
else { Add(l);
esyslog(LOG_ERR, "error in %s, line %d\n", fileName, line); else {
delete l; esyslog(LOG_ERR, "error in %s, line %d\n", fileName, line);
result = false; delete l;
break; result = false;
break;
}
} }
} }
fclose(f); fclose(f);