Use the constants from <limits.h> for the sizes of integral C types

rather than defining them ourselves.
This commit is contained in:
Robert Drehmel 2002-06-11 11:27:20 +00:00
parent 7a9378e7f5
commit ddd16e87d0
5 changed files with 10 additions and 12 deletions

View File

@ -47,9 +47,6 @@
/* the following definitions are for the Tahoe */ /* the following definitions are for the Tahoe */
/* they might have to be changed for other machines */ /* 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 */ /* MAXTABLE is the maximum table size */
/* BITS_PER_WORD is the number of bits in a C unsigned */ /* BITS_PER_WORD is the number of bits in a C unsigned */
/* WORDSIZE computes the number of words needed to */ /* WORDSIZE computes the number of words needed to */
@ -58,9 +55,6 @@
/* from r (0-indexed) */ /* from r (0-indexed) */
/* SETBIT sets the n-th bit starting from r */ /* SETBIT sets the n-th bit starting from r */
#define MAXCHAR 255
#define MAXSHORT 32767
#define MINSHORT -32768
#define MAXTABLE 32500 #define MAXTABLE 32500
#define BITS_PER_WORD 32 #define BITS_PER_WORD 32
#define WORDSIZE(n) (((n)+(BITS_PER_WORD-1))/BITS_PER_WORD) #define WORDSIZE(n) (((n)+(BITS_PER_WORD-1))/BITS_PER_WORD)

View File

@ -43,6 +43,7 @@ static char sccsid[] = "@(#)lalr.c 5.3 (Berkeley) 6/1/90";
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD$"); __FBSDID("$FreeBSD$");
#include <limits.h>
#include <stdlib.h> #include <stdlib.h>
#include "defs.h" #include "defs.h"
@ -252,7 +253,7 @@ set_goto_map()
if (ISTOKEN(symbol)) break; if (ISTOKEN(symbol)) break;
if (ngotos == MAXSHORT) if (ngotos == SHRT_MAX)
fatal("too many gotos"); fatal("too many gotos");
ngotos++; ngotos++;

View File

@ -43,6 +43,7 @@ static char sccsid[] = "@(#)lr0.c 5.3 (Berkeley) 1/20/91";
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD$"); __FBSDID("$FreeBSD$");
#include <limits.h>
#include <stdlib.h> #include <stdlib.h>
#include "defs.h" #include "defs.h"
@ -358,7 +359,7 @@ int symbol;
fprintf(stderr, "Entering new_state(%d)\n", symbol); fprintf(stderr, "Entering new_state(%d)\n", symbol);
#endif #endif
if (nstates >= MAXSHORT) if (nstates >= SHRT_MAX)
fatal("too many states"); fatal("too many states");
isp1 = kernel_base[symbol]; isp1 = kernel_base[symbol];

View File

@ -43,6 +43,7 @@ static char sccsid[] = "@(#)output.c 5.7 (Berkeley) 5/24/93";
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD$"); __FBSDID("$FreeBSD$");
#include <limits.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "defs.h" #include "defs.h"
@ -331,7 +332,7 @@ token_actions()
{ {
froms[i] = r = NEW2(shiftcount, short); froms[i] = r = NEW2(shiftcount, short);
tos[i] = s = NEW2(shiftcount, short); tos[i] = s = NEW2(shiftcount, short);
min = MAXSHORT; min = SHRT_MAX;
max = 0; max = 0;
for (j = 0; j < ntokens; ++j) for (j = 0; j < ntokens; ++j)
{ {
@ -351,7 +352,7 @@ token_actions()
{ {
froms[nstates+i] = r = NEW2(reducecount, short); froms[nstates+i] = r = NEW2(reducecount, short);
tos[nstates+i] = s = NEW2(reducecount, short); tos[nstates+i] = s = NEW2(reducecount, short);
min = MAXSHORT; min = SHRT_MAX;
max = 0; max = 0;
for (j = 0; j < ntokens; ++j) for (j = 0; j < ntokens; ++j)
{ {

View File

@ -43,6 +43,7 @@ static char sccsid[] = "@(#)reader.c 5.7 (Berkeley) 1/20/91";
#include <sys/cdefs.h> #include <sys/cdefs.h>
__FBSDID("$FreeBSD$"); __FBSDID("$FreeBSD$");
#include <limits.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "defs.h" #include "defs.h"
@ -720,7 +721,7 @@ get_literal()
++cptr; ++cptr;
} }
} }
if (n > MAXCHAR) illegal_character(c_cptr); if (n > UCHAR_MAX) illegal_character(c_cptr);
c = n; c = n;
break; break;
@ -736,7 +737,7 @@ get_literal()
if (i < 0 || i >= 16) break; if (i < 0 || i >= 16) break;
++cptr; ++cptr;
n = (n << 4) + i; n = (n << 4) + i;
if (n > MAXCHAR) illegal_character(c_cptr); if (n > UCHAR_MAX) illegal_character(c_cptr);
} }
c = n; c = n;
break; break;