Update __parse_DUP_COUNT and __parse_BACKREF to use the traits class to recognize digits. Fixes PR18514

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@199541 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/regex b/include/regex
index b7416f8..8c95145 100644
--- a/include/regex
+++ b/include/regex
@@ -3310,10 +3310,14 @@
         _ForwardIterator __temp = _VSTD::next(__first);
         if (__temp != __last)
         {
-            if (*__first == '\\' && '1' <= *__temp && *__temp <= '9')
-            {
-                __push_back_ref(*__temp - '0');
-                __first = ++__temp;
+            if (*__first == '\\')
+            { 
+                int __val = __traits_.value(*__temp, 10);
+                if (__val >= 1 && __val <= 9)
+                {
+                    __push_back_ref(__val);
+                    __first = ++__temp;
+                }
             }
         }
     }
@@ -4052,14 +4056,19 @@
                                                 _ForwardIterator __last,
                                                 int& __c)
 {
-    if (__first != __last && '0' <= *__first && *__first <= '9')
+    if (__first != __last )
     {
-        __c = *__first - '0';
-        for (++__first; __first != __last && '0' <= *__first && *__first <= '9';
-                                                                      ++__first)
+        int __val = __traits_.value(*__first, 10);
+        if ( __val != -1 )
         {
-            __c *= 10;
-            __c += *__first - '0';
+            __c = __val;
+            for (++__first; 
+                 __first != __last && ( __val = __traits_.value(*__first, 10)) != -1;
+                 ++__first)
+            {
+                __c *= 10;
+                __c += __val;
+            }
         }
     }
     return __first;