- FOREACH_HASH_VAL(pos, Z_ARRVAL(ex_arr), entry) {
- int ident_len;
- double quality;
- char *selected, *identifier, *freeme;
- const char *separator;
-
-#if PHP_HTTP_DBG_NEG
- fprintf(stderr, "Checking %s\n", Z_STRVAL_PP(entry));
-#endif
-
- if ((separator = strchr(Z_STRVAL_PP(entry), ';'))) {
- const char *ptr = separator;
-
- while (*++ptr && !PHP_HTTP_IS_CTYPE(digit, *ptr) && '.' != *ptr);
-
- quality = zend_strtod(ptr, NULL);
- identifier = estrndup(Z_STRVAL_PP(entry), ident_len = separator - Z_STRVAL_PP(entry));
- } else {
- quality = 1000.0 - i++;
- identifier = estrndup(Z_STRVAL_PP(entry), ident_len = Z_STRLEN_PP(entry));
- }
- freeme = identifier;
-
- while (PHP_HTTP_IS_CTYPE(space, *identifier)) {
- ++identifier;
- --ident_len;
- }
- while (ident_len && PHP_HTTP_IS_CTYPE(space, identifier[ident_len - 1])) {
- identifier[--ident_len] = '\0';
- }
-
- if ((selected = neg(identifier, &quality, supported TSRMLS_CC))) {
- /* don't overwrite previously set with higher quality */
- if (!zend_hash_exists(Z_ARRVAL(array), selected, strlen(selected) + 1)) {
- add_assoc_double(&array, selected, quality);
- }
- }
-
- efree(freeme);
+ if (key.type == HASH_KEY_IS_STRING) {
+ add_assoc_double_ex(&arr, key.str, key.len, q);
+ } else {
+ add_index_double(&arr, key.num, q);