From 36375b59118bad3cefeda373805f6f364818b46a Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Mon, 19 Jan 2009 08:00:15 +0000 Subject: Fixed a few compiler warnings. --- ChangeLog | 9 ++++++++- Src/Modules/regex.c | 14 ++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index cc69f249e..b6e3d3d28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-01-19 Wayne Davison + + * unposted: fixed compiler warnings in zcond_regex_match(), + including a (useless) warning about matchessz potentially + being used uninitialized, some signed/unsigned warnings + about re.re_nsub. Split a couple compound lines too. + 2009-01-19 Doug Kearns * 26361: Completion/Unix/Command/_rake: update for version 0.8.3. @@ -10930,5 +10937,5 @@ ***************************************************** * This is used by the shell to define $ZSH_PATCHLEVEL -* $Revision: 1.4514 $ +* $Revision: 1.4515 $ ***************************************************** diff --git a/Src/Modules/regex.c b/Src/Modules/regex.c index 00ed46b3b..0051c6df0 100644 --- a/Src/Modules/regex.c +++ b/Src/Modules/regex.c @@ -55,7 +55,7 @@ zcond_regex_match(char **a, int id) { regex_t re; regmatch_t *m, *matches = NULL; - size_t matchessz; + size_t matchessz = 0; char *lhstr, *rhre, *s, **arr, **x; int r, n, return_value, rcflags, reflags, nelem, start; @@ -77,15 +77,16 @@ zcond_regex_match(char **a, int id) /* re.re_nsub is number of parenthesized groups, we also need * 1 for the 0 offset, which is the entire matched portion */ - if (re.re_nsub < 0) { + if ((int)re.re_nsub < 0) { zwarn("INTERNAL ERROR: regcomp() returned " - "negative subpattern count %d", re.re_nsub); + "negative subpattern count %d", (int)re.re_nsub); break; } matchessz = (re.re_nsub + 1) * sizeof(regmatch_t); matches = zalloc(matchessz); r = regexec(&re, lhstr, re.re_nsub+1, matches, reflags); - if (r == REG_NOMATCH) /**/; + if (r == REG_NOMATCH) + ; /* We do nothing when we fail to match. */ else if (r == 0) { return_value = 1; if (isset(BASHREMATCH)) { @@ -99,7 +100,7 @@ zcond_regex_match(char **a, int id) /* entire matched portion + re_nsub substrings + NULL */ if (nelem) { arr = x = (char **) zalloc(sizeof(char *) * (nelem + 1)); - for (m = matches + start, n = start; n <= re.re_nsub; ++n, ++m, ++x) { + 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 = NULL; @@ -114,7 +115,8 @@ zcond_regex_match(char **a, int id) setaparam("match", arr); } } - else zregex_regerrwarn(r, &re, "regex matching error"); + else + zregex_regerrwarn(r, &re, "regex matching error"); break; default: DPUTS(1, "bad regex option"); -- cgit 1.4.1