From ee00374eee5208edf98cb5c670e5420abb8dae49 Mon Sep 17 00:00:00 2001 From: Michael Ow Date: Mon, 12 Jan 2009 23:02:36 +0000 Subject: [PATCH] ICU-3933 Move swapping of file sep char to filetools.h. Update Makefile and project files. X-SVN-Rev: 25236 --- icu4c/source/tools/pkgdata/pkgdata.cpp | 6 ++---- icu4c/source/tools/toolutil/Makefile.in | 2 +- .../tools/toolutil/{filestat.cpp => filetools.cpp} | 10 +++++++++- .../tools/toolutil/{filestat.h => filetools.h} | 12 +++++++----- icu4c/source/tools/toolutil/toolutil.vcproj | 8 ++++---- 5 files changed, 23 insertions(+), 15 deletions(-) rename icu4c/source/tools/toolutil/{filestat.cpp => filetools.cpp} (90%) rename icu4c/source/tools/toolutil/{filestat.h => filetools.h} (73%) diff --git a/icu4c/source/tools/pkgdata/pkgdata.cpp b/icu4c/source/tools/pkgdata/pkgdata.cpp index f381eb4e63..7a61d57b00 100644 --- a/icu4c/source/tools/pkgdata/pkgdata.cpp +++ b/icu4c/source/tools/pkgdata/pkgdata.cpp @@ -50,7 +50,7 @@ #include "pkg_genc.h" #include "pkg_gencmn.h" #include "flagparser.h" -#include "filestat.h" +#include "filetools.h" #if U_HAVE_POPEN @@ -632,9 +632,7 @@ static int32_t pkg_executeOptions(UPKGOptions *o) { #ifdef WINDOWS_WITH_GNUC /* Need to fix the file seperator character when using MinGW. */ - for (int32_t i = 0, size = uprv_strlen(gencFilePath); i < size; i++) { - gencFilePath[i] = (gencFilePath[i] ==U_FILE_SEP_CHAR ) ? '/' : gencFilePath[i]; - } + swapFileSepChar(gencFilePath, U_FILE_SEP_CHAR, '/'); #endif result = pkg_createWithAssemblyCode(targetDir, mode, gencFilePath); diff --git a/icu4c/source/tools/toolutil/Makefile.in b/icu4c/source/tools/toolutil/Makefile.in index 9a415ce0d7..33b7447bd7 100644 --- a/icu4c/source/tools/toolutil/Makefile.in +++ b/icu4c/source/tools/toolutil/Makefile.in @@ -54,7 +54,7 @@ LIBS = $(LIBICUI18N) $(LIBICUUC) $(DEFAULT_LIBS) OBJECTS = filestrm.o package.o pkgitems.o swapimpl.o toolutil.o unewdata.o \ ucm.o ucmstate.o uoptions.o uparse.o \ ucbuf.o xmlparser.o writesrc.o \ -pkg_icu.o pkg_genc.o pkg_gencmn.o flagparser.o filestat.o +pkg_icu.o pkg_genc.o pkg_gencmn.o flagparser.o filetools.o STATIC_OBJECTS = $(OBJECTS:.o=.$(STATIC_O)) diff --git a/icu4c/source/tools/toolutil/filestat.cpp b/icu4c/source/tools/toolutil/filetools.cpp similarity index 90% rename from icu4c/source/tools/toolutil/filestat.cpp rename to icu4c/source/tools/toolutil/filetools.cpp index 5bf42d5be7..058a6f7ccb 100644 --- a/icu4c/source/tools/toolutil/filestat.cpp +++ b/icu4c/source/tools/toolutil/filetools.cpp @@ -4,7 +4,7 @@ ******************************************************************************* */ -#include "filestat.h" +#include "filetools.h" #include "filestrm.h" #include "cstring.h" #include "unicode/putil.h" @@ -116,3 +116,11 @@ static int32_t whichFileModTimeIsLater(const char *file1, const char *file2) { return result; } + +/* Swap the file separater character given with the new one in the file path. */ +U_CAPI void U_EXPORT2 +swapFileSepChar(char *filePath, const char oldFileSepChar, const char newFileSepChar) { + for (int32_t i = 0, length = uprv_strlen(filePath); i < length; i++) { + filePath[i] = (filePath[i] == oldFileSepChar ) ? newFileSepChar : filePath[i]; + } +} diff --git a/icu4c/source/tools/toolutil/filestat.h b/icu4c/source/tools/toolutil/filetools.h similarity index 73% rename from icu4c/source/tools/toolutil/filestat.h rename to icu4c/source/tools/toolutil/filetools.h index 0e00799860..7d4e139055 100644 --- a/icu4c/source/tools/toolutil/filestat.h +++ b/icu4c/source/tools/toolutil/filetools.h @@ -5,7 +5,7 @@ * Corporation and others. All Rights Reserved. * ******************************************************************************* -* file name: flagparser.h +* file name: filetools.h * encoding: US-ASCII * tab size: 8 (not used) * indentation:4 @@ -13,18 +13,20 @@ * created on: 2009jan09 * created by: Michael Ow * -* Compares modification times on specified files using ICU and intended for use in ICU tests and in build tools. +* Contains various functions to handle files. * Not suitable for production use. Not supported. * Not conformant. Not efficient. -* But very small. */ -#ifndef __FILESTAT_H__ -#define __FILESTAT_H__ +#ifndef __FILETOOLS_H__ +#define __FILETOOLS_H__ #include "unicode/utypes.h" U_CAPI UBool U_EXPORT2 isFileModTimeLater(const char *filePath, const char *checkAgainst, UBool isDir=FALSE); +U_CAPI void U_EXPORT2 +swapFileSepChar(char *filePath, const char oldFileSepChar, const char newFileSepChar); + #endif diff --git a/icu4c/source/tools/toolutil/toolutil.vcproj b/icu4c/source/tools/toolutil/toolutil.vcproj index 5f0cfd9732..7eab1f2da9 100644 --- a/icu4c/source/tools/toolutil/toolutil.vcproj +++ b/icu4c/source/tools/toolutil/toolutil.vcproj @@ -413,11 +413,11 @@ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" >