ICU-9745 add icu4cscan

X-SVN-Rev: 32888
This commit is contained in:
Steven R. Loomis 2012-11-26 19:47:30 +00:00
parent d04e04229d
commit 29e8c542e3
18 changed files with 9149 additions and 0 deletions

7
.gitattributes vendored
View file

@ -873,6 +873,13 @@ tools/multi/c/patch/3_2 -text
tools/multi/c/patch/3_4_1 -text
tools/multi/common/Makefile-multi.inc -text
tools/multi/j/Makefile-j.inc -text
tools/multi/proj/icu4cscan/Makefile -text
tools/multi/proj/icu4cscan/Makefile.local.sample -text
tools/multi/proj/icu4cscan/Makefile_c -text
tools/multi/proj/icu4cscan/Makefile_j -text
tools/multi/proj/icu4cscan/dtd/icucaps.dtd -text
tools/multi/proj/icu4cscan/old-xmls.tar.bz2 -text
tools/multi/proj/icu4cscan/zappit.sed -text
tools/multi/proj/icu4jscan/.classpath -text
tools/multi/proj/icu4jscan/.project -text
tools/multi/proj/icu4jscan/src/com/ibm/icu/dev/scan/CapDocument.java -text

View file

@ -0,0 +1,121 @@
# Copyright (C) 2008-2012 IBM Corporation and Others. All Rights Reserved.
MULTICU_ROOT=../../multicu/
include $(MULTICU_ROOT)/Makefile-multi.inc
XML=./xml
JXML=./jxml
JVMXML=./jvmxml
COOKED=cooked
INPUT=input
INTROXMLS=$(wildcard $(INPUT)/*-introduction.xml)
FEATXMLS=$(INTROXMLS:$(INPUT)/%-introduction.xml=$(COOKED)/%-cooked.xml) $(COOKED)/characters.xml
ALLCOOKED=cooked/features.xml
# java stuff
MergerName=Merger
PropagateName=PropagateFeatures
PropagateCharsName=PropagateCharacters
MergerPackage=com.ibm.icu.dev.meta
MergerPackageSlash=$(subst .,/,$(MergerPackage))
## ICUMETA=/xsrl/E/data/meta (in Makefile.local)
MergerLib=$(ICUMETA)/lib
MergerJar=$(ICUMETA)/icumeta.jar
#was: $(ICUMETA)/classes
MergerClassPath=$(shell ls $(MergerLib)/*.jar | tr '\n' ':')$(MergerJar)
include Makefile.local
MergerBuild=$(ICUMETA)/build.xml
#MergerClass=$(ICUMETA)/classes/$(MergerPackageSlash)/$(MergerName).class
#MergerJava=$(ICUMETA)/src/$(MergerPackageSlash)/$(MergerName).java
#BASEXMLS=$(ICUMETA)/xml/icumeta.xml
BASEXMLS=$(ICUMETA)/input/versions.xml
APRECIOUS=$(ICUVERS:%=$(BLD)/%/$(S_SRC)) $(ICUVERS:%=$(BLD)/%/$(S_BLD)) $(ICUVERS:%=$(INS)/%/$(S_INS))
.PRECIOUS: $(APRECIOUS)
tehprecious:
echo $(APRECIOUS)
$(MergerJar):
( cd $(ICUMETA) ; ant jar )
$(BLD):
-mkdir $(BLD)
$(XML):
mkdir $(XML)
$(JXML):
mkdir $(JXML)
ifeq ($(JVMSH),)
JVMSH_WARN=warn-jvmsh
warn-jvmsh:
@echo "Note: No $(JVM)/*$(JVM_CFG) files found, see $(JVM)/readme.txt"
endif
DTDCACHE=$(shell pwd)/dtdcache
DTDTMP=$(shell pwd)/dtdtmp
DTDOVR=$(ICUMETA)/dtd
JAVADEBUG=-DCLDR_DTD_CACHE_DEBUG=n -DCLDR_DTD_CACHE_ADEBUG=n
JAVAPROPS= -DCLDR_DTD_CACHE=$(DTDCACHE) -DCLDR_DTD_OVERRIDE=$(DTDOVR) -DICU_DTD_CACHE=$(DTDCACHE) -DICU_DTD_OVERRIDE=$DTDOVR
#//$(DTD)/Makefile: $(ICUMETA)/dtd/Makfile
#// ln -s $^ $@
#//
#//dtd/icucaps.dtd: $(DTD)/Makefile dtd/icucaps.rnc
#// make -C $(DTD)
ICUMETA_XML=$(ICUMETA)/xml/icumeta.xml
BASE_VERSION=$(COOKED)/allversions.xml
BASE_SOURCE=$(BASEXMLS) $(INPUT)/java.xml
#$(ICUMETA)/xml/icumeta.xml: $(MergerBuild)
# ( cd $(ICUMETA) ; ant xml )
ALLXMLS=$(wildcard $(XML)/*.xml $(JXML)/*.xml $(JVMXML)/*.xml)
allxmls: $(XML) $(JXML) $(JVMXML)
$(MAKE) -f Makefile_c outfiles
$(MAKE) -f Makefile_j outfiles
featxmls: $(FEATXMLS)
allcooked: $(ALLCOOKED)
$(COOKED):
-mkdir $(COOKED)
$(BASE_VERSION): $(BASE_SOURCE) $(MergerJar) | $(COOKED)
-rm -rf ./dtdcache
mkdir dtdcache
java $(JAVAPROPS) -classpath $(MergerClassPath) $(MergerPackage).$(MergerName) -v -o:$@ $(BASE_SOURCE)
$(ALLCOOKED): $(FEATXMLS) $(MergerJar)
-rm -rf ./dtdcache
mkdir dtdcache
java $(JAVAPROPS) -classpath $(MergerClassPath) $(MergerPackage).$(MergerName) -v -o:$@ $(FEATXMLS)
$(COOKED)/%-cooked.xml: $(BASE_VERSION) $(INPUT)/%-introduction.xml $(MergerJar) | $(COOKED)
-rm -rf ./dtdcache
mkdir dtdcache
java $(JAVAPROPS) -classpath $(MergerClassPath) $(MergerPackage).$(PropagateName) $(BASE_VERSION) $(INPUT)/$*-introduction.xml > $(COOKED)/$*-cooked.xml
$(COOKED)/characters.xml: $(ALLXMLS) $(COOKED)/junicode-cooked.xml $(MergerJar)
java $(JAVAPROPS) -classpath $(MergerClassPath) $(MergerPackage).$(PropagateCharsName) > $@ $(ALLXMLS) $(COOKED)/junicode-cooked.xml || (rm ./$@ ; false)
icucaps.xml: allxmls $(BASE_VERSION) $(ALLXMLS) $(MergerJar) $(ALLCOOKED)
-rm -rf ./dtdcache
mkdir dtdcache
# -rm -rf ./dtdtmp
# mkdir dtdtmp
# ln -s $(ICUMETA)/dtd/*.dtd ./dtdtmp/
# ln -s ./dtd/*.dtd ./dtdtmp/
java $(JAVAPROPS) -classpath $(MergerClassPath) $(MergerPackage).$(MergerName) -v -o:$@ $(BASE_VERSION) $(ALLXMLS) $(ALLJXMLS) $(ALLCOOKED)

View file

@ -0,0 +1,11 @@
# Copyright (C) 2012 IBM Corporation and Others. All Rights Reserved.
# meta path
ICUMETA=/xsrl/E/data/meta
# exemplar jar
ICUJAR=$(ICUMETA)/lib/icu4j.jar
#MAKE_OPTS=-j2
post: icucaps.xml
-mkdir bk
cp icucaps.xml bk/icucaps_`date '+%Y%m%d_%H%M%S.xml'`
scp icucaps.xml icu-project.org:public_html/tmp/

View file

@ -0,0 +1,45 @@
# Copyright (C) 2012 IBM Corporation and Others. All Rights Reserved.
CPPFLAGS+=-DU_DISABLE_RENAMING=1 -I. -I/xsrl/IIE/include -I/xsrl/E/icu/source/tools/toolutil
OBJECTS=testxml.o xmlout.o
CXX_SOURCES:=$(OBJECTS:%.o=%.cpp)
C_SOURCES=
HEADERS=xmlout.h
TARGET=testxml
all:
@echo To build and list "'" $(OUTFILES) "'" in "'" $(C_GOOD) "'" use "$(MAKE) check"
MULTICU_ROOT=../../multicu/
include $(MULTICU_ROOT)/Makefile-c.inc
OUT=./xml
$(OUT):
mkdir $(OUT)
OUTFILES=$(C_GOOD:%=$(OUT)/%.xml)
.PRECIOUS: $(C_CLEAN_TARGET)
## Generate a file
$(OUT)/%.xml: $(OUT) $(C_INS)/%/bin/$(TARGET)
$(shell $(C_INS)/$*/bin/icu-config --invoke) $(C_INS)/$*/bin/$(TARGET) > $@
## clean
clean:
-rm -f $(C_CLEAN_TARGET)
-rm -f ./$(OUT)/*
-rmdir $(OUT)
## Just generate
outfiles: $(OUTFILES)
## Test: generate out files, and print them.
check: $(OUTFILES)
@for file in $(OUTFILES); \
do \
echo; \
sed -e "s%^%$$file: %g" < $$file; \
done

View file

@ -0,0 +1,223 @@
# Copyright (C) 2012 IBM Corporation and Others. All Rights Reserved.
## Name of the app
TARGET=icu4jscan
all:
@echo To build and list "'" $(OUTFILES) "'" in "'" $(J_GOOD) "'" use "$(MAKE) check"
## Setup multicu
MULTICU_ROOT=../../multicu
include $(MULTICU_ROOT)/Makefile-j.inc
## The output files. Will result in: out/3_8.txt out/4_0.txt etc.
OUT=jxml
OUTFILES=$(J_GOOD:%=$(OUT)/%.txt)
.PRECIOUS: $(C_CLEAN_TARGET)
## Generate a file
$(OUT)/%.txt: $(OUT) $(C_INS)/%/bin/$(TARGET)
$(shell $(C_INS)/$*/bin/icu-config --invoke) $(C_INS)/$*/bin/$(TARGET) > $@
## clean
clean:
-rm -f $(C_CLEAN_TARGET)
-rm -f ./$(OUT)/*
-rmdir $(OUT)
## Test: generate out files, and print them.
check: $(OUTFILES)
@for file in $(OUTFILES); \
do \
echo; \
sed -e "s%^%$$file: %g" < $$file; \
done
MULTICU_ROOT=../../multicu/
include $(MULTICU_ROOT)/Makefile-multi.inc
XML=./xml
JVMXML=./jvmxml
JVM=$(MULTICU_ROOT)/j/jvm
JVM_CFG=.sh
JVMSH:=$(wildcard $(JVM)/[0-9]*$(JVM_CFG))
ALLICUS=$(ICUVERS:%=$(BLD)/%/$(S_BLD))
IICUS=$(ICUVERS:%=$(INS)/%/$(S_INS))
ALLAPPS=$(ICUVERS:%=$(INS)/%/bin/$(TARGET))
ALLXMLS=$(ICUVERS:%=$(XML)/%.xml)
COOKED=cooked
INPUT=input
INTROXMLS=$(wildcard $(INPUT)/*-introduction.xml)
FEATXMLS=$(INTROXMLS:$(INPUT)/%-introduction.xml=$(COOKED)/%-cooked.xml) $(COOKED)/characters.xml
ALLCOOKED=cooked/features.xml
JXML=./jxml
#ICU4JVERS
ALLICU4JS=$(ICU4JVERS:%=$(ICUS)/icu4j-%.jar)
ALLJXMLS=$(J_GOOD:%=$(JXML)/%.xml)
JSCAN=ScanICU
alljxmls: $(JXML) $(ALLJXMLS)
JSCANDIR=../icu4jscan
JCLASSFILE=$(JSCANDIR)/bin/com/ibm/icu/dev/scan/$(JSCAN).class
JScanPackage=com.ibm.icu.dev.scan
ALLJVM=$(JVMSH:$(JVM)/%$(JVM_CFG)=%)
ALLJVMXMLS=$(ALLJVM:%=$(JVMXML)/%.xml)
JVMSCAN=ScanJava
alljvmxmls: $(JVMXML) $(ALLJVMXMLS)
JVMCLASSFILE=$(JSCANDIR)/bin/com/ibm/icu/dev/scan/$(JVMSCAN).class
# java stuff
JAVA=java
MergerName=Merger
PropagateName=PropagateFeatures
PropagateCharsName=PropagateCharacters
MergerPackage=com.ibm.icu.dev.meta
MergerPackageSlash=$(subst .,/,$(MergerPackage))
## ICUMETA=/xsrl/E/data/meta (in Makefile.local)
MergerLib=$(ICUMETA)/lib
MergerJar=$(ICUMETA)/icumeta.jar
#was: $(ICUMETA)/classes
MergerClassPath=$(shell ls $(MergerLib)/*.jar | tr '\n' ':')$(MergerJar)
include Makefile.local
MergerBuild=$(ICUMETA)/build.xml
#MergerClass=$(ICUMETA)/classes/$(MergerPackageSlash)/$(MergerName).class
#MergerJava=$(ICUMETA)/src/$(MergerPackageSlash)/$(MergerName).java
#BASEXMLS=$(ICUMETA)/xml/icumeta.xml
BASEXMLS=$(ICUMETA)/input/versions.xml
APRECIOUS=$(ICUVERS:%=$(BLD)/%/$(S_SRC)) $(ICUVERS:%=$(BLD)/%/$(S_BLD)) $(ICUVERS:%=$(INS)/%/$(S_INS))
.PRECIOUS: $(APRECIOUS)
tehprecious:
echo $(APRECIOUS)
$(MergerJar):
( cd $(ICUMETA) ; ant jar )
$(BLD):
-mkdir $(BLD)
$(INS)/%/$(S_INS): $(BLD)/%/$(S_BLD)
@if [ -f $(BLD)/$*/build.err ]; then echo Error for $* stored in $(BLD)/$*/build.err; false; fi
( make $(MAKE_OPTS) -C $(BLD)/$*/icu/source 2>&1 all install | tee $(BLD)/$*/build.log ) || ( mv $(BLD)/$*/build.log $(BLD)/$*/build.err ; false )
touch -c $@
$(BLD)/%/$(S_SRC): $(ICUS)/icu4c-%-src.tgz
-mv $(BLD)/$* $(BLD)/$*.old
-( rm -rf ./$(BLD)/$*.old& )
mkdir -p $(BLD)/$*
( cd $(BLD)/$* ; tar xfpz $(DOT)/$^ )
([ -f patch/$* ] && patch -d $(BLD)/$* -p1 < $(DOT)/patch/$*) || true
touch -c $@
$(BLD)/%/$(S_BLD): $(BLD)/%/$(S_SRC)
-mkdir -p $(INS)
( cd $(BLD)/$*/icu/source ; ./configure --disable-renaming --enable-shared --disable-static --enable-release --disable-debug --prefix=$(DOT)/$(INS)/$* )
touch -c $@
$(INS)/%/bin/$(TARGET): $(INS)/%/$(S_INS) $(SRCS)
-rm -rf ./$(BLD)/$*/tmp
mkdir ./$(BLD)/$*/tmp
@for file in $(OBJECTS); \
do \
what=`basename $$file .o` ; \
echo compiling $*/$$what ; \
$(CXX) -c -o ./$(BLD)/$*/tmp/$$what.o $$what.cpp -I $(INS)/$*/include -I $(BLD)/$*/icu/source/tools/toolutil ; \
done
$(CXX) -o $@ $(OBJECTS:%.o=./$(BLD)/$*/tmp/%.o) -licudata -licuuc -licutu -licui18n -L$(INS)/$*/lib
$(XML):
mkdir $(XML)
$(JXML):
mkdir $(JXML)
ifeq ($(JVMSH),)
JVMSH_WARN=warn-jvmsh
warn-jvmsh:
@echo "Note: No $(JVM)/*$(JVM_CFG) files found, see $(JVM)/readme.txt"
endif
$(JVMXML):
mkdir $(JVMXML)
$(XML)/%.xml: $(INS)/%/bin/$(TARGET) $(XML)
$(shell $(INS)/$*/bin/icu-config --invoke) $(INS)/$*/bin/$(TARGET) > $@
allxmls: $(ALLXMLS) | $(OUT)
alljvmxmls: $(ALLJVMXMLS) $(JVMSH_WARN) | $(JVMXML)
allapps: $(BLD) $(ALLAPPS)
allicus: $(BLD) $(ALLICUS)
clean-allapps:
-rm -f $(ALLAPPS)
iicus: $(BLD) $(IICUS)
DTDCACHE=$(shell pwd)/dtdcache
DTDTMP=$(shell pwd)/dtdtmp
DTDOVR=$(ICUMETA)/dtd
JAVADEBUG=-DCLDR_DTD_CACHE_DEBUG=n -DCLDR_DTD_CACHE_ADEBUG=n
JAVAPROPS= -DCLDR_DTD_CACHE=$(DTDCACHE) -DCLDR_DTD_OVERRIDE=$(DTDOVR) -DICU_DTD_CACHE=$(DTDCACHE) -DICU_DTD_OVERRIDE=$DTDOVR
#//$(DTD)/Makefile: $(ICUMETA)/dtd/Makfile
#// ln -s $^ $@
#//
#//dtd/icucaps.dtd: $(DTD)/Makefile dtd/icucaps.rnc
#// make -C $(DTD)
ICUMETA_XML=$(ICUMETA)/xml/icumeta.xml
#$(ICUMETA)/xml/icumeta.xml: $(MergerBuild)
# ( cd $(ICUMETA) ; ant xml )
featxmls: $(FEATXMLS)
allcooked: $(ALLCOOKED)
$(ALLCOOKED): $(FEATXMLS) $(MergerJar)
-rm -rf ./dtdcache
mkdir dtdcache
$(JAVA) $(JAVAPROPS) -classpath $(MergerClassPath) $(MergerPackage).$(MergerName) -v -o:$@ $(FEATXMLS)
$(COOKED)/%-cooked.xml: $(ICUMETA_XML) $(INPUT)/%-introduction.xml $(MergerJar)
-rm -rf ./dtdcache
mkdir dtdcache
$(JAVA) $(JAVAPROPS) -classpath $(MergerClassPath) $(MergerPackage).$(PropagateName) $(ICUMETA_XML) $(INPUT)/$*-introduction.xml > $(COOKED)/$*-cooked.xml
$(COOKED)/characters.xml: $(ALLJXMLS) $(ALLXMLS) $(MergerJar)
$(JAVA) $(JAVAPROPS) -classpath $(MergerClassPath) $(MergerPackage).$(PropagateCharsName) > $@ $(ALLJXMLS) $(ALLXMLS) || (rm ./$@ ; false)
icucaps.xml: $(BASEXMLS) $(ALLJXMLS) $(ALLXMLS) $(MergerJar) $(ALLCOOKED)
-rm -rf ./dtdcache
mkdir dtdcache
# -rm -rf ./dtdtmp
# mkdir dtdtmp
# ln -s $(ICUMETA)/dtd/*.dtd ./dtdtmp/
# ln -s ./dtd/*.dtd ./dtdtmp/
$(JAVA) $(JAVAPROPS) -classpath $(MergerClassPath) $(MergerPackage).$(MergerName) -v -o:$@ $(BASEXMLS) $(ALLXMLS) $(ALLJXMLS) $(ALLCOOKED)
# --- J
$(JXML)/%.xml: $(JCLASSFILE) $(ICUS)/icu4j-%.jar | $(JXML)
$(JAVA) -classpath $(JSCANDIR)/bin:$(ICUS)/icu4j-$*.jar:$(JSCANDIR)/lib/icumeta.jar:$(JSCANDIR)/lib/xalan.jar:$(JSCANDIR)/lib/cldr.jar:$(JSCANDIR)/lib/utilities.jar:$(MergerJar):$(MergerLib)/utilities.jar:$(MergerLib)/cldr.jar:$(JSCANDIR)/lib/xerces.jar $(JScanPackage).$(JSCAN) > $@ || (rm -f ./$@ ; false)
$(JVMXML)/%.xml: $(JVMCLASSFILE) $(JVM)/%$(JVM_CFG) | $(JVMXML)
$(JVM)/invoke.sh $(JVM)/$*$(JVM_CFG) $(JSCANDIR)/bin:$(ICUS)/icu4j-$*.jar:$(JSCANDIR)/lib/icumeta.jar:$(JSCANDIR)/lib/xalan.jar:$(JSCANDIR)/lib/cldr.jar:$(MergerJar):$(MergerJar):$(MergerLib)/utilities.jar:$(MergerLib)/cldr.jar:$(JSCANDIR)/lib/utilities.jar:$(JSCANDIR)/lib/xerces.jar $(JScanPackage).$(JVMSCAN) > $@ || (rm ./$@ ; false)
## Just generate
outfiles: $(XML) $(JXML) $(ALLJXMLS) $(ALLJVMXMLS)

