Junio C Hamano <gits...@pobox.com> writes:

> Stefan Beller <sbel...@google.com> writes:
>
>> +static void strip_url_ending(char *url, size_t *_len)
>> +{
>> +    int check_url_stripping = 1;
>> +    size_t len = _len ? *_len : strlen(url);
>> +
>> +    while (check_url_stripping) {
>> +            check_url_stripping = 0;
>> +            if (is_dir_sep(url[len-2]) && url[len-1] == '.') {
>
> This is "strip /. at the end" it seems.
>
> Does anything in the loop control guarantees 2 <= len at this point?
>
>> +                    url[len-2] = '\0';
>> +                    len -= 2;
>> +                    check_url_stripping = 1;
>> +            }
>> +
>> +            if (is_dir_sep(url[len-1])) {
>
> This is "strip / at the end" it seems.
>
> Does anything in the loop control guarantees 1 <= len at this point?
>
>> +                    url[len-1] = '\0';
>> +                    len--;
>> +                    check_url_stripping = 1;
>> +            }
>> +    }

I also somehow find the "check-url-stripping" variable ugly.

        while (URL still has something that could be stripped) {
                if (ends with "/.") {
                        strip "/.";
                        continue;
                }
                if (ends with "/") {
                        strip "/";
                        continue;
                }
                break;
        }

perhaps?

Reply via email to