scuffed-code/icu4c/source/tools/genrb/util.c

61 lines
1.4 KiB
C
Raw Normal View History

1999-08-16 21:50:52 +00:00
/*
*******************************************************************************
*
* Copyright (C) 1998-2000, International Business Machines
* Corporation and others. All Rights Reserved.
*
1999-08-16 21:50:52 +00:00
*******************************************************************************
*
* File util.c
*
* Modification History:
*
* Date Name Description
* 06/10/99 stephen Creation.
*******************************************************************************
*/
#include "unicode/putil.h"
1999-08-16 21:50:52 +00:00
#include "util.h"
#include "cmemory.h"
#include "cstring.h"
/* go from "/usr/local/include/curses.h" to "/usr/local/include" */
void
get_dirname(char *dirname,
2002-04-02 02:55:31 +00:00
const char *filename)
1999-08-16 21:50:52 +00:00
{
const char *lastSlash = uprv_strrchr(filename, U_FILE_SEP_CHAR) + 1;
1999-08-16 21:50:52 +00:00
if(lastSlash>filename) {
uprv_strncpy(dirname, filename, (lastSlash - filename));
*(dirname + (lastSlash - filename)) = '\0';
} else {
*dirname = '\0';
1999-08-16 21:50:52 +00:00
}
}
/* go from "/usr/local/include/curses.h" to "curses" */
void
get_basename(char *basename,
2002-04-02 02:55:31 +00:00
const char *filename)
1999-08-16 21:50:52 +00:00
{
/* strip off any leading directory portions */
const char *lastSlash = uprv_strrchr(filename, U_FILE_SEP_CHAR) + 1;
1999-08-16 21:50:52 +00:00
char *lastDot;
if(lastSlash>filename) {
uprv_strcpy(basename, lastSlash);
} else {
uprv_strcpy(basename, filename);
1999-08-16 21:50:52 +00:00
}
/* strip off any suffix */
lastDot = uprv_strrchr(basename, '.');
if(lastDot != NULL) {
*lastDot = '\0';
1999-08-16 21:50:52 +00:00
}
}