From ddd16e87d0a152f2e09c5f9a7223972bcfdb7049 Mon Sep 17 00:00:00 2001 From: Robert Drehmel Date: Tue, 11 Jun 2002 11:27:20 +0000 Subject: [PATCH] Use the constants from for the sizes of integral C types rather than defining them ourselves. --- usr.bin/yacc/defs.h | 6 ------ usr.bin/yacc/lalr.c | 3 ++- usr.bin/yacc/lr0.c | 3 ++- usr.bin/yacc/output.c | 5 +++-- usr.bin/yacc/reader.c | 5 +++-- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/usr.bin/yacc/defs.h b/usr.bin/yacc/defs.h index 4efc8a39610c..cb8b083bff41 100644 --- a/usr.bin/yacc/defs.h +++ b/usr.bin/yacc/defs.h @@ -47,9 +47,6 @@ /* the following definitions are for the Tahoe */ /* they might have to be changed for other machines */ -/* MAXCHAR is the largest unsigned character value */ -/* MAXSHORT is the largest value of a C short */ -/* MINSHORT is the most negative value of a C short */ /* MAXTABLE is the maximum table size */ /* BITS_PER_WORD is the number of bits in a C unsigned */ /* WORDSIZE computes the number of words needed to */ @@ -58,9 +55,6 @@ /* from r (0-indexed) */ /* SETBIT sets the n-th bit starting from r */ -#define MAXCHAR 255 -#define MAXSHORT 32767 -#define MINSHORT -32768 #define MAXTABLE 32500 #define BITS_PER_WORD 32 #define WORDSIZE(n) (((n)+(BITS_PER_WORD-1))/BITS_PER_WORD) diff --git a/usr.bin/yacc/lalr.c b/usr.bin/yacc/lalr.c index 3fe94fbbd6bd..95d87de2dc1e 100644 --- a/usr.bin/yacc/lalr.c +++ b/usr.bin/yacc/lalr.c @@ -43,6 +43,7 @@ static char sccsid[] = "@(#)lalr.c 5.3 (Berkeley) 6/1/90"; #include __FBSDID("$FreeBSD$"); +#include #include #include "defs.h" @@ -252,7 +253,7 @@ set_goto_map() if (ISTOKEN(symbol)) break; - if (ngotos == MAXSHORT) + if (ngotos == SHRT_MAX) fatal("too many gotos"); ngotos++; diff --git a/usr.bin/yacc/lr0.c b/usr.bin/yacc/lr0.c index efeaed236f27..cd8d1a1e624e 100644 --- a/usr.bin/yacc/lr0.c +++ b/usr.bin/yacc/lr0.c @@ -43,6 +43,7 @@ static char sccsid[] = "@(#)lr0.c 5.3 (Berkeley) 1/20/91"; #include __FBSDID("$FreeBSD$"); +#include #include #include "defs.h" @@ -358,7 +359,7 @@ int symbol; fprintf(stderr, "Entering new_state(%d)\n", symbol); #endif - if (nstates >= MAXSHORT) + if (nstates >= SHRT_MAX) fatal("too many states"); isp1 = kernel_base[symbol]; diff --git a/usr.bin/yacc/output.c b/usr.bin/yacc/output.c index 835f21e7fad4..b0b520a7e30d 100644 --- a/usr.bin/yacc/output.c +++ b/usr.bin/yacc/output.c @@ -43,6 +43,7 @@ static char sccsid[] = "@(#)output.c 5.7 (Berkeley) 5/24/93"; #include __FBSDID("$FreeBSD$"); +#include #include #include #include "defs.h" @@ -331,7 +332,7 @@ token_actions() { froms[i] = r = NEW2(shiftcount, short); tos[i] = s = NEW2(shiftcount, short); - min = MAXSHORT; + min = SHRT_MAX; max = 0; for (j = 0; j < ntokens; ++j) { @@ -351,7 +352,7 @@ token_actions() { froms[nstates+i] = r = NEW2(reducecount, short); tos[nstates+i] = s = NEW2(reducecount, short); - min = MAXSHORT; + min = SHRT_MAX; max = 0; for (j = 0; j < ntokens; ++j) { diff --git a/usr.bin/yacc/reader.c b/usr.bin/yacc/reader.c index 5beb19990b19..3e01e8f0c91a 100644 --- a/usr.bin/yacc/reader.c +++ b/usr.bin/yacc/reader.c @@ -43,6 +43,7 @@ static char sccsid[] = "@(#)reader.c 5.7 (Berkeley) 1/20/91"; #include __FBSDID("$FreeBSD$"); +#include #include #include #include "defs.h" @@ -720,7 +721,7 @@ get_literal() ++cptr; } } - if (n > MAXCHAR) illegal_character(c_cptr); + if (n > UCHAR_MAX) illegal_character(c_cptr); c = n; break; @@ -736,7 +737,7 @@ get_literal() if (i < 0 || i >= 16) break; ++cptr; n = (n << 4) + i; - if (n > MAXCHAR) illegal_character(c_cptr); + if (n > UCHAR_MAX) illegal_character(c_cptr); } c = n; break;