/*
*******************************************************************************
*
- * Copyright (C) 2003-2007, International Business Machines
+ * Copyright (C) 2003-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
}
b1[b1Len++] = src[j];
}
- // step 2
- NamePrepTransform* prep = TestIDNA::getInstance(*status);
+ NamePrepTransform* prep = TestIDNA::getInstance(*status);
if(U_FAILURE(*status)){
goto CLEANUP;
}
- b1Len = prep->process(src,srcLength,b1, b1Capacity,allowUnassigned,parseError,*status);
+ // step 2 is performed only if the source contains non ASCII
+ if (!srcIsASCII) {
+ b1Len = prep->process(src,srcLength,b1, b1Capacity,allowUnassigned,parseError,*status);
- if(*status == U_BUFFER_OVERFLOW_ERROR){
- // redo processing of string
- /* we do not have enough room so grow the buffer*/
- b1 = (UChar*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
- if(b1==NULL){
- *status = U_MEMORY_ALLOCATION_ERROR;
- goto CLEANUP;
- }
+ if(*status == U_BUFFER_OVERFLOW_ERROR){
+ // redo processing of string
+ /* we do not have enough room so grow the buffer*/
+ b1 = (UChar*) uprv_malloc(b1Len * U_SIZEOF_UCHAR);
+ if(b1==NULL){
+ *status = U_MEMORY_ALLOCATION_ERROR;
+ goto CLEANUP;
+ }
- *status = U_ZERO_ERROR; // reset error
+ *status = U_ZERO_ERROR; // reset error
- b1Len = prep->process(src,srcLength,b1, b1Len,allowUnassigned, parseError, *status);
- }
- // error bail out
- if(U_FAILURE(*status)){
- goto CLEANUP;
+ b1Len = prep->process(src,srcLength,b1, b1Len,allowUnassigned, parseError, *status);
+ }
+ // error bail out
+ if(U_FAILURE(*status)){
+ goto CLEANUP;
+ }
}
if(b1Len == 0){
}
if(srcIsASCII){
if(b1Len <= destCapacity){
- uprv_memmove(dest, b1, b1Len * U_SIZEOF_UCHAR);
+ u_memmove(dest, b1, b1Len);
reqLength = b1Len;
}else{
reqLength = b1Len;
goto CLEANUP;
}
//Step 7: prepend the ACE prefix
- uprv_memcpy(dest,ACE_PREFIX,ACE_PREFIX_LENGTH * U_SIZEOF_UCHAR);
+ u_memcpy(dest, ACE_PREFIX, ACE_PREFIX_LENGTH);
//Step 6: copy the contents in b2 into dest
- uprv_memcpy(dest+ACE_PREFIX_LENGTH, b2, b2Len * U_SIZEOF_UCHAR);
+ u_memcpy(dest+ACE_PREFIX_LENGTH, b2, b2Len);
}else{
*status = U_IDNA_ACE_PREFIX_ERROR;
// copy everything to b1
if(srcLength < b1Capacity){
- uprv_memmove(b1,src, srcLength * U_SIZEOF_UCHAR);
+ u_memmove(b1, src, srcLength);
}else{
/* we do not have enough room so grow the buffer*/
b1 = (UChar*) uprv_malloc(srcLength * U_SIZEOF_UCHAR);
*status = U_MEMORY_ALLOCATION_ERROR;
goto CLEANUP;
}
- uprv_memmove(b1,src, srcLength * U_SIZEOF_UCHAR);
+ u_memmove(b1, src, srcLength);
}
b1Len = srcLength;
}
//step 8: return output of step 5
reqLength = b2Len;
if(b2Len <= destCapacity) {
- uprv_memmove(dest, b2, b2Len * U_SIZEOF_UCHAR);
+ u_memmove(dest, b2, b2Len);
}
}else{
// verify that STD3 ASCII rules are satisfied
}
//copy the source to destination
if(srcLength <= destCapacity){
- uprv_memmove(dest,src,srcLength * U_SIZEOF_UCHAR);
+ u_memmove(dest, src, srcLength);
}
reqLength = srcLength;
}
//copy the source to destination
if(dest && srcLength <= destCapacity){
if(srcLength == -1) {
- uprv_memmove(dest,src,u_strlen(src)* U_SIZEOF_UCHAR);
+ u_memmove(dest, src, u_strlen(src));
} else {
- uprv_memmove(dest,src,srcLength * U_SIZEOF_UCHAR);
+ u_memmove(dest, src, srcLength);
}
}
reqLength = srcLength;
int32_t tempLen = (reqLength + b1Len );
// copy to dest
if( tempLen< destCapacity){
- uprv_memmove(dest+reqLength, b1, b1Len * U_SIZEOF_UCHAR);
+ u_memmove(dest+reqLength, b1, b1Len);
}
reqLength = tempLen;
int32_t tempLen = (reqLength + b1Len );
// copy to dest
if( tempLen< destCapacity){
- uprv_memmove(dest+reqLength, b1, b1Len * U_SIZEOF_UCHAR);
+ u_memmove(dest+reqLength, b1, b1Len);
}
reqLength = tempLen;
int32_t tempLen = (reqLength + b1Len );
// copy to dest
if( tempLen< destCapacity){
- uprv_memmove(dest+reqLength, b1, b1Len * U_SIZEOF_UCHAR);
+ u_memmove(dest+reqLength, b1, b1Len);
}
reqLength = tempLen;
int32_t tempLen = (reqLength + b1Len );
// copy to dest
if( tempLen< destCapacity){
- uprv_memmove(dest+reqLength, b1, b1Len * U_SIZEOF_UCHAR);
+ u_memmove(dest+reqLength, b1, b1Len);
}
reqLength = tempLen;