From owner-svn-src-head@FreeBSD.ORG Tue Feb 5 22:54:10 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 8D4004E1; Tue, 5 Feb 2013 22:54:10 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 75949DB2; Tue, 5 Feb 2013 22:54:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r15MsAgP070334; Tue, 5 Feb 2013 22:54:10 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r15MsACE070333; Tue, 5 Feb 2013 22:54:10 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201302052254.r15MsACE070333@svn.freebsd.org> From: Jilles Tjoelker Date: Tue, 5 Feb 2013 22:54:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r246371 - head/bin/sh X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Feb 2013 22:54:10 -0000 Author: jilles Date: Tue Feb 5 22:54:09 2013 New Revision: 246371 URL: http://svnweb.freebsd.org/changeset/base/246371 Log: 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: head/bin/sh/mksyntax.c Modified: head/bin/sh/mksyntax.c ============================================================================== --- head/bin/sh/mksyntax.c Tue Feb 5 20:08:33 2013 (r246370) +++ head/bin/sh/mksyntax.c Tue Feb 5 22:54:09 2013 (r246371) @@ -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 \n", hfile); @@ -248,8 +240,6 @@ main(int argc __unused, char **argv __un add("_", "ISUNDER"); add("#?$!-*@", "ISSPECL"); print("is_type"); - if (! digit_contig) - digit_convert(); exit(0); } @@ -341,12 +331,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 }; @@ -355,41 +346,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); }