]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/test/cintltst/nfsprep.c
ICU-66108.tar.gz
[apple/icu.git] / icuSources / test / cintltst / nfsprep.c
index fc7e2482daa264e511db67a4407bb0f4c17c13d9..43da0eda6e7c4b3513119d2215efb55d0eb07e04 100644 (file)
@@ -1,12 +1,14 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /*
  *******************************************************************************
  *
- *   Copyright (C) 2003, International Business Machines
+ *   Copyright (C) 2003-2014, International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *
  *******************************************************************************
  *   file name:  nfsprep.c
- *   encoding:   US-ASCII
+ *   encoding:   UTF-8
  *   tab size:   8 (not used)
  *   indentation:4
  *
@@ -21,8 +23,8 @@
 #include "nfsprep.h"
 #include "ustr_imp.h"
 #include "cintltst.h"
+#include "cmemory.h"
 
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
 #define NFS4_MAX_BUFFER_SIZE 1000
 #define PREFIX_SUFFIX_SEPARATOR 0x0040 /* '@' */
 
@@ -132,46 +134,6 @@ CLEANUP:
     return u_terminateChars(dest, destCapacity, reqLength, status);
 }
 
-static void
-syntaxError( const UChar* rules, 
-             int32_t pos,
-             int32_t rulesLen,
-             UParseError* parseError){
-    int32_t start, stop;
-    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 */
-    start = (pos <=U_PARSE_CONTEXT_LEN)? 0 : (pos - (U_PARSE_CONTEXT_LEN-1));
-    stop  = pos;
-    
-    u_memcpy(parseError->preContext,rules+start,stop-start);
-    /* null terminate the buffer */
-    parseError->preContext[stop-start] = 0;
-    
-    /* for post-context */
-    start = pos;
-    if(start<rulesLen) {
-        U16_FWD_1(rules, start, 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;
-    }
-    
-}
-
-
 /* sorted array for binary search*/
 static const char* special_prefixes[]={
     "\x0041\x004e\x004f\x004e\x0059\x004d\x004f\x0055\x0053",    
@@ -235,7 +197,7 @@ getPrefixSuffix(const char *src, int32_t srcLength,
     *prefixLen = i;
     *suffixLen = srcLength - i;
     /* special prefixes must not be followed by suffixes! */
-    if((findStringIndex(special_prefixes,LENGTHOF(special_prefixes), *prefix, *prefixLen-1) != -1) && (*suffix != NULL)){
+    if((findStringIndex(special_prefixes,UPRV_LENGTHOF(special_prefixes), *prefix, *prefixLen-1) != -1) && (*suffix != NULL)){
         *status = U_PARSE_ERROR;
         return;
     }