From 1338a264d57ad5f74ce6f8283966020a8e978d2e Mon Sep 17 00:00:00 2001 From: reinelt Date: Sat, 26 Jun 2004 09:27:21 +0000 Subject: [lcd4linux @ 2004-06-26 09:27:20 by reinelt] added '-W' to CFLAGS changed all C++ comments to C ones ('//' => '/* */') cleaned up a lot of signed/unsigned mistakes git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@480 3ae390bd-cb1e-0410-b409-cd5a39f66f1f --- cfg.c | 94 ++++++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 50 insertions(+), 44 deletions(-) (limited to 'cfg.c') diff --git a/cfg.c b/cfg.c index 4a9ebea..67ac5b7 100644 --- a/cfg.c +++ b/cfg.c @@ -1,4 +1,4 @@ -/* $Id: cfg.c,v 1.40 2004/06/20 10:09:52 reinelt Exp $^ +/* $Id: cfg.c,v 1.41 2004/06/26 09:27:20 reinelt Exp $^ * * config file stuff * @@ -23,6 +23,12 @@ * * * $Log: cfg.c,v $ + * Revision 1.41 2004/06/26 09:27:20 reinelt + * + * added '-W' to CFLAGS + * changed all C++ comments to C ones ('//' => '/* */') + * cleaned up a lot of signed/unsigned mistakes + * * Revision 1.40 2004/06/20 10:09:52 reinelt * * 'const'ified the whole source @@ -282,7 +288,7 @@ static ENTRY *Config=NULL; static int nConfig=0; -// bsearch compare function for config entries +/* bsearch compare function for config entries */ static int c_lookup (const void *a, const void *b) { char *key=(char*)a; @@ -292,7 +298,7 @@ static int c_lookup (const void *a, const void *b) } -// qsort compare function for variables +/* qsort compare function for variables */ static int c_sort (const void *a, const void *b) { ENTRY *ea=(ENTRY*)a; @@ -302,7 +308,7 @@ static int c_sort (const void *a, const void *b) } -// remove leading and trailing whitespace +/* remove leading and trailing whitespace */ static char *strip (char *s, const int strip_comments) { char *p; @@ -321,7 +327,7 @@ static char *strip (char *s, const int strip_comments) } -// unquote a string +/* unquote a string */ static char *dequote (char *string) { int quote=0; @@ -358,16 +364,16 @@ static char *dequote (char *string) } -// which if a string contains only valid chars -// i.e. start with a char and contains chars and nums +/* which if a string contains only valid chars */ +/* i.e. start with a char and contains chars and nums */ static int validchars (const char *string) { const char *c; for (c=string; *c; c++) { - // first and following chars + /* first and following chars */ if ((*c>='A' && *c<='Z') || (*c>='a' && *c<='z') || (*c=='_')) continue; - // only following chars + /* only following chars */ if ((c>string) && ((*c>='0' && *c<='9') || (*c=='.') || (*c=='-'))) continue; return 0; } @@ -380,18 +386,18 @@ static void cfg_add (const char *section, const char *key, const char *val, cons char *buffer; ENTRY *entry; - // allocate buffer + /* allocate buffer */ buffer=malloc(strlen(section)+strlen(key)+2); *buffer='\0'; - // prepare section.key + /* prepare section.key */ if (section!=NULL && *section!='\0') { strcpy(buffer, section); strcat(buffer, "."); } strcat (buffer, key); - // does the key already exist? + /* does the key already exist? */ entry=bsearch(buffer, Config, nConfig, sizeof(ENTRY), c_lookup); if (entry!=NULL) { @@ -439,19 +445,19 @@ char *cfg_list (const char *section) int i, len; char *key, *list; - // calculate key length + /* calculate key length */ len=strlen(section)+1; - // prepare search key + /* prepare search key */ key=malloc(len+1); strcpy (key, section); strcat (key, "."); - // start with empty string + /* start with empty string */ list=malloc(1); *list='\0'; - // search matching entries + /* search matching entries */ for (i=0; i sizeof(section)) { error ("error in config file '%s' line %d: section buffer overflow", file, lineno); error=1; @@ -727,9 +733,9 @@ static int cfg_read (const char *file) continue; } - // on section-close, remove last section name + /* on section-close, remove last section name */ if (section_close) { - // sanity check: section already empty? + /* sanity check: section already empty? */ if (*section=='\0') { error ("error in config file '%s' line %d: unmatched closing brace", file, lineno); error=1; @@ -744,12 +750,12 @@ static int cfg_read (const char *file) continue; } - // finally: add key + /* finally: add key */ cfg_add (section, key, val, 0); } - // sanity check: are the braces balanced? + /* sanity check: are the braces balanced? */ if (!error && *section!='\0') { error ("error in config file '%s' line %d: unbalanced braces", file, lineno); error=1; -- cgit v1.2.3