View file

@ -0,0 +1,12 @@
<!-- Copyright (C) 2008-2012 IBM Corporation and Others. All Rights Reserved. -->
element capabilities
{
element feature
{
attribute type {text },
attribute total {text}?,
attribute version {text},
text
}*
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Copyright (c) 2008-2012 IBM Corporation and Others, All Rights Reserved. -->
<!DOCTYPE icuInfo SYSTEM "http://icu-project.org/dtd/icumeta.dtd">
<icuInfo>
<icuProducts>
<icuProduct type="java">
<names>
<name type="full">Java</name>
<name type="short">Java</name>
</names>
<releases>
<release version="1.3.1"/>
<release version="1.4.2"/>
<release version="1.5.0"/>
<release version="1.6.0"/>
<release version="1.7.0"/>
</releases>
</icuProduct>
</icuProducts>
</icuInfo>

View file

@ -0,0 +1,25 @@
<!-- Copyright (C) 2008-2012 IBM Corporation and Others. All Rights Reserved. -->
<icuInfo>
<icuProducts>
<icuProduct type="java">
<releases>
<release version="1.4.2">
<capabilities>
<feature type="layout">
Arab Hebr Thai Beng Deva Gujr Knda Mlym Orya Punj Taml Telu Urdu Hans Hant Jpan Latn Cyrl Grek Armn Geor Runr Ogam Thai
</feature>
</capabilities>
</release>
<release version="1.5.0">
<capabilities>
<feature type="layout">
+Khmr Hang Sinh Tibt
</feature>
</capabilities>
</release>
</releases>
</icuProduct>
</icuProducts>
</icuInfo>

View file

@ -0,0 +1,36 @@
<!-- Copyright (C) 2008-2012 IBM Corporation and Others. All Rights Reserved. -->
<icuInfo>
<icuProducts>
<icuProduct type="java">
<releases>
<release version="1.4.2">
<capabilities>
<feature type="unicode" version="3.0"/>
</capabilities>
</release>
<release version="1.5.0">
<capabilities>
<feature type="unicode" version="4.0"/>
</capabilities>
</release>
<release version="1.6.0">
<capabilities>
<feature type="unicode" version="4.0"/>
</capabilities>
</release>
<release version="1.7.0">
<capabilities>
<feature type="unicode" version="6.0"/>
</capabilities>
</release>
</releases>
</icuProduct>
</icuProducts>
</icuInfo>

View file

@ -0,0 +1,61 @@
<!-- Copyright (C) 2012 IBM Corporation and Others. All Rights Reserved. -->
<icuInfo>
<icuProducts>
<icuProduct type="icu4c">
<releases>
<release version="1.7">
<capabilities>
<feature type="layout">
Arab Hebr Thai Beng Deva Gujr Knda Mlym Orya Punj Taml Telu
</feature>
</capabilities>
</release>
<release version="2.2">
<capabilities>
<feature type="layout">
+Urdu
</feature>
</capabilities>
</release>
<release version="2.6">
<capabilities>
<feature type="layout">
+Hans Hant Jpan
<!-- CJK Language Variants? -->
</feature>
</capabilities>
</release>
<release version="3.0">
<capabilities>
<feature type="layout">
+Latn Cyrl Grek Armn Geor Runr Ogam Thai
</feature>
</capabilities>
</release>
<release version="3.4">
<capabilities>
<feature type="layout">
+Khmr
</feature>
</capabilities>
</release>
<release version="3.6">
<capabilities>
<feature type="layout">
+Hang Sinh Tibt
</feature>
</capabilities>
</release>
</releases>
</icuProduct>
</icuProducts>
</icuInfo>

View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:215e9cc66b7962f53a08db564558553366f06f64eb6d8508a3ff2dac47c90cb6
size 9713

View file

@ -0,0 +1,546 @@
// Copyright (C) 2008-2012 IBM Corporation and Others. All Rights Reserved.
#include <ostream>
#include "xmlout.h"
#include <stdio.h>
#include <stdlib.h>
#include "uoptions.h"
#include "unicode/putil.h"
#include "unicode/ucol.h"
#include "unicode/ucal.h"
#include "unicode/uchar.h"
#include "unicode/ures.h"
#include "unicode/udat.h"
#include "unicode/ustring.h"
#if (U_ICU_VERSION_MAJOR_NUM > 2) || ((U_ICU_VERSION_MAJOR_NUM>1)&&(U_ICU_VERSION_MINOR_NUM>5))
#include "unicode/uclean.h"
#endif
static char *progName;
static UOption options[]={
UOPTION_HELP_H, /* 0 */
UOPTION_HELP_QUESTION_MARK, /* 1 */
UOPTION_VERBOSE, /* 2 */
UOPTION_ICUDATADIR, /* 3 */
UOPTION_DESTDIR, /* 4 */
UOPTION_COPYRIGHT, /* 5 */
};
const char *u_errorNameShort(UErrorCode code) {
switch(code) {
case U_ZERO_ERROR: return "ok";
case U_MISSING_RESOURCE_ERROR: return "missing";
default: return u_errorName(code);
}
}
void usageAndDie(int retCode) {
printf("Usage: %s [-v] [-options] -o output-file dictionary-file\n", progName);
printf("\tRead in word list and write out compact trie dictionary\n"
"options:\n"
"\t-h or -? or --help this usage text\n"
"\t-V or --version show a version message\n"
"\t-c or --copyright include a copyright notice\n"
"\t-v or --verbose turn on verbose output\n"
"\t-i or --icudatadir directory for locating any needed intermediate data files,\n"
"\t followed by path, defaults to %s\n"
"\t-d or --destdir destination directory, followed by the path\n",
u_getDataDirectory());
exit (retCode);
}
/*U_CAPI void U_EXPORT2*/
static void _versionFromUString(UVersionInfo versionArray, const UChar *versionString) {
if(versionArray==NULL) {
return;
}
if(versionString!=NULL) {
char verchars[U_MAX_VERSION_LENGTH+1];
u_UCharsToChars(versionString, verchars, U_MAX_VERSION_LENGTH);
u_versionFromString(versionArray, verchars);
}
}
/*U_CAPI void U_EXPORT2*/
static void _getCLDRVersionDirect(UVersionInfo versionArray, UErrorCode *status) {
UResourceBundle *resindx;
resindx = ures_openDirect(NULL, "supplementalData", status);
if(!U_FAILURE(*status)) {
// fprintf(stderr, "Err: could not open res_index, %s\n", u_errorName(status));
// fflush(stderr);
// } else {
const UChar *cldrver;
int32_t len;
cldrver = ures_getStringByKey(resindx, "cldrVersion", &len, status);
if(!U_FAILURE(*status)) {
// fprintf(stderr, "ERR: could not load CLDRVersion key: %s\n", u_errorName(*status));
// fflush(stderr);
// } else {
// UVersionInfo cldrVersion;
_versionFromUString(versionArray, cldrver);
// strcpy(tmp, "type=\"cldr\" version=\"");
// u_versionToString(cldrVersion, tmp+strlen(tmp));
// strcat(tmp, "\"");
// XMLElement icuData(xf, "feature", tmp, TRUE);
}
ures_close(resindx);
}
}
/*U_CAPI void U_EXPORT2*/
static void _getCLDRVersionOld(UVersionInfo versionArray, UErrorCode *status) {
UResourceBundle *resindx;
resindx = ures_openDirect(NULL, "res_index", status);
if(!U_FAILURE(*status)) {
// fprintf(stderr, "Err: could not open res_index, %s\n", u_errorName(status));
// fflush(stderr);
// } else {
const UChar *cldrver;
int32_t len;
cldrver = ures_getStringByKey(resindx, "CLDRVersion", &len, status);
if(!U_FAILURE(*status)) {
// fprintf(stderr, "ERR: could not load CLDRVersion key: %s\n", u_errorName(*status));
// fflush(stderr);
// } else {
// UVersionInfo cldrVersion;
_versionFromUString(versionArray, cldrver);
// strcpy(tmp, "type=\"cldr\" version=\"");
// u_versionToString(cldrVersion, tmp+strlen(tmp));
// strcat(tmp, "\"");
// XMLElement icuData(xf, "feature", tmp, TRUE);
}
ures_close(resindx);
}
}
int could_open(const char *locale, char *comments) {
char tmp[200];
UResourceBundle *rb = NULL;
UErrorCode status = U_ZERO_ERROR;
rb = ures_open(NULL, locale, &status);
if(U_FAILURE(status)) {
sprintf(tmp, " open:%s", u_errorName(status));
strcat(comments, tmp);
return 0;
} else {
ures_close(rb);
sprintf(tmp, " open:%s", u_errorNameShort(status));
strcat(comments, tmp);
return 1;
}
}
int col_could_open(const char *locale, char *comments) {
char tmp[200];
UCollator *rb = NULL;
UErrorCode status = U_ZERO_ERROR;
rb = ucol_open(locale, &status);
if(U_FAILURE(status)) {
sprintf(tmp, " open:%s", u_errorName(status));
/*strcat(comments, tmp); */
return 0;
} else {
ucol_close(rb);
sprintf(tmp, " open:%s", u_errorNameShort(status));
/* strcat(comments, tmp); */
return 1;
}
}
const char *UDateFormatSymbolType_name(UDateFormatSymbolType i) {
switch(i) {
case UDAT_ERAS: return "UDAT_ERAS"; break;
/** The month names, for example February */
case UDAT_MONTHS: return "UDAT_MONTHS"; break;
/** The short month names, for example Feb. */
case UDAT_SHORT_MONTHS: return "UDAT_SHORT_MONTHS"; break;
/** The weekday names, for example Monday */
case UDAT_WEEKDAYS: return "UDAT_WEEKDAYS"; break;
/** The short weekday names, for example Mon. */
case UDAT_SHORT_WEEKDAYS: return "UDAT_SHORT_WEEKDAYS"; break;
/** The AM/PM names, for example AM */
case UDAT_AM_PMS: return "UDAT_AM_PMS"; break;
/** The localized characters */
case UDAT_LOCALIZED_CHARS: return "UDAT_LOCALIZED_CHARS"; break;
/** The long era names, for example Anno Domini */
#if U_ICU_VERSION_MAJOR_NUM>3 || U_ICU_VERSION_MAJOR_NUM>3
case UDAT_ERA_NAMES: return "UDAT_ERA_NAMES"; break;
#endif
#if U_ICU_VERSION_MAJOR_NUM>3 || U_ICU_VERSION_MAJOR_NUM>3
/** The narrow month names, for example F */
case UDAT_NARROW_MONTHS: return "UDAT_NARROW_MONTHS"; break;
/** The narrow weekday names, for example N */
case UDAT_NARROW_WEEKDAYS: return "UDAT_NARROW_WEEKDAYS"; break;
/** Standalone context versions of months */
case UDAT_STANDALONE_MONTHS: return "UDAT_STANDALONE_MONTHS"; break;
case UDAT_STANDALONE_SHORT_MONTHS: return "UDAT_STANDALONE_SHORT_MONTHS"; break;
case UDAT_STANDALONE_NARROW_MONTHS: return "UDAT_STANDALONE_NARROW_MONTHS"; break;
/** Standalone context versions of weekdays */
case UDAT_STANDALONE_WEEKDAYS: return "UDAT_STANDALONE_WEEKDAYS"; break;
case UDAT_STANDALONE_SHORT_WEEKDAYS: return "UDAT_STANDALONE_SHORT_WEEKDAYS"; break;
case UDAT_STANDALONE_NARROW_WEEKDAYS: return "UDAT_STANDALONE_NARROW_WEEKDAYS"; break;
#endif
#if U_ICU_VERSION_MAJOR_NUM>3 || U_ICU_VERSION_MAJOR_NUM>4
/** The quarters, for example 1st Quarter */
case UDAT_QUARTERS: return "UDAT_QUARTERS"; break;
/** The short quarter names, for example Q1 */
case UDAT_SHORT_QUARTERS: return "UDAT_SHORT_QUARTERS"; break;
/** Standalone context versions of quarters */
case UDAT_STANDALONE_QUARTERS: return "UDAT_STANDALONE_QUARTERS"; break;
case UDAT_STANDALONE_SHORT_QUARTERS: return "UDAT_STANDALONE_SHORT_QUARTERS"; break;
#endif
}
return "<Unknown>";
}
UDateFormatSymbolType scanArray[] = {
UDAT_ERAS,
/** The month names, for example February */
UDAT_MONTHS,
/** The short month names, for example Feb. */
UDAT_SHORT_MONTHS,
/** The weekday names, for example Monday */
UDAT_WEEKDAYS,
/** The short weekday names, for example Mon. */
UDAT_SHORT_WEEKDAYS,
/** The AM/PM names, for example AM */
// UDAT_AM_PMS,
/** The localized characters */
// UDAT_LOCALIZED_CHARS,
/** The long era names, for example Anno Domini */
// UDAT_ERA_NAMES,
/** The narrow month names, for example F */
// UDAT_NARROW_MONTHS,
};
int *starts = NULL;
UChar ***rootdata = NULL;
void initroot(UErrorCode *status) {
UDateFormat *fmt;
fmt = udat_open(UDAT_DEFAULT, UDAT_DEFAULT, "root", NULL, -1,NULL,0, status);
rootdata = (UChar***)malloc((sizeof(scanArray)/sizeof(scanArray[0]))*sizeof(rootdata[0]));
starts = (int*)malloc((sizeof(scanArray)/sizeof(scanArray[0]))*sizeof(starts[0]));
for(int i=0;U_SUCCESS(*status)&&i<sizeof(scanArray)/sizeof(scanArray[0]);i++) {
int thisCount = udat_countSymbols(fmt, scanArray[i]);
rootdata[i]=0;
rootdata[i]=(UChar**)malloc(thisCount*sizeof(rootdata[i][0]));
switch(scanArray[i]) {
case UDAT_WEEKDAYS:
case UDAT_SHORT_WEEKDAYS:
starts[i]=1;
break;
default:
starts[i]=0;
}
for(int j=starts[i];U_SUCCESS(*status)&&j<thisCount;j++) {
rootdata[i][j]=(UChar*)malloc(1024);
int sz =
udat_getSymbols(fmt,
scanArray[i],
j,
rootdata[i][j],
1024,
status);
}
}
}
/* Format the date */
static void
date(const UChar *tz,
UDateFormatStyle style,
char *format,
const char *locale, char *comments,
UErrorCode *status)
{
UChar *s = 0;
int32_t len = 0;
UDateFormat *fmt;
UChar uFormat[100];
char tmp[200];
int tc=0; // total count
int tf=0; // total found
int tl = 0;
fmt = udat_open(style, style, locale, tz, -1,NULL,0, status);
if ( format != NULL ) {
u_charsToUChars(format,uFormat,strlen(format)),
udat_applyPattern(fmt,FALSE,uFormat,strlen(format));
}
len = udat_format(fmt, ucal_getNow(), 0, len, 0, status);
if(*status == U_BUFFER_OVERFLOW_ERROR) {
*status = U_ZERO_ERROR;
s = (UChar*) malloc(sizeof(UChar) * (len+1));
if(s == 0) goto finish;
udat_format(fmt, ucal_getNow(), s, len + 1, 0, status);
if(U_FAILURE(*status)) goto finish;
}
/* print the date string */
//uprint(s, stdout, status);
/* print a trailing newline */
//printf("\n");
/* count bits */
UChar outbuf[1024];
for(int i=0;U_SUCCESS(*status)&&i<sizeof(scanArray)/sizeof(scanArray[0]);i++) {
int thisCount = udat_countSymbols(fmt, scanArray[i]);
tc += thisCount;
for(int j=starts[i];U_SUCCESS(*status)&&j<thisCount;j++) {
*status = U_ZERO_ERROR;
int sz =
udat_getSymbols(fmt,
scanArray[i],
j,
outbuf,
1024,
status);
if(U_SUCCESS(*status)) { tf++; tl += u_strlen(outbuf); }
//if(!u_strcmp(outbuf,rootdata[i][j])) {
if(*status != U_ZERO_ERROR) {
#if 0
fprintf(stderr, "<!-- %s: err: data %s:%d:%d is missing: %X... -->\n", locale, UDateFormatSymbolType_name(scanArray[i]), i, j, outbuf[0]);
#endif
sprintf(tmp, " missing: %s#%d-%s ", UDateFormatSymbolType_name(scanArray[i]), j, u_errorNameShort(*status));
*status = U_MISSING_RESOURCE_ERROR;
strcat(comments, tmp);
}
}
}
finish:
sprintf(tmp, " syms:%d/%d#%d:%s", tf, tc, tl, u_errorNameShort(*status));
strcat(comments,tmp);
udat_close(fmt);
free(s);
}
static void writeOkComments(XMLFile &xf, int ok, const char *comments, const char *locale) {
char tmp[2000];
tmp[0]=0;
if(ok) {
if(!comments||!*comments) {
strcpy(tmp,locale);
strcat(tmp, " ");
} else {
sprintf(tmp, "%s <!-- %s -->", locale, comments);
}
} else if(comments&&*comments) {
sprintf(tmp, "<!-- !! %s: %s -->", locale, comments);
}
if(tmp&&*tmp) {
xf.writeln(tmp);
}
}
int could_fmt_dow(const char *locale, char *comments) {
char tmp[200];
// UResourceBundle *rb = NULL;
UErrorCode status = U_ZERO_ERROR;
date(NULL,
UDAT_LONG,
NULL,
locale, comments,
&status);
if(U_FAILURE(status) || status != U_ZERO_ERROR) {
sprintf(tmp, " fmt:%s", u_errorNameShort(status));
strcat(comments, tmp);
return 0;
} else {
sprintf(tmp, " fmt:%s", u_errorNameShort(status));
strcat(comments, tmp);
return 1;
}
}
void probeCapability(XMLFile& xf, const char *locale) {
char comments[1000];
int ok=1;
int rc =0;
//fprintf(stderr, "PROBE: %s\n", locale);
comments[0]=0;
if(!could_open(locale, comments)) {
ok = 0;
}
#if (U_ICU_VERSION_MAJOR_NUM > 2) || ((U_ICU_VERSION_MAJOR_NUM>1)&&(U_ICU_VERSION_MINOR_NUM>2))
if(!could_fmt_dow(locale, comments)) {
ok = 0;
}
#endif
writeOkComments(xf,ok, comments,locale);
}
void probeColCapability(XMLFile& xf, const char *locale) {
char comments[1000];
int ok=1;
int rc =0;
UErrorCode status = U_ZERO_ERROR;
//fprintf(stderr, "PROBE: %s\n", locale);
comments[0]=0;
if(!col_could_open(locale, comments)) {
ok = 0;
}
/*
if(!col_could_fmt_dow(locale, comments)) {
ok = 0;
}
*/
writeOkComments(xf,ok, comments,locale);
}
int main (int argc, char ** argv) {
U_MAIN_INIT_ARGS(argc, argv);
progName = argv[0];
argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options);
// const char *loc;
{
UErrorCode status = U_ZERO_ERROR;
#if (U_ICU_VERSION_MAJOR_NUM > 2) || ((U_ICU_VERSION_MAJOR_NUM>1)&&(U_ICU_VERSION_MINOR_NUM>5))
u_init(&status);
#else
ures_open(NULL, "en_US", &status);
#endif
fprintf(stderr, " Init: %s\n", u_errorName(status));
}
{
UErrorCode is = U_ZERO_ERROR;
#if (U_ICU_VERSION_MAJOR_NUM > 2) || ((U_ICU_VERSION_MAJOR_NUM>1)&&(U_ICU_VERSION_MINOR_NUM>2))
initroot(&is);
fprintf(stderr, "Init: %s\n", u_errorNameShort(is));
#endif
}
if(argc<0) {
// Unrecognized option
fprintf(stderr, "error in command line argument \"%s\"\n", argv[-argc]);
usageAndDie(U_ILLEGAL_ARGUMENT_ERROR);
}
if(options[0].doesOccur || options[1].doesOccur) {
// -? or -h for help.
usageAndDie(0);
}
{
char tmp[200];
XMLFile xf(stdout);
{
xf.writeln("<!DOCTYPE icuInfo SYSTEM \"http://icu-project.org/dtd/icumeta.dtd\">");
XMLElement icuInfo(xf, "icuInfo");
XMLElement icuProducts(xf, "icuProducts");
XMLElement icuProduct(xf, "icuProduct", "type=\"icu4c\"");
XMLElement releases(xf, "releases");
sprintf(tmp, "version=\"%s\"", U_ICU_VERSION);
XMLElement release(xf, "release", tmp);
XMLElement capabilities(xf, "capabilities");
{
sprintf(tmp, "type=\"unicode\" version=\"%s\"",
U_UNICODE_VERSION);
XMLElement icuData(xf, "feature", tmp, TRUE);
}
{
UCollator *col;
char ucavers[200];
UVersionInfo vers;
UErrorCode status = U_ZERO_ERROR;
col = ucol_open("root", &status);
#if (U_ICU_VERSION_MAJOR_NUM>2) || ((U_ICU_VERSION_MAJOR_NUM>1)&&(U_ICU_VERSION_MINOR_NUM>7))
ucol_getUCAVersion(col, vers);
u_versionToString(vers, ucavers);
#else
strcpy(ucavers, "???");
#endif
sprintf(tmp, "type=\"uca\" version=\"%s\"",
ucavers);
XMLElement icuData(xf, "feature", tmp, TRUE);
ucol_close(col);
}
#if (U_ICU_VERSION_MAJOR_NUM>3) || ((U_ICU_VERSION_MAJOR_NUM > 2) && (U_ICU_VERSION_MINOR_NUM >7))
{
const char *tzvers;
UErrorCode status = U_ZERO_ERROR;
tzvers = ucal_getTZDataVersion(&status);
sprintf(tmp, "type=\"tz\" version=\"%s\"",
tzvers);
XMLElement icuData(xf, "feature", tmp, TRUE);
}
#endif
{
UErrorCode status = U_ZERO_ERROR;
UVersionInfo cldrVersion;
_getCLDRVersionDirect(cldrVersion, &status);
if(U_FAILURE(status)) {
UErrorCode subStatus = U_ZERO_ERROR;
_getCLDRVersionOld(cldrVersion, &subStatus);
if(U_SUCCESS(subStatus)) {
status = subStatus;
}
}
if(U_FAILURE(status)) {
fprintf(stderr, "Err: could not get CLDR Version, %s\n", u_errorName(status));
fflush(stderr);
} else {
strcpy(tmp, "type=\"cldr\" version=\"");
u_versionToString(cldrVersion, tmp+strlen(tmp));
strcat(tmp, "\"");
XMLElement icuData(xf, "feature", tmp, TRUE);
}
}
if(1) {
int n = uloc_countAvailable();
sprintf(tmp, "type=\"formatting\" total=\"%d\" version=\"%s\"",
n,
"???");
XMLElement icuData(xf, "feature", tmp);
// probeCapability(xf, "root");
for(int j=0;j<n;j++) {
probeCapability(xf, uloc_getAvailable(j));
}
}
if(1) {
int n = ucol_countAvailable();
sprintf(tmp, "type=\"collation\" total=\"%d\" version=\"%s\"",
n,
"???");
XMLElement icuData(xf, "feature", tmp);
// probeCapability(xf, "root");
for(int j=0;j<n;j++) {
probeColCapability(xf, ucol_getAvailable(j));
}
}
}
}
return 0;
}

