svn commit: r247058 - stable/9/bin/sh
Jilles Tjoelker
jilles at FreeBSD.org
Wed Feb 20 21:57:01 UTC 2013
Author: jilles
Date: Wed Feb 20 21:57:01 2013
New Revision: 247058
URL: http://svnweb.freebsd.org/changeset/base/247058
Log:
MFC r246371: sh: Do not test for digit_contig in mksyntax.
ISO/IEC 9899:1999 (E) 5.2.1p3 guarantees that the values of the characters
0123456789 are contiguous.
The generated syntax.c and syntax.h remain the same.
Submitted by: Christoph Mallon
Modified:
stable/9/bin/sh/mksyntax.c
Directory Properties:
stable/9/bin/sh/ (props changed)
Modified: stable/9/bin/sh/mksyntax.c
==============================================================================
--- stable/9/bin/sh/mksyntax.c Wed Feb 20 21:49:52 2013 (r247057)
+++ stable/9/bin/sh/mksyntax.c Wed Feb 20 21:57:01 2013 (r247058)
@@ -107,14 +107,12 @@ static const char *syntax[513];
static int base;
static int size; /* number of values which a char variable can have */
static int nbits; /* number of bits in a character */
-static int digit_contig;/* true if digits are contiguous */
static void filltable(const char *);
static void init(void);
static void add(const char *, const char *);
static void print(const char *);
static void output_type_macros(void);
-static void digit_convert(void);
int
main(int argc __unused, char **argv __unused)
@@ -125,7 +123,6 @@ main(int argc __unused, char **argv __un
int i;
char buf[80];
int pos;
- static char digit[] = "0123456789";
/* Create output files */
if ((cfile = fopen("syntax.c", "w")) == NULL) {
@@ -158,11 +155,6 @@ main(int argc __unused, char **argv __un
base = 1;
if (sign)
base += 1 << (nbits - 1);
- digit_contig = 1;
- for (i = 0 ; i < 10 ; i++) {
- if (digit[i] != '0' + i)
- digit_contig = 0;
- }
fputs("#include <sys/cdefs.h>\n", hfile);
fputs("#include <ctype.h>\n", hfile);
@@ -249,8 +241,6 @@ main(int argc __unused, char **argv __un
add("_", "ISUNDER");
add("#?$!-*@", "ISSPECL");
print("is_type");
- if (! digit_contig)
- digit_convert();
exit(0);
}
@@ -342,12 +332,13 @@ print(const char *name)
*/
static const char *macro[] = {
- "#define is_digit(c)\t((is_type+SYNBASE)[(int)c] & ISDIGIT)",
+ "#define is_digit(c)\t((unsigned int)((c) - '0') <= 9)",
"#define is_eof(c)\t((c) == PEOF)",
"#define is_alpha(c)\t((is_type+SYNBASE)[(int)c] & (ISUPPER|ISLOWER))",
"#define is_name(c)\t((is_type+SYNBASE)[(int)c] & (ISUPPER|ISLOWER|ISUNDER))",
"#define is_in_name(c)\t((is_type+SYNBASE)[(int)c] & (ISUPPER|ISLOWER|ISUNDER|ISDIGIT))",
"#define is_special(c)\t((is_type+SYNBASE)[(int)c] & (ISSPECL|ISDIGIT))",
+ "#define digit_val(c)\t((c) - '0')",
NULL
};
@@ -356,41 +347,6 @@ output_type_macros(void)
{
const char **pp;
- if (digit_contig)
- macro[0] = "#define is_digit(c)\t((unsigned int)((c) - '0') <= 9)";
for (pp = macro ; *pp ; pp++)
fprintf(hfile, "%s\n", *pp);
- if (digit_contig)
- fputs("#define digit_val(c)\t((c) - '0')\n", hfile);
- else
- fputs("#define digit_val(c)\t(digit_value[c])\n", hfile);
-}
-
-
-
-/*
- * Output digit conversion table (if digits are not contiguous).
- */
-
-static void
-digit_convert(void)
-{
- int maxdigit;
- static char digit[] = "0123456789";
- char *p;
- int i;
-
- maxdigit = 0;
- for (p = digit ; *p ; p++)
- if (*p > maxdigit)
- maxdigit = *p;
- fputs("extern const char digit_value[];\n", hfile);
- fputs("\n\nconst char digit_value[] = {\n", cfile);
- for (i = 0 ; i <= maxdigit ; i++) {
- for (p = digit ; *p && *p != i ; p++);
- if (*p == '\0')
- p = digit;
- fprintf(cfile, " %d,\n", (int)(p - digit));
- }
- fputs("};\n", cfile);
}
More information about the svn-src-stable-9
mailing list