diff options
| author | mike_s <none@none> | 2005-06-29 12:09:32 -0700 |
|---|---|---|
| committer | mike_s <none@none> | 2005-06-29 12:09:32 -0700 |
| commit | e29394bdbeaa07ae3f4105ff3bb78c69b5639940 (patch) | |
| tree | 580cda23d6c6c9ae0e933c3a283d3191b166855f /usr/src/cmd/sgs/yacc/common | |
| parent | 56d7adc646bc459090594b76f6e6a050ca65216f (diff) | |
| download | illumos-joyent-e29394bdbeaa07ae3f4105ff3bb78c69b5639940.tar.gz | |
6273872 gcc and sgs/yacc don't get along
--HG--
rename : usr/src/cmd/sgs/yacc/common/dextern => usr/src/cmd/sgs/yacc/common/dextern.h
Diffstat (limited to 'usr/src/cmd/sgs/yacc/common')
| -rw-r--r-- | usr/src/cmd/sgs/yacc/common/dextern.h (renamed from usr/src/cmd/sgs/yacc/common/dextern) | 73 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/yacc/common/libmai.c | 11 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/yacc/common/y1.c | 52 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/yacc/common/y2.c | 55 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/yacc/common/y3.c | 39 | ||||
| -rw-r--r-- | usr/src/cmd/sgs/yacc/common/y4.c | 39 |
6 files changed, 120 insertions, 149 deletions
diff --git a/usr/src/cmd/sgs/yacc/common/dextern b/usr/src/cmd/sgs/yacc/common/dextern.h index 8bcb69afd7..844b87d551 100644 --- a/usr/src/cmd/sgs/yacc/common/dextern +++ b/usr/src/cmd/sgs/yacc/common/dextern.h @@ -20,59 +20,34 @@ * CDDL HEADER END */ /* - * Copyright 1993 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1988 AT&T */ /* All Rights Reserved */ +#ifndef _DEXTERN_H +#define _DEXTERN_H + #pragma ident "%Z%%M% %I% %E% SMI" #include <stdio.h> +#include <inttypes.h> #include <ctype.h> #include <memory.h> #include <string.h> #include <malloc.h> #include <values.h> -#ifdef __STDC__ +#include <widec.h> +#include <unistd.h> #include <stdlib.h> -#else -extern char *malloc(); -extern char *calloc(); -extern char *realloc(); -extern void exit(); -#include <sys/types.h> /* for size_t */ -#ifndef _SIZE_T -#define _SIZE_T -#if defined(_LP64) || defined(_I32LPx) -typedef unsigned long size_t; /* size of something in bytes */ -#else -typedef unsigned int size_t; /* (historical version) */ -#endif -#endif -#endif -#ifdef NOLIBW -/* - * no wide char classification macro or I/O. - * mimic these with whatever we have. - * "%ws", L'c' and L"ssss" in the source files are - * replaced by sed in makefile. - */ -#define iswascii(c) isascii((char)(c)) -#define iswspace(c) isspace((char)(c)) -#define iswalpha(c) isalpha((char)(c)) -#define iswdigit(c) isdigit((char)(c)) -#define iswxdigit(c) isxdigit((char)(c)) -#define iswupper(c) isupper((char)(c)) -#define iswlower(c) islower((char)(c)) -#define towlower(c) ((wchar_t) tolower((char)(c))) -#define getwc(f) getc(f) -#define ungetwc(c, f) ungetc((char)(c), f) -#define putwc(c, f) putc((char)(c), (f)) -#else /* !NOLIBW */ /* This is probably a SysV with MNLS extension. */ #include <wctype.h> -#endif /* !NOLIBW */ + +#ifdef __cplusplus +extern "C" { +#endif + /* MANIFEST CONSTANT DEFINITIONS */ #if u3b || u3b15 || u3b2 || vax || uts || sparc #define WORD32 @@ -181,13 +156,13 @@ typedef unsigned int size_t; /* (historical version) */ /* I/O descriptors */ -extern FILE * finput; /* input file */ -extern FILE * faction; /* file for saving actions */ -extern FILE * fdefine; /* file for #defines */ -extern FILE * ftable; /* y.tab.c file */ -extern FILE * ftemp; /* tempfile to pass 2 */ -extern FILE * fdebug; /* tempfile for two debugging info arrays */ -extern FILE * foutput; /* y.output file */ +extern FILE *finput; /* input file */ +extern FILE *faction; /* file for saving actions */ +extern FILE *fdefine; /* file for #defines */ +extern FILE *ftable; /* y.tab.c file */ +extern FILE *ftemp; /* tempfile to pass 2 */ +extern FILE *fdebug; /* tempfile for two debugging info arrays */ +extern FILE *foutput; /* y.output file */ /* structure declarations */ @@ -298,7 +273,7 @@ extern int zzsrconf; /* define external functions */ -extern void setup(int, char * []); +extern void setup(int, char *[]); extern void closure(int); extern void output(void); extern void aryfil(int *, int, int); @@ -313,7 +288,7 @@ extern wchar_t *symnam(int); extern wchar_t *writem(int *); extern void exp_mem(int); extern void exp_act(int **); -extern apack(int *, int); +extern int apack(int *, int); extern int state(int); extern void fprintf3(FILE *, const char *, const wchar_t *, const char *, ...); extern void error3(const char *, const wchar_t *, const char *, ...); @@ -352,3 +327,9 @@ extern char *parser; #ifndef PARSER #define PARSER "/usr/ccs/lib/yaccpar" #endif + +#ifdef __cplusplus +} +#endif + +#endif /* _DEXTERN_H */ diff --git a/usr/src/cmd/sgs/yacc/common/libmai.c b/usr/src/cmd/sgs/yacc/common/libmai.c index a648a69a24..dc089d5698 100644 --- a/usr/src/cmd/sgs/yacc/common/libmai.c +++ b/usr/src/cmd/sgs/yacc/common/libmai.c @@ -19,15 +19,15 @@ * * CDDL HEADER END */ -/* Copyright (c) 1989 AT&T */ -/* All Rights Reserved */ - /* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* Copyright (c) 1989 AT&T */ +/* All Rights Reserved */ + #pragma ident "%Z%%M% %I% %E% SMI" #include <locale.h> @@ -35,8 +35,9 @@ #pragma weak yyparse extern int yyparse(void); +/* ARGSUSED */ int -main() +main(int argc, char **argv) { setlocale(LC_ALL, ""); yyparse(); diff --git a/usr/src/cmd/sgs/yacc/common/y1.c b/usr/src/cmd/sgs/yacc/common/y1.c index 2f6fec977c..666c95ba27 100644 --- a/usr/src/cmd/sgs/yacc/common/y1.c +++ b/usr/src/cmd/sgs/yacc/common/y1.c @@ -20,7 +20,7 @@ * CDDL HEADER END */ /* - * Copyright 1990 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -29,7 +29,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" -#include "dextern" +#include "dextern.h" #include <sys/param.h> #include <sys/errno.h> #include <unistd.h> @@ -40,7 +40,7 @@ static void mktbls(void); static void others(void); static void summary(void); static wchar_t *chcopy(wchar_t *, wchar_t *); -static setunion(int *, int *); +static int setunion(int *, int *); static void prlook(LOOKSETS *); static void cpres(void); static void cpfir(void); @@ -113,9 +113,8 @@ char run_directory[MAXPATHLEN]; char current_work_directory[MAXPATHLEN]; extern int find_run_directory(char *, char *, char *, char **, char *); -main(argc, argv) -int argc; -char *argv[]; +int +main(int argc, char *argv[]) { setlocale(LC_ALL, ""); #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ @@ -140,8 +139,7 @@ char *argv[]; summary(); callopt(); others(); - exit(0); - /* NOTREACHED */ + return (0); } @@ -250,8 +248,7 @@ static void others() { extern int gen_lines; - extern int act_lines; - register c, i, j; + int c, i, j; int tmpline; /* This routine has been "stolen" from the driver */ @@ -396,7 +393,7 @@ int *pp; for (i = 0; i < isize; ++i) sarr[i] = L' '; } - for (p = pp; *p > 0; ++p) /* EMPTY */; + for (p = pp; *p > 0; ++p) /* NULL */; p = prdptr[-*p]; q = chcopy(sarr, nontrst[*p-NTBASE].name); q = chcopy(q, L" : "); @@ -440,7 +437,7 @@ int *pp; /* return a pointer to the name of symbol i */ wchar_t * -symnam(i) +symnam(int i) { wchar_t *cp; @@ -476,8 +473,10 @@ summary() (void) fprintf(foutput, "%d/%d working sets used\n", zzcwp, wsetsz); (void) fprintf(foutput, - "memory: states,etc. %d/%d, parser %d/%d\n", - mem-tracemem, new_memsize, memp-amem, new_actsize); + "memory: states,etc. %" PRIdPTR + "/%d, parser %" PRIdPTR "/%d\n", + mem-tracemem, new_memsize, + memp-amem, new_actsize); (void) fprintf(foutput, "%d/%d distinct lookahead sets\n", nlset, lsetsize); (void) fprintf(foutput, @@ -600,11 +599,11 @@ int *v, n, c; /* set a to the union of a and b */ /* return 1 if b is not a subset of a, 0 otherwise */ -static +static int setunion(a, b) -register *a, *b; +int *a, *b; { - register i, x, sub; + int i, x, sub; sub = 0; SETLOOP(i) { @@ -619,7 +618,7 @@ static void prlook(p) LOOKSETS *p; { - register j, *pp; + int j, *pp; pp = p->lset; if (pp == 0) (void) fprintf(foutput, "\tNULL"); @@ -642,9 +641,9 @@ LOOKSETS *p; static void cpres() { - register **ptrpy; + int **ptrpy; int **pyield; - register c, j, i; + int c, j, i; /* * 2/29/88 - @@ -717,7 +716,7 @@ static int indebug = 0; static void cpfir() { - register *p, **s, i, **t, ch, changes; + int *p, **s, i, **t, ch, changes; zzcwp = nnonter; NTLOOP(i) { @@ -772,7 +771,7 @@ int state(int c) { int size1, size2; - register i; + int i; ITEM *p1, *p2, *k, *l, *q1, *q2; p1 = pstate[nstate]; p2 = pstate[nstate+1]; @@ -887,7 +886,7 @@ cempty() #define EMPTY 1 #define WHOKNOWS 0 #define OK 1 - register i, *p; + int i, *p; /* * first, use the array pempty to detect productions @@ -976,7 +975,7 @@ static void stagen() { int i, j; - register c; + int c; register WSET *p, *q; /* initialize */ @@ -1042,8 +1041,9 @@ stagen() /* generate the closure of state i */ static int cldebug = 0; /* debugging flag for closure */ + void -closure(i) +closure(int i) { int c, ch, work, k; register WSET *u, *v; @@ -1177,7 +1177,7 @@ LOOKSETS *p; /* return pointer to a perminent location for the set */ int j, *w; - register *u, *v; + int *u, *v; register LOOKSETS *q; for (q = &lkst[nlset]; q-- > lkst; ) { diff --git a/usr/src/cmd/sgs/yacc/common/y2.c b/usr/src/cmd/sgs/yacc/common/y2.c index a0f450f4ce..b58f1a56cd 100644 --- a/usr/src/cmd/sgs/yacc/common/y2.c +++ b/usr/src/cmd/sgs/yacc/common/y2.c @@ -20,7 +20,7 @@ * CDDL HEADER END */ /* - * Copyright 2002 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -29,8 +29,10 @@ #pragma ident "%Z%%M% %I% %E% SMI" -#include "dextern" +#include "dextern.h" #include "sgs.h" +#include <stdio.h> + #define IDENTIFIER 257 #define MARK 258 @@ -162,11 +164,9 @@ static int gen_testing = 0; /* flag for version stamping--default turned off */ static char *v_stmp = "n"; -#ifndef NOLIBW /* No wchar_t, no multibyte char handling! */ int nmbchars = 0; /* number of mb literals in mbchars */ MBCLIT *mbchars = (MBCLIT *) 0; /* array of mb literals */ int nmbcharsz = 0; /* allocated space for mbchars */ -#endif /* !NOLIBW */ void setup(argc, argv) @@ -184,10 +184,6 @@ char *argv[]; #define F_NAME_LENGTH 128 char fname[F_NAME_LENGTH+1]; - extern char *optarg; - extern int optind; - extern getopt(); - foutput = NULL; fdefine = NULL; i = 1; @@ -801,7 +797,7 @@ char *argv[]; if (ntypes && !(levprd[nprod] & ACTFLAG) && nontrst[*prdptr[nprod]-NTBASE].tvalue) { /* no explicit action, LHS has value */ - register tempty; + int tempty; tempty = prdptr[nprod][1]; if (tempty < 0) /* @@ -896,12 +892,11 @@ register wchar_t *s; } static int -defin(t, s) -register wchar_t *s; +defin(int t, wchar_t *s) { /* define s to be a terminal if t=0 or a nonterminal if t=1 */ - register val; + int val; if (t) { if (++nnonter >= nnontersz) @@ -1099,12 +1094,12 @@ defout() ndefout = ntokens+1; } -static +static int gettok() { - register i, base; + int i, base; static int peekline; /* number of '\n' seen in lookahead */ - register c, match, reserve; + int c, match, reserve; begin: reserve = 0; lineno += peekline; @@ -1273,11 +1268,11 @@ begin: return (IDENTIFIER); } -static -fdtype(t) +static int +fdtype(int t) { /* determine the type of a symbol */ - register v; + int v; if (t >= NTBASE) v = nontrst[t-NTBASE].tvalue; else @@ -1290,9 +1285,8 @@ fdtype(t) return (v); } -static -chfind(t, s) -register wchar_t *s; +static int +chfind(int t, wchar_t *s) { int i; @@ -1410,11 +1404,11 @@ cpycode() "eof before %%}")); } -static +static int skipcom() { /* skip over comments */ - register c, i = 0; /* i is the number of lines skipped */ + int c, i = 0; /* i is the number of lines skipped */ /* skipcom is called after reading a / */ @@ -1439,10 +1433,11 @@ skipcom() error(gettext( "EOF inside comment")); /* NOTREACHED */ + return (0); } static void -cpyact(offset) +cpyact(int offset) { /* copy C action to the next ; or closing } */ int brac, c, match, i, t, j, s, tok, argument, m; @@ -1472,7 +1467,7 @@ swt: s = 1; tok = -1; argument = 1; - while ((c = getwc(finput)) == L' ' || c == L'\t') /* EMPTY */; + while ((c = getwc(finput)) == L' ' || c == L'\t') /* NULL */; if (c == L'<') { /* type description */ (void) ungetwc(c, finput); if (gettok() != TYPENAME) @@ -1521,10 +1516,10 @@ swt: else id_sw = 0; while ((c = getwc(finput)) == L' ' || - c == L'\t') /* EMPTY */; + c == L'\t') /* NULL */; if (c == L'#') { while ((c = getwc(finput)) == L' ' || - c == L'\t') /* EMPTY */; + c == L'\t') /* NULL */; if (iswdigit(c)) { m = 0; while (iswdigit(c)) { @@ -1697,7 +1692,7 @@ lcopy: /* * Error. Silently ignore. */ - ; + /* EMPTY */; } /* * If c has a possibility to be a @@ -2045,9 +2040,6 @@ int chlit; */ { int i; -#ifdef NOLIBW - return (chlit); /* assume always singlebyte char */ -#else /* !NOLIBW */ if (chlit < 0xff) return (chlit); /* single-byte char */ @@ -2068,7 +2060,6 @@ int chlit; mbchars[nmbchars-1].character = chlit; return (mbchars[nmbchars-1].tvalue = extval++); /* Return the newly assigned token. */ -#endif /* !NOLIBW */ } /* diff --git a/usr/src/cmd/sgs/yacc/common/y3.c b/usr/src/cmd/sgs/yacc/common/y3.c index 13cb2e88e8..6213c9fe01 100644 --- a/usr/src/cmd/sgs/yacc/common/y3.c +++ b/usr/src/cmd/sgs/yacc/common/y3.c @@ -20,7 +20,7 @@ * CDDL HEADER END */ /* - * Copyright 1990 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -29,16 +29,14 @@ #pragma ident "%Z%%M% %I% %E% SMI" -#include "dextern" +#include "dextern.h" static void go2gen(int); static void precftn(int, int, int); static void wract(int); static void wrstate(int); static void wdef(wchar_t *, int); -#ifndef NOLIBW static void wrmbchars(void); -#endif /* !NOLIBW */ /* important local variables */ static int lastred; /* number of the last reduction of a state */ int *defact; @@ -116,21 +114,21 @@ output() (void) fprintf(ftable, "\t};\n"); wdef(L"YYNPROD", nprod); -#ifndef NOLIBW if (nmbchars > 0) { wrmbchars(); } -#endif /* !NOLIBW */ } static int pkdebug = 0; +int apack(p, n) int *p; +int n; { /* pack state i from temp1 into amem */ int off; - register *pp, *qq; - int *q, *r, *rr; + int *pp, *qq; + int *q, *rr; int diff; /* @@ -142,7 +140,7 @@ int *p; q = p + n; for (pp = p, off = 0; *pp == 0 && pp <= q; ++pp, --off) - /* EMPTY */; + /* NULL */; if (pp > q) return (0); /* no actions */ p = pp; @@ -170,7 +168,7 @@ int *p; if (pkdebug && foutput != NULL) (void) fprintf(foutput, - "off = %d, k = %d\n", off, rr-amem); + "off = %d, k = %" PRIdPTR "\n", off, rr-amem); qq = rr; for (pp = p; pp <= q; ++pp, ++qq) { @@ -248,7 +246,7 @@ go2out() } static int g2debug = 0; -static void go2gen(c) +static void go2gen(int c) { /* output the gotos for nonterminal c */ int i, work, cc; @@ -306,7 +304,7 @@ static void go2gen(c) /* decide a shift/reduce conflict by precedence. */ static void -precftn(r, t, s) +precftn(int r, int t, int s) { /* @@ -347,7 +345,7 @@ precftn(r, t, s) } static void -wract(i) +wract(int i) { /* output state i */ /* temp1 has the actions, lastred the default */ @@ -427,10 +425,10 @@ wract(i) } static void -wrstate(i) +wrstate(int i) { /* writes state i */ - register j0, j1; + int j0, j1; register ITEM *pp, *qq; register WSET *u; @@ -481,8 +479,7 @@ wrstate(i) } static void -wdef(s, n) -wchar_t *s; +wdef(wchar_t *s, int n) { /* output a definition of s to the value n */ (void) fprintf(ftable, "# define %ws %d\n", s, n); @@ -493,7 +490,7 @@ warray(s, v, n) wchar_t *s; int *v, n; { - register i; + int i; (void) fprintf(ftable, "static YYCONST yytabelem %ws[]={\n", s); for (i = 0; i < n; ) { if (i % 10 == 0) @@ -516,7 +513,7 @@ hideprod() * derived by productions in levprd. */ - register i, j; + int i, j; j = 0; levprd[0] = 0; @@ -542,7 +539,6 @@ hideprod() } -#ifndef NOLIBW static int cmpmbchars(p, q) MBCLIT *p, *q; @@ -563,7 +559,7 @@ wrmbchars() "\n\tint tvalue;\n}yymbchars[YYNMBCHARS]={\n"); for (i = 0; i < nmbchars; ++i) { (void) fprintf(ftable, "\t{%#x,%d}", - mbchars[i].character, mbchars[i].tvalue); + (int)mbchars[i].character, mbchars[i].tvalue); if (i < nmbchars - 1) { /* Not the last. */ (void) fprintf(ftable, ",\n"); @@ -571,4 +567,3 @@ wrmbchars() } (void) fprintf(ftable, "\n};\n"); } -#endif /* !NOLIBW */ diff --git a/usr/src/cmd/sgs/yacc/common/y4.c b/usr/src/cmd/sgs/yacc/common/y4.c index 698d2bde30..d6e967ab26 100644 --- a/usr/src/cmd/sgs/yacc/common/y4.c +++ b/usr/src/cmd/sgs/yacc/common/y4.c @@ -20,7 +20,7 @@ * CDDL HEADER END */ /* - * Copyright 1990 Sun Microsystems, Inc. All rights reserved. + * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -29,7 +29,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" -#include "dextern" +#include "dextern.h" #define NOMORE -1000 static void gin(int); @@ -55,7 +55,7 @@ static int adb = 0; void callopt() { - register i, *p, j, k, *q; + int i, *p, j, k, *q; ggreed = (int *) malloc(sizeof (int) * size); pgo = (int *) malloc(sizeof (int) * size); @@ -184,7 +184,7 @@ callopt() if (adb > 2) { /* print a array */ for (p = amem; p <= maxa; p += 10) { - (void) fprintf(ftable, "%4d ", p-amem); + (void) fprintf(ftable, "%4" PRIdPTR " ", p-amem); for (i = 0; i < 10; ++i) (void) fprintf(ftable, "%4d ", p[i]); (void) fprintf(ftable, "\n"); @@ -197,9 +197,9 @@ callopt() } static void -gin(i) +gin(int i) { - register *r, *s, *q1, *q2; + int *r, *s, *q1, *q2; int *p; /* enter gotos on nonterminal i into array amem */ @@ -271,9 +271,9 @@ gin(i) } static void -stin(i) +stin(int i) { - register *r, n, nn, flag, j, *q1, *q2; + int *r, n, nn, flag, j, *q1, *q2; int *s; tystate[i] = 0; @@ -290,7 +290,7 @@ stin(i) flag = 0; for (r = q1; r < q2; r += 2) { s = *r + n + amem; - if ((int) s < (int) amem) + if (s < amem) goto nextn; /* * Check if action table needs to @@ -368,10 +368,11 @@ stin(i) /* NOTREACHED */ } -static nxti() +static int +nxti() { /* finds the next i */ - register i, max, maxi; + int i, max, maxi; max = 0; for (i = 1; i <= nnonter; ++i) @@ -397,7 +398,7 @@ static void osummary() { /* write summary */ - register i, *p; + int i, *p; if (foutput == NULL) return; @@ -408,10 +409,11 @@ osummary() } (void) fprintf(foutput, - "Optimizer space used: input %d/%d, output %d/%d\n", + "Optimizer space used: input %" PRIdPTR + "/%d, output %" PRIdPTR "/%d\n", optimmem-tracemem + 1, new_memsize, maxa-amem + 1, new_actsize); (void) fprintf(foutput, - "%d table entries, %d zero\n", (maxa-amem) + 1, i); + "%" PRIdPTR " table entries, %d zero\n", (maxa-amem) + 1, i); (void) fprintf(foutput, "maximum spread: %d, maximum offset: %d\n", maxspr, maxoff); @@ -423,7 +425,7 @@ aoutput() /* this version is for C */ /* write out the optimized parser */ - (void) fprintf(ftable, "# define YYLAST %d\n", maxa-amem + 1); + (void) fprintf(ftable, "# define YYLAST %" PRIdPTR "\n", maxa-amem + 1); arout(L"yyact", amem, (maxa - amem) + 1); arout(L"yypact", indgo, nstate); arout(L"yypgo", pgo, nnonter + 1); @@ -434,7 +436,7 @@ arout(s, v, n) wchar_t *s; int *v, n; { - register i; + int i; (void) fprintf(ftable, "static YYCONST yytabelem %ws[]={\n", s); for (i = 0; i < n; ) { @@ -448,9 +450,10 @@ int *v, n; } } -static gtnm() +static int +gtnm() { - register s, val, c; + int s, val, c; /* read and convert an integer from the standard input */ /* return the terminating character */ |
