login
Header Space

 
 

Re: [PATCH 1/4] Implement normalize_absolute_path

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: David Reiss <dreiss@...>
Cc: <git@...>
Date: Tuesday, May 20, 2008 - 6:24 pm

David Reiss, Tue, May 20, 2008 08:48:54 +0200:

Heh...
http://thread.gmane.org/gmane.comp.version-control.git/68786/focus=68812

The test of the function has these cases:

static void check(const char *cwd, const char *path, const char *good);

int main(int argc, char **argv)
{
	/* 1 */ check("/onelevel", "aa", "onelevel/aa");
	/* 2 */ check("/", "..", "");
	/* 3 */ check("/", "../..", "");
	/* 4 */ check("/one", "aa/../bb", "one/bb");
	/* 5 */ check("/one/two", "aa//bb", "one/two/aa/bb");
	/* 6 */ check("", "/aa//bb", "aa/bb");
	/* 7 */ check("/one/two", "", "one/two");
	/* 8 */ check("/one/two", "aa/..bb/x/../cc/", "one/two/aa/..bb/cc");
	/* 9 */ check("/one/two", "aa/x/././cc////", "one/two/aa/x/cc");
	/* 10 */ check("/one/two", "../../../../aa", "aa");
	/* 11 */ check("one/", "../one/two", "one/two");
	/* 12 */ check("", "../../two", "two");
	/* 13 */ check("a/b/c", "../../two", "a/two");
	/* 14 */ check("a/b/", "../two", "a/two");
	/* 15 */ check("///", "../two", "two");
	return 0;
}

static void check(const char *cwd, const char *path, const char *good)
{
	static int n = 0;
	printf("%-2d: %10s$ cd %s", ++n, cwd, path);
	char *t = pathexpand(cwd, path);
	if ( strcmp(t, good) )
		printf(" ____________________failed(%s)\n", t);
	else
		printf(" \033[32m%s\033[0m\n", t);
	free(t);
}


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 1/4] Implement normalize_absolute_path, David Reiss, (Tue May 20, 2:48 am)
Re: [PATCH 1/4] Implement normalize_absolute_path, Alex Riesen, (Tue May 20, 6:24 pm)
Re: [PATCH 1/4] Implement normalize_absolute_path, David Reiss, (Wed May 21, 4:34 am)
Re: [PATCH 1/4] Implement normalize_absolute_path, Alex Riesen, (Thu May 22, 8:48 am)
Re: [PATCH 1/4] Implement normalize_absolute_path, Johannes Schindelin, (Tue May 20, 8:22 am)
Re: [PATCH 1/4] Implement normalize_absolute_path, David Reiss, (Tue May 20, 12:44 pm)
speck-geostationary