size = n + MBSTRG(default_detect_order_list_size);
/* make list */
list = (const mbfl_encoding **)pecalloc(size, sizeof(mbfl_encoding*), persistent);
- if (list != NULL) {
- entry = list;
- n = 0;
- bauto = 0;
- p1 = tmpstr;
- do {
- p2 = p = (char*)php_memnstr(p1, ",", 1, endp);
- if (p == NULL) {
- p = endp;
- }
+ entry = list;
+ n = 0;
+ bauto = 0;
+ p1 = tmpstr;
+ do {
+ p2 = p = (char*)php_memnstr(p1, ",", 1, endp);
+ if (p == NULL) {
+ p = endp;
+ }
+ *p = '\0';
+ /* trim spaces */
+ while (p1 < p && (*p1 == ' ' || *p1 == '\t')) {
+ p1++;
+ }
+ p--;
+ while (p > p1 && (*p == ' ' || *p == '\t')) {
*p = '\0';
- /* trim spaces */
- while (p1 < p && (*p1 == ' ' || *p1 == '\t')) {
- p1++;
- }
p--;
- while (p > p1 && (*p == ' ' || *p == '\t')) {
- *p = '\0';
- p--;
- }
- /* convert to the encoding number and check encoding */
- if (strcasecmp(p1, "auto") == 0) {
- if (!bauto) {
- const enum mbfl_no_encoding *src = MBSTRG(default_detect_order_list);
- const size_t identify_list_size = MBSTRG(default_detect_order_list_size);
- size_t i;
- bauto = 1;
- for (i = 0; i < identify_list_size; i++) {
- *entry++ = mbfl_no2encoding(*src++);
- n++;
- }
- }
- } else {
- const mbfl_encoding *encoding = mbfl_name2encoding(p1);
- if (encoding) {
- *entry++ = encoding;
+ }
+ /* convert to the encoding number and check encoding */
+ if (strcasecmp(p1, "auto") == 0) {
+ if (!bauto) {
+ const enum mbfl_no_encoding *src = MBSTRG(default_detect_order_list);
+ const size_t identify_list_size = MBSTRG(default_detect_order_list_size);
+ size_t i;
+ bauto = 1;
+ for (i = 0; i < identify_list_size; i++) {
+ *entry++ = mbfl_no2encoding(*src++);
n++;
- } else {
- ret = FAILURE;
}
}
- p1 = p2 + 1;
- } while (n < size && p2 != NULL);
- if (n > 0) {
- if (return_list) {
- *return_list = list;
+ } else {
+ const mbfl_encoding *encoding = mbfl_name2encoding(p1);
+ if (encoding) {
+ *entry++ = encoding;
+ n++;
} else {
- ret = 0;
- pefree(list, persistent);
++ ret = FAILURE;
}
+ }
+ p1 = p2 + 1;
+ } while (n < size && p2 != NULL);
+ if (n > 0) {
+ if (return_list) {
+ *return_list = list;
} else {
pefree(list, persistent);
- if (return_list) {
- *return_list = NULL;
- }
- ret = FAILURE;
- }
- if (return_size) {
- *return_size = n;
}
} else {
+ pefree(list, persistent);
if (return_list) {
*return_list = NULL;
}
- ret = 0;
- if (return_size) {
- *return_size = 0;
- }
+ ret = FAILURE;
}
+ if (return_size) {
+ *return_size = n;
+ }
efree(tmpstr);
}