summary refs log tree commit diff
path: root/Src/parse.c
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2020-03-19 18:00:16 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2020-03-22 02:23:53 +0000
commit386d9ac8ff961b8f0333d09511e927ab31011658 (patch)
tree442bdeb53c2f867ab5c5878dd1c45ea49dbd6c76 /Src/parse.c
parenta3c6c5513dcfc25d952735449bf6da476d905184 (diff)
downloadzsh-386d9ac8ff961b8f0333d09511e927ab31011658.tar.gz
zsh-386d9ac8ff961b8f0333d09511e927ab31011658.tar.xz
zsh-386d9ac8ff961b8f0333d09511e927ab31011658.zip
45583/0008: Add the 'function -T' syntax.
Config/version.mk was bumped in the previous commit.
Diffstat (limited to 'Src/parse.c')
-rw-r--r--Src/parse.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Src/parse.c b/Src/parse.c
index 0111c25b6..0342ee1f8 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -173,7 +173,7 @@ struct heredocs *hdocs;
  *     - followed by offset to first string
  *     - followed by length of string table
  *     - followed by number of patterns for body
- *     - followed by a placeholder
+ *     - followed by an integer indicating tracing status
  *     - followed by codes for body
  *     - followed by strings for body
  *     - if number of names is 0, followed by:
@@ -1670,6 +1670,7 @@ par_funcdef(int *cmplx)
     int oecused = ecused, num = 0, onp, p, c = 0;
     int so, oecssub = ecssub;
     zlong oldlineno = lineno;
+    int do_tracing = 0;
 
     lineno = 0;
     nocorrect = 1;
@@ -1679,6 +1680,12 @@ par_funcdef(int *cmplx)
     p = ecadd(0);
     ecadd(0); /* p + 1 */
 
+    if (tok == STRING && tokstr[0] == Dash &&
+	tokstr[1] == 'T' && !tokstr[2]) {
+	++do_tracing;
+	zshlex();
+    }
+
     while (tok == STRING) {
 	if ((*tokstr == Inbrace || *tokstr == '{') &&
 	    !tokstr[1]) {
@@ -1732,7 +1739,7 @@ par_funcdef(int *cmplx)
     ecbuf[p + num + 2] = so - oecssub;
     ecbuf[p + num + 3] = ecsoffs - so; /* "length of string table" */
     ecbuf[p + num + 4] = ecnpats; /* "number of patterns for body" */
-    ecbuf[p + num + 5] = 0;
+    ecbuf[p + num + 5] = do_tracing;
     ecbuf[p + 1] = num; /* "number of names" */
 
     ecnpats = onp;