mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-14 17:24:01 +00:00
ICU-20438 BRS64RC Fix Clang compiler warnings in ICU4C samples
This commit is contained in:
parent
f128f75cb8
commit
ca8eb03f30
5 changed files with 35 additions and 32 deletions
|
@ -48,13 +48,13 @@ int main(int argc, char **argv) {
|
|||
UDate date;
|
||||
|
||||
// The languages in which we will display the date
|
||||
static char* LANGUAGE[] = {
|
||||
static const char* LANGUAGE[] = {
|
||||
"en", "de", "fr"
|
||||
};
|
||||
static const int32_t N_LANGUAGE = sizeof(LANGUAGE)/sizeof(LANGUAGE[0]);
|
||||
|
||||
// The time zones in which we will display the time
|
||||
static char* TIMEZONE[] = {
|
||||
static const char* TIMEZONE[] = {
|
||||
"America/Los_Angeles",
|
||||
"America/New_York",
|
||||
"Europe/Paris",
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
* others. All Rights Reserved.
|
||||
*************************************************************************/
|
||||
|
||||
#define __STDC_FORMAT_MACROS 1
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "unicode/unistr.h"
|
||||
#include "unicode/fmtable.h"
|
||||
#include <stdio.h>
|
||||
|
@ -95,10 +98,15 @@ UnicodeString formattableToString(const Formattable& f) {
|
|||
return UnicodeString(buf, "");
|
||||
}
|
||||
case Formattable::kLong:
|
||||
{
|
||||
char buf[256];
|
||||
sprintf(buf, "%" PRId32 "L", f.getLong());
|
||||
return UnicodeString(buf, "");
|
||||
}
|
||||
case Formattable::kInt64:
|
||||
{
|
||||
char buf[256];
|
||||
sprintf(buf, "%ldL", f.getLong());
|
||||
sprintf(buf, "%" PRId64 "L", f.getInt64());
|
||||
return UnicodeString(buf, "");
|
||||
}
|
||||
case Formattable::kString:
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
* for Unicode character properties.
|
||||
*/
|
||||
|
||||
#define __STDC_FORMAT_MACROS 1
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/uchar.h"
|
||||
|
@ -38,13 +41,13 @@ printProps(UChar32 codePoint) {
|
|||
u_charName(codePoint, U_UNICODE_CHAR_NAME, buffer, sizeof(buffer), &errorCode);
|
||||
|
||||
/* print the code point and the character name */
|
||||
printf("U+%04lx\t%s\n", codePoint, buffer);
|
||||
printf("U+%04" PRId32 "\t%s\n", codePoint, buffer);
|
||||
|
||||
/* print some properties */
|
||||
printf(" general category (numeric enum value): %u\n", u_charType(codePoint));
|
||||
|
||||
/* note: these APIs do not provide the data from SpecialCasing.txt */
|
||||
printf(" is lowercase: %d uppercase: U+%04lx\n", u_islower(codePoint), u_toupper(codePoint));
|
||||
printf(" is lowercase: %d uppercase: U+%04" PRId32 "\n", u_islower(codePoint), u_toupper(codePoint));
|
||||
|
||||
printf(" is digit: %d decimal digit value: %d\n", u_isdigit(codePoint), u_charDigitValue(codePoint));
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ main(int argc, const char *argv[]) {
|
|||
uint16_t intValue=2000;
|
||||
|
||||
long dataLength;
|
||||
uint32_t size;
|
||||
size_t size;
|
||||
#ifdef WIN32
|
||||
char *currdir = _getcwd(NULL, 0);
|
||||
#else
|
||||
|
@ -107,19 +107,8 @@ main(int argc, const char *argv[]) {
|
|||
|
||||
|
||||
if(dataLength!=(long)size) {
|
||||
fprintf(stderr, "Error: data length %ld != calculated size %lu\n", dataLength, size);
|
||||
fprintf(stderr, "Error: data length %ld != calculated size %zu\n", dataLength, size);
|
||||
exit(U_INTERNAL_PROGRAM_ERROR);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -23,6 +23,9 @@
|
|||
* with ICU.
|
||||
*/
|
||||
|
||||
#define __STDC_FORMAT_MACROS 1
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include "unicode/utypes.h"
|
||||
#include "unicode/uchar.h"
|
||||
|
@ -299,7 +302,7 @@ static void demoCaseMapInC() {
|
|||
if(U_SUCCESS(errorCode)) {
|
||||
printUString("full-lowercased/en: ", buffer, length);
|
||||
} else {
|
||||
printf("error in u_strToLower(en)=%ld error=%s\n", length, u_errorName(errorCode));
|
||||
printf("error in u_strToLower(en)=%" PRId32 " error=%s\n", length, u_errorName(errorCode));
|
||||
}
|
||||
/* lowercase/Turkish */
|
||||
errorCode=U_ZERO_ERROR;
|
||||
|
@ -307,7 +310,7 @@ static void demoCaseMapInC() {
|
|||
if(U_SUCCESS(errorCode)) {
|
||||
printUString("full-lowercased/tr: ", buffer, length);
|
||||
} else {
|
||||
printf("error in u_strToLower(tr)=%ld error=%s\n", length, u_errorName(errorCode));
|
||||
printf("error in u_strToLower(tr)=%" PRId32 " error=%s\n", length, u_errorName(errorCode));
|
||||
}
|
||||
/* uppercase/English */
|
||||
errorCode=U_ZERO_ERROR;
|
||||
|
@ -315,7 +318,7 @@ static void demoCaseMapInC() {
|
|||
if(U_SUCCESS(errorCode)) {
|
||||
printUString("full-uppercased/en: ", buffer, length);
|
||||
} else {
|
||||
printf("error in u_strToUpper(en)=%ld error=%s\n", length, u_errorName(errorCode));
|
||||
printf("error in u_strToUpper(en)=%" PRId32 " error=%s\n", length, u_errorName(errorCode));
|
||||
}
|
||||
/* uppercase/Turkish */
|
||||
errorCode=U_ZERO_ERROR;
|
||||
|
@ -323,7 +326,7 @@ static void demoCaseMapInC() {
|
|||
if(U_SUCCESS(errorCode)) {
|
||||
printUString("full-uppercased/tr: ", buffer, length);
|
||||
} else {
|
||||
printf("error in u_strToUpper(tr)=%ld error=%s\n", length, u_errorName(errorCode));
|
||||
printf("error in u_strToUpper(tr)=%" PRId32 " error=%s\n", length, u_errorName(errorCode));
|
||||
}
|
||||
/* titlecase/English */
|
||||
errorCode=U_ZERO_ERROR;
|
||||
|
@ -331,7 +334,7 @@ static void demoCaseMapInC() {
|
|||
if(U_SUCCESS(errorCode)) {
|
||||
printUString("full-titlecased/en: ", buffer, length);
|
||||
} else {
|
||||
printf("error in u_strToTitle(en)=%ld error=%s\n", length, u_errorName(errorCode));
|
||||
printf("error in u_strToTitle(en)=%" PRId32 " error=%s\n", length, u_errorName(errorCode));
|
||||
}
|
||||
/* titlecase/Turkish */
|
||||
errorCode=U_ZERO_ERROR;
|
||||
|
@ -339,7 +342,7 @@ static void demoCaseMapInC() {
|
|||
if(U_SUCCESS(errorCode)) {
|
||||
printUString("full-titlecased/tr: ", buffer, length);
|
||||
} else {
|
||||
printf("error in u_strToTitle(tr)=%ld error=%s\n", length, u_errorName(errorCode));
|
||||
printf("error in u_strToTitle(tr)=%" PRId32 " error=%s\n", length, u_errorName(errorCode));
|
||||
}
|
||||
/* case-fold/default */
|
||||
errorCode=U_ZERO_ERROR;
|
||||
|
@ -347,7 +350,7 @@ static void demoCaseMapInC() {
|
|||
if(U_SUCCESS(errorCode)) {
|
||||
printUString("full-case-folded/default: ", buffer, length);
|
||||
} else {
|
||||
printf("error in u_strFoldCase(default)=%ld error=%s\n", length, u_errorName(errorCode));
|
||||
printf("error in u_strFoldCase(default)=%" PRId32 " error=%s\n", length, u_errorName(errorCode));
|
||||
}
|
||||
/* case-fold/Turkic */
|
||||
errorCode=U_ZERO_ERROR;
|
||||
|
@ -355,7 +358,7 @@ static void demoCaseMapInC() {
|
|||
if(U_SUCCESS(errorCode)) {
|
||||
printUString("full-case-folded/Turkic: ", buffer, length);
|
||||
} else {
|
||||
printf("error in u_strFoldCase(Turkic)=%ld error=%s\n", length, u_errorName(errorCode));
|
||||
printf("error in u_strFoldCase(Turkic)=%" PRId32 " error=%s\n", length, u_errorName(errorCode));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -461,7 +464,7 @@ demoUnicodeStringStorage() {
|
|||
printUnicodeString("readonly-aliasing string after modification: ", three);
|
||||
// the aliased array is not modified
|
||||
for(i=0; i<three.length(); ++i) {
|
||||
printf("readonly buffer[%d] after modifying its string: 0x%lx\n",
|
||||
printf("readonly buffer[%d] after modifying its string: 0x%" PRId32 "\n",
|
||||
i, readonly[i]);
|
||||
}
|
||||
// setTo() readonly alias
|
||||
|
@ -483,7 +486,7 @@ demoUnicodeStringStorage() {
|
|||
// a modification writes through to the buffer
|
||||
four.setCharAt(1, 0x39);
|
||||
for(i=0; i<four.length(); ++i) {
|
||||
printf("writeable-alias backing buffer[%d]=0x%lx "
|
||||
printf("writeable-alias backing buffer[%d]=0x%" PRId32 " "
|
||||
"after modification\n", i, writeable[i]);
|
||||
}
|
||||
// a copy will not alias any more;
|
||||
|
@ -491,7 +494,7 @@ demoUnicodeStringStorage() {
|
|||
two=four;
|
||||
two.setCharAt(1, 0x21);
|
||||
for(i=0; i<two.length(); ++i) {
|
||||
printf("writeable-alias backing buffer[%d]=0x%lx after "
|
||||
printf("writeable-alias backing buffer[%d]=0x%" PRId32 " after "
|
||||
"modification of string copy\n", i, writeable[i]);
|
||||
}
|
||||
// setTo() writeable alias, capacity==length
|
||||
|
@ -503,8 +506,8 @@ demoUnicodeStringStorage() {
|
|||
one.truncate(one.length()-1);
|
||||
// we still operate on the copy
|
||||
one.setCharAt(1, 0x25);
|
||||
printf("string after growing too much and then shrinking[1]=0x%lx\n"
|
||||
" backing store for this[1]=0x%lx\n",
|
||||
printf("string after growing too much and then shrinking[1]=0x%" PRId32 "\n"
|
||||
" backing store for this[1]=0x%" PRId32 "\n",
|
||||
one.charAt(1), writeable[1]);
|
||||
// if we need it in the original buffer, then extract() to it
|
||||
// extract() does not do anything if the string aliases that same buffer
|
||||
|
@ -516,7 +519,7 @@ demoUnicodeStringStorage() {
|
|||
}
|
||||
one.extract(0, i, writeable);
|
||||
for(i=0; i<UPRV_LENGTHOF(writeable); ++i) {
|
||||
printf("writeable-alias backing buffer[%d]=0x%lx after re-extract\n",
|
||||
printf("writeable-alias backing buffer[%d]=0x%" PRId32 " after re-extract\n",
|
||||
i, writeable[i]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue