Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1817)

Unified Diff: source/common/uts46.cpp

Issue 845603002: Update ICU to 54.1 step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: remove unusued directories Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/common/utrie2_builder.cpp ('k') | source/common/utypeinfo.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/common/uts46.cpp
diff --git a/source/common/uts46.cpp b/source/common/uts46.cpp
index 8e6c8ff1e7d1b1fc035770580b14392b0baf7d8e..80900a019b42f2c9b18f105d631951a3e48caf97 100644
--- a/source/common/uts46.cpp
+++ b/source/common/uts46.cpp
@@ -1,6 +1,6 @@
/*
*******************************************************************************
-* Copyright (C) 2010-2012, International Business Machines
+* Copyright (C) 2010-2014, International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
* file name: uts46.cpp
@@ -27,8 +27,6 @@
#include "ubidi_props.h"
#include "ustr_imp.h"
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
// Note about tests for UIDNA_ERROR_DOMAIN_NAME_TOO_LONG:
//
// The domain name length limit is 255 octets in an internal DNS representation
@@ -321,9 +319,7 @@ UTS46::process(const UnicodeString &src,
info.reset();
int32_t srcLength=src.length();
if(srcLength==0) {
- if(toASCII) {
- info.errors|=UIDNA_ERROR_EMPTY_LABEL;
- }
+ info.errors|=UIDNA_ERROR_EMPTY_LABEL;
return dest;
}
UChar *destArray=dest.getBuffer(srcLength);
@@ -381,13 +377,11 @@ UTS46::process(const UnicodeString &src,
++i; // '.' was copied to dest already
break;
}
- if(toASCII) {
- // Permit an empty label at the end but not elsewhere.
- if(i==labelStart && i<(srcLength-1)) {
- info.labelErrors|=UIDNA_ERROR_EMPTY_LABEL;
- } else if((i-labelStart)>63) {
- info.labelErrors|=UIDNA_ERROR_LABEL_TOO_LONG;
- }
+ if(i==labelStart) {
+ info.labelErrors|=UIDNA_ERROR_EMPTY_LABEL;
+ }
+ if(toASCII && (i-labelStart)>63) {
+ info.labelErrors|=UIDNA_ERROR_LABEL_TOO_LONG;
}
info.errors|=info.labelErrors;
info.labelErrors=0;
@@ -423,9 +417,7 @@ UTS46::processUTF8(const StringPiece &src,
// Arguments are fine, reset output values.
info.reset();
if(srcLength==0) {
- if(toASCII) {
- info.errors|=UIDNA_ERROR_EMPTY_LABEL;
- }
+ info.errors|=UIDNA_ERROR_EMPTY_LABEL;
dest.Flush();
return;
}
@@ -436,7 +428,7 @@ UTS46::processUTF8(const StringPiece &src,
char stackArray[256];
int32_t destCapacity;
char *destArray=dest.GetAppendBuffer(srcLength, srcLength+20,
- stackArray, LENGTHOF(stackArray), &destCapacity);
+ stackArray, UPRV_LENGTHOF(stackArray), &destCapacity);
UBool disallowNonLDHDot=(options&UIDNA_USE_STD3_RULES)!=0;
int32_t i;
for(i=0;; ++i) {
@@ -483,13 +475,11 @@ UTS46::processUTF8(const StringPiece &src,
if(isLabel) {
break; // Replacing with U+FFFD can be complicated for toASCII.
}
- if(toASCII) {
- // Permit an empty label at the end but not elsewhere.
- if(i==labelStart && i<(srcLength-1)) {
- info.labelErrors|=UIDNA_ERROR_EMPTY_LABEL;
- } else if((i-labelStart)>63) {
- info.labelErrors|=UIDNA_ERROR_LABEL_TOO_LONG;
- }
+ if(i==labelStart) {
+ info.labelErrors|=UIDNA_ERROR_EMPTY_LABEL;
+ }
+ if(toASCII && (i-labelStart)>63) {
+ info.labelErrors|=UIDNA_ERROR_LABEL_TOO_LONG;
}
info.errors|=info.labelErrors;
info.labelErrors=0;
@@ -748,9 +738,7 @@ UTS46::processLabel(UnicodeString &dest,
}
// Validity check
if(labelLength==0) {
- if(toASCII) {
- info.labelErrors|=UIDNA_ERROR_EMPTY_LABEL;
- }
+ info.labelErrors|=UIDNA_ERROR_EMPTY_LABEL;
return replaceLabel(dest, destLabelStart, destLabelLength, *labelString, labelLength);
}
// labelLength>0
« no previous file with comments | « source/common/utrie2_builder.cpp ('k') | source/common/utypeinfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698