summaryrefslogtreecommitdiff
path: root/Src/Modules/regex.c
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2009-01-19 08:00:15 +0000
committerWayne Davison <wayned@users.sourceforge.net>2009-01-19 08:00:15 +0000
commit36375b59118bad3cefeda373805f6f364818b46a (patch)
tree636c1aa837057d7027e8244366e3e64d429b5f6f /Src/Modules/regex.c
parentde41104d67547029dd32968cd0a623dfdd541633 (diff)
downloadzsh-36375b59118bad3cefeda373805f6f364818b46a.tar.gz
zsh-36375b59118bad3cefeda373805f6f364818b46a.zip
Fixed a few compiler warnings.
Diffstat (limited to 'Src/Modules/regex.c')
-rw-r--r--Src/Modules/regex.c14
1 files changed, 8 insertions, 6 deletions
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");