[dhcp-agent-commits] dhcp-agent/src dhcp-client-cache.c,1.11,1.12 dhcp-tokenizer.c,1.2,1.3
Status: Alpha
Brought to you by:
actmodern
From: <act...@us...> - 2002-12-30 03:41:55
|
Update of /cvsroot/dhcp-agent/dhcp-agent/src In directory sc8-pr-cvs1:/tmp/cvs-serv15845 Modified Files: dhcp-client-cache.c dhcp-tokenizer.c Log Message: parser now properly handles escapes; cache now escapes Index: dhcp-client-cache.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-client-cache.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** dhcp-client-cache.c 23 Dec 2002 01:21:52 -0000 1.11 --- dhcp-client-cache.c 30 Dec 2002 03:41:51 -0000 1.12 *************** *** 322,326 **** --- 322,328 ---- char *val; dhcp_option_t *opt; + stringbuffer_t *sb; + sb = stringbuffer_create(); name = get_fname_tmp(cc); fp = file_create_and_truncate_safe(name, "a"); *************** *** 353,360 **** } ! fprintf(fp, "%d=\"%s\" # %s\n", opt->tag, val, dhcp_option_printable_string_get(opt->tag)); xfree(val); } fclose(fp); return 0; --- 355,368 ---- } ! stringbuffer_clear(sb); ! stringbuffer_append(sb, val); ! stringbuffer_replace(sb, "\\", "\\\\"); ! stringbuffer_replace(sb, "\"", "\\\""); ! ! fprintf(fp, "%d=\"%s\" # %s\n", opt->tag, stringbuffer_getstring(sb), dhcp_option_printable_string_get(opt->tag)); xfree(val); } + stringbuffer_destroy(sb); fclose(fp); return 0; Index: dhcp-tokenizer.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/src/dhcp-tokenizer.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dhcp-tokenizer.c 23 Dec 2002 00:51:25 -0000 1.2 --- dhcp-tokenizer.c 30 Dec 2002 03:41:52 -0000 1.3 *************** *** 82,86 **** { if(c == '\\') ! return 0; if(isalnum(c) || ispunct(c)) --- 82,86 ---- { if(c == '\\') ! return 1; if(isalnum(c) || ispunct(c)) *************** *** 147,166 **** case '\\': - c2 = getc(tokenizer->fp); - if(c2 != '\\') { ! ungetc(c2, tokenizer->fp); if(tokenize_gobble_line(tokenizer) != TOKEN_NEWLINE) return TOKEN_ERROR; else break; ! } else ! ungetc(c2, tokenizer->fp); ! /* otherwise put it back and fall through. */ ! ungetc(c, tokenizer->fp); - /* fall through */ default: if(is_valid_string_char(c) || c == ' ' || c == '\t') --- 147,165 ---- case '\\': ! c2 = getc(tokenizer->fp); + if(c2 == '\n' || c2 == '\r' || c2 == ' ' || c2 == '\t') { if(tokenize_gobble_line(tokenizer) != TOKEN_NEWLINE) return TOKEN_ERROR; else break; ! } ! /* anything else means insert c2 without handling it specially*/ ! ! stringbuffer_append_c(tokenizer->data_buff, (char)c2); ! break; default: if(is_valid_string_char(c) || c == ' ' || c == '\t') *************** *** 199,214 **** case '\\': c2 = getc(tokenizer->fp); - if(c2 != '\\') { ! ungetc(c2, tokenizer->fp); - if(tokenize_gobble_line(tokenizer) != TOKEN_NEWLINE) - return TOKEN_ERROR; - else - break; - } else ungetc(c2, tokenizer->fp); - /* fall through. */ default: --- 198,212 ---- case '\\': c2 = getc(tokenizer->fp); ! if(c2 == ' ' || c2 == '\t' || c2 == '\n' || c2 == '\r') { ungetc(c2, tokenizer->fp); + return TOKEN_STRING; + } else { + + stringbuffer_append_c(tokenizer->data_buff, (char)c2); + break; + } default: |