#include <portable.h>
+#include <stdio.h>
+
#include "rewrite-int.h"
static int
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 ) {
*argc = cnt;
return 1;
}
- for ( p++; isspace( p[ 0 ] ); p++ );
+ for ( p++; isspace( (unsigned char) p[ 0 ] ); p++ );
begin = p;
p--;
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;
return 1;
}
- for ( p++; isspace( p[ 0 ] ); p++ );
+ for ( p++; isspace( (unsigned char) p[ 0 ] ); p++ );
begin = p;
p--;
}
}
int
-read_rewrite(
+rewrite_read(
FILE *fin,
struct rewrite_info *info
)