@@ -19,6 +19,14 @@
# Some common subroutines for use by opt[ch]-gen.awk.
+# Define some helpful character classes, for portability.
+BEGIN {
+ alpha = "abcdefghijklmnopqrstuvwxyz"
+ ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ numeric = "0123456789"
+ alnum = alpha "" ALPHA "" numeric
+}
+
# Return nonzero if FLAGS contains a flag matching REGEX.
function flag_set_p(regex, flags)
{
@@ -127,7 +135,7 @@ function static_var(name, flags)
{
if (global_state_p(flags) || !needs_state_p(flags))
return ""
- gsub ("[^A-Za-z0-9]", "_", name)
+ gsub ("[^" alnum "]", "_", name)
return "VAR_" name
}
@@ -206,7 +214,7 @@ function opt_sanitized_name(name)
{
if (name == "gdwarf+")
name = "gdwarfplus"
- gsub ("[^A-Za-z0-9]", "_", name)
+ gsub ("[^" alnum "]", "_", name)
return name
}
@@ -127,7 +127,7 @@ print ""
print "const char * const lang_names[] =\n{"
for (i = 0; i < n_langs; i++) {
macros[i] = "CL_" langs[i]
- gsub( "[^A-Za-z0-9_]", "X", macros[i] )
+ gsub( "[^" alnum "_]", "X", macros[i] )
s = substr(" ", length (macros[i]))
print " " quote langs[i] quote ","
}
@@ -172,13 +172,13 @@ n_target_int = 0;
n_target_other = 0;
for (i = 0; i < n_target_save; i++) {
- if (target_save_decl[i] ~ "^((un)?signed +)?int +[_a-zA-Z0-9]+$")
+ if (target_save_decl[i] ~ "^((un)?signed +)?int +[_" alnum "]+$")
var_target_int[n_target_int++] = target_save_decl[i];
- else if (target_save_decl[i] ~ "^((un)?signed +)?short +[_a-zA-Z0-9]+$")
+ else if (target_save_decl[i] ~ "^((un)?signed +)?short +[_" alnum "]+$")
var_target_short[n_target_short++] = target_save_decl[i];
- else if (target_save_decl[i] ~ "^((un)?signed +)?char +[_a-zA-Z0-9]+$")
+ else if (target_save_decl[i] ~ "^((un)?signed +)?char +[_ " alnum "]+$")
var_target_char[n_target_char++] = target_save_decl[i];
else
@@ -316,7 +316,7 @@ print ""
for (i = 0; i < n_langs; i++) {
macros[i] = "CL_" langs[i]
- gsub( "[^A-Za-z0-9_]", "X", macros[i] )
+ gsub( "[^" alnum "_]", "X", macros[i] )
s = substr(" ", length (macros[i]))
print "#define " macros[i] s " (1 << " i ")"
}