diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2012-07-22 21:40:10 +0200 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2012-07-22 21:40:10 +0200 |
commit | 5c7ac461932c17df91374e6c2740ad22c95481af (patch) | |
tree | 85d21004331d9d1bfca266d111000acd7fa1725a /Src/Modules | |
parent | 3988419a8dc4a74e491df584804a77a2f8be88cd (diff) | |
parent | e27142d45686cacc6ed155e5045b97dd6243d44c (diff) | |
download | zsh-5c7ac461932c17df91374e6c2740ad22c95481af.tar.gz zsh-5c7ac461932c17df91374e6c2740ad22c95481af.zip |
New upstream release
Diffstat (limited to 'Src/Modules')
-rw-r--r-- | Src/Modules/parameter.c | 20 | ||||
-rw-r--r-- | Src/Modules/regex.c | 23 |
2 files changed, 34 insertions, 9 deletions
diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c index 092efa0c3..4d29ba635 100644 --- a/Src/Modules/parameter.c +++ b/Src/Modules/parameter.c @@ -531,7 +531,11 @@ functracegetfn(UNUSED(Param pm)) char *colonpair; colonpair = zhalloc(strlen(f->caller) + (f->lineno > 9999 ? 24 : 6)); +#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD) + sprintf(colonpair, "%s:%lld", f->caller, f->lineno); +#else sprintf(colonpair, "%s:%ld", f->caller, (long)f->lineno); +#endif *p = colonpair; } @@ -559,7 +563,11 @@ funcsourcetracegetfn(UNUSED(Param pm)) char *fname = f->filename ? f->filename : ""; colonpair = zhalloc(strlen(fname) + (f->flineno > 9999 ? 24 : 6)); +#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD) + sprintf(colonpair, "%s:%lld", fname, f->flineno); +#else sprintf(colonpair, "%s:%ld", fname, (long)f->flineno); +#endif *p = colonpair; } @@ -594,7 +602,11 @@ funcfiletracegetfn(UNUSED(Param pm)) */ colonpair = zhalloc(strlen(f->caller) + (f->lineno > 9999 ? 24 : 6)); +#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD) + sprintf(colonpair, "%s:%lld", f->caller, f->lineno); +#else sprintf(colonpair, "%s:%ld", f->caller, (long)f->lineno); +#endif } else { /* * Calling context is a function or eval; we need to find @@ -604,7 +616,7 @@ funcfiletracegetfn(UNUSED(Param pm)) * together with the $functrace line number for the current * context. */ - long flineno = (long)(f->prev->flineno + f->lineno); + zlong flineno = f->prev->flineno + f->lineno; /* * Line numbers in eval start from 1, not zero, * so offset by one to get line in file. @@ -614,7 +626,11 @@ funcfiletracegetfn(UNUSED(Param pm)) fname = f->prev->filename ? f->prev->filename : ""; colonpair = zhalloc(strlen(fname) + (flineno > 9999 ? 24 : 6)); - sprintf(colonpair, "%s:%ld", fname, flineno); +#if defined(ZLONG_IS_LONG_LONG) && defined(PRINTF_HAS_LLD) + sprintf(colonpair, "%s:%lld", fname, flineno); +#else + sprintf(colonpair, "%s:%ld", fname, (long)flineno); +#endif } *p = colonpair; diff --git a/Src/Modules/regex.c b/Src/Modules/regex.c index 08e815003..ce57de986 100644 --- a/Src/Modules/regex.c +++ b/Src/Modules/regex.c @@ -3,7 +3,7 @@ * * This file is part of zsh, the Z shell. * - * Copyright (c) 2007 Phil Pennock + * Copyright (c) 2007,2012 Phil Pennock * All Rights Reserved. * * Permission is hereby granted, without written agreement and without @@ -56,14 +56,19 @@ zcond_regex_match(char **a, int id) regex_t re; regmatch_t *m, *matches = NULL; size_t matchessz = 0; - char *lhstr, *rhre, *s, **arr, **x; + char *lhstr, *lhstr_zshmeta, *rhre, *rhre_zshmeta, *s, **arr, **x; int r, n, return_value, rcflags, reflags, nelem, start; - lhstr = cond_str(a,0,0); - rhre = cond_str(a,1,0); + lhstr_zshmeta = cond_str(a,0,0); + rhre_zshmeta = cond_str(a,1,0); rcflags = reflags = 0; return_value = 0; /* 1 => matched successfully */ + lhstr = ztrdup(lhstr_zshmeta); + unmetafy(lhstr, NULL); + rhre = ztrdup(rhre_zshmeta); + unmetafy(rhre, NULL); + switch(id) { case ZREGEX_EXTENDED: rcflags |= REG_EXTENDED; @@ -101,7 +106,7 @@ zcond_regex_match(char **a, int id) if (nelem) { arr = x = (char **) zalloc(sizeof(char *) * (nelem + 1)); for (m = matches + start, n = start; n <= (int)re.re_nsub; ++n, ++m, ++x) { - *x = ztrduppfx(lhstr + m->rm_so, m->rm_eo - m->rm_so); + *x = metafy(lhstr + m->rm_so, m->rm_eo - m->rm_so, META_DUP); } *x = NULL; } @@ -112,7 +117,7 @@ zcond_regex_match(char **a, int id) char *ptr; m = matches; - s = ztrduppfx(lhstr + m->rm_so, m->rm_eo - m->rm_so); + s = metafy(lhstr + m->rm_so, m->rm_eo - m->rm_so, META_DUP); setsparam("MATCH", s); /* * Count the characters before the match. @@ -174,12 +179,16 @@ zcond_regex_match(char **a, int id) break; default: DPUTS(1, "bad regex option"); - return 0; /* nothing to cleanup, especially not "re". */ + return_value = 0; + goto CLEAN_BASEMETA; } if (matches) zfree(matches, matchessz); regfree(&re); +CLEAN_BASEMETA: + free(lhstr); + free(rhre); return return_value; } |