Vanilla icu4c 73.1

This commit is contained in:
Christoph M. Becker
2024-08-30 23:51:28 +02:00
parent 78566e4dd3
commit 38dca97391
1118 changed files with 34965 additions and 26083 deletions
+127 -123
View File
@@ -91,7 +91,7 @@ static void pkg_destroyOptMatchArch(char *optMatchArch);
#endif
static int32_t pkg_createWithAssemblyCode(const char *targetDir, const char mode, const char *gencFilePath);
static int32_t pkg_generateLibraryFile(const char *targetDir, const char mode, const char *objectFile, char *command = NULL, UBool specialHandling=false);
static int32_t pkg_generateLibraryFile(const char *targetDir, const char mode, const char *objectFile, char *command = nullptr, UBool specialHandling=false);
static int32_t pkg_archiveLibrary(const char *targetDir, const char *version, UBool reverseExt);
static void createFileNames(UPKGOptions *o, const char mode, const char *version_major, const char *version, const char *libName, const UBool reverseExt, UBool noVersion);
static int32_t initializePkgDataFlags(UPKGOptions *o);
@@ -215,7 +215,7 @@ static const char* FLAG_NAMES[PKGDATA_FLAGS_SIZE] = {
"RANLIB",
"INSTALL_CMD"
};
static char **pkgDataFlags = NULL;
static char **pkgDataFlags = nullptr;
enum {
LIB_FILE,
@@ -423,7 +423,7 @@ main(int argc, char* argv[]) {
if (options[BLDOPT].doesOccur) {
o.options = options[BLDOPT].value;
} else {
o.options = NULL;
o.options = nullptr;
}
#endif
if(options[COPYRIGHT].doesOccur) {
@@ -449,7 +449,7 @@ main(int argc, char* argv[]) {
if( options[INSTALL].doesOccur ) {
o.install = options[INSTALL].value;
} else {
o.install = NULL;
o.install = nullptr;
}
if( options[SOURCEDIR].doesOccur ) {
@@ -479,7 +479,7 @@ main(int argc, char* argv[]) {
}
/* OK options are set up. Now the file lists. */
tail = NULL;
tail = nullptr;
for( n=1; n<argc; n++) {
o.fileListFiles = pkg_appendToList(o.fileListFiles, &tail, uprv_strdup(argv[n]));
}
@@ -493,32 +493,32 @@ main(int argc, char* argv[]) {
result = pkg_executeOptions(&o);
if (pkgDataFlags != NULL) {
if (pkgDataFlags != nullptr) {
for (n = 0; n < PKGDATA_FLAGS_SIZE; n++) {
if (pkgDataFlags[n] != NULL) {
if (pkgDataFlags[n] != nullptr) {
uprv_free(pkgDataFlags[n]);
}
}
uprv_free(pkgDataFlags);
}
if (o.cShortName != NULL) {
if (o.cShortName != nullptr) {
uprv_free((char *)o.cShortName);
}
if (o.fileListFiles != NULL) {
if (o.fileListFiles != nullptr) {
pkg_deleteList(o.fileListFiles);
}
if (o.filePaths != NULL) {
if (o.filePaths != nullptr) {
pkg_deleteList(o.filePaths);
}
if (o.files != NULL) {
if (o.files != nullptr) {
pkg_deleteList(o.files);
}
return result;
}
static int runCommand(const char* command, UBool specialHandling) {
char *cmd = NULL;
char *cmd = nullptr;
char cmdBuffer[SMALL_BUFFER_MAX_SIZE];
int32_t len = static_cast<int32_t>(strlen(command));
@@ -528,16 +528,19 @@ static int runCommand(const char* command, UBool specialHandling) {
if (!specialHandling) {
#if defined(USING_CYGWIN) || U_PLATFORM == U_PF_MINGW || U_PLATFORM == U_PF_OS400
int32_t buff_len;
if ((len + BUFFER_PADDING_SIZE) >= SMALL_BUFFER_MAX_SIZE) {
cmd = (char *)uprv_malloc(len + BUFFER_PADDING_SIZE);
buff_len = len + BUFFER_PADDING_SIZE;
} else {
cmd = cmdBuffer;
buff_len = SMALL_BUFFER_MAX_SIZE;
}
#if defined(USING_CYGWIN) || U_PLATFORM == U_PF_MINGW
sprintf(cmd, "bash -c \"%s\"", command);
snprintf(cmd, buff_len, "bash -c \"%s\"", command);
#elif U_PLATFORM == U_PF_OS400
sprintf(cmd, "QSH CMD('%s')", command);
snprintf(cmd, buff_len "QSH CMD('%s')", command);
#endif
#else
goto normal_command_mode;
@@ -580,9 +583,9 @@ static int32_t pkg_executeOptions(UPKGOptions *o) {
if (IN_FILES_MODE(mode)) {
/* Copy the raw data to the installation directory. */
if (o->install != NULL) {
if (o->install != nullptr) {
uprv_strcpy(targetDir, o->install);
if (o->shortName != NULL) {
if (o->shortName != nullptr) {
uprv_strcat(targetDir, PKGDATA_FILE_SEP_STRING);
uprv_strcat(targetDir, o->shortName);
}
@@ -612,7 +615,7 @@ static int32_t pkg_executeOptions(UPKGOptions *o) {
if(o->verbose) {
fprintf(stdout, "# Writing package file %s ..\n", datFileNamePath);
}
result = writePackageDatFile(datFileNamePath, o->comment, o->srcDir, o->fileListFiles->str, NULL, U_CHARSET_FAMILY ? 'e' : U_IS_BIG_ENDIAN ? 'b' : 'l');
result = writePackageDatFile(datFileNamePath, o->comment, o->srcDir, o->fileListFiles->str, nullptr, U_CHARSET_FAMILY ? 'e' : U_IS_BIG_ENDIAN ? 'b' : 'l');
if (result != 0) {
fprintf(stderr,"Error writing package dat file.\n");
return result;
@@ -649,7 +652,7 @@ static int32_t pkg_executeOptions(UPKGOptions *o) {
}
}
if (o->install != NULL) {
if (o->install != nullptr) {
result = pkg_installCommonMode(o->install, targetFileNamePath);
}
@@ -661,7 +664,7 @@ static int32_t pkg_executeOptions(UPKGOptions *o) {
#if !defined(WINDOWS_WITH_MSVC) || defined(USING_CYGWIN)
/* Get the version major number. */
if (o->version != NULL) {
if (o->version != nullptr) {
for (uint32_t i = 0;i < sizeof(version_major);i++) {
if (o->version[i] == '.') {
version_major[i] = 0;
@@ -685,14 +688,14 @@ static int32_t pkg_executeOptions(UPKGOptions *o) {
}
#endif
/* Using the base libName and version number, generate the library file names. */
createFileNames(o, mode, version_major, o->version == NULL ? "" : o->version, o->libName, reverseExt, noVersion);
createFileNames(o, mode, version_major, o->version == nullptr ? "" : o->version, o->libName, reverseExt, noVersion);
if ((o->version!=NULL || IN_STATIC_MODE(mode)) && o->rebuild == false && o->pdsbuild == false) {
if ((o->version!=nullptr || IN_STATIC_MODE(mode)) && o->rebuild == false && o->pdsbuild == false) {
/* Check to see if a previous built data library file exists and check if it is the latest. */
sprintf(checkLibFile, "%s%s", targetDir, libFileNames[LIB_FILE_VERSION]);
snprintf(checkLibFile, sizeof(checkLibFile), "%s%s", targetDir, libFileNames[LIB_FILE_VERSION]);
if (T_FileStream_file_exists(checkLibFile)) {
if (isFileModTimeLater(checkLibFile, o->srcDir, true) && isFileModTimeLater(checkLibFile, o->options)) {
if (o->install != NULL) {
if (o->install != nullptr) {
if(o->verbose) {
fprintf(stdout, "# Installing already-built library into %s\n", o->install);
}
@@ -703,15 +706,15 @@ static int32_t pkg_executeOptions(UPKGOptions *o) {
}
}
return result;
} else if (o->verbose && (o->install!=NULL)) {
} else if (o->verbose && (o->install!=nullptr)) {
fprintf(stdout, "# Not installing up-to-date library %s into %s\n", checkLibFile, o->install);
}
} else if(o->verbose && (o->install!=NULL)) {
} else if(o->verbose && (o->install!=nullptr)) {
fprintf(stdout, "# Not installing missing %s into %s\n", checkLibFile, o->install);
}
}
if (pkg_checkFlag(o) == NULL) {
if (pkg_checkFlag(o) == nullptr) {
/* Error occurred. */
return result;
}
@@ -732,7 +735,7 @@ static int32_t pkg_executeOptions(UPKGOptions *o) {
datFileNamePath,
o->tmpDir,
o->entryName,
NULL,
nullptr,
gencFilePath,
sizeof(gencFilePath));
@@ -741,7 +744,7 @@ static int32_t pkg_executeOptions(UPKGOptions *o) {
fprintf(stderr, "Error generating assembly code for data.\n");
return result;
} else if (IN_STATIC_MODE(mode)) {
if(o->install != NULL) {
if(o->install != nullptr) {
if(o->verbose) {
fprintf(stdout, "# Installing static library into %s\n", o->install);
}
@@ -766,15 +769,15 @@ static int32_t pkg_executeOptions(UPKGOptions *o) {
#endif
} else {
#ifdef CAN_WRITE_OBJ_CODE
/* Try to detect the arch type, use NULL if unsuccessful */
/* Try to detect the arch type, use nullptr if unsuccessful */
char optMatchArch[10] = { 0 };
pkg_createOptMatchArch(optMatchArch);
writeObjectCode(
datFileNamePath,
o->tmpDir,
o->entryName,
(optMatchArch[0] == 0 ? NULL : optMatchArch),
NULL,
(optMatchArch[0] == 0 ? nullptr : optMatchArch),
nullptr,
gencFilePath,
sizeof(gencFilePath),
true);
@@ -827,7 +830,7 @@ static int32_t pkg_executeOptions(UPKGOptions *o) {
#if !U_PLATFORM_USES_ONLY_WIN32_API
/* Install the libraries if option was set. */
if (o->install != NULL) {
if (o->install != nullptr) {
if(o->verbose) {
fprintf(stdout, "# Installing library file to %s ..\n", o->install);
}
@@ -857,16 +860,16 @@ static int32_t initializePkgDataFlags(UPKGOptions *o) {
#if !defined(WINDOWS_WITH_MSVC) || defined(USING_CYGWIN)
do {
#endif
if (pkgDataFlags != NULL) {
if (pkgDataFlags != nullptr) {
for (int32_t i = 0; i < PKGDATA_FLAGS_SIZE; i++) {
pkgDataFlags[i] = (char*)uprv_malloc(sizeof(char) * currentBufferSize);
if (pkgDataFlags[i] != NULL) {
if (pkgDataFlags[i] != nullptr) {
pkgDataFlags[i][0] = 0;
} else {
fprintf(stderr,"Error allocating memory for pkgDataFlags.\n");
/* If an error occurs, ensure that the rest of the array is NULL */
/* If an error occurs, ensure that the rest of the array is nullptr */
for (int32_t n = i + 1; n < PKGDATA_FLAGS_SIZE; n++) {
pkgDataFlags[n] = NULL;
pkgDataFlags[n] = nullptr;
}
return -1;
}
@@ -876,7 +879,7 @@ static int32_t initializePkgDataFlags(UPKGOptions *o) {
return -1;
}
if (o->options == NULL) {
if (o->options == nullptr) {
return result;
}
@@ -891,7 +894,7 @@ static int32_t initializePkgDataFlags(UPKGOptions *o) {
for (int32_t i = 0; i < PKGDATA_FLAGS_SIZE; i++) {
if (pkgDataFlags[i]) {
uprv_free(pkgDataFlags[i]);
pkgDataFlags[i] = NULL;
pkgDataFlags[i] = nullptr;
}
}
currentBufferSize = tmpResult;
@@ -926,15 +929,15 @@ static void createFileNames(UPKGOptions *o, const char mode, const char *version
#if U_PLATFORM == U_PF_MINGW
/* MinGW does not need the library prefix when building in dll mode. */
if (IN_DLL_MODE(mode)) {
sprintf(libFileNames[LIB_FILE], "%s", libName);
snprintf(libFileNames[LIB_FILE], sizeof(libFileNames[LIB_FILE]), "%s", libName);
} else {
sprintf(libFileNames[LIB_FILE], "%s%s%s",
snprintf(libFileNames[LIB_FILE], sizeof(libFileNames[LIB_FILE]), "%s%s%s",
(strstr(libName, "icudt") ? "lib" : ""),
pkgDataFlags[LIBPREFIX],
libName);
}
#else
sprintf(libFileNames[LIB_FILE], "%s%s",
snprintf(libFileNames[LIB_FILE], sizeof(libFileNames[LIB_FILE]), "%s%s",
pkgDataFlags[LIBPREFIX],
libName);
#endif
@@ -945,13 +948,13 @@ static void createFileNames(UPKGOptions *o, const char mode, const char *version
#if U_PLATFORM == U_PF_MINGW
// Name the import library lib*.dll.a
sprintf(libFileNames[LIB_FILE_MINGW], "lib%s.dll.a", libName);
snprintf(libFileNames[LIB_FILE_MINGW], sizeof(libFileNames[LIB_FILE_MINGW]), "lib%s.dll.a", libName);
#elif U_PLATFORM == U_PF_CYGWIN
sprintf(libFileNames[LIB_FILE_CYGWIN], "cyg%s%s%s",
snprintf(libFileNames[LIB_FILE_CYGWIN], sizeof(libFileNames[LIB_FILE_CYGWIN]), "cyg%s%s%s",
libName,
FILE_EXTENSION_SEP,
pkgDataFlags[SO_EXT]);
sprintf(libFileNames[LIB_FILE_CYGWIN_VERSION], "cyg%s%s%s%s",
snprintf(libFileNames[LIB_FILE_CYGWIN_VERSION], sizeof(libFileNames[LIB_FILE_CYGWIN_VERSION]), "cyg%s%s%s%s",
libName,
version_major,
FILE_EXTENSION_SEP,
@@ -960,32 +963,32 @@ static void createFileNames(UPKGOptions *o, const char mode, const char *version
uprv_strcat(pkgDataFlags[SO_EXT], ".");
uprv_strcat(pkgDataFlags[SO_EXT], pkgDataFlags[A_EXT]);
#elif U_PLATFORM == U_PF_OS400 || defined(_AIX)
sprintf(libFileNames[LIB_FILE_VERSION_TMP], "%s%s%s",
snprintf(libFileNames[LIB_FILE_VERSION_TMP], sizeof(libFileNames[LIB_FILE_VERSION_TMP]), "%s%s%s",
libFileNames[LIB_FILE],
FILE_EXTENSION_SEP,
pkgDataFlags[SOBJ_EXT]);
#elif U_PLATFORM == U_PF_OS390
sprintf(libFileNames[LIB_FILE_VERSION_TMP], "%s%s%s%s%s",
snprintf(libFileNames[LIB_FILE_VERSION_TMP], sizeof(libFileNames[LIB_FILE_VERSION_TMP]), "%s%s%s%s%s",
libFileNames[LIB_FILE],
pkgDataFlags[LIB_EXT_ORDER][0] == '.' ? "." : "",
reverseExt ? version : pkgDataFlags[SOBJ_EXT],
FILE_EXTENSION_SEP,
reverseExt ? pkgDataFlags[SOBJ_EXT] : version);
sprintf(libFileNames[LIB_FILE_OS390BATCH_VERSION], "%s%s.x",
snprintf(libFileNames[LIB_FILE_OS390BATCH_VERSION], sizeof(libFileNames[LIB_FILE_OS390BATCH_VERSION]), "%s%s.x",
libFileNames[LIB_FILE],
version);
sprintf(libFileNames[LIB_FILE_OS390BATCH_MAJOR], "%s%s.x",
snprintf(libFileNames[LIB_FILE_OS390BATCH_MAJOR], sizeof(libFileNames[LIB_FILE_OS390BATCH_MAJOR]), "%s%s.x",
libFileNames[LIB_FILE],
version_major);
#else
if (noVersion && !reverseExt) {
sprintf(libFileNames[LIB_FILE_VERSION_TMP], "%s%s%s",
snprintf(libFileNames[LIB_FILE_VERSION_TMP], sizeof(libFileNames[LIB_FILE_VERSION_TMP]), "%s%s%s",
libFileNames[LIB_FILE],
FILE_SUFFIX,
pkgDataFlags[SOBJ_EXT]);
} else {
sprintf(libFileNames[LIB_FILE_VERSION_TMP], "%s%s%s%s%s",
snprintf(libFileNames[LIB_FILE_VERSION_TMP], sizeof(libFileNames[LIB_FILE_VERSION_TMP]), "%s%s%s%s%s",
libFileNames[LIB_FILE],
FILE_SUFFIX,
reverseExt ? version : pkgDataFlags[SOBJ_EXT],
@@ -994,24 +997,24 @@ static void createFileNames(UPKGOptions *o, const char mode, const char *version
}
#endif
if (noVersion && !reverseExt) {
sprintf(libFileNames[LIB_FILE_VERSION_MAJOR], "%s%s%s",
snprintf(libFileNames[LIB_FILE_VERSION_MAJOR], sizeof(libFileNames[LIB_FILE_VERSION_TMP]), "%s%s%s",
libFileNames[LIB_FILE],
FILE_SUFFIX,
pkgDataFlags[SO_EXT]);
sprintf(libFileNames[LIB_FILE_VERSION], "%s%s%s",
snprintf(libFileNames[LIB_FILE_VERSION], sizeof(libFileNames[LIB_FILE_VERSION]), "%s%s%s",
libFileNames[LIB_FILE],
FILE_SUFFIX,
pkgDataFlags[SO_EXT]);
} else {
sprintf(libFileNames[LIB_FILE_VERSION_MAJOR], "%s%s%s%s%s",
snprintf(libFileNames[LIB_FILE_VERSION_MAJOR], sizeof(libFileNames[LIB_FILE_VERSION_MAJOR]), "%s%s%s%s%s",
libFileNames[LIB_FILE],
FILE_SUFFIX,
reverseExt ? version_major : pkgDataFlags[SO_EXT],
FILE_EXTENSION_SEP,
reverseExt ? pkgDataFlags[SO_EXT] : version_major);
sprintf(libFileNames[LIB_FILE_VERSION], "%s%s%s%s%s",
snprintf(libFileNames[LIB_FILE_VERSION], sizeof(libFileNames[LIB_FILE_VERSION]), "%s%s%s%s%s",
libFileNames[LIB_FILE],
FILE_SUFFIX,
reverseExt ? version : pkgDataFlags[SO_EXT],
@@ -1029,7 +1032,7 @@ static void createFileNames(UPKGOptions *o, const char mode, const char *version
#endif
if(IN_STATIC_MODE(mode)) {
sprintf(libFileNames[LIB_FILE_VERSION], "%s.%s", libFileNames[LIB_FILE], pkgDataFlags[A_EXT]);
snprintf(libFileNames[LIB_FILE_VERSION], sizeof(libFileNames[LIB_FILE_VERSION]), "%s.%s", libFileNames[LIB_FILE], pkgDataFlags[A_EXT]);
libFileNames[LIB_FILE_VERSION_MAJOR][0]=0;
if(o->verbose) {
fprintf(stdout, "# libFileName[LIB_FILE_VERSION] = %s (static)\n", libFileNames[LIB_FILE_VERSION]);
@@ -1052,7 +1055,7 @@ static int32_t pkg_createSymLinks(const char *targetDir, UBool specialHandling)
return result;
}
sprintf(cmd, "cd %s && %s %s && %s %s %s",
snprintf(cmd, sizeof(cmd), "cd %s && %s %s && %s %s %s",
targetDir,
RM_CMD,
libFileNames[LIB_FILE_VERSION_MAJOR],
@@ -1068,14 +1071,14 @@ static int32_t pkg_createSymLinks(const char *targetDir, UBool specialHandling)
if (specialHandling) {
#if U_PLATFORM == U_PF_CYGWIN
sprintf(name1, "%s", libFileNames[LIB_FILE_CYGWIN]);
sprintf(name2, "%s", libFileNames[LIB_FILE_CYGWIN_VERSION]);
snprintf(name1, sizeof(name1), "%s", libFileNames[LIB_FILE_CYGWIN]);
snprintf(name2, sizeof(name2), "%s", libFileNames[LIB_FILE_CYGWIN_VERSION]);
#elif U_PLATFORM == U_PF_OS390
/* Create the symbolic links for the import data */
/* Use the cmd buffer to store path to import data file to check its existence */
sprintf(cmd, "%s/%s", targetDir, libFileNames[LIB_FILE_OS390BATCH_VERSION]);
snprintf(cmd, sizeof(cmd), "%s/%s", targetDir, libFileNames[LIB_FILE_OS390BATCH_VERSION]);
if (T_FileStream_file_exists(cmd)) {
sprintf(cmd, "cd %s && %s %s && %s %s %s",
snprintf(cmd, sizeof(cmd), "cd %s && %s %s && %s %s %s",
targetDir,
RM_CMD,
libFileNames[LIB_FILE_OS390BATCH_MAJOR],
@@ -1088,7 +1091,7 @@ static int32_t pkg_createSymLinks(const char *targetDir, UBool specialHandling)
return result;
}
sprintf(cmd, "cd %s && %s %s.x && %s %s %s.x",
snprintf(cmd, sizeof(cmd), "cd %s && %s %s.x && %s %s %s.x",
targetDir,
RM_CMD,
libFileNames[LIB_FILE],
@@ -1103,8 +1106,8 @@ static int32_t pkg_createSymLinks(const char *targetDir, UBool specialHandling)
}
/* Needs to be set here because special handling skips it */
sprintf(name1, "%s%s%s", libFileNames[LIB_FILE], FILE_EXTENSION_SEP, pkgDataFlags[SO_EXT]);
sprintf(name2, "%s", libFileNames[LIB_FILE_VERSION]);
snprintf(name1, sizeof(name1), "%s%s%s", libFileNames[LIB_FILE], FILE_EXTENSION_SEP, pkgDataFlags[SO_EXT]);
snprintf(name2, sizeof(name2), "%s", libFileNames[LIB_FILE_VERSION]);
#else
goto normal_symlink_mode;
#endif
@@ -1112,11 +1115,11 @@ static int32_t pkg_createSymLinks(const char *targetDir, UBool specialHandling)
#if U_PLATFORM != U_PF_CYGWIN
normal_symlink_mode:
#endif
sprintf(name1, "%s%s%s", libFileNames[LIB_FILE], FILE_EXTENSION_SEP, pkgDataFlags[SO_EXT]);
sprintf(name2, "%s", libFileNames[LIB_FILE_VERSION]);
snprintf(name1, sizeof(name1), "%s%s%s", libFileNames[LIB_FILE], FILE_EXTENSION_SEP, pkgDataFlags[SO_EXT]);
snprintf(name2, sizeof(name2), "%s", libFileNames[LIB_FILE_VERSION]);
}
sprintf(cmd, "cd %s && %s %s && %s %s %s",
snprintf(cmd, sizeof(cmd), "cd %s && %s %s && %s %s %s",
targetDir,
RM_CMD,
name1,
@@ -1134,7 +1137,7 @@ static int32_t pkg_installLibrary(const char *installDir, const char *targetDir,
char cmd[SMALL_BUFFER_MAX_SIZE];
auto ret = snprintf(cmd,
SMALL_BUFFER_MAX_SIZE,
sizeof(cmd),
"cd %s && %s %s %s%s%s",
targetDir,
pkgDataFlags[INSTALL_CMD],
@@ -1151,7 +1154,7 @@ static int32_t pkg_installLibrary(const char *installDir, const char *targetDir,
}
#ifdef CYGWINMSVC
sprintf(cmd, "cd %s && %s %s.lib %s",
snprintf(cmd, sizeof(cmd), "cd %s && %s %s.lib %s",
targetDir,
pkgDataFlags[INSTALL_CMD],
libFileNames[LIB_FILE],
@@ -1164,7 +1167,7 @@ static int32_t pkg_installLibrary(const char *installDir, const char *targetDir,
return result;
}
#elif U_PLATFORM == U_PF_CYGWIN
sprintf(cmd, "cd %s && %s %s %s",
snprintf(cmd, sizeof(cmd), "cd %s && %s %s %s",
targetDir,
pkgDataFlags[INSTALL_CMD],
libFileNames[LIB_FILE_CYGWIN_VERSION],
@@ -1179,7 +1182,7 @@ static int32_t pkg_installLibrary(const char *installDir, const char *targetDir,
#elif U_PLATFORM == U_PF_OS390
if (T_FileStream_file_exists(libFileNames[LIB_FILE_OS390BATCH_VERSION])) {
sprintf(cmd, "%s %s %s",
snprintf(cmd, sizeof(cmd), "%s %s %s",
pkgDataFlags[INSTALL_CMD],
libFileNames[LIB_FILE_OS390BATCH_VERSION],
installDir
@@ -1214,9 +1217,9 @@ static int32_t pkg_installCommonMode(const char *installDir, const char *fileNam
}
}
#ifndef U_WINDOWS_WITH_MSVC
sprintf(cmd, "%s %s %s", pkgDataFlags[INSTALL_CMD], fileName, installDir);
snprintf(cmd, sizeof(cmd), "%s %s %s", pkgDataFlags[INSTALL_CMD], fileName, installDir);
#else
sprintf(cmd, "%s %s %s %s", WIN_INSTALL_CMD, fileName, installDir, WIN_INSTALL_CMD_FLAGS);
snprintf(cmd, sizeof(cmd), "%s %s %s %s", WIN_INSTALL_CMD, fileName, installDir, WIN_INSTALL_CMD_FLAGS);
#endif
result = runCommand(cmd);
@@ -1250,9 +1253,9 @@ static int32_t pkg_installFileMode(const char *installDir, const char *srcDir, c
int32_t bufferLength = 0;
FileStream *f = T_FileStream_open(fileListName, "r");
if (f != NULL) {
if (f != nullptr) {
for(;;) {
if (T_FileStream_readLine(f, buffer, SMALL_BUFFER_MAX_SIZE) != NULL) {
if (T_FileStream_readLine(f, buffer, SMALL_BUFFER_MAX_SIZE) != nullptr) {
bufferLength = static_cast<int32_t>(uprv_strlen(buffer));
/* Remove new line character. */
if (bufferLength > 0) {
@@ -1260,7 +1263,7 @@ static int32_t pkg_installFileMode(const char *installDir, const char *srcDir, c
}
auto ret = snprintf(cmd,
SMALL_BUFFER_MAX_SIZE,
sizeof(cmd),
"%s %s%s%s %s%s%s",
pkgDataFlags[INSTALL_CMD],
srcDir, PKGDATA_FILE_SEP_STRING, buffer,
@@ -1287,7 +1290,7 @@ static int32_t pkg_installFileMode(const char *installDir, const char *srcDir, c
fprintf(stderr, "Unable to open list file: %s\n", fileListName);
}
#else
sprintf(cmd, "%s %s %s %s", WIN_INSTALL_CMD, srcDir, installDir, WIN_INSTALL_CMD_FLAGS);
snprintf(cmd, sizeof(cmd), "%s %s %s %s", WIN_INSTALL_CMD, srcDir, installDir, WIN_INSTALL_CMD_FLAGS);
result = runCommand(cmd);
if (result != 0) {
fprintf(stderr, "Failed to install data file with command: %s\n", cmd);
@@ -1308,13 +1311,13 @@ static int32_t pkg_archiveLibrary(const char *targetDir, const char *version, UB
* archive file suffix is the same, then the final library needs to be archived.
*/
if (uprv_strcmp(pkgDataFlags[SOBJ_EXT], pkgDataFlags[SO_EXT]) != 0 && uprv_strcmp(pkgDataFlags[A_EXT], pkgDataFlags[SO_EXT]) == 0) {
sprintf(libFileNames[LIB_FILE_VERSION], "%s%s%s.%s",
snprintf(libFileNames[LIB_FILE_VERSION], sizeof(libFileNames[LIB_FILE_VERSION]), "%s%s%s.%s",
libFileNames[LIB_FILE],
pkgDataFlags[LIB_EXT_ORDER][0] == '.' ? "." : "",
reverseExt ? version : pkgDataFlags[SO_EXT],
reverseExt ? pkgDataFlags[SO_EXT] : version);
sprintf(cmd, "%s %s %s%s %s%s",
snprintf(cmd, sizeof(cmd), "%s %s %s%s %s%s",
pkgDataFlags[AR],
pkgDataFlags[ARFLAGS],
targetDir,
@@ -1328,7 +1331,7 @@ static int32_t pkg_archiveLibrary(const char *targetDir, const char *version, UB
return result;
}
sprintf(cmd, "%s %s%s",
snprintf(cmd, sizeof(cmd), "%s %s%s",
pkgDataFlags[RANLIB],
targetDir,
libFileNames[LIB_FILE_VERSION]);
@@ -1340,7 +1343,7 @@ static int32_t pkg_archiveLibrary(const char *targetDir, const char *version, UB
}
/* Remove unneeded library file. */
sprintf(cmd, "%s %s%s",
snprintf(cmd, sizeof(cmd), "%s %s%s",
RM_CMD,
targetDir,
libFileNames[LIB_FILE_VERSION_TMP]);
@@ -1364,7 +1367,7 @@ static int32_t pkg_archiveLibrary(const char *targetDir, const char *version, UB
*/
static int32_t pkg_generateLibraryFile(const char *targetDir, const char mode, const char *objectFile, char *command, UBool specialHandling) {
int32_t result = 0;
char *cmd = NULL;
char *cmd = nullptr;
UBool freeCmd = false;
int32_t length = 0;
@@ -1375,15 +1378,15 @@ static int32_t pkg_generateLibraryFile(const char *targetDir, const char mode, c
* containing many object files and so the calling function should supply a command buffer that is large
* enough to handle this. Otherwise, use the default size.
*/
if (command != NULL) {
if (command != nullptr) {
cmd = command;
}
if (IN_STATIC_MODE(mode)) {
if (cmd == NULL) {
if (cmd == nullptr) {
length = static_cast<int32_t>(uprv_strlen(pkgDataFlags[AR]) + uprv_strlen(pkgDataFlags[ARFLAGS]) + uprv_strlen(targetDir) +
uprv_strlen(libFileNames[LIB_FILE_VERSION]) + uprv_strlen(objectFile) + uprv_strlen(pkgDataFlags[RANLIB]) + BUFFER_PADDING_SIZE);
if ((cmd = (char *)uprv_malloc(sizeof(char) * length)) == NULL) {
if ((cmd = (char *)uprv_malloc(sizeof(char) * length)) == nullptr) {
fprintf(stderr, "Unable to allocate memory for command.\n");
return -1;
}
@@ -1406,7 +1409,7 @@ static int32_t pkg_generateLibraryFile(const char *targetDir, const char mode, c
result = runCommand(cmd);
}
} else /* if (IN_DLL_MODE(mode)) */ {
if (cmd == NULL) {
if (cmd == nullptr) {
length = static_cast<int32_t>(uprv_strlen(pkgDataFlags[GENLIB]) + uprv_strlen(pkgDataFlags[LDICUDTFLAGS]) +
((uprv_strlen(targetDir) + uprv_strlen(libFileNames[LIB_FILE_VERSION_TMP])) * 2) +
uprv_strlen(objectFile) + uprv_strlen(pkgDataFlags[LD_SONAME]) +
@@ -1417,7 +1420,7 @@ static int32_t pkg_generateLibraryFile(const char *targetDir, const char mode, c
#elif U_PLATFORM == U_PF_MINGW
length += static_cast<int32_t>(uprv_strlen(targetDir) + uprv_strlen(libFileNames[LIB_FILE_MINGW]));
#endif
if ((cmd = (char *)uprv_malloc(sizeof(char) * length)) == NULL) {
if ((cmd = (char *)uprv_malloc(sizeof(char) * length)) == nullptr) {
fprintf(stderr, "Unable to allocate memory for command.\n");
return -1;
}
@@ -1554,7 +1557,7 @@ static int32_t pkg_createWithAssemblyCode(const char *targetDir, const char mode
}
/* Generate the object file. */
sprintf(cmd.getAlias(), "%s %s -o %s %s",
snprintf(cmd.getAlias(), length, "%s %s -o %s %s",
pkgDataFlags[COMPILER],
pkgDataFlags[LIBFLAGS],
tempObjectFile,
@@ -1612,9 +1615,9 @@ static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetD
char tempObjectFile[SMALL_BUFFER_MAX_SIZE] = "";
#ifdef USE_SINGLE_CCODE_FILE
char icudtAll[SMALL_BUFFER_MAX_SIZE] = "";
FileStream *icudtAllFile = NULL;
FileStream *icudtAllFile = nullptr;
sprintf(icudtAll, "%s%s%sall.c",
snprintf(icudtAll, sizeof(icudtAll), "%s%s%sall.c",
o->tmpDir,
PKGDATA_FILE_SEP_STRING,
libFileNames[LIB_FILE]);
@@ -1624,23 +1627,23 @@ static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetD
return result;
}
if((icudtAllFile = T_FileStream_open(icudtAll, "w"))==NULL) {
if((icudtAllFile = T_FileStream_open(icudtAll, "w"))==nullptr) {
fprintf(stderr, "Unable to write to icudtall file: %s\n", icudtAll);
return result;
}
#endif
if (list == NULL || listNames == NULL) {
/* list and listNames should never be NULL since we are looping through the CharList with
if (list == nullptr || listNames == nullptr) {
/* list and listNames should never be nullptr since we are looping through the CharList with
* the given size.
*/
return -1;
}
if ((cmd = (char *)uprv_malloc((listSize + 2) * SMALL_BUFFER_MAX_SIZE)) == NULL) {
if ((cmd = (char *)uprv_malloc((listSize + 2) * SMALL_BUFFER_MAX_SIZE)) == nullptr) {
fprintf(stderr, "Unable to allocate memory for cmd.\n");
return -1;
} else if ((buffer = (char *)uprv_malloc((listSize + 1) * SMALL_BUFFER_MAX_SIZE)) == NULL) {
} else if ((buffer = (char *)uprv_malloc((listSize + 1) * SMALL_BUFFER_MAX_SIZE)) == nullptr) {
fprintf(stderr, "Unable to allocate memory for buffer.\n");
uprv_free(cmd);
return -1;
@@ -1652,7 +1655,7 @@ static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetD
if (i == 0) {
/* The first iteration calls the gencmn function and initializes the buffer. */
createCommonDataFile(o->tmpDir, o->shortName, o->entryName, NULL, o->srcDir, o->comment, o->fileListFiles->str, 0, true, o->verbose, gencmnFile);
createCommonDataFile(o->tmpDir, o->shortName, o->entryName, nullptr, o->srcDir, o->comment, o->fileListFiles->str, 0, true, o->verbose, gencmnFile);
buffer[0] = 0;
#ifdef USE_SINGLE_CCODE_FILE
uprv_strcpy(tempObjectFile, gencmnFile);
@@ -1685,7 +1688,7 @@ static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetD
sprintf(dataDirName, "%s%s", DATA_PREFIX[n], PKGDATA_FILE_SEP_STRING);
/* If the name contains a prefix (indicating directory), alter the new name accordingly. */
pSubstring = uprv_strstr(name, dataDirName);
if (pSubstring != NULL) {
if (pSubstring != nullptr) {
char newNameTmp[SMALL_BUFFER_MAX_SIZE] = "";
const char *p = name + uprv_strlen(dataDirName);
for (int32_t i = 0;;i++) {
@@ -1699,14 +1702,14 @@ static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetD
}
}
auto ret = snprintf(newName,
SMALL_BUFFER_MAX_SIZE,
sizeof(newName),
"%s_%s",
DATA_PREFIX[n],
newNameTmp);
(void)ret;
U_ASSERT(0 <= ret && ret < SMALL_BUFFER_MAX_SIZE);
ret = snprintf(dataName,
SMALL_BUFFER_MAX_SIZE,
sizeof(dataName),
"%s_%s",
o->shortName,
DATA_PREFIX[n]);
@@ -1725,8 +1728,9 @@ static int32_t pkg_createWithoutAssemblyCode(UPKGOptions *o, const char *targetD
writeCCode(
file,
o->tmpDir,
nullptr,
dataName[0] != 0 ? dataName : o->shortName,
newName[0] != 0 ? newName : NULL,
newName[0] != 0 ? newName : nullptr,
gencmnFile,
sizeof(gencmnFile));
@@ -1819,14 +1823,14 @@ static int32_t pkg_createWindowsDLL(const char mode, const char *gencFilePath, U
char staticLibFilePath[SMALL_BUFFER_MAX_SIZE] = "";
#ifdef CYGWINMSVC
sprintf(staticLibFilePath, "%s%s%s%s%s",
snprintf(staticLibFilePath, sizeof(staticLibFilePath), "%s%s%s%s%s",
o->targetDir,
PKGDATA_FILE_SEP_STRING,
pkgDataFlags[LIBPREFIX],
o->libName,
LIB_EXT);
#else
sprintf(staticLibFilePath, "%s%s%s%s%s",
snprintf(staticLibFilePath, sizeof(staticLibFilePath), "%s%s%s%s%s",
o->targetDir,
PKGDATA_FILE_SEP_STRING,
(strstr(o->libName, "icudt") ? "s" : ""),
@@ -1834,7 +1838,7 @@ static int32_t pkg_createWindowsDLL(const char mode, const char *gencFilePath, U
LIB_EXT);
#endif
sprintf(cmd, "%s\"%s\" \"%s\"",
snprintf(cmd, sizeof(cmd), "%s\"%s\" \"%s\"",
LIB_CMD,
staticLibFilePath,
gencFilePath);
@@ -1874,7 +1878,7 @@ static int32_t pkg_createWindowsDLL(const char mode, const char *gencFilePath, U
uprv_strcat(tmpResFilePath, ICUDATA_RES_FILE);
if (T_FileStream_file_exists(tmpResFilePath)) {
sprintf(resFilePath, "\"%s\"", tmpResFilePath);
snprintf(resFilePath, sizeof(resFilePath), "\"%s\"", tmpResFilePath);
}
/* Check if dll file and lib file exists and that it is not newer than genc file. */
@@ -1904,7 +1908,7 @@ static int32_t pkg_createWindowsDLL(const char mode, const char *gencFilePath, U
}
#endif
sprintf(cmd, "%s\"%s\" %s %s\"%s\" \"%s\" %s",
snprintf(cmd, sizeof(cmd), "%s\"%s\" %s %s\"%s\" \"%s\" %s",
LINK_CMD,
dllFilePath,
extraFlags,
@@ -1927,11 +1931,11 @@ static int32_t pkg_createWindowsDLL(const char mode, const char *gencFilePath, U
static UPKGOptions *pkg_checkFlag(UPKGOptions *o) {
#if U_PLATFORM == U_PF_AIX
/* AIX needs a map file. */
char *flag = NULL;
char *flag = nullptr;
int32_t length = 0;
char tmpbuffer[SMALL_BUFFER_MAX_SIZE];
const char MAP_FILE_EXT[] = ".map";
FileStream *f = NULL;
FileStream *f = nullptr;
char mapFile[SMALL_BUFFER_MAX_SIZE] = "";
int32_t start = -1;
uint32_t count = 0;
@@ -1942,16 +1946,16 @@ static UPKGOptions *pkg_checkFlag(UPKGOptions *o) {
/* This portion of the code removes 'rm -f all' in the GENLIB.
* Only occurs in AIX.
*/
if (uprv_strstr(flag, rm_cmd) != NULL) {
char *tmpGenlibFlagBuffer = NULL;
if (uprv_strstr(flag, rm_cmd) != nullptr) {
char *tmpGenlibFlagBuffer = nullptr;
int32_t i, offset;
length = static_cast<int32_t>(uprv_strlen(flag) + 1);
tmpGenlibFlagBuffer = (char *)uprv_malloc(length);
if (tmpGenlibFlagBuffer == NULL) {
if (tmpGenlibFlagBuffer == nullptr) {
/* Memory allocation error */
fprintf(stderr,"Unable to allocate buffer of size: %d.\n", length);
return NULL;
return nullptr;
}
uprv_strcpy(tmpGenlibFlagBuffer, flag);
@@ -2012,11 +2016,11 @@ static UPKGOptions *pkg_checkFlag(UPKGOptions *o) {
uprv_strcat(mapFile, MAP_FILE_EXT);
f = T_FileStream_open(mapFile, "w");
if (f == NULL) {
if (f == nullptr) {
fprintf(stderr,"Unable to create map file: %s.\n", mapFile);
return NULL;
return nullptr;
} else {
sprintf(tmpbuffer, "%s%s ", o->entryName, UDATA_CMN_INTERMEDIATE_SUFFIX);
snprintf(tmpbuffer, sizeof(tmpbuffer), "%s%s ", o->entryName, UDATA_CMN_INTERMEDIATE_SUFFIX);
T_FileStream_writeLine(f, tmpbuffer);
@@ -2025,7 +2029,7 @@ static UPKGOptions *pkg_checkFlag(UPKGOptions *o) {
}
#elif U_PLATFORM == U_PF_CYGWIN || U_PLATFORM == U_PF_MINGW
/* Cygwin needs to change flag options. */
char *flag = NULL;
char *flag = nullptr;
int32_t length = 0;
flag = pkgDataFlags[GENLIB];
@@ -2043,7 +2047,7 @@ static UPKGOptions *pkg_checkFlag(UPKGOptions *o) {
uprv_memset(flag + position, 0, length - position);
#elif U_PLATFORM == U_PF_OS400
/* OS/400 needs to fix the ld options (swap single quote with double quote) */
char *flag = NULL;
char *flag = nullptr;
int32_t length = 0;
flag = pkgDataFlags[GENLIB];
@@ -2064,7 +2068,7 @@ static UPKGOptions *pkg_checkFlag(UPKGOptions *o) {
static void loadLists(UPKGOptions *o, UErrorCode *status)
{
CharList *l, *tail = NULL, *tail2 = NULL;
CharList *l, *tail = nullptr, *tail2 = nullptr;
FileStream *in;
char line[16384];
char *linePtr, *lineNext;
@@ -2087,7 +2091,7 @@ static void loadLists(UPKGOptions *o, UErrorCode *status)
return;
}
while(T_FileStream_readLine(in, line, sizeof(line))!=NULL) { /* for each line */
while(T_FileStream_readLine(in, line, sizeof(line))!=nullptr) { /* for each line */
ln++;
if(uprv_strlen(line)>lineMax) {
fprintf(stderr, "%s:%d - line too long (over %d chars)\n", l->str, (int)ln, (int)lineMax);
@@ -2115,7 +2119,7 @@ static void loadLists(UPKGOptions *o, UErrorCode *status)
}
/* Now, process the line */
lineNext = NULL;
lineNext = nullptr;
while(linePtr && *linePtr) { /* process space-separated items */
while(*linePtr == ' ') {
@@ -2125,7 +2129,7 @@ static void loadLists(UPKGOptions *o, UErrorCode *status)
if(linePtr[0] == '"')
{
lineNext = uprv_strchr(linePtr+1, '"');
if(lineNext == NULL) {
if(lineNext == nullptr) {
fprintf(stderr, "%s:%d - missing trailing double quote (\")\n",
l->str, (int)ln);
exit(1);
@@ -2160,7 +2164,7 @@ static void loadLists(UPKGOptions *o, UErrorCode *status)
}
/* The +5 is to add a little extra space for, among other things, PKGDATA_FILE_SEP_STRING */
tmpLength = static_cast<int32_t>(uprv_strlen(o->srcDir) + uprv_strlen(s) + 5);
if((tmp = (char *)uprv_malloc(tmpLength)) == NULL) {
if((tmp = (char *)uprv_malloc(tmpLength)) == nullptr) {
fprintf(stderr, "pkgdata: Error: Unable to allocate tmp buffer size: %d\n", tmpLength);
exit(U_MEMORY_ALLOCATION_ERROR);
}
@@ -2253,15 +2257,15 @@ static void pkg_createOptMatchArch(char *optMatchArch) {
const char* code = "void oma(){}";
const char* source = "oma.c";
const char* obj = "oma.obj";
FileStream* stream = NULL;
FileStream* stream = nullptr;
stream = T_FileStream_open(source,"w");
if (stream != NULL) {
if (stream != nullptr) {
T_FileStream_writeLine(stream, code);
T_FileStream_close(stream);
char cmd[LARGE_BUFFER_MAX_SIZE];
sprintf(cmd, "%s %s -o %s",
snprintf(cmd, sizeof(cmd), "%s %s -o %s",
pkgDataFlags[COMPILER],
source,
obj);