aboutsummaryrefslogtreecommitdiffstats
path: root/awkgram.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2014-07-10 15:50:25 -0700
committerArnold D. Robbins <arnold@skeeve.com>2014-07-10 15:50:25 -0700
commit21606db0d06b91332b1514f6662f7bc6d414e54e (patch)
tree2bff9fd5b11f4ff4ac77696d5155fdcc321abc9d /awkgram.c
parent38cc76cf9fbaa6bc7ff4af803f6a10da70cc769e (diff)
parenta8fa027b743c00a80b2ca300e3b71b6770fd4866 (diff)
downloadegawk-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.c40
1 files changed, 34 insertions, 6 deletions
diff --git a/awkgram.c b/awkgram.c
index 94ca1313..711c2e37 100644
--- a/awkgram.c
+++ b/awkgram.c
@@ -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());