From 2abba7243a736a2fc626f3cc917d8a67014d4d20 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 5 Jun 2015 11:21:22 +0100 Subject: 35386: expand tabs where useful in builtins outputing function. Also add to zed -f. Option is -x . --- Src/pattern.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'Src/pattern.c') diff --git a/Src/pattern.c b/Src/pattern.c index 4e5e8a110..7e07548f9 100644 --- a/Src/pattern.c +++ b/Src/pattern.c @@ -2202,20 +2202,15 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalen, if ((patglobflags & GF_MATCHREF) && !(patflags & PAT_FILE)) { char *str = ztrduppfx(patinstart, patinlen); - char *ptr = patinstart; - int mlen = 0; + int mlen; /* * Count the characters. We're not using CHARSUB() - * because the string is still metafied. We're - * not using mb_metastrlen() because that expects - * the string to be null terminated. + * because the string is still metafied. */ MB_METACHARINIT(); - while (ptr < patinstart + patinlen) { - mlen++; - ptr += MB_METACHARLEN(ptr); - } + mlen = MB_METASTRLEN2END(patinstart, 0, + patinstart + patinlen); setsparam("MATCH", str); setiparam("MBEGIN", -- cgit v1.2.3 From 77130df6747c94c44ea4cb522177d611a24fd5d0 Mon Sep 17 00:00:00 2001 From: Han Pingtian Date: Thu, 18 Jun 2015 10:37:39 +0800 Subject: 35514: [[:foo:]] tests in completion should be more specific --- ChangeLog | 4 ++++ Src/pattern.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'Src/pattern.c') diff --git a/ChangeLog b/ChangeLog index f3be8cf1b..d0e2b256d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2015-06-24 Peter Stephenson + * 35514: Han Pingtian: Src/pattern.c: [[:foo:]] + tests in completion weren't specific enough about + foo. + * 35590: Src/text.c, Test/B02typeset.ztst: tweak and test text output for typeset. diff --git a/Src/pattern.c b/Src/pattern.c index 7e07548f9..8fa1a727f 100644 --- a/Src/pattern.c +++ b/Src/pattern.c @@ -1113,8 +1113,8 @@ range_type(char *start, int len) const char **csp; for (csp = colon_stuffs; *csp; csp++) { - if (!strncmp(start, *csp, len)) - return (csp - colon_stuffs) + PP_FIRST; + if (strlen(*csp) == len && !strncmp(start, *csp, len)) + return (csp - colon_stuffs) + PP_FIRST; } return PP_UNKWN; -- cgit v1.2.3 From df5f825538720a9422859200d58d075d1dd075fc Mon Sep 17 00:00:00 2001 From: "Barton E. Schaefer" Date: Sun, 9 Aug 2015 17:37:23 -0700 Subject: 36033: a few more queue_signals() to protect global state changes --- ChangeLog | 5 +++++ Src/glob.c | 4 ++++ Src/pattern.c | 8 +++++++- 3 files changed, 16 insertions(+), 1 deletion(-) (limited to 'Src/pattern.c') diff --git a/ChangeLog b/ChangeLog index 1456675bc..37043e679 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-08-09 Barton E. Schaefer + + * 36033: Src/glob.c, Src/pattern.c: a few more queue_signals() + to protect global state changes + 2015-08-09 Mikael Magnusson * unposted: Test/C03traps.ztst: add tests for outputting traps diff --git a/Src/glob.c b/Src/glob.c index eff34a24e..f82c3bd30 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -216,22 +216,26 @@ static struct globdata curglobdata; #define save_globstate(N) \ do { \ + queue_signals(); \ memcpy(&(N), &curglobdata, sizeof(struct globdata)); \ (N).gd_pathpos = pathpos; \ (N).gd_pathbuf = pathbuf; \ (N).gd_glob_pre = glob_pre; \ (N).gd_glob_suf = glob_suf; \ pathbuf = NULL; \ + unqueue_signals(); \ } while (0) #define restore_globstate(N) \ do { \ + queue_signals(); \ zfree(pathbuf, pathbufsz); \ memcpy(&curglobdata, &(N), sizeof(struct globdata)); \ pathpos = (N).gd_pathpos; \ pathbuf = (N).gd_pathbuf; \ glob_pre = (N).gd_glob_pre; \ glob_suf = (N).gd_glob_suf; \ + unqueue_signals(); \ } while (0) /* pathname component in filename patterns */ diff --git a/Src/pattern.c b/Src/pattern.c index 8fa1a727f..7d38988a0 100644 --- a/Src/pattern.c +++ b/Src/pattern.c @@ -520,6 +520,8 @@ patcompile(char *exp, int inflags, char **endexp) char *lng, *strp = NULL; Patprog p; + queue_signals(); + startoff = sizeof(struct patprog); /* Ensure alignment of start of program string */ startoff = (startoff + sizeof(union upat) - 1) & ~(sizeof(union upat) - 1); @@ -582,8 +584,10 @@ patcompile(char *exp, int inflags, char **endexp) if (!strp || (*strp && *strp != '/')) { /* No, do normal compilation. */ strp = NULL; - if (patcompswitch(0, &flags) == 0) + if (patcompswitch(0, &flags) == 0) { + unqueue_signals(); return NULL; + } } else { /* * Yes, copy the string, and skip compilation altogether. @@ -715,6 +719,8 @@ patcompile(char *exp, int inflags, char **endexp) if (endexp) *endexp = patparse; + + unqueue_signals(); return p; } -- cgit v1.2.3