This mini series adds a fall-back for the `dirname()` function that we use e.g. in git-am. This is necessary because not all platforms have a working libgen.h. While at it, we ensure that our basename() drop-in conforms to the POSIX specifications. In addition to the interdiff vs v2, the commit message was fixed to mention basename("") as cornercase (not basename("abc")). Johannes Schindelin (4): Refactor skipping DOS drive prefixes compat/basename: make basename() conform to POSIX Provide a dirname() function when NO_LIBGEN_H=YesPlease t0060: verify that basename() and dirname() work as expected compat/basename.c | 66 ++++++++++++++++++-- compat/mingw.c | 14 ++--- compat/mingw.h | 10 ++- git-compat-util.h | 10 +++ path.c | 14 ++--- t/t0060-path-utils.sh | 3 + test-path-utils.c | 166 ++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 259 insertions(+), 24 deletions(-) Interdiff vs v2: diff --git a/test-path-utils.c b/test-path-utils.c index 74e74c9..4ab68ac 100644 --- a/test-path-utils.c +++ b/test-path-utils.c @@ -40,15 +40,15 @@ static void normalize_argv_string(const char **var, const char *input) } struct test_data { - char *from; /* input: transform from this ... */ - char *to; /* output: ... to this. */ + const char *from; /* input: transform from this ... */ + const char *to; /* output: ... to this. */ }; static int test_function(struct test_data *data, char *(*func)(char *input), const char *funcname) { int failed = 0, i; - static char buffer[1024]; + char buffer[1024]; char *to; for (i = 0; data[i].to; i++) { @@ -61,10 +61,10 @@ static int test_function(struct test_data *data, char *(*func)(char *input), if (strcmp(to, data[i].to)) { error("FAIL: %s(%s) => '%s' != '%s'\n", funcname, data[i].from, to, data[i].to); - failed++; + failed = 1; } } - return !!failed; + return failed; } static struct test_data basename_data[] = { @@ -132,7 +132,6 @@ static struct test_data basename_data[] = { #endif #endif - { NULL, "." }, { NULL, NULL } }; @@ -197,7 +196,6 @@ static struct test_data dirname_data[] = { #endif #endif - { NULL, "." }, { NULL, NULL } }; -- 2.6.3.windows.1.300.g1c25e49 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html