diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2014-07-10 15:50:25 -0700 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2014-07-10 15:50:25 -0700 |
commit | 21606db0d06b91332b1514f6662f7bc6d414e54e (patch) | |
tree | 2bff9fd5b11f4ff4ac77696d5155fdcc321abc9d /awkgram.c | |
parent | 38cc76cf9fbaa6bc7ff4af803f6a10da70cc769e (diff) | |
parent | a8fa027b743c00a80b2ca300e3b71b6770fd4866 (diff) | |
download | egawk-21606db0d06b91332b1514f6662f7bc6d414e54e.tar.gz egawk-21606db0d06b91332b1514f6662f7bc6d414e54e.tar.bz2 egawk-21606db0d06b91332b1514f6662f7bc6d414e54e.zip |
Merge branch 'gawk-4.1-stable'
Diffstat (limited to 'awkgram.c')
-rw-r--r-- | awkgram.c | 40 |
1 files changed, 34 insertions, 6 deletions
@@ -5130,6 +5130,34 @@ tokexpand() return tok; } +/* check_bad_char --- fatal if c isn't allowed in gawk source code */ + +/* + * The error message was inspired by someone who decided to put + * a physical \0 byte into the source code to see what would + * happen and then filed a bug report about it. Sigh. + */ + +static void +check_bad_char(int c) +{ + /* allow escapes. needed for autoconf. bleah. */ + switch (c) { + case '\a': + case '\b': + case '\f': + case '\n': + case '\r': + case '\t': + return; + default: + break; + } + + if (iscntrl(c) && ! isspace(c)) + fatal(_("PEBKAC error: invalid character '\\%03o' in source code"), c); +} + /* nextc --- get the next input character */ #if MBS_SUPPORT @@ -5186,8 +5214,8 @@ again: 0 : work_ring_idx + 1; cur_char_ring[work_ring_idx] = 0; } - if (check_for_bad && iscntrl(*lexptr) && ! isspace(*lexptr)) - fatal(_("PEBKAC error: invalid character '\\%03o' in source code"), *lexptr); + if (check_for_bad) + check_bad_char(*lexptr); return (int) (unsigned char) *lexptr++; } else { @@ -5195,8 +5223,8 @@ again: if (lexeof) return END_FILE; if (lexptr && lexptr < lexend) { - if (check_for_bad && iscntrl(*lexptr) && ! isspace(*lexptr)) - fatal(_("PEBKAC error: invalid character '\\%03o' in source code"), *lexptr); + if (check_for_bad) + check_bad_char(*lexptr); return ((int) (unsigned char) *lexptr++); } } while (get_src_buf()); @@ -5213,8 +5241,8 @@ nextc(bool check_for_bad) if (lexeof) return END_FILE; if (lexptr && lexptr < lexend) { - if (check_for_bad && iscntrl(*lexptr) && ! isspace(*lexptr)) - fatal(_("PEBKAC error: invalid character '\\%03o' in source code"), *lexptr); + if (check_for_bad) + check_bad_char(*lexptr); return ((int) (unsigned char) *lexptr++); } } while (get_src_buf()); |