summaryrefslogtreecommitdiff
path: root/usr.bin/awk/b.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2024-08-03 21:12:17 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2024-08-03 21:12:17 +0000
commit237c0548fd402837033a6828c1e7b68d77ede4ec (patch)
treec03b804849f4746ece21e733fcb8c6b47cab1573 /usr.bin/awk/b.c
parentabf92e24cbe1b61b1dac99a2a04228b07a0d2833 (diff)
Update awk to the July 28, 2024 version.
* Fixed readcsvrec resize segfault when reading csv records longer than 8k. * Rewrite if-else chain in quoted as a switch.
Diffstat (limited to 'usr.bin/awk/b.c')
-rw-r--r--usr.bin/awk/b.c53
1 files changed, 33 insertions, 20 deletions
diff --git a/usr.bin/awk/b.c b/usr.bin/awk/b.c
index 53a36d27b63..8b5ef83b272 100644
--- a/usr.bin/awk/b.c
+++ b/usr.bin/awk/b.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: b.c,v 1.53 2024/06/03 00:55:05 millert Exp $ */
+/* $OpenBSD: b.c,v 1.54 2024/08/03 21:12:16 millert Exp $ */
/****************************************************************
Copyright (C) Lucent Technologies 1997
All Rights Reserved
@@ -372,36 +372,49 @@ int quoted(const uschar **pp) /* pick up next thing after a \\ */
/* BUG: should advance by utf-8 char even if makes no sense */
- if ((c = *p++) == 't') {
+ switch ((c = *p++)) {
+ case 't':
c = '\t';
- } else if (c == 'n') {
+ break;
+ case 'n':
c = '\n';
- } else if (c == 'f') {
+ break;
+ case 'f':
c = '\f';
- } else if (c == 'r') {
+ break;
+ case 'r':
c = '\r';
- } else if (c == 'b') {
+ break;
+ case 'b':
c = '\b';
- } else if (c == 'v') {
+ break;
+ case 'v':
c = '\v';
- } else if (c == 'a') {
+ break;
+ case 'a':
c = '\a';
- } else if (c == '\\') {
+ break;
+ case '\\':
c = '\\';
- } else if (c == 'x') { /* 2 hex digits follow */
- c = hexstr(&p, 2); /* this adds a null if number is invalid */
- } else if (c == 'u') { /* unicode char number up to 8 hex digits */
+ break;
+ case 'x': /* 2 hex digits follow */
+ c = hexstr(&p, 2); /* this adds a null if number is invalid */
+ break;
+ case 'u': /* unicode char number up to 8 hex digits */
c = hexstr(&p, 8);
- } else if (isoctdigit(c)) { /* \d \dd \ddd */
- int n = c - '0';
- if (isoctdigit(*p)) {
- n = 8 * n + *p++ - '0';
- if (isoctdigit(*p))
+ break;
+ default:
+ if (isoctdigit(c)) { /* \d \dd \ddd */
+ int n = c - '0';
+ if (isoctdigit(*p)) {
n = 8 * n + *p++ - '0';
+ if (isoctdigit(*p))
+ n = 8 * n + *p++ - '0';
+ }
+ c = n;
}
- c = n;
- } /* else */
- /* c = c; */
+ }
+
*pp = p;
return c;
}