]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
A hack to support array types in Squid's Config structure. Mostly this
authorwessels <>
Fri, 5 Jan 2001 02:05:28 +0000 (02:05 +0000)
committerwessels <>
Fri, 5 Jan 2001 02:05:28 +0000 (02:05 +0000)
is to eliminate compiler warnings.  The compiler wants us to write
   parse_bar(&Config.bar[0]);
rather than
   parse_bar(&Config.bar);

src/cf_gen.cc

index 6353701ad78d8482664cfd56d7dc9336bc119ad4..2eb55468f55445b04f4993f794d2a634939ff38c 100644 (file)
@@ -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");
     }