From 9e419cfbc401e9b9fd45c8e854fdf5ae799261d5 Mon Sep 17 00:00:00 2001 From: "Arnold D. Robbins" Date: Tue, 11 Jul 2017 08:17:14 +0300 Subject: Some cleanup about checking letters and identifiers. --- awkgram.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'awkgram.c') diff --git a/awkgram.c b/awkgram.c index 82ac3589..db295267 100644 --- a/awkgram.c +++ b/awkgram.c @@ -6506,7 +6506,7 @@ retry: } } - if (c != '_' && ! is_alpha(c)) { + if (! is_letter(c)) { yyerror(_("invalid char '%c' in expression"), c); return lasttok = LEX_EOF; } @@ -8728,6 +8728,18 @@ is_alnum(int c) } +/* + * is_letter --- function to check letters + * isalpha() isn't good enough since it can look at the locale. + * Underscore counts as a letter in awk identifiers + */ + +bool +is_letter(int c) +{ + return (is_alpha(c) || c == '_'); +} + /* is_identchar --- return true if c can be in an identifier */ bool -- cgit v1.2.3