Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / icu / source / common / ucnvsel.cpp
index cc626ee..e0e8699 100644 (file)
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 2008-2009, International Business Machines
+*   Copyright (C) 2008-2011, International Business Machines
 *   Corporation, Google and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -26,6 +26,8 @@
 
 #include "unicode/ucnvsel.h"
 
+#if !UCONFIG_NO_CONVERSION
+
 #include <string.h>
 
 #include "unicode/uchar.h"
@@ -755,19 +757,21 @@ ucnvsel_selectForString(const UConverterSelector* sel,
   }
   uprv_memset(mask, ~0, columns *4);
 
-  const UChar *limit;
-  if (length >= 0) {
-    limit = s + length;
-  } else {
-    limit = NULL;
-  }
-
-  while (limit == NULL ? *s != 0 : s != limit) {
-    UChar32 c;
-    uint16_t pvIndex;
-    UTRIE2_U16_NEXT16(sel->trie, s, limit, c, pvIndex);
-    if (intersectMasks(mask, sel->pv+pvIndex, columns)) {
-      break;
+  if(s!=NULL) {
+    const UChar *limit;
+    if (length >= 0) {
+      limit = s + length;
+    } else {
+      limit = NULL;
+    }
+    
+    while (limit == NULL ? *s != 0 : s != limit) {
+      UChar32 c;
+      uint16_t pvIndex;
+      UTRIE2_U16_NEXT16(sel->trie, s, limit, c, pvIndex);
+      if (intersectMasks(mask, sel->pv+pvIndex, columns)) {
+        break;
+      }
     }
   }
   return selectForMask(sel, mask, status);
@@ -798,14 +802,19 @@ ucnvsel_selectForUTF8(const UConverterSelector* sel,
   if (length < 0) {
     length = (int32_t)uprv_strlen(s);
   }
-  const char *limit = s + length;
 
-  while (s != limit) {
-    uint16_t pvIndex;
-    UTRIE2_U8_NEXT16(sel->trie, s, limit, pvIndex);
-    if (intersectMasks(mask, sel->pv+pvIndex, columns)) {
-      break;
+  if(s!=NULL) {
+    const char *limit = s + length;
+    
+    while (s != limit) {
+      uint16_t pvIndex;
+      UTRIE2_U8_NEXT16(sel->trie, s, limit, pvIndex);
+      if (intersectMasks(mask, sel->pv+pvIndex, columns)) {
+        break;
+      }
     }
   }
   return selectForMask(sel, mask, status);
 }
+
+#endif  // !UCONFIG_NO_CONVERSION