From f3fe03c6f53f8741b18164629ca7ea307fbe18f3 Mon Sep 17 00:00:00 2001 From: Alan Liu Date: Tue, 24 Feb 2004 05:26:03 +0000 Subject: [PATCH] ICU-2952 make idna conform to UParseError conventions X-SVN-Rev: 14569 --- icu4c/source/common/usprep.cpp | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/icu4c/source/common/usprep.cpp b/icu4c/source/common/usprep.cpp index e773584db4..aa8da72455 100644 --- a/icu4c/source/common/usprep.cpp +++ b/icu4c/source/common/usprep.cpp @@ -413,34 +413,28 @@ uprv_syntaxError(const UChar* rules, if(parseError == NULL){ return; } - if(pos == rulesLen && rulesLen >0){ - pos--; - } parseError->offset = pos; parseError->line = 0 ; // we are not using line numbers // for pre-context int32_t start = (pos <=U_PARSE_CONTEXT_LEN)? 0 : (pos - (U_PARSE_CONTEXT_LEN-1)); - int32_t stop = pos; + int32_t limit = pos; - u_memcpy(parseError->preContext,rules+start,stop-start); + u_memcpy(parseError->preContext,rules+start,limit-start); //null terminate the buffer - parseError->preContext[stop-start] = 0; + parseError->preContext[limit-start] = 0; - //for post-context + // for post-context; include error rules[pos] start = pos; - if(start rulesLen) { + limit = rulesLen; } - - stop = ((pos+U_PARSE_CONTEXT_LEN)<= rulesLen )? (pos+(U_PARSE_CONTEXT_LEN)) : - rulesLen; - if(start < stop){ - u_memcpy(parseError->postContext,rules+start,stop-start); - //null terminate the buffer - parseError->postContext[stop-start]= 0; + if (start < rulesLen) { + u_memcpy(parseError->postContext,rules+start,limit-start); } - + //null terminate the buffer + parseError->postContext[limit-start]= 0; }