6502: cc65 doesn't understand 0 sized struct terminal arrays
authorAlan Cox <alan@linux.intel.com>
Wed, 22 Nov 2017 17:51:52 +0000 (17:51 +0000)
committerAlan Cox <alan@linux.intel.com>
Wed, 22 Nov 2017 17:51:52 +0000 (17:51 +0000)
Work around it the 'traditional' way

Applications/MWC/cmd/deroff.c
Applications/MWC/cmd/tar.c

index 6c2b8e8..a41847d 100644 (file)
@@ -20,9 +20,10 @@ char **flist;                        /* list of files to open */
 
 typedef struct FNAME {
        struct FNAME *fn_next;
-       char fn_name[0];
 } FNAME;
 
+#define FN_NAME(x)     ((char *)((x) + 1))
+
 FNAME *fnames;
 
 char line[NLINE];
@@ -48,7 +49,7 @@ FILE *dopen(char *fname)
        register FILE *fp;
 
        for (fnp = fnames; fnp != NULL; fnp = fnp->fn_next)
-               if (strcmp(fnp->fn_name, fname) == 0)
+               if (strcmp(FN_NAME(fnp), fname) == 0)
                        return (NULL);
        if ((fp = fopen(fname, "r")) == NULL)
                fprintf(stderr, "deroff: cannot open `%s'\n", fname);
@@ -57,7 +58,7 @@ FILE *dopen(char *fname)
                 NULL) {
                fnp->fn_next = fnames;
                fnames = fnp;
-               strcpy(fnp->fn_name, fname);
+               strcpy(FN_NAME(fnp), fname);
        }
        return (fp);
 }
index f87b287..c59d62c 100644 (file)
@@ -888,9 +888,10 @@ typedef struct link_t {
        ino_t t_ino;
        unsigned short t_nlink;
        struct link_t *t_next;
-       char t_link[0];
 } link_t;
 
+#define T_LINK(x)      ((char *)(x + 1))
+
 #define        NHASH   64
 
 link_t *linklist[NHASH];
@@ -910,7 +911,7 @@ void filelink(dev_t dev, ino_t ino, unsigned short nlink, char *link)
                lp->t_dev = dev;
                lp->t_ino = ino;
                lp->t_nlink = nlink;
-               strcpy(lp->t_link, link);
+               strcpy(T_LINK(lp), link);
        }
 }
 
@@ -922,7 +923,7 @@ char *havelink(dev_t dev, ino_t ino, flag_t flag)
                if (lp->t_ino == ino && lp->t_dev == dev) {
                        if (flag)
                                --lp->t_nlink;
-                       return (lp->t_link);
+                       return (T_LINK(lp));
                }
        }
        return (NULL);
@@ -942,7 +943,7 @@ void misslink(void)
                                fprintf(stderr,
                                        "Tar: missed %d link%s to %s\n",
                                        nlink, nlink == 1 ? "" : "s",
-                                       lp->t_link);
+                                       T_LINK(lp));
                }
        }
 }