ICU-89 change int8_t to uint8_t per compiler warnings

X-SVN-Rev: 2193
This commit is contained in:
Alan Liu 2000-08-11 17:31:41 +00:00
parent c48b7acd6f
commit 2209a45f2d
2 changed files with 36 additions and 14 deletions

View File

@ -5,8 +5,8 @@
******************************************************************************* *******************************************************************************
* *
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/tool/normalizer/Attic/CPPWriter.java,v $ * $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/tool/normalizer/Attic/CPPWriter.java,v $
* $Date: 2000/07/12 16:41:26 $ * $Date: 2000/08/11 17:31:41 $
* $Revision: 1.3 $ * $Revision: 1.4 $
* *
***************************************************************************************** *****************************************************************************************
*/ */
@ -171,20 +171,31 @@ class CPPWriter extends SourceWriter {
public void write(String name, byte[] array) { public void write(String name, byte[] array) {
header.println(""); header.println("");
header.println(" static const int8_t " + name + "[];"); header.println(" static const uint8_t " + name + "[];");
source.println(""); source.println("");
source.println("const int8_t " + className + "::" + name + "[] = {"); source.println("const uint8_t " + className + "::" + name + "[] = {");
source.print(" "); source.print(" ");
for (int i = 0; i < array.length; i++) { for (int i = 0; i < array.length; i++) {
if (i > 0 && i % 8 == 0) { if (i > 0 && i % 8 == 0) {
source.print(Utility.LINE_SEPARATOR + " "); source.print(Utility.LINE_SEPARATOR + " ");
} }
int value = array[i]; source.print("0x" + hex2(array[i]) + ", ");
if (value < 0) value += 256;
source.print("(int8_t)0x" + Integer.toString(value,16) + ", ");
} }
source.println("};"); source.println("};");
} }
private static StringBuffer __buf = new StringBuffer();
// This method not multithread safe!
private static final String hex2(int x) {
__buf.setLength(0);
__buf.append(hex1(x>>4)).append(hex1(x));
return __buf.toString();
}
private static final char hex1(int x) {
return "0123456789ABCDEF".charAt(x & 0xF);
}
} }

View File

@ -5,8 +5,8 @@
******************************************************************************* *******************************************************************************
* *
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/tools/normalizer/Attic/CPPWriter.java,v $ * $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/tools/normalizer/Attic/CPPWriter.java,v $
* $Date: 2000/07/12 16:41:26 $ * $Date: 2000/08/11 17:31:41 $
* $Revision: 1.3 $ * $Revision: 1.4 $
* *
***************************************************************************************** *****************************************************************************************
*/ */
@ -171,20 +171,31 @@ class CPPWriter extends SourceWriter {
public void write(String name, byte[] array) { public void write(String name, byte[] array) {
header.println(""); header.println("");
header.println(" static const int8_t " + name + "[];"); header.println(" static const uint8_t " + name + "[];");
source.println(""); source.println("");
source.println("const int8_t " + className + "::" + name + "[] = {"); source.println("const uint8_t " + className + "::" + name + "[] = {");
source.print(" "); source.print(" ");
for (int i = 0; i < array.length; i++) { for (int i = 0; i < array.length; i++) {
if (i > 0 && i % 8 == 0) { if (i > 0 && i % 8 == 0) {
source.print(Utility.LINE_SEPARATOR + " "); source.print(Utility.LINE_SEPARATOR + " ");
} }
int value = array[i]; source.print("0x" + hex2(array[i]) + ", ");
if (value < 0) value += 256;
source.print("(int8_t)0x" + Integer.toString(value,16) + ", ");
} }
source.println("};"); source.println("};");
} }
private static StringBuffer __buf = new StringBuffer();
// This method not multithread safe!
private static final String hex2(int x) {
__buf.setLength(0);
__buf.append(hex1(x>>4)).append(hex1(x));
return __buf.toString();
}
private static final char hex1(int x) {
return "0123456789ABCDEF".charAt(x & 0xF);
}
} }