From 52202b9b9efd412e4ce60dad17fa4fb5f0449091 Mon Sep 17 00:00:00 2001 From: Ram Viswanadha Date: Wed, 3 Dec 2003 23:36:31 +0000 Subject: [PATCH] ICU-2962 convert ASCII strings to their hex equivalent X-SVN-Rev: 13982 --- icu4c/source/test/cintltst/nfsprep.c | 64 ++++++++++++++-------------- icu4c/source/test/cintltst/nfsprep.h | 1 + 2 files changed, 33 insertions(+), 32 deletions(-) diff --git a/icu4c/source/test/cintltst/nfsprep.c b/icu4c/source/test/cintltst/nfsprep.c index 7069b6eaf8f..993e3a4f54c 100644 --- a/icu4c/source/test/cintltst/nfsprep.c +++ b/icu4c/source/test/cintltst/nfsprep.c @@ -169,43 +169,43 @@ syntaxError( const UChar* rules, } - /* sorted array for binary search*/ - static const char* special_prefixes[]={ - "ANONYMOUS", - "AUTHENTICATED", - "BATCH", - "DIALUP", - "EVERYONE", - "GROUP", - "INTERACTIVE", - "NETWORK", - "OWNER", - }; +/* sorted array for binary search*/ +static const char* special_prefixes[]={ + "\x0041\x004e\x004f\x004e\x0059\x004d\x004f\x0055\x0053", + "\x0041\x0055\x0054\x0048\x0045\x004e\x0054\x0049\x0043\x0041\x0054\x0045\x0044", + "\x0042\x0041\x0054\x0043\x0048", + "\x0044\x0049\x0041\x004c\x0055\x0050", + "\x0045\x0056\x0045\x0052\x0059\x004f\x004e\x0045", + "\x0047\x0052\x004f\x0055\x0050", + "\x0049\x004e\x0054\x0045\x0052\x0041\x0043\x0054\x0049\x0056\x0045", + "\x004e\x0045\x0054\x0057\x004f\x0052\x004b", + "\x004f\x0057\x004e\x0045\x0052", +}; - /* binary search the sorted array */ - static int - findStringIndex(const char* const *sortedArr, int32_t sortedArrLen, const char* target, int32_t targetLen){ +/* binary search the sorted array */ +static int +findStringIndex(const char* const *sortedArr, int32_t sortedArrLen, const char* target, int32_t targetLen){ - int left, middle, right,rc; + int left, middle, right,rc; - left =0; - right= sortedArrLen-1; + left =0; + right= sortedArrLen-1; - while(left <= right){ - middle = (left+right)/2; - rc=strncmp(sortedArr[middle],target, targetLen); - - if(rc<0){ - left = middle+1; - }else if(rc >0){ - right = middle -1; - }else{ - return middle; - } + while(left <= right){ + middle = (left+right)/2; + rc=strncmp(sortedArr[middle],target, targetLen); + + if(rc<0){ + left = middle+1; + }else if(rc >0){ + right = middle -1; + }else{ + return middle; } - return -1; } + return -1; +} static void getPrefixSuffix(const char *src, int32_t srcLength, @@ -238,7 +238,7 @@ getPrefixSuffix(const char *src, int32_t srcLength, } } -#define AT_SIGN 0x0040 + int32_t nfs4_mixed_prepare( const char* src, int32_t srcLength, char* dest, int32_t destCapacity, @@ -297,7 +297,7 @@ nfs4_mixed_prepare( const char* src, int32_t srcLength, memmove(dest, p, pLen); /* add the suffix */ if(suffix!=NULL){ - dest[pLen++] = AT_SIGN; + dest[pLen++] = PREFIX_SUFFIX_SEPARATOR; memmove(dest+pLen, s, sLen); } } diff --git a/icu4c/source/test/cintltst/nfsprep.h b/icu4c/source/test/cintltst/nfsprep.h index adb5c6aceb2..af1263949b6 100644 --- a/icu4c/source/test/cintltst/nfsprep.h +++ b/icu4c/source/test/cintltst/nfsprep.h @@ -25,6 +25,7 @@ #include +/* this enum must be kept in syn with NFS4DataFileNames array in nfsprep.c */ enum NFS4ProfileState{ NFS4_CS_PREP_CS, NFS4_CS_PREP_CI,