distinguish between NUL chars and 0 integers

This commit is contained in:
marschap
2006-04-24 17:37:53 +00:00
parent 9d5444f95f
commit 61c80a199b
+14 -14
View File
@@ -625,16 +625,16 @@ int process_config( section ** current_section, char (*get_next_char)(), char mo
case '[': case '[':
/* It's a section name*/ /* It's a section name*/
state = ST_SECTIONNAME; state = ST_SECTIONNAME;
sectionname[0] = 0; sectionname[0] = '\0';
sectionname_pos = 0; sectionname_pos = 0;
break; break;
case 0: case '\0':
break; break;
default: default:
/* It's a keyname*/ /* It's a keyname*/
state = ST_KEYNAME; state = ST_KEYNAME;
keyname[0] = ch; keyname[0] = ch;
keyname[1] = 0; keyname[1] = '\0';
keyname_pos = 1; keyname_pos = 1;
} }
break; break;
@@ -665,13 +665,13 @@ int process_config( section ** current_section, char (*get_next_char)(), char mo
} }
state = ST_INITIAL; state = ST_INITIAL;
break; break;
case 0: case '\0':
report( RPT_WARNING, "Section name incorrectly closed on line %d of %s: %s", line_nr, source_descr, sectionname ); report( RPT_WARNING, "Section name incorrectly closed on line %d of %s: %s", line_nr, source_descr, sectionname );
break; break;
default: default:
if( sectionname_pos<MAXSECTIONNAMELENGTH ) { if( sectionname_pos < MAXSECTIONNAMELENGTH ) {
sectionname[sectionname_pos++] = ch; sectionname[sectionname_pos++] = ch;
sectionname[sectionname_pos] = 0; sectionname[sectionname_pos] = '\0';
} else { } else {
report( RPT_WARNING, "Section name too long on line %d of %s: %s", line_nr, source_descr, sectionname ); report( RPT_WARNING, "Section name too long on line %d of %s: %s", line_nr, source_descr, sectionname );
state = ST_INVALID_SECTIONNAME; state = ST_INVALID_SECTIONNAME;
@@ -688,7 +688,7 @@ int process_config( section ** current_section, char (*get_next_char)(), char mo
break; break;
case ST_KEYNAME: case ST_KEYNAME:
switch( ch ) { switch( ch ) {
case 0: case '\0':
case '\n': case '\n':
case '\r': case '\r':
case '\t': case '\t':
@@ -704,7 +704,7 @@ int process_config( section ** current_section, char (*get_next_char)(), char mo
break; break;
case '=': case '=':
state = ST_VALUE; state = ST_VALUE;
value[0] = 0; value[0] = '\0';
value_pos = 0; value_pos = 0;
break; break;
default: default:
@@ -713,7 +713,7 @@ int process_config( section ** current_section, char (*get_next_char)(), char mo
state = ST_INVALID_KEYNAME; state = ST_INVALID_KEYNAME;
} else { } else {
keyname[keyname_pos++] = ch; keyname[keyname_pos++] = ch;
keyname[keyname_pos] = 0; keyname[keyname_pos] = '\0';
} }
} }
break; break;
@@ -737,7 +737,7 @@ int process_config( section ** current_section, char (*get_next_char)(), char mo
case '"': case '"':
state = ST_QUOTEDVALUE; state = ST_QUOTEDVALUE;
break; break;
case 0: case '\0':
case '\n': case '\n':
case '\r': case '\r':
case '\t': case '\t':
@@ -756,7 +756,7 @@ int process_config( section ** current_section, char (*get_next_char)(), char mo
default: default:
if( value_pos<MAXVALUELENGTH ) { if( value_pos<MAXVALUELENGTH ) {
value[value_pos++] = ch; value[value_pos++] = ch;
value[value_pos] = 0; value[value_pos] = '\0';
} else { } else {
report( RPT_WARNING, "Value key is too long on line %d of %s, at key: %s", line_nr, source_descr, keyname ); report( RPT_WARNING, "Value key is too long on line %d of %s, at key: %s", line_nr, source_descr, keyname );
state = ST_INVALID_KEYNAME; state = ST_INVALID_KEYNAME;
@@ -774,7 +774,7 @@ int process_config( section ** current_section, char (*get_next_char)(), char mo
break; break;
case ST_QUOTEDVALUE: case ST_QUOTEDVALUE:
switch( ch ) { switch( ch ) {
case 0: case '\0':
case '\n': case '\n':
report( RPT_WARNING, "String is incorrectly terminated on line %d of %s: %s", line_nr, source_descr, keyname ); report( RPT_WARNING, "String is incorrectly terminated on line %d of %s: %s", line_nr, source_descr, keyname );
state = ST_INITIAL; state = ST_INITIAL;
@@ -800,7 +800,7 @@ int process_config( section ** current_section, char (*get_next_char)(), char mo
quote = 0; quote = 0;
} }
value[value_pos++] = ch; value[value_pos++] = ch;
value[value_pos] = 0; value[value_pos] = '\0';
} }
break; break;
case ST_INVALID_QUOTEDVALUE: case ST_INVALID_QUOTEDVALUE:
@@ -813,7 +813,7 @@ int process_config( section ** current_section, char (*get_next_char)(), char mo
} }
break; break;
} }
if( ch == 0 ) { if( ch == '\0' ) {
state = ST_END; state = ST_END;
} }
} }