This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 2/2] gconv: Replace norm_add_slashes with __gconv_norm_add_slashes
- From: Florian Weimer <fweimer at redhat dot com>
- To: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- Cc: libc-alpha at sourceware dot org
- Date: Wed, 21 Jun 2017 22:27:13 +0200
- Subject: Re: [PATCH 2/2] gconv: Replace norm_add_slashes with __gconv_norm_add_slashes
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx08.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=fweimer at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1E0ABC01BD33
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1E0ABC01BD33
- References: <1497985923-18986-1-git-send-email-adhemerval.zanella@linaro.org> <1497985923-18986-2-git-send-email-adhemerval.zanella@linaro.org>
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