#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
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);
++i; // '.' was copied to dest already
break;
}
- if(toASCII) {
- if(i==labelStart) {
- 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;
// 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;
}
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) {
if(isLabel) {
break; // Replacing with U+FFFD can be complicated for toASCII.
}
- if(toASCII) {
- if(i==labelStart) {
- 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;
}
// 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