X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Faccess.c;h=44c7e1b2f5d129d366bcaf45341eaadbbbf39eb5;hp=f5240c121c26bf2003a5a1c2423b62140b1e177a;hb=a8987e73ec254703634802b4f7ee30d3a485524d;hpb=46722468f47c2b77b3987729b4bcf2321cccfd01 diff --git a/ncurses/tinfo/access.c b/ncurses/tinfo/access.c index f5240c12..44c7e1b2 100644 --- a/ncurses/tinfo/access.c +++ b/ncurses/tinfo/access.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998,2000,2001 Free Software Foundation, Inc. * + * Copyright (c) 1998,2001,2003 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -34,7 +34,7 @@ #include #include -MODULE_ID("$Id: access.c,v 1.9 2001/06/23 22:11:49 tom Exp $") +MODULE_ID("$Id: access.c,v 1.10 2003/07/05 19:31:28 tom Exp $") #define LOWERCASE(c) ((isalpha(UChar(c)) && isupper(UChar(c))) ? tolower(UChar(c)) : (c)) @@ -64,19 +64,28 @@ _nc_rootname(char *path) return result; } -NCURSES_EXPORT(char *) -_nc_basename(char *path) +/* + * Return index of the basename + */ +NCURSES_EXPORT(unsigned) +_nc_pathlast(const char *path) { - char *result = strrchr(path, '/'); + const char *test = strrchr(path, '/'); #ifdef __EMX__ - if (result == 0) - result = strrchr(path, '\\'); + if (test == 0) + test = strrchr(path, '\\'); #endif - if (result == 0) - result = path; + if (test == 0) + test = path; else - result++; - return result; + test++; + return (test - path); +} + +NCURSES_EXPORT(char *) +_nc_basename(char *path) +{ + return path + _nc_pathlast(path); } NCURSES_EXPORT(int)