X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibrewrite%2Fparse.c;h=42b0180ba38e7740c1db2a31270a71cbb956fcc4;hb=c0f8e30d2290b22718f3cfd6800679dfb4c253a9;hp=bf4426cebf3e329b54f393dddede7849c21e6b24;hpb=74fa239a201cd2d785fe34bdbaf6804161bdb231;p=openldap diff --git a/libraries/librewrite/parse.c b/libraries/librewrite/parse.c index bf4426cebf..42b0180ba3 100644 --- a/libraries/librewrite/parse.c +++ b/libraries/librewrite/parse.c @@ -24,6 +24,8 @@ #include +#include + #include "rewrite-int.h" static int @@ -38,14 +40,14 @@ parse_line( int in_quoted_field = 0, cnt = 0; char quote = '\0'; - for ( p = buf; isspace( p[ 0 ] ); p++ ); + for ( p = buf; isspace( (unsigned char) p[ 0 ] ); p++ ); if ( p[ 0 ] == '#' ) { return 0; } for ( begin = p; p[ 0 ] != '\0'; p++ ) { - if ( p[ 0 ] == '\\' ) { + if ( p[ 0 ] == '\\' && p[ 1 ] != '\0' ) { p++; } else if ( p[ 0 ] == '\'' || p[ 0 ] == '\"') { if ( in_quoted_field && p[ 0 ] == quote ) { @@ -57,7 +59,7 @@ parse_line( *argc = cnt; return 1; } - for ( p++; isspace( p[ 0 ] ); p++ ); + for ( p++; isspace( (unsigned char) p[ 0 ] ); p++ ); begin = p; p--; @@ -69,7 +71,7 @@ parse_line( in_quoted_field = 1 - in_quoted_field; quote = p[ 0 ]; } - } else if ( isspace( p[ 0 ] ) && !in_quoted_field ) { + } else if ( isspace( (unsigned char) p[ 0 ] ) && !in_quoted_field ) { p[ 0 ] = '\0'; argv[ cnt ] = begin; @@ -78,7 +80,7 @@ parse_line( return 1; } - for ( p++; isspace( p[ 0 ] ); p++ ); + for ( p++; isspace( (unsigned char) p[ 0 ] ); p++ ); begin = p; p--; } @@ -90,7 +92,7 @@ parse_line( } int -read_rewrite( +rewrite_read( FILE *fin, struct rewrite_info *info )