]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/tools/toolutil/ppucd.cpp
ICU-57132.0.1.tar.gz
[apple/icu.git] / icuSources / tools / toolutil / ppucd.cpp
index c2a1b77d4b7dc5b1e6ff1269f2bb484244f3eaec..ed5229be786a600707be72fcd1f59cfdcbbeb6fa 100644 (file)
@@ -1,6 +1,6 @@
 /*
 *******************************************************************************
 /*
 *******************************************************************************
-*   Copyright (C) 2011-2012, International Business Machines
+*   Copyright (C) 2011-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *******************************************************************************
 *   file name:  ppucd.cpp
 *   Corporation and others.  All Rights Reserved.
 *******************************************************************************
 *   file name:  ppucd.cpp
@@ -23,8 +23,6 @@
 #include <stdio.h>
 #include <string.h>
 
 #include <stdio.h>
 #include <string.h>
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
 U_NAMESPACE_BEGIN
 
 PropertyNames::~PropertyNames() {}
 U_NAMESPACE_BEGIN
 
 PropertyNames::~PropertyNames() {}
@@ -41,7 +39,7 @@ PropertyNames::getPropertyValueEnum(int32_t property, const char *name) const {
 
 UniProps::UniProps()
         : start(U_SENTINEL), end(U_SENTINEL),
 
 UniProps::UniProps()
         : start(U_SENTINEL), end(U_SENTINEL),
-          bmg(U_SENTINEL),
+          bmg(U_SENTINEL), bpb(U_SENTINEL),
           scf(U_SENTINEL), slc(U_SENTINEL), stc(U_SENTINEL), suc(U_SENTINEL),
           digitValue(-1), numericValue(NULL),
           name(NULL), nameAlias(NULL) {
           scf(U_SENTINEL), slc(U_SENTINEL), stc(U_SENTINEL), suc(U_SENTINEL),
           digitValue(-1), numericValue(NULL),
           name(NULL), nameAlias(NULL) {
@@ -71,7 +69,7 @@ PreparsedUCD::PreparsedUCD(const char *filename, UErrorCode &errorCode)
     }
     if(file==NULL) {
         perror("error opening preparsed UCD");
     }
     if(file==NULL) {
         perror("error opening preparsed UCD");
-        fprintf(stderr, "error opening preparsed UCD file %s\n", filename);
+        fprintf(stderr, "error opening preparsed UCD file %s\n", filename ? filename : "\"no file name given\"");
         errorCode=U_FILE_ACCESS_ERROR;
         return;
     }
         errorCode=U_FILE_ACCESS_ERROR;
         return;
     }
@@ -298,7 +296,7 @@ PreparsedUCD::parseProperty(UniProps &props, const char *field, UnicodeSet &newV
     int32_t prop=pnames->getPropertyEnum(p);
     if(prop<0) {
         for(int32_t i=0;; ++i) {
     int32_t prop=pnames->getPropertyEnum(p);
     if(prop<0) {
         for(int32_t i=0;; ++i) {
-            if(i==LENGTHOF(ppucdProperties)) {
+            if(i==UPRV_LENGTHOF(ppucdProperties)) {
                 // Ignore unknown property names.
                 return TRUE;
             }
                 // Ignore unknown property names.
                 return TRUE;
             }
@@ -327,6 +325,11 @@ PreparsedUCD::parseProperty(UniProps &props, const char *field, UnicodeSet &newV
                 "for non-binary property on line %ld\n",
                 field, (long)lineNumber);
         errorCode=U_PARSE_ERROR;
                 "for non-binary property on line %ld\n",
                 field, (long)lineNumber);
         errorCode=U_PARSE_ERROR;
+    } else if (prop < UCHAR_INT_START) {
+        fprintf(stderr,
+                "error in preparsed UCD: prop value is invalid: '%d' for line %ld\n",
+                prop, (long)lineNumber);
+        errorCode=U_PARSE_ERROR;
     } else if(prop<UCHAR_INT_LIMIT) {
         int32_t value=pnames->getPropertyValueEnum(prop, v);
         if(value==UCHAR_INVALID_CODE && prop==UCHAR_CANONICAL_COMBINING_CLASS) {
     } else if(prop<UCHAR_INT_LIMIT) {
         int32_t value=pnames->getPropertyValueEnum(prop, v);
         if(value==UCHAR_INVALID_CODE && prop==UCHAR_CANONICAL_COMBINING_CLASS) {
@@ -351,6 +354,9 @@ PreparsedUCD::parseProperty(UniProps &props, const char *field, UnicodeSet &newV
         case UCHAR_BIDI_MIRRORING_GLYPH:
             props.bmg=U_SENTINEL;
             break;
         case UCHAR_BIDI_MIRRORING_GLYPH:
             props.bmg=U_SENTINEL;
             break;
+        case UCHAR_BIDI_PAIRED_BRACKET:
+            props.bpb=U_SENTINEL;
+            break;
         case UCHAR_SIMPLE_CASE_FOLDING:
             props.scf=U_SENTINEL;
             break;
         case UCHAR_SIMPLE_CASE_FOLDING:
             props.scf=U_SENTINEL;
             break;
@@ -405,6 +411,9 @@ PreparsedUCD::parseProperty(UniProps &props, const char *field, UnicodeSet &newV
         case UCHAR_BIDI_MIRRORING_GLYPH:
             props.bmg=parseCodePoint(v, errorCode);
             break;
         case UCHAR_BIDI_MIRRORING_GLYPH:
             props.bmg=parseCodePoint(v, errorCode);
             break;
+        case UCHAR_BIDI_PAIRED_BRACKET:
+            props.bpb=parseCodePoint(v, errorCode);
+            break;
         case UCHAR_SIMPLE_CASE_FOLDING:
             props.scf=parseCodePoint(v, errorCode);
             break;
         case UCHAR_SIMPLE_CASE_FOLDING:
             props.scf=parseCodePoint(v, errorCode);
             break;