Skip to content

Commit

Permalink
locale.c: Simplify loop
Browse files Browse the repository at this point in the history
A slight restructuring saves some lines.
  • Loading branch information
khwilliamson committed Nov 22, 2023
1 parent 2a2a278 commit c6e0ebb
Showing 1 changed file with 9 additions and 18 deletions.
27 changes: 9 additions & 18 deletions locale.c
Expand Up @@ -5893,31 +5893,22 @@ S_populate_hash_from_localeconv(pTHX_ HV * hv,

/* For each field for the given category ... */
const lconv_offset_t * category_strings = strings[i];
while (1) {
const char * name = category_strings->name;
if (! name) { /* Quit at the end */
break;
}
while (category_strings->name) {

/* we have set things up so that we know where in the returned
/* We have set things up so that we know where in the returned
* structure, when viewed as a string, the corresponding value is.
* */
const char *value = *((const char **)( lcbuf_as_string
+ category_strings->offset));

/* Set to get next string on next iteration */
category_strings++;

/* Skip if this platform doesn't have this field. */
if (! value) {
continue;
if (value) { /* Copy to the hash */
(void) hv_store(hv,
category_strings->name,
strlen(category_strings->name),
newSVpv(value, strlen(value)),
0);
}

/* Copy to the hash */
(void) hv_store(hv,
name, strlen(name),
newSVpv(value, strlen(value)),
0);
category_strings++;
}

/* Add any int fields to the HV* */
Expand Down

0 comments on commit c6e0ebb

Please sign in to comment.