/*****************************************************************************
*
-* Copyright (C) 1999-2011, International Business Machines
+* Copyright (C) 1999-2014, International Business Machines
* Corporation and others. All Rights Reserved.
*
******************************************************************************/
#include <unicode/translit.h>
#include <unicode/uset.h>
#include <unicode/uclean.h>
+#include <unicode/utf16.h>
#include <stdio.h>
#include <errno.h>
U_CFUNC char uconvmsg_dat[];
#endif
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
#define DEFAULT_BUFSZ 4096
#define UCONVMSG "uconvmsg"
ps = 1;
/* Set up our static data - if any */
-#ifdef UCONVMSG_LINK
+#if defined(UCONVMSG_LINK) && U_PLATFORM != U_PF_OS390 /* On z/OS, this is failing. */
udata_setAppData(UCONVMSG, (const void*) uconvmsg_dat, &err);
if (U_FAILURE(err)) {
fprintf(stderr, "%s: warning, problem installing our static resource bundle data uconvmsg: %s - trying anyways.\n",
UConverter *convto = 0;
UErrorCode err = U_ZERO_ERROR;
UBool flush;
+ UBool closeFile = FALSE;
const char *cbufp, *prevbufp;
char *bufp;
u_wmsg(stderr, "cantOpenInputF", str1.getBuffer(), str2.getBuffer());
return FALSE;
}
+ closeFile = TRUE;
} else {
infilestr = "-";
infile = stdin;
parse.line = -1;
if (uprv_strchr(translit, ':') || uprv_strchr(translit, '>') || uprv_strchr(translit, '<') || uprv_strchr(translit, '>')) {
- t = Transliterator::createFromRules("Uconv", str, UTRANS_FORWARD, parse, err);
+ t = Transliterator::createFromRules(UNICODE_STRING_SIMPLE("Uconv"), str, UTRANS_FORWARD, parse, err);
} else {
- t = Transliterator::createInstance(translit, UTRANS_FORWARD, err);
+ t = Transliterator::createInstance(UnicodeString(translit, -1, US_INV), UTRANS_FORWARD, err);
}
if (U_FAILURE(err)) {
int8_t i, length, errorLength;
UErrorCode localError = U_ZERO_ERROR;
- errorLength = (int8_t)LENGTHOF(errorUChars);
+ errorLength = (int8_t)UPRV_LENGTHOF(errorUChars);
ucnv_getInvalidUChars(convto, errorUChars, &errorLength, &localError);
if (U_FAILURE(localError) || errorLength == 0) {
// need at least 1 so that we don't access beyond the length of fromoffsets[]
delete t;
#endif
- if (infile != stdin) {
+ if (closeFile) {
fclose(infile);
}
fclose(outfile);
}
+ u_cleanup();
+
return ret;
}