Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/dist/nawk cleanup some (uschar **) to (char **) casts which ...



details:   https://anonhg.NetBSD.org/src/rev/1095044a3f70
branches:  trunk
changeset: 554254:1095044a3f70
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Sun Oct 26 11:34:23 2003 +0000

description:
cleanup some (uschar **) to (char **) casts which break
strict aliasing rules, so that this builds with gcc 3.3; this was done
by changing variables & function arguments to uschar where appropriate

diffstat:

 dist/nawk/awk.h   |   4 ++--
 dist/nawk/b.c     |  20 ++++++++++----------
 dist/nawk/lex.c   |  14 +++++++-------
 dist/nawk/lib.c   |  17 +++++++++--------
 dist/nawk/proto.h |   8 ++++----
 dist/nawk/run.c   |  47 ++++++++++++++++++++++++++---------------------
 6 files changed, 58 insertions(+), 52 deletions(-)

diffs (truncated from 402 to 300 lines):

diff -r 9ee57c37a184 -r 1095044a3f70 dist/nawk/awk.h
--- a/dist/nawk/awk.h   Sun Oct 26 11:30:42 2003 +0000
+++ b/dist/nawk/awk.h   Sun Oct 26 11:34:23 2003 +0000
@@ -61,7 +61,7 @@
 extern Awkfloat *RSTART;
 extern Awkfloat *RLENGTH;
 
-extern char    *record;        /* points to $0 */
+extern uschar  *record;        /* points to $0 */
 extern int     lineno;         /* line number in awk program */
 extern int     errorflag;      /* 1 if error has occurred */
 extern int     donefld;        /* 1 if record broken into fields */
@@ -70,7 +70,7 @@
 
 extern int     dbg;
 
-extern char    *patbeg;        /* beginning of pattern matched */
+extern uschar  *patbeg;        /* beginning of pattern matched */
 extern int     patlen;         /* length of pattern matched.  set in b.c */
 
 /* Cell:  all information about a variable or constant */
diff -r 9ee57c37a184 -r 1095044a3f70 dist/nawk/b.c
--- a/dist/nawk/b.c     Sun Oct 26 11:30:42 2003 +0000
+++ b/dist/nawk/b.c     Sun Oct 26 11:34:23 2003 +0000
@@ -68,7 +68,7 @@
 static int setcnt;
 static int poscnt;
 
-char   *patbeg;
+uschar *patbeg;
 int    patlen;
 
 #define        NFA     20      /* cache this many dynamic fa's */
@@ -248,7 +248,7 @@
 
 #define isoctdigit(c) ((c) >= '0' && (c) <= '7')       /* multiple use of arg */
 
