1
--- maradns-1.3.02/parse/Csv2_rr_wks.c 2006-10-08 16:32:42.000000000 -0700
2
+++ maradns-1.3.03/parse/Csv2_rr_wks.c 2007-02-04 19:53:08.000000000 -0800
4
-/* Copyright (c) 2004-2006 Sam Trenholme
5
+/* Copyright (c) 2004-2007 Sam Trenholme
11
/* Read the port numbers, putting them in the ports
13
+ /* Allow the tilde to end a list */
14
+ if(stream->tilde_handling == 103) {
15
+ csv2_allow_tilde(stream);
17
look = csv2_justread(stream);
19
- for(x = 0; x < 100; x++) {
20
- /* This is one of the few places where we treat a newline
21
- * differently than a space or tab; a newline (or EOF) ends
22
- * the WKS list of ports */
23
- if(look == -2 || look == '\n' || look == '\r') {
26
- /* Comments also end the WKS list of ports */
27
- else if(csv2_is_hash(look)) {
28
- process_comment(stream);
30
+ for(x = 0; x < 1000; x++) {
31
+ if(stream->tilde_handling != 103) {
32
+ /* This is one of the few places where we treat a
33
+ * newline differently than a space or tab; a newline
34
+ * (or EOF) ends the WKS list of ports */
35
+ if(look == -2 || look == '\n' || look == '\r') {
38
+ /* Comments also end the WKS list of ports */
39
+ else if(csv2_is_hash(look)) {
40
+ process_comment(stream);
43
+ } else { /* If we use the tilde as a record separator,
44
+ * no need to use hacks to determine when we
45
+ * are at the end of the record */
48
+ } else if(csv2_is_hash(look)) {
49
+ process_comment(stream);
50
+ look = csv2_read_unicode(stream);
54
/* Numbers are processed one byte at a time */
55
- else if(csv2_is_number(look)) {
56
+ if(csv2_is_number(look)) {
57
num *= 10; /* Decimal */
58
num += look - '0'; /* Random thought: It would have
59
* made hexadecimal processing
64
- /* If it's a space, tab, or comma... */
65
- else if(csv2_is_wks(look)) {
66
+ /* If it's a space, tab, or comma... (or newline
67
+ * if we use the tilde to separate records) */
68
+ else if(csv2_is_wks(look) || (stream->tilde_handling == 103
69
+ && (look == '\r' || look == '\n'))) {
70
/* Take the number we've been processing and add it
71
* to the list of ports */
72
if(portindex >= CSV2_WKS_PORTS_MAX) {
74
/* (optionally) get the size, horizontal precision, and vertical
77
- for(x = 0; x < 100; x++) {
79
+ /* Allow the tilde to end a list */
80
+ if(stream->tilde_handling == 103) {
81
+ csv2_allow_tilde(stream);
84
+ for(x = 0; x < 1000; x++) {
85
if(csv2_is_wks(look) || look == '\r' || look == '\n' ||
86
look == -2 || csv2_is_hash(look)) {
92
- if(look == -2 || look == '\n' || look == '\r') {
95
- else if(csv2_is_hash(look)) {
96
- process_comment(stream);
98
+ /* If we are not using the ~ to separate records */
99
+ if(stream->tilde_handling != 103) {
100
+ if(look == -2 || look == '\n' || look == '\r') {
103
+ else if(csv2_is_hash(look)) {
104
+ process_comment(stream);
107
+ } else { /* When we use the tilde to separate records, we
108
+ * don't need hacks to determine when we are at the
109
+ * end of a record */
112
+ } else if(csv2_is_hash(look)) {
113
+ process_comment(stream);
114
+ look = csv2_read_unicode(stream);
118
- else if(csv2_is_number(look)) {
119
+ /* Numbers are processed one character at a time */
120
+ if(csv2_is_number(look)) {
127
- else if(!csv2_is_wks(look) && look != 'm') {
129
+ /* Error if not space, 'm', or, optionally, newline
130
+ * if we're using tildes (~) to separate records */
131
+ else if(!csv2_is_wks(look) && look != 'm' &&
132
+ !(stream->tilde_handling == 103 &&
133
+ (look == '\r' || look == '\n'))) {
134
+ return 0; /* Error */
136
look = csv2_read_unicode(stream);
138
--- maradns-1.3.03/parse/Csv2_parse.c.orig 2007-02-04 19:29:19.000000000 -0800
139
+++ maradns-1.3.03/parse/Csv2_parse.c 2007-02-04 19:29:19.000000000 -0800
141
/* If this character is not OK (is not a character we're looking for)
142
* and is not a delimiter (whitespace, comment, or |), then it's an
144
- if(in != -328 && !csv2_is_delimiter(in)) {
145
+ if(in != -328 && !csv2_is_delimiter(in) && !(in == '~' &&
146
+ stream->tilde_handling == 103)) {
147
csv2_error(stream,"Unexpected character");
148
return FATAL_CSV2_READ;
152
/* Reset the count of the number of tildes we have seen */
153
csv2_reset_tilde_seen(stream);
154
+ /* If the current character is a tilde, increment the count */
156
+ stream->tilde_seen++;
160
for(x = 0; x < 10000; x++) {