svn commit: r212190 - head/bin/sh

Jilles Tjoelker jilles at FreeBSD.org
Fri Sep 3 22:13:55 UTC 2010


Author: jilles
Date: Fri Sep  3 22:13:54 2010
New Revision: 212190
URL: http://svn.freebsd.org/changeset/base/212190

Log:
  sh: Do not use locale for determining if something is a name.
  
  This makes it impossible to use locale-specific characters in variable
  names.
  
  Names containing locale-specific characters make scripts only work with the
  correct locale setting. Also, they did not even work in many practical cases
  because multibyte character sets such as utf-8 are not supported.
  
  This also avoids weirdness if LC_CTYPE is changed in the middle of a script.

Modified:
  head/bin/sh/mksyntax.c

Modified: head/bin/sh/mksyntax.c
==============================================================================
--- head/bin/sh/mksyntax.c	Fri Sep  3 21:59:12 2010	(r212189)
+++ head/bin/sh/mksyntax.c	Fri Sep  3 22:13:54 2010	(r212190)
@@ -338,12 +338,12 @@ print(const char *name)
  */
 
 static const char *macro[] = {
-	"#define is_digit(c)\t((is_type+SYNBASE)[c] & ISDIGIT)",
+	"#define is_digit(c)\t((is_type+SYNBASE)[(int)c] & ISDIGIT)",
 	"#define is_eof(c)\t((c) == PEOF)",
-	"#define is_alpha(c)\t(((c) < CTLESC || (c) > CTLQUOTEMARK) && isalpha((unsigned char) (c)))",
-	"#define is_name(c)\t(((c) < CTLESC || (c) > CTLQUOTEMARK) && ((c) == '_' || isalpha((unsigned char) (c))))",
-	"#define is_in_name(c)\t(((c) < CTLESC || (c) > CTLQUOTEMARK) && ((c) == '_' || isalnum((unsigned char) (c))))",
-	"#define is_special(c)\t((is_type+SYNBASE)[c] & (ISSPECL|ISDIGIT))",
+	"#define is_alpha(c)\t(((c) < CTLESC || (c) > CTLQUOTEMARK) && (is_type+SYNBASE)[(int)c] & (ISUPPER|ISLOWER))",
+	"#define is_name(c)\t(((c) < CTLESC || (c) > CTLQUOTEMARK) && (is_type+SYNBASE)[(int)c] & (ISUPPER|ISLOWER|ISUNDER))",
+	"#define is_in_name(c)\t(((c) < CTLESC || (c) > CTLQUOTEMARK) && (is_type+SYNBASE)[(int)c] & (ISUPPER|ISLOWER|ISUNDER|ISDIGIT))",
+	"#define is_special(c)\t((is_type+SYNBASE)[(int)c] & (ISSPECL|ISDIGIT))",
 	NULL
 };
 


More information about the svn-src-head mailing list