-int quoted(char **pp)  /* pick up next thing after a \\ */
+int quoted(uschar **pp)        /* pick up next thing after a \\ */
                        /* and increment *pp */
 {
        char *p = *pp;
@@ -296,20 +296,20 @@
        bp = buf;
        for (i = 0; (c = *p++) != 0; ) {
                if (c == '\\') {
-                       c = quoted((char **) &p);
+                       c = quoted(&p);
                } else if (c == '-' && i > 0 && bp[-1] != 0) {
                        if (*p != 0) {
                                c = bp[-1];
                                c2 = *p++;
                                if (c2 == '\\')
-                                       c2 = quoted((char **) &p);
+                                       c2 = quoted(&p);
                                if (c > c2) {   /* empty; ignore */
                                        bp--;
                                        i--;
                                        continue;
                                }
                                while (c < c2) {
-                                       if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, 0))
+                                       if (!adjbuf(&buf, &bufsz, bp-buf+2, 100, &bp, 0))
                                                FATAL("out of space for character class [%.10s...] 2", p);
                                        *bp++ = ++c;
                                        i++;
@@ -317,7 +317,7 @@
                                continue;
                        }
                }
-               if (!adjbuf((char **) &buf, &bufsz, bp-buf+2, 100, (char **) &bp, 0))
+               if (!adjbuf(&buf, &bufsz, bp-buf+2, 100, &bp, 0))
                        FATAL("out of space for character class [%.10s...] 3", p);
                *bp++ = c;
                i++;
@@ -483,7 +483,7 @@
        int i, k;
 
        s = f->reset ? makeinit(f,1) : f->initstat;
-       patbeg = (char *) p;
+       patbeg = p;
        patlen = -1;
        do {
                q = p;
@@ -758,7 +758,7 @@
        case ')':
                return c;
        case '\\':
-               rlxval = quoted((char **) &prestr);
+               rlxval = quoted(&prestr);
                return CHAR;
        default:
                rlxval = c;
@@ -774,7 +774,7 @@
                else
                        cflag = 0;
                n = 2 * strlen((const char *) prestr)+1;
-               if (!adjbuf((char **) &buf, &bufsz, n, n, (char **) &bp, 0))
+               if (!adjbuf(&buf, &bufsz, n, n, &bp, 0))
                        FATAL("out of space for reg expr %.10s...", lastre);
                for (; ; ) {
                        if ((c = *prestr++) == '\\') {
@@ -793,7 +793,7 @@
                                    prestr[2 + cc->cc_namelen] == ']') {
                                        prestr += cc->cc_namelen + 3;
                                        for (i = 0; i < NCHARS; i++) {
-                                               if (!adjbuf((char **) &buf, &bufsz, bp-buf+1, 100, (char **) &bp, 0))
+                                               if (!adjbuf(&buf, &bufsz, bp-buf+1, 100, &bp, 0))
                                                    FATAL("out of space for reg expr %.10s...", lastre);
                                                if (cc->cc_func(i)) {
                                                        *bp++ = i;
diff -r 9ee57c37a184 -r 1095044a3f70 dist/nawk/lex.c
--- a/dist/nawk/lex.c   Sun Oct 26 11:30:42 2003 +0000
+++ b/dist/nawk/lex.c   Sun Oct 26 11:34:23 2003 +0000
@@ -113,9 +113,9 @@
 int gettok(char **pbuf, int *psz)      /* get next input token */
 {
        int c, retc;
-       char *buf = *pbuf;
+       uschar *buf = (uschar *) *pbuf;
        int sz = *psz;
-       char *bp = buf;
+       uschar *bp = buf;
 
        c = input();
        if (c == 0)
@@ -159,7 +159,7 @@
                *bp = 0;
                strtod(buf, &rem);      /* parse the number */
                unputstr(rem);          /* put rest back for later */
-               if (rem == buf) {       /* it wasn't a valid number at all */
+               if (rem == (char*)buf){ /* it wasn't a valid number at all */
                        buf[1] = 0;     /* so return one character as token */
                        retc = buf[0];  /* character is its own type */
                } else {        /* some prefix was a number */
@@ -368,8 +368,8 @@
 int string(void)
 {
        int c, n;
-       char *s, *bp;
-       static char *buf = 0;
+       uschar *s, *bp;
+       static uschar *buf = 0;
        static int bufsz = 500;
 
        if (buf == 0 && (buf = (char *) malloc(bufsz)) == NULL)
@@ -514,9 +514,9 @@
 int regexpr(void)
 {
        int c;
-       static char *buf = 0;
+       static uschar *buf = 0;
        static int bufsz = 500;
-       char *bp;
+       uschar *bp;
 
        if (buf == 0 && (buf = (char *) malloc(bufsz)) == NULL)
                FATAL("out of space for rex expr");
diff -r 9ee57c37a184 -r 1095044a3f70 dist/nawk/lib.c
--- a/dist/nawk/lib.c   Sun Oct 26 11:30:42 2003 +0000
+++ b/dist/nawk/lib.c   Sun Oct 26 11:34:23 2003 +0000
@@ -34,7 +34,7 @@
 
 FILE   *infile = NULL;
 char   *file   = "";
-char   *record;
+uschar *record;
 int    recsize = RECSIZE;
 char   *fields;
 int    fieldssize = RECSIZE;
@@ -101,11 +101,11 @@
        infile = stdin;         /* no filenames, so use stdin */
 }
 
-int getrec(char **pbuf, int *pbufsize, int isrecord)   /* get next input record */
+int getrec(uschar **pbuf, int *pbufsize, int isrecord) /* get next input record */
 {                      /* note: cares whether buf == record */
        int c;
        static int firsttime = 1;
-       char *buf = *pbuf;
+       uschar *buf = *pbuf;
        int bufsize = *pbufsize;
 
        if (firsttime) {
@@ -177,10 +177,10 @@
        argno++;
 }
 
-int readrec(char **pbuf, int *pbufsize, FILE *inf)     /* read one record into buf */
+int readrec(uschar **pbuf, int *pbufsize, FILE *inf)   /* read one record into buf */
 {
        int sep, c;
-       char *rr, *buf = *pbuf;
+       uschar *rr, *buf = *pbuf;
        int bufsize = *pbufsize;
 
        if (strlen(*FS) >= sizeof(inputFS))
@@ -431,8 +431,8 @@
                if (nematch(pfa, rec)) {
                        pfa->initstat = 2;      /* horrible coupling to b.c */
                           dprintf( ("match %s (%d chars)\n", patbeg, patlen) );
-                       strncpy(fr, rec, patbeg-rec);
-                       fr += patbeg - rec + 1;
+                       strncpy(fr, rec, ((char*)patbeg)-rec);
+                       fr += ((char*)patbeg) - rec + 1;
                        *(fr-1) = '\0';
                        rec = patbeg + patlen;
                } else {
@@ -448,7 +448,8 @@
 void recbld(void)      /* create $0 from $1..$NF if necessary */
 {
        int i;
-       char *r, *p;
+       uschar *r;
+       char *p;
 
        if (donerec == 1)
                return;
diff -r 9ee57c37a184 -r 1095044a3f70 dist/nawk/proto.h
--- a/dist/nawk/proto.h Sun Oct 26 11:30:42 2003 +0000
+++ b/dist/nawk/proto.h Sun Oct 26 11:34:23 2003 +0000
@@ -44,7 +44,7 @@
 extern void    penter(Node *);
 extern void    freetr(Node *);
 extern int     hexstr(char **);
-extern int     quoted(char **);
+extern int     quoted(uschar **);
 extern char    *cclenter(const char *);
 extern void    overflo(const char *);
 extern void    cfoll(fa *, Node *);
@@ -118,9 +118,9 @@
 extern void    initgetrec(void);
 extern void    makefields(int, int);
 extern void    growfldtab(int n);
-extern int     getrec(char **, int *, int);
+extern int     getrec(uschar **, int *, int);
 extern void    nextfile(void);
-extern int     readrec(char **buf, int *bufsize, FILE *inf);
+extern int     readrec(uschar **buf, int *bufsize, FILE *inf);
 extern char    *getargv(int);
 extern void    setclvar(char *);
 extern void    fldbld(void);
@@ -143,7 +143,7 @@
 extern int     isclvar(const char *);
 extern int     is_number(const char *);
 
-extern int     adjbuf(char **pb, int *sz, int min, int q, char **pbp, const char *what);
+extern int     adjbuf(uschar **pb, int *sz, int min, int q, uschar **pbp, const char *what);
 extern void    run(Node *);
 extern Cell    *execute(Node *);
 extern Cell    *program(Node **, int);
diff -r 9ee57c37a184 -r 1095044a3f70 dist/nawk/run.c
--- a/dist/nawk/run.c   Sun Oct 26 11:30:42 2003 +0000
+++ b/dist/nawk/run.c   Sun Oct 26 11:34:23 2003 +0000
@@ -91,7 +91,7 @@
 Node   *curnode = NULL;        /* the node being executed, for debugging */
 
 /* buffer memory management */
-int adjbuf(char **pbuf, int *psiz, int minlen, int quantum, char **pbptr,
+int adjbuf(uschar **pbuf, int *psiz, int minlen, int quantum, uschar **pbptr,
        const char *whatrtn)
 /* pbuf:    address of pointer to buffer being managed
  * psiz:    address of buffer size variable
@@ -383,7 +383,7 @@
        Cell *r, *x;
        extern Cell **fldtab;
        FILE *fp;
-       char *buf;
+       uschar *buf;
        int bufsize = recsize;
        int mode;
 
@@ -443,7 +443,7 @@
        Cell *x, *y, *z;
        char *s;
        Node *np;
-       char *buf;
+       uschar *buf;
        int bufsz = recsize;
        int nsub = strlen(*SUBSEP);
 
@@ -482,7 +482,7 @@
 {
        Cell *x, *y;
        Node *np;
-       char *s;
+       uschar *s;
        int nsub = strlen(*SUBSEP);
 
        x = execute(a[0]);      /* Cell* for symbol table */
@@ -495,8 +495,8 @@
                x->sval = (char *) makesymtab(NSYMTAB);
        } else {
                int bufsz = recsize;
-               char *buf;
-               if ((buf = (char *) malloc(bufsz)) == NULL)
+               uschar *buf;
+               if ((buf = malloc(bufsz)) == NULL)
                        FATAL("out of memory in adelete");
                buf[0] = 0;



Home | Main Index | Thread Index | Old Index