From: wessels <> Date: Fri, 5 Jan 2001 02:05:28 +0000 (+0000) Subject: A hack to support array types in Squid's Config structure. Mostly this X-Git-Tag: SQUID_3_0_PRE1~1701 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b3de4c9b210bf6f6b93577e9179b440f59be586d;p=thirdparty%2Fsquid.git A hack to support array types in Squid's Config structure. Mostly this is to eliminate compiler warnings. The compiler wants us to write parse_bar(&Config.bar[0]); rather than parse_bar(&Config.bar); --- diff --git a/src/cf_gen.cc b/src/cf_gen.cc index 6353701ad7..2eb55468f5 100644 --- a/src/cf_gen.cc +++ b/src/cf_gen.cc @@ -1,6 +1,6 @@ /* - * $Id: cf_gen.cc,v 1.38 2001/01/04 03:42:34 wessels Exp $ + * $Id: cf_gen.cc,v 1.39 2001/01/04 19:05:28 wessels Exp $ * * DEBUG: none Generate squid.conf and cf_parser.c * AUTHOR: Max Okumoto @@ -102,6 +102,7 @@ typedef struct Entry { char *ifdef; Line *doc; Line *nocomment; + int array_flag; struct Entry *next; } Entry; @@ -221,6 +222,11 @@ main(int argc, char *argv[]) printf("Error on line %d\n", linenum); exit(1); } + /* hack to support arrays, rather than pointers */ + if (0 == strcmp(ptr + strlen(ptr) - 2, "[]")) { + curr->array_flag = 1; + *(ptr + strlen(ptr) - 2) = '\0'; + } curr->type = xstrdup(ptr); } else if (!strncmp(buff, "IFDEF:", 6)) { if ((ptr = strtok(buff + 6, WS)) == NULL) { @@ -485,8 +491,9 @@ gen_parse(Entry * head, FILE * fp) ); } else { fprintf(fp, - "\t\tparse_%s(&%s);\n", - entry->type, entry->loc + "\t\tparse_%s(&%s%s);\n", + entry->type, entry->loc, + entry->array_flag ? "[0]" : "" ); } if (entry->ifdef) @@ -545,7 +552,9 @@ gen_free(Entry * head, FILE * fp) continue; if (entry->ifdef) fprintf(fp, "#if %s\n", entry->ifdef); - fprintf(fp, "\tfree_%s(&%s);\n", entry->type, entry->loc); + fprintf(fp, "\tfree_%s(&%s%s);\n", + entry->type, entry->loc, + entry->array_flag ? "[0]" : ""); if (entry->ifdef) fprintf(fp, "#endif\n"); }