[Pcre-svn] [735] code/trunk: Rewrite code that broke under M…

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [735] code/trunk: Rewrite code that broke under Mac OS ( isxdigit with ++ in its argument).
Revision: 735
          http://vcs.pcre.org/viewvc?view=rev&revision=735
Author:   ph10
Date:     2011-10-13 16:51:27 +0100 (Thu, 13 Oct 2011)


Log Message:
-----------
Rewrite code that broke under Mac OS (isxdigit with ++ in its argument).

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/pcretest.c


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2011-10-12 16:35:29 UTC (rev 734)
+++ code/trunk/ChangeLog    2011-10-13 15:51:27 UTC (rev 735)
@@ -107,6 +107,13 @@
 20. Fixed an ASCII-dependent infelicity in pcretest that would have made it
     fail to work when decoding hex characters in data strings in EBCDIC 
     environments. 
+    
+21. It appears that in at least one Mac OS environment, the isxdigit() function 
+    is implemented as a macro that evaluates to its argument more than once,
+    contravening the C 90 Standard (I haven't checked a later standard). There
+    was an instance in pcretest which caused it to go wrong when processing
+    \x{...} escapes in subject strings. The has been rewritten to avoid using 
+    things like p++ in the argument of isxdigit().



Version 8.13 16-Aug-2011

Modified: code/trunk/pcretest.c
===================================================================
--- code/trunk/pcretest.c    2011-10-12 16:35:29 UTC (rev 734)
+++ code/trunk/pcretest.c    2011-10-13 15:51:27 UTC (rev 735)
@@ -2346,7 +2346,13 @@
           {
           unsigned char *pt = p;
           c = 0;
-          while (isxdigit(*(++pt)))
+          
+          /* We used to have "while (isxdigit(*(++pt)))" here, but it fails
+          when isxdigit() is a macro that refers to its argument more than
+          once. This is banned by the C Standard, but apparently happens in at
+          least one MacOS environment. */
+          
+          for (pt++; isxdigit(*pt); pt++)
             c = c * 16 + tolower(*pt) - ((isdigit(*pt))? '0' : 'a' - 10);
           if (*pt == '}')
             {