ICU-7355 gennorm2: #if !U_HAVE_STD_STRING then UCONFIG_NO_NORMALIZATION=1 because the tool implementation uses STL string and vector

X-SVN-Rev: 27382
This commit is contained in:
Markus Scherer 2010-01-22 20:48:46 +00:00
parent 9639075dd6
commit 91a3e286ef
3 changed files with 25 additions and 14 deletions

View File

@ -17,17 +17,18 @@
* parses them, and builds a binary data file.
*/
#include "unicode/utypes.h"
#include "unicode/std_string.h" // U_HAVE_STD_STRING, #include <string>
#include "n2builder.h" // UCONFIG_NO_NORMALIZATION=1 if !U_HAVE_STD_STRING
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include "unicode/utypes.h"
#include "unicode/errorcode.h"
#include "unicode/localpointer.h"
#include "unicode/putil.h"
#include "unicode/uchar.h"
#include "unicode/unistr.h"
#include "n2builder.h"
#include "normalizer2impl.h"
#include "toolutil.h"
#include "uoptions.h"
@ -137,7 +138,7 @@ main(int argc, char* argv[]) {
builder->setUnicodeVersion(options[UNICODE_VERSION].value);
// prepare the filename beginning with the source dir
std::string filename(options[SOURCEDIR].value);
U_STD_NSQ string filename(options[SOURCEDIR].value);
int32_t pathLength=filename.length();
if( pathLength>0 &&
filename[pathLength-1]!=U_FILE_SEP_CHAR &&

View File

@ -17,13 +17,16 @@
* For the file format see source/common/normalizer2impl.h.
*/
#include "n2builder.h"
#include "unicode/utypes.h"
#include "unicode/std_string.h" // U_HAVE_STD_STRING, #include <string>
#include "n2builder.h" // UCONFIG_NO_NORMALIZATION=1 if !U_HAVE_STD_STRING
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if U_HAVE_STD_STRING
#include <vector>
#include "unicode/utypes.h"
#endif
#include "unicode/errorcode.h"
#include "unicode/localpointer.h"
#include "unicode/putil.h"
@ -113,7 +116,7 @@ struct Norm {
int32_t mappingPhase;
MappingType mappingType;
std::vector<CompositionPair> *compositions;
U_STD_NSQ vector<CompositionPair> *compositions;
uint8_t cc;
UBool combinesBack;
UBool hasNoCompBoundaryAfter;
@ -340,13 +343,13 @@ Normalizer2DataBuilder::addComposition(UChar32 start, UChar32 end, uint32_t valu
// Insert (trail, composite) pair into compositions list for the lead character.
CompositionPair pair(trail, start);
Norm *leadNorm=createNorm(lead);
std::vector<CompositionPair> *compositions=leadNorm->compositions;
U_STD_NSQ vector<CompositionPair> *compositions=leadNorm->compositions;
if(compositions==NULL) {
compositions=leadNorm->compositions=new std::vector<CompositionPair>;
compositions=leadNorm->compositions=new U_STD_NSQ vector<CompositionPair>;
compositions->push_back(pair);
} else {
// Insertion sort, and check for duplicate trail characters.
std::vector<CompositionPair>::iterator it;
U_STD_NSQ vector<CompositionPair>::iterator it;
for(it=compositions->begin(); it!=compositions->end(); ++it) {
if(trail==it->trail) {
fprintf(stderr,
@ -366,9 +369,9 @@ Normalizer2DataBuilder::addComposition(UChar32 start, UChar32 end, uint32_t valu
UBool Normalizer2DataBuilder::combinesWithCCBetween(const Norm &norm,
uint8_t lowCC, uint8_t highCC) const {
const std::vector<CompositionPair> *compositions=norm.compositions;
const U_STD_NSQ vector<CompositionPair> *compositions=norm.compositions;
if(compositions!=NULL && (highCC-lowCC)>=2) {
std::vector<CompositionPair>::const_iterator it;
U_STD_NSQ vector<CompositionPair>::const_iterator it;
for(it=compositions->begin(); it!=compositions->end(); ++it) {
uint8_t trailCC=getCC(it->trail);
if(lowCC<trailCC && trailCC<highCC) {
@ -380,9 +383,9 @@ UBool Normalizer2DataBuilder::combinesWithCCBetween(const Norm &norm,
}
UChar32 Normalizer2DataBuilder::combine(const Norm &norm, UChar32 trail) const {
const std::vector<CompositionPair> *compositions=norm.compositions;
const U_STD_NSQ vector<CompositionPair> *compositions=norm.compositions;
if(compositions!=NULL) {
std::vector<CompositionPair>::const_iterator it;
U_STD_NSQ vector<CompositionPair>::const_iterator it;
for(it=compositions->begin(); it!=compositions->end(); ++it) {
if(trail==it->trail) {
return it->composite;

View File

@ -18,6 +18,13 @@
#define __N2BUILDER_H__
#include "unicode/utypes.h"
#include "unicode/std_string.h"
#if !U_HAVE_STD_STRING
// The gennorm2 implementation uses STL classes like string and vector.
#undef UCONFIG_NO_NORMALIZATION
#define UCONFIG_NO_NORMALIZATION 1
#endif
#if !UCONFIG_NO_NORMALIZATION