View file

@ -0,0 +1,77 @@
// Copyright (C) 2008-2012 IBM Corporation and Others. All Rights Reserved.
#include <stdio.h>
#include "xmlout.h"
#include <unistd.h>
#include <stdlib.h>
XMLFile::XMLFile(FILE *f) {
file = f;
level = 0;
}
XMLFile::~XMLFile()
{
}
void XMLFile::write(const char *s) {
fputs(s, file);
}
void XMLFile::writeln(const char *s) {
writeIndent();
write(s);
write("\n");
}
int XMLFile::indent(const char *s, bool single) {
int oldLevel = level;
writeln(s);
level++;
if(single) {
level--;
}
return oldLevel;
}
int XMLFile::outdent(const char *s) {
level--;
writeln(s);
return level;
}
void XMLFile::writeIndent() {
for(int i=0;i<level;i++) {
write("\t");
}
}
XMLElement::XMLElement(XMLFile &f, const char *name, const char *attribs, bool single) : file(f), name(name), single(single) {
char outs[200];
if(attribs!=NULL) {
sprintf(outs,"<%s %s", name, attribs);
} else {
sprintf(outs, "<%s", name);
}
if(single) {
strcat(outs, "/>");
} else {
strcat(outs, ">");
}
oldlevel = file.indent(outs, single);
}
XMLElement::~XMLElement() {
if(!single) {
char outs[200];
sprintf(outs,"</%s>", name);
int newlevel = file.outdent(outs);
if(newlevel != oldlevel) {
fprintf(stderr, "@@@ ERROR: elemet %s popped out to level %d but expected %d. Abort.\n", name, newlevel, oldlevel);
fflush(stderr);
abort();
}
}
}

