the quoted_string regexp in uat_load() fails badly on "...\\", workarround in uat_save() using \x5c and \x22 (hex for \ and ")

svn path=/trunk/; revision=20706
This commit is contained in:
Luis Ontanon 2007-02-04 02:29:06 +00:00
parent a84df38651
commit 8bfa2bace4
2 changed files with 11 additions and 6 deletions

View File

@ -165,12 +165,10 @@ static void putfld(FILE* fp, void* rec, uat_field_t* f) {
for(i=0;i<fld_len;i++) {
char c = fld_ptr[i];
if (c == '"') {
fputs("\134\042",fp);
} else if (isprint(c)) {
putc(c,fp);
} else {
if (c == '"' || c == '\\' || ! isprint(c) ) {
fprintf(fp,"\\x%.2x",c);
} else {
putc(c,fp);
}
}
@ -207,6 +205,8 @@ gboolean uat_save(uat_t* uat, char** error) {
*error = NULL;
fprintf(fp,"# This file is automatically generated, DO NOT MODIFY.\n");
for ( i = 0 ; i < uat->user_data->len ; i++ ) {
void* rec = uat->user_data->data + (uat->record_size * i);
uat_field_t* f;

View File

@ -82,9 +82,14 @@
#define DUMP_FIELD(s)
#define DUMP(s)
#endif
/*
* XXX
* quoted_string below fails badly on "...\\"
* workarround in uat_save(), using /x5c and /x22
*/
%}
quoted_string \042([^\042]|\134\042)*\042
quoted_string \042([^\042]|\134\134|\134\042)*\042
binstring ([0-9a-zA-Z][0-9a-zA-Z])+
separator [ \t]*,
newline [ \t]*[\r]?\n