summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2024-11-07 09:20:10 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2024-11-07 09:20:10 +0000
commit8019a4a1223de88524d132947624e7c7db2aab63 (patch)
tree347253ceb7b5ec80950cdbb4c0685e52dd1ecca9 /usr.sbin
parent35eff45350be179c55ee2d291a976e5ccbd25f8e (diff)
Add multi-line strings support to the bt(5) script parser.
From Christian Ludwig
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/btrace/bt_parse.y40
1 files changed, 30 insertions, 10 deletions
diff --git a/usr.sbin/btrace/bt_parse.y b/usr.sbin/btrace/bt_parse.y
index 2497ae4eadd..6e23b7bcd2d 100644
--- a/usr.sbin/btrace/bt_parse.y
+++ b/usr.sbin/btrace/bt_parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: bt_parse.y,v 1.60 2024/03/30 07:41:45 mpi Exp $ */
+/* $OpenBSD: bt_parse.y,v 1.61 2024/11/07 09:20:09 mpi Exp $ */
/*
* Copyright (c) 2019-2023 Martin Pieuchot <mpi@openbsd.org>
@@ -793,15 +793,10 @@ allowed_in_string(int x)
return (isalnum(x) || x == '_');
}
-int
-yylex(void)
+static int
+skip(void)
{
- unsigned char buf[1024];
- unsigned char *ebuf, *p, *str;
- int c;
-
- ebuf = buf + sizeof(buf);
- p = buf;
+ int c;
again:
/* skip whitespaces */
@@ -838,6 +833,22 @@ again:
}
}
+ return c;
+}
+
+int
+yylex(void)
+{
+ unsigned char buf[1024];
+ unsigned char *ebuf, *p, *str;
+ int c;
+
+ ebuf = buf + sizeof(buf);
+ p = buf;
+
+again:
+ c = skip();
+
switch (c) {
case '!':
case '=':
@@ -962,7 +973,16 @@ again:
return 0;
case '"':
/* parse C-like string */
- while ((c = lgetc()) != EOF && c != '"') {
+ while ((c = lgetc()) != EOF) {
+ if (c == '"') {
+ /* handle multi-line strings */
+ c = skip();
+ if (c == '"')
+ continue;
+ else
+ lungetc();
+ break;
+ }
if (c == '\\') {
c = lgetc();
switch (c) {