View file

@ -0,0 +1,47 @@
// Copyright (C) 2008-2012 IBM Corporation and Others. All Rights Reserved.
#include <stdio.h>
#include "unicode/utypes.h"
#include <string.h>
class XMLFile {
public:
XMLFile(FILE *f);
~XMLFile();
/**
* Write indent at current level, increment level, and then return what the initial level was
*/
int indent(const char *s, bool single = FALSE);
/**
* Decrement level, write indent of 'outer' level, and return what the new level is. Should match your earlier call to indent.
*/
int outdent(const char *s);
/**
* Write some string
*/
void writeln(const char *s);
private:
void writeIndent();
/**
* Write some string without indent. */
void write(const char *s);
int level;
FILE *file;
};
class XMLElement {
public:
XMLElement(XMLFile &f, const char *name, const char *attribs = NULL, bool single=FALSE);
~XMLElement();
const char *name;
int oldlevel;
XMLFile &file;
bool single;
};

View file

@ -0,0 +1,3 @@
# Copyright (C) 2008-2012 IBM Corporation and Others. All Rights Reserved.
s%<!--.*-->%%g
s%[ ][ ]*% %g

View file

@ -0,0 +1,3 @@
#!/bin/sh
# Copyright (C) 2008-2012 IBM Corporation and Others. All Rights Reserved.
sed -f zappit.sed | tr -s ' \012 ' ' '

View file

@ -0,0 +1,2 @@
# Copyright (C) 2012 IBM Corporation and Others. All Rights Reserved.
This project isn't used directly (except you can run it as an eclipse project for development). It's called from ../icu4cscan