[PATCH 2/2] gconv: Replace norm_add_slashes with __gconv_norm_add_slashes
Florian Weimer
fweimer@redhat.com
Wed Jun 21 20:27:00 GMT 2017
On 06/20/2017 09:12 PM, Adhemerval Zanella wrote:
> +char *
> +__gconv_norm_add_slashes (const char *name, size_t name_len,
> + const char *suffix)
> +{
> + size_t cnt = 0;
> + for (size_t i = 0; i < name_len; i++)
> + if (name[i] == '/')
> + cnt++;
> +
> + struct char_array result;
> + if (!char_array_init_str_size (&result, name, name_len))
> + return NULL;
> +
> + for (size_t i = 0; i < char_array_length (&result); i++)
> + *char_array_at (&result, i) = __toupper_l (name[i], _nl_C_locobj_ptr);
> +
> + if (cnt < 2)
> + {
> + if (!char_array_append_str (&result, "/"))
> + return NULL;
> + if (cnt < 1)
> + {
> + if (!char_array_append_str (&result, "/")
> + | !char_array_append_str (&result, suffix))
> + return NULL;
> + }
> + }
> +
> + return char_array_finalize (&result, NULL);
> +}
Thanks for posting this. I'll plan to compare this with a plain
dynarray-based implementation, to see what the generated code is like in
both cases.
Florian
More information about the Libc-alpha
mailing list