From: Peter Verthez Date: Sun, 27 Oct 2002 18:05:03 +0000 (+0000) Subject: Function to compute a simple case of base name. X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=bce04a4dc65cd47ec644c0f58b79519de53095d1;p=gedcom-parse.git Function to compute a simple case of base name. --- diff --git a/t/src/portability.c b/t/src/portability.c index e44f7c3..d724595 100644 --- a/t/src/portability.c +++ b/t/src/portability.c @@ -21,6 +21,7 @@ /* $Id$ */ /* $Name$ */ +#include #include "config.h" char* null_str = "(null)"; @@ -72,3 +73,13 @@ void* int_to_void_ptr(int i) t = i; return (void*)t; } + +char* simple_base_name(char* filename) +{ + char* runner = NULL; + if (filename) { + runner = filename + strlen(filename) - 1; + while (runner != filename && *(runner-1) != '/') runner--; + } + return runner; +} diff --git a/t/src/portability.h b/t/src/portability.h index 0aa2bb9..89099a0 100644 --- a/t/src/portability.h +++ b/t/src/portability.h @@ -28,5 +28,6 @@ long int void_ptr_to_int(void* ptr); void* int_to_void_ptr(int t); char* str_val(char* input); char* ptr_val(void* ptr); +char* simple_base_name(char* filename); #endif /* __PORTABILITY_H */