From 962624e8c343e3968fbb55160b8a14b460400bc0 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Sun, 19 Jun 2011 16:26:10 +0000 Subject: 29491: remove some variables set but not used --- Src/Modules/db_gdbm.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'Src/Modules') diff --git a/Src/Modules/db_gdbm.c b/Src/Modules/db_gdbm.c index bdbbe19d8..9a2a7a5b9 100644 --- a/Src/Modules/db_gdbm.c +++ b/Src/Modules/db_gdbm.c @@ -39,7 +39,9 @@ #include +#if 0 /* what is this for? */ static char *backtype = "db/gdbm"; +#endif static const struct gsu_scalar gdbm_gsu = { gdbmgetfn, gdbmsetfn, gdbmunsetfn }; @@ -138,7 +140,6 @@ static void gdbmsetfn(Param pm, char *val) { datum key, content; - int ret; GDBM_FILE dbf; key.dptr = pm->node.nam; @@ -147,7 +148,7 @@ gdbmsetfn(Param pm, char *val) content.dsize = strlen(content.dptr) + 1; dbf = (GDBM_FILE)(pm->u.hash->tmpdata); - ret = gdbm_store(dbf, key, content, GDBM_REPLACE); + (void)gdbm_store(dbf, key, content, GDBM_REPLACE); } /**/ @@ -155,14 +156,13 @@ static void gdbmunsetfn(Param pm, int um) { datum key; - int ret; GDBM_FILE dbf; key.dptr = pm->node.nam; key.dsize = strlen(key.dptr) + 1; dbf = (GDBM_FILE)(pm->u.hash->tmpdata); - ret = gdbm_delete(dbf, key); + (void)gdbm_delete(dbf, key); } /**/ @@ -171,12 +171,10 @@ getgdbmnode(HashTable ht, const char *name) { int len; char *nameu; - datum key; Param pm = NULL; nameu = dupstring(name); unmetafy(nameu, &len); - key.dptr = nameu; pm = (Param) hcalloc(sizeof(struct param)); pm->node.nam = nameu; -- cgit v1.2.3 From bbbaed2b5395e0a646dc618cd8c6bdd7dde25c81 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 10 Aug 2011 11:31:18 +0000 Subject: 29663: add $EPOCHREALTIME to zsh/datetime --- ChangeLog | 13 ++++++++++++- Doc/Zsh/mod_datetime.yo | 10 +++++++++- Src/Modules/datetime.c | 27 +++++++++++++++++++++++++++ Src/module.c | 5 +++++ configure.ac | 4 +++- 5 files changed, 56 insertions(+), 3 deletions(-) (limited to 'Src/Modules') diff --git a/ChangeLog b/ChangeLog index 078971581..658dca388 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2011-08-10 Peter Stephenson + + * 29663: configure.ac, Src/module.c, Src/Modules/datetime.c, + Doc/Zsh/mod_datetime.yo: add $EPOCHREALTIME for time in + double precision floating point. + +2011-08-04 Peter Stephenson + + * 29643: Src/signals.c, Src/utils.c, Src/zle_main.c: set + incompfunc to zero when executing hook or trap function. + 2011-08-09 Peter Stephenson * 29661: Doc/Zsh/redirect.yo: Improve the documentation for @@ -15213,5 +15224,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5417 $ +* $Revision: 1.5418 $ ***************************************************** diff --git a/Doc/Zsh/mod_datetime.yo b/Doc/Zsh/mod_datetime.yo index 145d4a181..514c43037 100644 --- a/Doc/Zsh/mod_datetime.yo +++ b/Doc/Zsh/mod_datetime.yo @@ -30,9 +30,17 @@ in seconds if tt(-r) is given) to var(scalar) instead of printing it. ) enditem() -The tt(zsh/datetime) module makes available one parameter: +The tt(zsh/datetime) module makes available several parameters: startitem() +vindex(EPOCHREALTIME) +item(tt(EPOCHREALTIME))( +A floating point value representing the number of seconds since +the epoch. The notional accuracy is to nanoseconds if the +tt(clock_gettime) call is available and to microseconds otherwise, +but in practice the range of double precision floating point and +shell scheduling latencies may be significant effects. +) vindex(EPOCHSECONDS) item(tt(EPOCHSECONDS))( An integer value representing the number of seconds since the diff --git a/Src/Modules/datetime.c b/Src/Modules/datetime.c index 45818b968..1f2b7e81c 100644 --- a/Src/Modules/datetime.c +++ b/Src/Modules/datetime.c @@ -151,6 +151,28 @@ getcurrentsecs(UNUSED(Param pm)) return (zlong) time(NULL); } +static double +getcurrentrealtime(UNUSED(Param pm)) +{ +#ifdef HAVE_CLOCK_GETTIME + struct timespec now; + + if (clock_gettime(CLOCK_REALTIME, &now) < 0) { + zwarn("EPOCHREALTIME: unable to retrieve time: %e", errno); + return (double)0.0; + } + + return (double)now.tv_sec + (double)now.tv_nsec * 1e-9; +#else + struct timeval now; + struct timezone dummy_tz; + + gettimeofday(&now, &dummy_tz); + + return (double)now.tv_sec + (double)now.tv_usec * 1e-6; +#endif +} + static struct builtin bintab[] = { BUILTIN("strftime", 0, bin_strftime, 2, 2, 0, "qrs:", NULL), }; @@ -158,9 +180,14 @@ static struct builtin bintab[] = { static const struct gsu_integer epochseconds_gsu = { getcurrentsecs, NULL, stdunsetfn }; +static const struct gsu_float epochrealtime_gsu = +{ getcurrentrealtime, NULL, stdunsetfn }; + static struct paramdef patab[] = { SPECIALPMDEF("EPOCHSECONDS", PM_INTEGER|PM_READONLY, &epochseconds_gsu, NULL, NULL), + SPECIALPMDEF("EPOCHREALTIME", PM_FFLOAT|PM_READONLY, + &epochrealtime_gsu, NULL, NULL) }; static struct features module_features = { diff --git a/Src/module.c b/Src/module.c index 219bdfa8e..a5a6029b4 100644 --- a/Src/module.c +++ b/Src/module.c @@ -1081,6 +1081,11 @@ addparamdef(Paramdef d) pm->gsu.i = d->gsu ? (GsuInteger)d->gsu : &varinteger_gsu; break; + case PM_FFLOAT: + case PM_EFLOAT: + pm->gsu.f = d->gsu; + break; + case PM_ARRAY: pm->gsu.a = d->gsu ? (GsuArray)d->gsu : &vararray_gsu; break; diff --git a/configure.ac b/configure.ac index 1ce815ca5..54999b164 100644 --- a/configure.ac +++ b/configure.ac @@ -693,6 +693,8 @@ AC_CHECK_LIB(c, printf, [LIBS="$LIBS -lc"]) AC_CHECK_LIB(m, pow) +AC_CHECK_LIB(rt, clock_gettime) + dnl Various features of ncurses depend on having the right header dnl (the system's own curses.h may well not be good enough). dnl So don't search for ncurses unless we found the header. @@ -1170,7 +1172,7 @@ dnl need to integrate this function dnl AC_FUNC_STRFTIME AC_CHECK_FUNCS(strftime strptime mktime timelocal \ - difftime gettimeofday \ + difftime gettimeofday clock_gettime \ select poll \ readlink faccessx fchdir ftruncate \ fstat lstat lchown fchown fchmod \ -- cgit v1.2.3 From 8cbd5100022d651054b9edbbb79b38c8a442ec51 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 11 Aug 2011 18:45:04 +0000 Subject: 29674: add $epochtime to datetime --- Doc/Zsh/mod_datetime.yo | 17 ++++++++++++++++- Src/Modules/datetime.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 2 deletions(-) (limited to 'Src/Modules') diff --git a/Doc/Zsh/mod_datetime.yo b/Doc/Zsh/mod_datetime.yo index 514c43037..619067698 100644 --- a/Doc/Zsh/mod_datetime.yo +++ b/Doc/Zsh/mod_datetime.yo @@ -30,7 +30,8 @@ in seconds if tt(-r) is given) to var(scalar) instead of printing it. ) enditem() -The tt(zsh/datetime) module makes available several parameters: +The tt(zsh/datetime) module makes available several parameters; +all are readonly: startitem() vindex(EPOCHREALTIME) @@ -45,5 +46,19 @@ vindex(EPOCHSECONDS) item(tt(EPOCHSECONDS))( An integer value representing the number of seconds since the epoch. +) +vindex(epochtime) +item(tt(epochtime))( +An array value containing the number of seconds since the epoch +in the first element and the remainder of the time since the epoch +in nanoseconds in the second element. To ensure the two elements +are consistent the array should be copied or otherwise referenced +as a single substitution before the values are used. The following +idiom may be used: + +example(for secs nsecs in $epochtime; do + ... +done) + ) enditem() diff --git a/Src/Modules/datetime.c b/Src/Modules/datetime.c index 1f2b7e81c..98bcd7d65 100644 --- a/Src/Modules/datetime.c +++ b/Src/Modules/datetime.c @@ -173,6 +173,45 @@ getcurrentrealtime(UNUSED(Param pm)) #endif } +static char ** +getcurrenttime(UNUSED(Param pm)) +{ + char **arr; + char buf[DIGBUFSIZE]; + +#ifdef HAVE_CLOCK_GETTIME + struct timespec now; + + if (clock_gettime(CLOCK_REALTIME, &now) < 0) { + zwarn("EPOCHREALTIME: unable to retrieve time: %e", errno); + return NULL; + } + + arr = (char **)zhalloc(3 * sizeof(*arr)); + sprintf(buf, "%ld", (long)now.tv_sec); + arr[0] = dupstring(buf); + sprintf(buf, "%ld", now.tv_nsec); + arr[1] = dupstring(buf); + arr[2] = NULL; + + return arr; +#else + struct timeval now; + struct timezone dummy_tz; + + gettimeofday(&now, &dummy_tz); + + arr = (char **)zhalloc(3 * sizeof(*arr)); + sprintf(buf, "%ld", (long)now.tv_sec); + arr[0] = dupstring(buf); + sprintf(buf, "%ld", (long)now.tv_usec * 1000); + arr[1] = dupstring(buf); + arr[2] = NULL; + + return arr; +#endif +} + static struct builtin bintab[] = { BUILTIN("strftime", 0, bin_strftime, 2, 2, 0, "qrs:", NULL), }; @@ -183,11 +222,16 @@ static const struct gsu_integer epochseconds_gsu = static const struct gsu_float epochrealtime_gsu = { getcurrentrealtime, NULL, stdunsetfn }; +static const struct gsu_array epochtime_gsu = +{ getcurrenttime, NULL, stdunsetfn }; + static struct paramdef patab[] = { SPECIALPMDEF("EPOCHSECONDS", PM_INTEGER|PM_READONLY, &epochseconds_gsu, NULL, NULL), SPECIALPMDEF("EPOCHREALTIME", PM_FFLOAT|PM_READONLY, - &epochrealtime_gsu, NULL, NULL) + &epochrealtime_gsu, NULL, NULL), + SPECIALPMDEF("epochtime", PM_ARRAY|PM_READONLY, + &epochtime_gsu, NULL, NULL) }; static struct features module_features = { -- cgit v1.2.3 From 515554acbcc5aa1c9a3feb936a71e7a88822e774 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 11 Aug 2011 19:43:46 +0000 Subject: fix datetime autofeatures --- Src/Modules/datetime.mdd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Src/Modules') diff --git a/Src/Modules/datetime.mdd b/Src/Modules/datetime.mdd index 0e5ffffb2..b7c1a4a95 100644 --- a/Src/Modules/datetime.mdd +++ b/Src/Modules/datetime.mdd @@ -4,6 +4,6 @@ link=either load=no functions='Functions/Calendar/*' -autofeatures="b:strftime p:EPOCHSECONDS" +autofeatures="b:strftime p:EPOCHSECONDS p:EPOCHREALTIME p:epochtime" objects="datetime.o" -- cgit v1.2.3 From 3ba487ca77dcab94aeb0280a0e175bd1fda75230 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 15 Aug 2011 19:32:30 +0000 Subject: unposted: use pm->node.nam to get names for parameters in errors --- ChangeLog | 7 ++++++- Src/Modules/datetime.c | 10 ++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'Src/Modules') diff --git a/ChangeLog b/ChangeLog index e8625ca6e..acbd4c582 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-08-15 Peter Stephenson + + * unposted: Src/Modules/datetime.c: use pm->node.nam to get + parameter names for errors. + 2011-08-14 Mikael Magnusson * 29673: Doc/Zsh/compsys.yo: clarify what 'other' in the @@ -15260,5 +15265,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5429 $ +* $Revision: 1.5430 $ ***************************************************** diff --git a/Src/Modules/datetime.c b/Src/Modules/datetime.c index 98bcd7d65..a4e7eca86 100644 --- a/Src/Modules/datetime.c +++ b/Src/Modules/datetime.c @@ -152,13 +152,13 @@ getcurrentsecs(UNUSED(Param pm)) } static double -getcurrentrealtime(UNUSED(Param pm)) +getcurrentrealtime(Param pm) { #ifdef HAVE_CLOCK_GETTIME struct timespec now; if (clock_gettime(CLOCK_REALTIME, &now) < 0) { - zwarn("EPOCHREALTIME: unable to retrieve time: %e", errno); + zwarn("%s: unable to retrieve time: %e", pm->node.nam, errno); return (double)0.0; } @@ -167,6 +167,7 @@ getcurrentrealtime(UNUSED(Param pm)) struct timeval now; struct timezone dummy_tz; + (void)pm; gettimeofday(&now, &dummy_tz); return (double)now.tv_sec + (double)now.tv_usec * 1e-6; @@ -174,7 +175,7 @@ getcurrentrealtime(UNUSED(Param pm)) } static char ** -getcurrenttime(UNUSED(Param pm)) +getcurrenttime(Param pm) { char **arr; char buf[DIGBUFSIZE]; @@ -183,7 +184,7 @@ getcurrenttime(UNUSED(Param pm)) struct timespec now; if (clock_gettime(CLOCK_REALTIME, &now) < 0) { - zwarn("EPOCHREALTIME: unable to retrieve time: %e", errno); + zwarn("%s: unable to retrieve time: %e", pm->node.nam, errno); return NULL; } @@ -199,6 +200,7 @@ getcurrenttime(UNUSED(Param pm)) struct timeval now; struct timezone dummy_tz; + (void)pm; gettimeofday(&now, &dummy_tz); arr = (char **)zhalloc(3 * sizeof(*arr)); -- cgit v1.2.3 From 2f3c16d40fe1e8c6aa351224fd50530024c4f5c6 Mon Sep 17 00:00:00 2001 From: Phil Pennock Date: Mon, 24 Oct 2011 11:31:25 +0000 Subject: 29838: metafy/unmetafy strings for PCRE matching (UTF-8 fixes) --- ChangeLog | 10 ++++- Src/Modules/pcre.c | 61 ++++++++++++++++++++++-------- Test/V07pcre.ztst | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 160 insertions(+), 17 deletions(-) create mode 100644 Test/V07pcre.ztst (limited to 'Src/Modules') diff --git a/ChangeLog b/ChangeLog index 934fb881f..47fc89954 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-10-24 Phil Pennock + + * 29838: Src/Modules/pcre.c: metafy/unmetafy strings, to + correctly handle non-ASCII characters in UTF-8 for regexp + matches. + + * unposted: Test/V07pcre.ztst: some PCRE tests + 2011-10-23 Peter Stephenson * users/16492: MACHINES: OpenIndiana issue. @@ -15484,5 +15492,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5481 $ +* $Revision: 1.5482 $ ***************************************************** diff --git a/Src/Modules/pcre.c b/Src/Modules/pcre.c index e1a897944..e36013163 100644 --- a/Src/Modules/pcre.c +++ b/Src/Modules/pcre.c @@ -77,6 +77,7 @@ bin_pcre_compile(char *nam, char **args, Options ops, UNUSED(int func)) { int pcre_opts = 0, pcre_errptr; const char *pcre_error; + char *target; if(OPT_ISSET(ops,'a')) pcre_opts |= PCRE_ANCHORED; if(OPT_ISSET(ops,'i')) pcre_opts |= PCRE_CASELESS; @@ -92,8 +93,13 @@ bin_pcre_compile(char *nam, char **args, Options ops, UNUSED(int func)) if (pcre_pattern) pcre_free(pcre_pattern); - pcre_pattern = pcre_compile(*args, pcre_opts, &pcre_error, &pcre_errptr, NULL); + target = ztrdup(*args); + unmetafy(target, NULL); + + pcre_pattern = pcre_compile(target, pcre_opts, &pcre_error, &pcre_errptr, NULL); + free(target); + if (pcre_pattern == NULL) { zwarnnam(nam, "error in regex: %s", pcre_error); @@ -161,7 +167,7 @@ zpcre_get_substrings(char *arg, int *ovec, int ret, char *matchvar, sprintf(offset_all, "%d %d", ovec[0], ovec[1]); setsparam("ZPCRE_OP", ztrdup(offset_all)); } - match_all = ztrdup(captures[0]); + match_all = metafy(captures[0], -1, META_DUP); setsparam(matchvar, match_all); /* * If we're setting match, mbegin, mend we only do @@ -169,7 +175,15 @@ zpcre_get_substrings(char *arg, int *ovec, int ret, char *matchvar, * (c.f. regex.c). */ if (!want_begin_end || nelem) { - matches = zarrdup(&captures[capture_start]); + char **x, **y; + y = &captures[capture_start]; + matches = x = (char **) zalloc(sizeof(char *) * (arrlen(y) + 1)); + do { + if (*y) + *x++ = metafy(*y, -1, META_DUP); + else + *x++ = NULL; + } while (*y++); setaparam(substravar, matches); } @@ -255,6 +269,7 @@ bin_pcre_match(char *nam, char **args, Options ops, UNUSED(int func)) { int ret, capcount, *ovec, ovecsize, c; char *matched_portion = NULL; + char *plaintext = NULL; char *receptacle = NULL; int return_value = 1; /* The subject length and offset start are both int values in pcre_exec */ @@ -278,7 +293,7 @@ bin_pcre_match(char *nam, char **args, Options ops, UNUSED(int func)) } /* For the entire match, 'Return' the offset byte positions instead of the matched string */ if(OPT_ISSET(ops,'b')) want_offset_pair = 1; - + if(!*args) { zwarnnam(nam, "not enough arguments"); } @@ -288,26 +303,28 @@ bin_pcre_match(char *nam, char **args, Options ops, UNUSED(int func)) zwarnnam(nam, "error %d in fullinfo", ret); return 1; } - + ovecsize = (capcount+1)*3; ovec = zalloc(ovecsize*sizeof(int)); - - subject_len = (int)strlen(*args); + + plaintext = ztrdup(*args); + unmetafy(plaintext, NULL); + subject_len = (int)strlen(plaintext); if (offset_start < 0 || offset_start >= subject_len) ret = PCRE_ERROR_NOMATCH; else - ret = pcre_exec(pcre_pattern, pcre_hints, *args, subject_len, offset_start, 0, ovec, ovecsize); + ret = pcre_exec(pcre_pattern, pcre_hints, plaintext, subject_len, offset_start, 0, ovec, ovecsize); if (ret==0) return_value = 0; else if (ret==PCRE_ERROR_NOMATCH) /* no match */; else if (ret>0) { - zpcre_get_substrings(*args, ovec, ret, matched_portion, receptacle, + zpcre_get_substrings(plaintext, ovec, ret, matched_portion, receptacle, want_offset_pair, 0, 0); return_value = 0; } else { - zwarnnam(nam, "error in pcre_exec"); + zwarnnam(nam, "error in pcre_exec [%d]", ret); } if (ovec) @@ -322,7 +339,8 @@ cond_pcre_match(char **a, int id) { pcre *pcre_pat; const char *pcre_err; - char *lhstr, *rhre, *avar=NULL; + char *lhstr, *rhre, *lhstr_plain, *rhre_plain, *avar=NULL; + char *p; int r = 0, pcre_opts = 0, pcre_errptr, capcnt, *ov, ovsize; int return_value = 0; @@ -331,6 +349,10 @@ cond_pcre_match(char **a, int id) lhstr = cond_str(a,0,0); rhre = cond_str(a,1,0); + lhstr_plain = ztrdup(lhstr); + rhre_plain = ztrdup(rhre); + unmetafy(lhstr_plain, NULL); + unmetafy(rhre_plain, NULL); pcre_pat = NULL; ov = NULL; @@ -339,7 +361,7 @@ cond_pcre_match(char **a, int id) switch(id) { case CPCRE_PLAIN: - pcre_pat = pcre_compile(rhre, pcre_opts, &pcre_err, &pcre_errptr, NULL); + pcre_pat = pcre_compile(rhre_plain, pcre_opts, &pcre_err, &pcre_errptr, NULL); if (pcre_pat == NULL) { zwarn("failed to compile regexp /%s/: %s", rhre, pcre_err); break; @@ -347,7 +369,7 @@ cond_pcre_match(char **a, int id) pcre_fullinfo(pcre_pat, NULL, PCRE_INFO_CAPTURECOUNT, &capcnt); ovsize = (capcnt+1)*3; ov = zalloc(ovsize*sizeof(int)); - r = pcre_exec(pcre_pat, NULL, lhstr, strlen(lhstr), 0, 0, ov, ovsize); + r = pcre_exec(pcre_pat, NULL, lhstr_plain, strlen(lhstr_plain), 0, 0, ov, ovsize); /* r < 0 => error; r==0 match but not enough size in ov * r > 0 => (r-1) substrings found; r==1 => no substrings */ @@ -356,13 +378,16 @@ cond_pcre_match(char **a, int id) return_value = 1; break; } - else if (r==PCRE_ERROR_NOMATCH) return 0; /* no match */ + else if (r==PCRE_ERROR_NOMATCH) { + return_value = 0; /* no match */ + break; + } else if (r<0) { - zwarn("pcre_exec() error: %d", r); + zwarn("pcre_exec() error [%d]", r); break; } else if (r>0) { - zpcre_get_substrings(lhstr, ov, r, NULL, avar, 0, + zpcre_get_substrings(lhstr_plain, ov, r, NULL, avar, 0, isset(BASHREMATCH), !isset(BASHREMATCH)); return_value = 1; @@ -371,6 +396,10 @@ cond_pcre_match(char **a, int id) break; } + if (lhstr_plain) + free(lhstr_plain); + if(rhre_plain) + free(rhre_plain); if (pcre_pat) pcre_free(pcre_pat); if (ov) diff --git a/Test/V07pcre.ztst b/Test/V07pcre.ztst new file mode 100644 index 000000000..4dd173557 --- /dev/null +++ b/Test/V07pcre.ztst @@ -0,0 +1,106 @@ +%prep + + zmodload zsh/pcre + setopt rematch_pcre +# Find a UTF-8 locale. + setopt multibyte +# Don't let LC_* override our choice of locale. + unset -m LC_\* + mb_ok= + langs=(en_{US,GB}.{UTF-,utf}8 en.UTF-8 + $(locale -a 2>/dev/null | egrep 'utf8|UTF-8')) + for LANG in $langs; do + if [[ é = ? ]]; then + mb_ok=1 + break; + fi + done + if [[ -z $mb_ok ]]; then + ZTST_unimplemented="no UTF-8 locale or multibyte mode is not implemented" + else + print -u $ZTST_fd Testing PCRE multibyte with locale $LANG + mkdir multibyte.tmp && cd multibyte.tmp + fi + +%test + + [[ 'foo→bar' =~ .([^[:ascii:]]). ]] + print $MATCH + print $match[1] +0:Basic non-ASCII regexp matching +>o→b +>→ + + [[ foo =~ f.+ ]] ; print $? + [[ foo =~ x.+ ]] ; print $? + [[ ! foo =~ f.+ ]] ; print $? + [[ ! foo =~ x.+ ]] ; print $? + [[ foo =~ f.+ && bar =~ b.+ ]] ; print $? + [[ foo =~ x.+ && bar =~ b.+ ]] ; print $? + [[ foo =~ f.+ && bar =~ x.+ ]] ; print $? + [[ ! foo =~ f.+ && bar =~ b.+ ]] ; print $? + [[ foo =~ f.+ && ! bar =~ b.+ ]] ; print $? + [[ ! ( foo =~ f.+ && bar =~ b.+ ) ]] ; print $? + [[ ! foo =~ x.+ && bar =~ b.+ ]] ; print $? + [[ foo =~ x.+ && ! bar =~ b.+ ]] ; print $? + [[ ! ( foo =~ x.+ && bar =~ b.+ ) ]] ; print $? +0:Regex result inversion detection +>0 +>1 +>1 +>0 +>0 +>1 +>1 +>1 +>1 +>1 +>0 +>1 +>0 + +# Note that PCRE_ANCHORED only means anchored at the start +# Also note that we don't unset MATCH/match on failed match (and it's an +# open issue as to whether or not we should) + pcre_compile '.(→.)' + pcre_match foo→bar + print $? $MATCH $match ; unset MATCH match + pcre_match foo.bar + print $? $MATCH $match ; unset MATCH match + pcre_match foo†bar + print $? $MATCH $match ; unset MATCH match + pcre_match foo→†ar + print $? $MATCH $match ; unset MATCH match + pcre_study + pcre_match foo→bar + print $? $MATCH $match ; unset MATCH match + pcre_compile -a '.(→.)' + pcre_match foo→bar + print $? $MATCH $match ; unset MATCH match + pcre_match o→bar + print $? $MATCH $match ; unset MATCH match + pcre_match o→b + print $? $MATCH $match ; unset MATCH match + pcre_compile 'x.(→.)' + pcre_match xo→t + print $? $MATCH $match ; unset MATCH match + pcre_match Xo→t + print $? $MATCH $match ; unset MATCH match + pcre_compile -i 'x.(→.)' + pcre_match xo→t + print $? $MATCH $match ; unset MATCH match + pcre_match Xo→t + print $? $MATCH $match ; unset MATCH match +0:pcre_compile interface testing: basic, anchored & case-insensitive +>0 o→b →b +>1 +>1 +>0 o→† →† +>0 o→b →b +>1 +>0 o→b →b +>0 o→b →b +>0 xo→t →t +>1 +>0 xo→t →t +>0 Xo→t →t -- cgit v1.2.3 From 68d1c094db86d06e49cbb992fce51aa742418476 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Wed, 26 Oct 2011 16:46:09 +0000 Subject: 29865: don't compile pcre if no pcre-config --- ChangeLog | 4 +++- Src/Modules/pcre.mdd | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'Src/Modules') diff --git a/ChangeLog b/ChangeLog index a44700bbe..7cc2d1329 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2011-10-26 Peter Stephenson + * 29865: Src/Modules/pcre.mdd: don't compile if no pcre-config. + * 29859: Src/Zle/Complete.c: compadd handles its own options. 2011-10-24 Peter Stephenson @@ -15504,5 +15506,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5485 $ +* $Revision: 1.5486 $ ***************************************************** diff --git a/Src/Modules/pcre.mdd b/Src/Modules/pcre.mdd index 3e1579117..6eb3c691b 100644 --- a/Src/Modules/pcre.mdd +++ b/Src/Modules/pcre.mdd @@ -1,5 +1,5 @@ name=zsh/pcre -link=`if test x$enable_pcre = xyes; then echo dynamic; else echo no; fi` +link=`if test x$enable_pcre = xyes && (pcre-config --version >/dev/null 2>/dev/null); then echo dynamic; else echo no; fi` load=no autofeatures="b:pcre_compile b:pcre_study b:pcre_match" -- cgit v1.2.3 From fdb00982f5405a869392e0dfea6a76e044af212a Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 31 Oct 2011 09:48:58 +0000 Subject: Jun T: 29883: cast resource types to types they should be anyway --- ChangeLog | 8 +++++++- Src/Builtins/rlimits.c | 24 ++++++++++++------------ Src/Modules/zftp.c | 2 +- 3 files changed, 20 insertions(+), 14 deletions(-) (limited to 'Src/Modules') diff --git a/ChangeLog b/ChangeLog index 61d4e4643..84e92c328 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-10-31 Peter Stephenson + + * Jun T: 29883: Src/Builtins/rlimits.c, Src/Modules/zftp.c: cast + to type in printf to work around cases where types aren't + properly distinguished. + 2011-10-30 Peter Stephenson * users/16547: Completion/Unix/Command/_perforce: quote @@ -15527,5 +15533,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5490 $ +* $Revision: 1.5491 $ ***************************************************** diff --git a/Src/Builtins/rlimits.c b/Src/Builtins/rlimits.c index 73bbe10f1..670516169 100644 --- a/Src/Builtins/rlimits.c +++ b/Src/Builtins/rlimits.c @@ -102,9 +102,9 @@ showlimitvalue(int lim, rlim_t val) printf("%lld\n", val); # else # ifdef RLIM_T_IS_UNSIGNED - printf("%lu\n", val); + printf("%lu\n", (unsigned long)val); # else - printf("%ld\n", val); + printf("%ld\n", (long)val); # endif /* RLIM_T_IS_UNSIGNED */ # endif /* RLIM_T_IS_LONG_LONG */ # endif /* RLIM_T_IS_QUAD_T */ @@ -123,9 +123,9 @@ showlimitvalue(int lim, rlim_t val) printf("%lldus\n", val); # else # ifdef RLIM_T_IS_UNSIGNED - printf("%luus\n", val); + printf("%luus\n", (unsigned long)val); # else - printf("%ldus\n", val); + printf("%ldus\n", (long)val); # endif /* RLIM_T_IS_UNSIGNED */ # endif /* RLIM_T_IS_LONG_LONG */ # endif /* RLIM_T_IS_QUAD_T */ @@ -139,9 +139,9 @@ showlimitvalue(int lim, rlim_t val) printf("%lld\n", val); # else # ifdef RLIM_T_IS_UNSIGNED - printf("%lu\n", val); + printf("%lu\n", (unsigned long)val); # else - printf("%ld\n", val); + printf("%ld\n", (long)val); # endif /* RLIM_T_IS_UNSIGNED */ # endif /* RLIM_T_IS_LONG_LONG */ # endif /* RLIM_T_IS_QUAD_T */ @@ -158,13 +158,13 @@ showlimitvalue(int lim, rlim_t val) printf("%lldkB\n", val / 1024L); # else # ifdef RLIM_T_IS_UNSIGNED - printf("%luMB\n", val / (1024L * 1024L)); + printf("%luMB\n", (unsigned long)(val / (1024L * 1024L))); else - printf("%lukB\n", val / 1024L); + printf("%lukB\n", (unsigned long)(val / 1024L)); # else - printf("%ldMB\n", val / (1024L * 1024L)); + printf("%ldMB\n", (long)val / (1024L * 1024L)); else - printf("%ldkB\n", val / 1024L); + printf("%ldkB\n", (long)val / 1024L); # endif /* RLIM_T_IS_UNSIGNED */ # endif /* RLIM_T_IS_LONG_LONG */ # endif /* RLIM_T_IS_QUAD_T */ @@ -398,9 +398,9 @@ printulimit(char *nam, int lim, int hard, int head) printf("%lld\n", limit); # else # ifdef RLIM_T_IS_UNSIGNED - printf("%lu\n", limit); + printf("%lu\n", (unsigned long)limit); # else - printf("%ld\n", limit); + printf("%ld\n", (long)limit); # endif /* RLIM_T_IS_UNSIGNED */ # endif /* RLIM_T_IS_LONG_LONG */ # endif /* RLIM_T_IS_QUAD_T */ diff --git a/Src/Modules/zftp.c b/Src/Modules/zftp.c index 8d688abd4..d16e2f618 100644 --- a/Src/Modules/zftp.c +++ b/Src/Modules/zftp.c @@ -2520,7 +2520,7 @@ zftp_local(UNUSED(char *name), char **args, int flags) printf("%s %s\n", output64(sz), mt); #else DPUTS(sizeof(sz) > 4, "Shell compiled with wrong off_t size"); - printf("%ld %s\n", sz, mt); + printf("%ld %s\n", (long)sz, mt); #endif zsfree(mt); if (dofd) -- cgit v1.2.3 From cf4e27a129cbb04c8206d9efb41a3b58a558a241 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 17 Nov 2011 12:27:18 +0000 Subject: 29907: Jun T.: remove declaration of unused variable --- ChangeLog | 7 ++++++- Src/Modules/pcre.c | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'Src/Modules') diff --git a/ChangeLog b/ChangeLog index 71376d100..05c5ba28e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-11-17 Peter Stephenson + + * Jun T.: 29907: Src/Modules/pcre.c: remove declaration of + unused variable. + 2011-11-15 Barton E. Schaefer * users/16581: Src/utils.c: it seems wrong to shortcut correction @@ -15577,5 +15582,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.5499 $ +* $Revision: 1.5500 $ ***************************************************** diff --git a/Src/Modules/pcre.c b/Src/Modules/pcre.c index e36013163..2e3556a8d 100644 --- a/Src/Modules/pcre.c +++ b/Src/Modules/pcre.c @@ -340,7 +340,6 @@ cond_pcre_match(char **a, int id) pcre *pcre_pat; const char *pcre_err; char *lhstr, *rhre, *lhstr_plain, *rhre_plain, *avar=NULL; - char *p; int r = 0, pcre_opts = 0, pcre_errptr, capcnt, *ov, ovsize; int return_value = 0; -- cgit v1.2.3