unsigned char last_chars[2] = { 0, 0 };
while (len > 0) {
- inc_len = (*ptr == '\0' ? 1: php_mblen(ptr, len));
+ inc_len = (*ptr == '\0' ? 1 : php_mblen(ptr, len));
switch (inc_len) {
case -2:
case -1:
inc_len = 1;
- php_ignore_value(php_mblen(NULL, 0));
+ php_mb_reset();
break;
case 0:
goto quit_loop;
zend_bool first_field = 1;
/* initialize internal state */
- php_ignore_value(php_mblen(NULL, 0));
+ php_mb_reset();
/* Now into new section that parses buf for delimiter/enclosure fields */
tptr = temp;
- inc_len = (bptr < limit ? (*bptr == '\0' ? 1: php_mblen(bptr, limit - bptr)): 0);
+ inc_len = (bptr < limit ? (*bptr == '\0' ? 1 : php_mblen(bptr, limit - bptr)): 0);
if (inc_len == 1) {
char *tmp = bptr;
while ((*tmp != delimiter) && isspace((int)*(unsigned char *)tmp)) {
case -2:
case -1:
- php_ignore_value(php_mblen(NULL, 0));
+ php_mb_reset();
/* break is omitted intentionally */
case 1:
/* we need to determine if the enclosure is
}
break;
}
- inc_len = (bptr < limit ? (*bptr == '\0' ? 1: php_mblen(bptr, limit - bptr)): 0);
+ inc_len = (bptr < limit ? (*bptr == '\0' ? 1 : php_mblen(bptr, limit - bptr)): 0);
}
quit_loop_2:
case -2:
case -1:
inc_len = 1;
- php_ignore_value(php_mblen(NULL, 0));
+ php_mb_reset();
/* break is omitted intentionally */
case 1:
if (*bptr == delimiter) {
break;
}
bptr += inc_len;
- inc_len = (bptr < limit ? (*bptr == '\0' ? 1: php_mblen(bptr, limit - bptr)): 0);
+ inc_len = (bptr < limit ? (*bptr == '\0' ? 1 : php_mblen(bptr, limit - bptr)): 0);
}
quit_loop_3:
case -2:
case -1:
inc_len = 1;
- php_ignore_value(php_mblen(NULL, 0));
+ php_mb_reset();
/* break is omitted intentionally */
case 1:
if (*bptr == delimiter) {
break;
}
bptr += inc_len;
- inc_len = (bptr < limit ? (*bptr == '\0' ? 1: php_mblen(bptr, limit - bptr)): 0);
+ inc_len = (bptr < limit ? (*bptr == '\0' ? 1 : php_mblen(bptr, limit - bptr)): 0);
}
quit_loop_4:
memcpy(tptr, hunk_begin, bptr - hunk_begin);
#ifndef HAVE_MBLEN
# define php_mblen(ptr, len) 1
+# define php_mb_reset()
+#elif defined(_REENTRANT) && defined(HAVE_MBRLEN) && defined(HAVE_MBSTATE_T)
+# define php_mblen(ptr, len) ((int) mbrlen(ptr, len, &BG(mblen_state)))
+# define php_mb_reset() memset(&BG(mblen_state), 0, sizeof(BG(mblen_state)))
#else
-# if defined(_REENTRANT) && defined(HAVE_MBRLEN) && defined(HAVE_MBSTATE_T)
-# define php_mblen(ptr, len) ((ptr) == NULL ? memset(&BG(mblen_state), 0, sizeof(BG(mblen_state))): (int)mbrlen(ptr, len, &BG(mblen_state)))
-# else
-# define php_mblen(ptr, len) mblen(ptr, len)
-# endif
+# define php_mblen(ptr, len) mblen(ptr, len)
+# define php_mb_reset() mblen(NULL, 0)
#endif
void register_string_constants(INIT_FUNC_ARGS);