diff --git a/source/common/cstring.h b/source/common/cstring.h index 46af79e3e90..848e9cb71d1 100644 --- a/source/common/cstring.h +++ b/source/common/cstring.h @@ -36,12 +36,14 @@ #define icu_strcpy(dst, src) strcpy(dst, src) #define icu_strcpyWithSize(dst, src, size) strncpy(dst, src, size) +#define icu_strncpy(dst, src, size) strncpy(dst, src, size) #define icu_strlen(str) strlen(str) #define icu_strcmp(s1, s2) strcmp(s1, s2) #define icu_strncmp(s1, s2, n) strncmp(s1, s2, n) #define icu_strcat(dst, src) strcat(dst, src) #define icu_strncat(dst, src, n) strncat(dst, src, n) #define icu_strchr(s, c) strchr(s, c) +#define icu_strrchr(s, c) strrchr(s, c) #define icu_toupper(c) toupper(c) #define icu_tolower(c) tolower(c) diff --git a/source/tools/genrb/genrb.dsp b/source/tools/genrb/genrb.dsp index f7219d6b65a..64b6e181f93 100644 --- a/source/tools/genrb/genrb.dsp +++ b/source/tools/genrb/genrb.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /I "..\..\..\include" /I "..\..\..\source\common" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /MT /Za /W3 /GX /I "..\..\..\include" /I "..\..\..\source\common" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe @@ -66,7 +66,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\include" /I "..\..\..\source\common" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /Za /W3 /Gm /GX /ZI /Od /I "..\..\..\include" /I "..\..\..\source\common" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe diff --git a/source/tools/genrb/util.c b/source/tools/genrb/util.c index bc1e620fb59..c31b03dd138 100644 --- a/source/tools/genrb/util.c +++ b/source/tools/genrb/util.c @@ -24,7 +24,7 @@ /* Platform-specific directory separator */ -#ifdef WIN32 +#if defined(WIN32) || defined(_WIN32) || defined(OS2) || defined(__OS2__) # define DIR_SEP '\\' # define CUR_DIR ".\\" #else @@ -37,29 +37,14 @@ void get_dirname(char *dirname, const char *filename) { - const char *slash; - const char *lastSlash; + const char *lastSlash = icu_strrchr(filename, DIR_SEP) + 1; - /* if the first character isn't DIR_SEP or '.', return CUR_DIR */ - if(*filename != DIR_SEP && *filename != '.') { - icu_strcpy(dirname, CUR_DIR); - return; + if(lastSlash>filename) { + icu_strncpy(dirname, filename, (lastSlash - filename)); + *(dirname + (lastSlash - filename)) = '\0'; + } else { + *dirname = '\0'; } - - /* strip off and copy any leading directory portions */ - slash = lastSlash = filename; - for(;;) { - slash = icu_strchr(slash, DIR_SEP); - if(slash == 0) { - slash = lastSlash; - break; - } - ++slash; - lastSlash = slash; - } - - *dirname = '\0'; - icu_strncat(dirname, filename, (lastSlash - filename)); } /* go from "/usr/local/include/curses.h" to "curses" */ @@ -67,36 +52,20 @@ void get_basename(char *basename, const char *filename) { - const char *slash; - const char *lastSlash; - char *dot; + /* strip off any leading directory portions */ + const char *lastSlash = icu_strrchr(filename, DIR_SEP) + 1; char *lastDot; - /* strip off any leading directory portions */ - slash = lastSlash = filename; - for(;;) { - slash = icu_strchr(slash, DIR_SEP); - if(slash == 0) { - slash = lastSlash; - break; - } - ++slash; - lastSlash = slash; + if(lastSlash>filename) { + icu_strcpy(basename, lastSlash); + } else { + icu_strcpy(basename, filename); } - - icu_strcpy(basename, slash); /* strip off any suffix */ - dot = basename; - lastDot = 0; - for(;;) { - dot = icu_strchr(dot, '.'); - if(dot == 0) { - if(lastDot != 0) - *lastDot = '\0'; - break; - } - lastDot = dot; - ++dot; + lastDot = icu_strrchr(basename, '.'); + + if(lastDot != NULL) { + *lastDot = '\0'; } } diff --git a/source/tools/makedata.bat b/source/tools/makedata.bat index 237c46ad236..d17aed294e6 100755 --- a/source/tools/makedata.bat +++ b/source/tools/makedata.bat @@ -9,16 +9,19 @@ if "%1"=="" goto :error if "%ICU_DATA%"=="" set ICU_DATA=%1\icu\data\ set toolversion=Debug -cd %1\icu\data - rem create conversion tables -call %1\icu\source\tools\makeconv\mkcnvfle %toolversion% %1 +cd makeconv +call mkcnvfle %toolversion% %1 rem create locale resource bundles -call %1\icu\source\tools\genrb\genrb %1\icu\source\tools\genrb\%toolversion% %1 +cd ..\genrb +call genrb %toolversion% %1 rem create binary collation tables -%1\icu\source\tools\gencol\%toolversion%\gencol +cd ..\gencol +%toolversion%\gencol + +cd .. goto :end @@ -26,6 +29,6 @@ goto :end echo call makedata with the absolute path to the icu directory echo for example, if the full path is d:\mytools\icu then call echo makedata d:\mytools -echo the current directory will be changed to d:\mytools\icu\data +echo the current directory must be the icu\source\tools directory with makedata.bat :end