Re: [PATCH] submodule--helper: normalize funny urls

2 messages, 2 authors, 2016-10-18 · open the first message on its own page

Re: [PATCH] submodule--helper: normalize funny urls

From: Junio C Hamano <hidden>
Date: 2016-10-18 17:15:22

Junio C Hamano [off-list ref] writes:
Stefan Beller [off-list ref] writes:
quoted
+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?
quoted
+			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?
quoted
+			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?

Re: [PATCH] submodule--helper: normalize funny urls

From: Stefan Beller <hidden>
Date: 2016-10-18 17:17:50

On Tue, Oct 18, 2016 at 10:15 AM, Junio C Hamano [off-list ref] wrote:
I also somehow find the "check-url-stripping" variable ugly.

        while (URL still has something that could be stripped) {
for(;;) {

here ? (this code would not need a variable, and
for wins over while:
$ git grep "while (1)" |wc -l
107
$ git grep "for (;;)" |wc -l
128
)
                if (ends with "/.") {
                        strip "/.";
                        continue;
                }
                if (ends with "/") {
                        strip "/";
                        continue;
                }
                break;
        }

perhaps?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help