Skip to content

Commit 171fd93

Browse files
author
Moriyoshi Koizumi
committed
Style fix
1 parent 75d6810 commit 171fd93

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

ext/ereg/ereg.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,12 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
278278

279279
string_len = strlen(string);
280280

281-
if (icase)
281+
if (icase) {
282282
copts = REG_ICASE;
283-
if (extended)
283+
}
284+
if (extended) {
284285
copts |= REG_EXTENDED;
286+
}
285287

286288
err = regcomp(&re, pattern, copts);
287289
if (err) {
@@ -321,7 +323,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
321323

322324
new_l = strlen(buf) + subs[0].rm_so; /* part before the match */
323325
walk = replace;
324-
while (*walk)
326+
while (*walk) {
325327
if ('\\' == *walk && isdigit(walk[1]) && walk[1] - '0' <= ((char) re.re_nsub)) {
326328
if (subs[walk[1] - '0'].rm_so > -1 && subs[walk[1] - '0'].rm_eo > -1) {
327329
new_l += subs[walk[1] - '0'].rm_eo - subs[walk[1] - '0'].rm_so;
@@ -331,7 +333,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
331333
new_l++;
332334
walk++;
333335
}
334-
336+
}
335337
if (new_l + 1 > buf_len) {
336338
buf_len = 1 + buf_len + 2 * new_l;
337339
nbuf = emalloc(buf_len);
@@ -346,7 +348,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
346348
/* copy replacement and backrefs */
347349
walkbuf = &buf[tmp + subs[0].rm_so];
348350
walk = replace;
349-
while (*walk)
351+
while (*walk) {
350352
if ('\\' == *walk && isdigit(walk[1]) && walk[1] - '0' <= (int)re.re_nsub) {
351353
if (subs[walk[1] - '0'].rm_so > -1 && subs[walk[1] - '0'].rm_eo > -1
352354
/* this next case shouldn't happen. it does. */
@@ -359,13 +361,15 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
359361
walk += 2;
360362
} else {
361363
*walkbuf++ = *walk++;
362-
}
364+
}
365+
}
363366
*walkbuf = '\0';
364367

365368
/* and get ready to keep looking for replacements */
366369
if (subs[0].rm_so == subs[0].rm_eo) {
367-
if (subs[0].rm_so + pos >= string_len)
370+
if (subs[0].rm_so + pos >= string_len) {
368371
break;
372+
}
369373
new_l = strlen (buf) + 1;
370374
if (new_l + 1 > buf_len) {
371375
buf_len = 1 + buf_len + 2 * new_l;

ext/standard/reg.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,12 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
278278

279279
string_len = strlen(string);
280280

281-
if (icase)
281+
if (icase) {
282282
copts = REG_ICASE;
283-
if (extended)
283+
}
284+
if (extended) {
284285
copts |= REG_EXTENDED;
286+
}
285287

286288
err = regcomp(&re, pattern, copts);
287289
if (err) {
@@ -321,7 +323,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
321323

322324
new_l = strlen(buf) + subs[0].rm_so; /* part before the match */
323325
walk = replace;
324-
while (*walk)
326+
while (*walk) {
325327
if ('\\' == *walk && isdigit(walk[1]) && walk[1] - '0' <= ((char) re.re_nsub)) {
326328
if (subs[walk[1] - '0'].rm_so > -1 && subs[walk[1] - '0'].rm_eo > -1) {
327329
new_l += subs[walk[1] - '0'].rm_eo - subs[walk[1] - '0'].rm_so;
@@ -331,7 +333,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
331333
new_l++;
332334
walk++;
333335
}
334-
336+
}
335337
if (new_l + 1 > buf_len) {
336338
buf_len = 1 + buf_len + 2 * new_l;
337339
nbuf = emalloc(buf_len);
@@ -346,7 +348,7 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
346348
/* copy replacement and backrefs */
347349
walkbuf = &buf[tmp + subs[0].rm_so];
348350
walk = replace;
349-
while (*walk)
351+
while (*walk) {
350352
if ('\\' == *walk && isdigit(walk[1]) && walk[1] - '0' <= (int)re.re_nsub) {
351353
if (subs[walk[1] - '0'].rm_so > -1 && subs[walk[1] - '0'].rm_eo > -1
352354
/* this next case shouldn't happen. it does. */
@@ -359,13 +361,15 @@ PHPAPI char *php_reg_replace(const char *pattern, const char *replace, const cha
359361
walk += 2;
360362
} else {
361363
*walkbuf++ = *walk++;
362-
}
364+
}
365+
}
363366
*walkbuf = '\0';
364367

365368
/* and get ready to keep looking for replacements */
366369
if (subs[0].rm_so == subs[0].rm_eo) {
367-
if (subs[0].rm_so + pos >= string_len)
370+
if (subs[0].rm_so + pos >= string_len) {
368371
break;
372+
}
369373
new_l = strlen (buf) + 1;
370374
if (new_l + 1 > buf_len) {
371375
buf_len = 1 + buf_len + 2 * new_l;

0 commit comments

Comments
 (0)