From ee9b17ad2a687463a31e67106e9317618b73ad4e Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 1 Aug 2006 11:58:04 +0000 Subject: 22572: use of (#m) was broken with pure strings --- Src/pattern.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'Src') diff --git a/Src/pattern.c b/Src/pattern.c index 9ae00ca94..7d9729c0d 100644 --- a/Src/pattern.c +++ b/Src/pattern.c @@ -1915,6 +1915,32 @@ pattryrefs(Patprog prog, char *string, int stringlen, int unmetalen, patinlen = (int)prog->patmlen; /* if matching files, must update globbing flags */ patglobflags = prog->globend; + + if ((patglobflags & GF_MATCHREF) && + !(patflags & PAT_FILE)) { + char *str = ztrduppfx(patinstart, patinlen); + char *ptr = patinstart; + int mlen = 0; + + /* + * 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. + */ + MB_METACHARINIT(); + while (ptr < patinstart + patinlen) { + mlen++; + ptr += MB_METACHARLEN(ptr); + } + + setsparam("MATCH", str); + setiparam("MBEGIN", + (zlong)(patoffset + !isset(KSHARRAYS))); + setiparam("MEND", + (zlong)(mlen + patoffset + + !isset(KSHARRAYS) - 1)); + } } } -- cgit 1.4.1