diff options
author | /dev/humancontroller <devhc@example.com> | 2017-04-13 11:30:00 +0000 |
---|---|---|
committer | /dev/humancontroller <devhc@example.com> | 2017-04-15 12:11:01 +0200 |
commit | 60d92bbdcfc22c7248989ad7efb856989d299daa (patch) | |
tree | 74de9d4cb1f1a938705e13257ba136b9872b6600 /src/tools/lcc/cpp | |
parent | 1a5afab2fcd1d43e5d43160ee601fa3bfa375a76 (diff) |
update the tools to the latest revision
URL: https://github.com/darklegion/tremulous
revision: c862a5340c8de44dcc7abaff170c20c04f9340e8, equivalently f45fbef604e05144057dec8d1dbfc5d4f5a2a822
Diffstat (limited to 'src/tools/lcc/cpp')
-rw-r--r-- | src/tools/lcc/cpp/cpp.c | 12 | ||||
-rw-r--r-- | src/tools/lcc/cpp/cpp.h | 4 | ||||
-rw-r--r-- | src/tools/lcc/cpp/include.c | 7 | ||||
-rw-r--r-- | src/tools/lcc/cpp/macro.c | 11 | ||||
-rw-r--r-- | src/tools/lcc/cpp/nlist.c | 1 | ||||
-rw-r--r-- | src/tools/lcc/cpp/tokens.c | 2 | ||||
-rw-r--r-- | src/tools/lcc/cpp/unix.c | 15 |
7 files changed, 31 insertions, 21 deletions
diff --git a/src/tools/lcc/cpp/cpp.c b/src/tools/lcc/cpp/cpp.c index 6739e4d..5c0cfd7 100644 --- a/src/tools/lcc/cpp/cpp.c +++ b/src/tools/lcc/cpp/cpp.c @@ -9,7 +9,7 @@ char rcsid[] = "cpp.c - faked rcsid"; #define OUTS 16384 char outbuf[OUTS]; -char *outp = outbuf; +char *outbufp = outbuf; Source *cursource; int nerrs; struct token nltoken = { NL, 0, 0, 0, 1, (uchar*)"\n" }; @@ -51,7 +51,7 @@ process(Tokenrow *trp) for (;;) { if (trp->tp >= trp->lp) { trp->tp = trp->lp = trp->bp; - outp = outbuf; + outbufp = outbuf; anymacros |= gettokens(trp, 1); trp->tp = trp->bp; } @@ -204,9 +204,14 @@ control(Tokenrow *trp) error(WARNING, "Syntax error in #endif"); break; + case KWARNING: + trp->tp = tp+1; + error(WARNING, "#warning directive: %r", trp); + break; + case KERROR: trp->tp = tp+1; - error(WARNING, "#error directive: %r", trp); + error(ERROR, "#error directive: %r", trp); break; case KLINE: @@ -245,7 +250,6 @@ control(Tokenrow *trp) break; } setempty(trp); - return; } void * diff --git a/src/tools/lcc/cpp/cpp.h b/src/tools/lcc/cpp/cpp.h index ae855c9..ddd7502 100644 --- a/src/tools/lcc/cpp/cpp.h +++ b/src/tools/lcc/cpp/cpp.h @@ -24,7 +24,7 @@ enum toktype { END, UNCLASS, NAME, NUMBER, STRING, CCON, NL, WS, DSHARP, DSHARP1, NAME1, DEFINED, UMINUS }; enum kwtype { KIF, KIFDEF, KIFNDEF, KELIF, KELSE, KENDIF, KINCLUDE, KDEFINE, - KUNDEF, KLINE, KERROR, KPRAGMA, KDEFINED, + KUNDEF, KLINE, KWARNING, KERROR, KPRAGMA, KDEFINED, KLINENO, KFILE, KDATE, KTIME, KSTDC, KEVAL }; #define ISDEFINED 01 /* has #defined value */ @@ -143,7 +143,7 @@ void setobjname(char *); char *basepath( char *fname ); -extern char *outp; +extern char *outbufp; extern Token nltoken; extern Source *cursource; extern char *curtime; diff --git a/src/tools/lcc/cpp/include.c b/src/tools/lcc/cpp/include.c index 1bb8847..5ecd8b3 100644 --- a/src/tools/lcc/cpp/include.c +++ b/src/tools/lcc/cpp/include.c @@ -108,7 +108,6 @@ doinclude(Tokenrow *trp) return; syntax: error(ERROR, "Syntax error in #include"); - return; } /* @@ -121,7 +120,7 @@ genline(void) static Tokenrow tr = { &ta, &ta, &ta+1, 1 }; uchar *p; - ta.t = p = (uchar*)outp; + ta.t = p = (uchar*)outbufp; strcpy((char*)p, "#line "); p += sizeof("#line ")-1; p = (uchar*)outnum((char*)p, cursource->line); @@ -134,8 +133,8 @@ genline(void) strcpy((char*)p, cursource->filename); p += strlen((char*)p); *p++ = '"'; *p++ = '\n'; - ta.len = (char*)p-outp; - outp = (char*)p; + ta.len = (char*)p-outbufp; + outbufp = (char*)p; tr.tp = tr.bp; puttokens(&tr); } diff --git a/src/tools/lcc/cpp/macro.c b/src/tools/lcc/cpp/macro.c index 49d1129..2972083 100644 --- a/src/tools/lcc/cpp/macro.c +++ b/src/tools/lcc/cpp/macro.c @@ -218,7 +218,6 @@ expand(Tokenrow *trp, Nlist *np) insertrow(trp, ntokc, &ntr); trp->tp -= rowlen(&ntr); dofree(ntr.bp); - return; } /* @@ -471,10 +470,10 @@ builtin(Tokenrow *trp, int biname) /* most are strings */ tp->type = STRING; if (tp->wslen) { - *outp++ = ' '; + *outbufp++ = ' '; tp->wslen = 1; } - op = outp; + op = outbufp; *op++ = '"'; switch (biname) { @@ -509,7 +508,7 @@ builtin(Tokenrow *trp, int biname) } if (tp->type==STRING) *op++ = '"'; - tp->t = (uchar*)outp; - tp->len = op - outp; - outp = op; + tp->t = (uchar*)outbufp; + tp->len = op - outbufp; + outbufp = op; } diff --git a/src/tools/lcc/cpp/nlist.c b/src/tools/lcc/cpp/nlist.c index d76df86..d3a8357 100644 --- a/src/tools/lcc/cpp/nlist.c +++ b/src/tools/lcc/cpp/nlist.c @@ -29,6 +29,7 @@ struct kwtab { {"define", KDEFINE, ISKW}, {"undef", KUNDEF, ISKW}, {"line", KLINE, ISKW}, + {"warning", KWARNING, ISKW}, {"error", KERROR, ISKW}, {"pragma", KPRAGMA, ISKW}, {"eval", KEVAL, ISKW}, diff --git a/src/tools/lcc/cpp/tokens.c b/src/tools/lcc/cpp/tokens.c index 147569b..3570896 100644 --- a/src/tools/lcc/cpp/tokens.c +++ b/src/tools/lcc/cpp/tokens.c @@ -267,7 +267,7 @@ peektokens(Tokenrow *trp, char *str) if (str) fprintf(stderr, "%s ", str); if (tp<trp->bp || tp>trp->lp) - fprintf(stderr, "(tp offset %d) ", tp-trp->bp); + fprintf(stderr, "(tp offset %ld) ", (long int) (tp - trp->bp)); for (tp=trp->bp; tp<trp->lp && tp<trp->bp+32; tp++) { if (tp->type!=NL) { int c = tp->t[tp->len]; diff --git a/src/tools/lcc/cpp/unix.c b/src/tools/lcc/cpp/unix.c index 17986d8..75e5b6d 100644 --- a/src/tools/lcc/cpp/unix.c +++ b/src/tools/lcc/cpp/unix.c @@ -2,6 +2,7 @@ #include <stddef.h> #include <stdlib.h> #include <string.h> +#include <sys/stat.h> #include "cpp.h" extern int lcc_getopt(int, char *const *, const char *); @@ -66,7 +67,12 @@ setup(int argc, char **argv) error(FATAL, "Can't open input file %s", fp); } if (optind+1<argc) { - int fdo = creat(argv[optind+1], 0666); + int fdo; +#ifdef WIN32 + fdo = creat(argv[optind+1], _S_IREAD | _S_IWRITE); +#else + fdo = creat(argv[optind+1], 0666); +#endif if (fdo<0) error(FATAL, "Can't open output file %s", argv[optind+1]); dup2(fdo, 1); @@ -99,7 +105,8 @@ char *basepath( char *fname ) /* memmove is defined here because some vendors don't provide it at all and others do a terrible job (like calling malloc) */ // -- ouch, that hurts -- ln -#ifndef MACOS_X /* always use the system memmove() on Mac OS X. --ryan. */ +/* always use the system memmove() on Mac OS X. --ryan. */ +#if !defined(MACOS_X) && !defined(_MSC_VER) #ifdef memmove #undef memmove #endif @@ -109,7 +116,7 @@ memmove(void *dp, const void *sp, size_t n) unsigned char *cdp, *csp; if (n<=0) - return 0; + return dp; cdp = dp; csp = (unsigned char *)sp; if (cdp < csp) { @@ -123,6 +130,6 @@ memmove(void *dp, const void *sp, size_t n) *--cdp = *--csp; } while (--n); } - return 0; + return dp; } #endif |