[Pcre-svn] [1150] code/trunk: Fix byte order issue when the …

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [1150] code/trunk: Fix byte order issue when the result of badmode is shown .
Revision: 1150
          http://vcs.pcre.org/viewvc?view=rev&revision=1150
Author:   zherczeg
Date:     2012-10-21 07:35:52 +0100 (Sun, 21 Oct 2012)


Log Message:
-----------
Fix byte order issue when the result of badmode is shown.

Modified Paths:
--------------
    code/trunk/pcretest.c
    code/trunk/testdata/testoutput21-16
    code/trunk/testdata/testoutput21-32
    code/trunk/testdata/testoutput22-16
    code/trunk/testdata/testoutput22-32


Modified: code/trunk/pcretest.c
===================================================================
--- code/trunk/pcretest.c    2012-10-20 21:33:38 UTC (rev 1149)
+++ code/trunk/pcretest.c    2012-10-21 06:35:52 UTC (rev 1150)
@@ -3515,13 +3515,17 @@
       PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, NULL);
       if (rc == PCRE_ERROR_BADMODE)
         {
+        pcre_uint16 flags_in_host_byte_order;
+        if (REAL_PCRE_MAGIC(re) == MAGIC_NUMBER)
+          flags_in_host_byte_order = REAL_PCRE_FLAGS(re);
+        else
+          flags_in_host_byte_order = swap_uint16(REAL_PCRE_FLAGS(re));
         /* Simulate the result of the function call below. */
         fprintf(outfile, "Error %d from pcre%s_fullinfo(%d)\n", rc,
           pcre_mode == PCRE32_MODE ? "32" : pcre_mode == PCRE16_MODE ? "16" : "",
           PCRE_INFO_OPTIONS);
         fprintf(outfile, "Running in %d-bit mode but pattern was compiled in "
-          "%d-bit mode\n", 8 * CHAR_SIZE,
-          8 * (REAL_PCRE_FLAGS(re) & PCRE_MODE_MASK));
+          "%d-bit mode\n", 8 * CHAR_SIZE, 8 * (flags_in_host_byte_order & PCRE_MODE_MASK));
         new_free(re);
         fclose(f);
         continue;


Modified: code/trunk/testdata/testoutput21-16
===================================================================
--- code/trunk/testdata/testoutput21-16    2012-10-20 21:33:38 UTC (rev 1149)
+++ code/trunk/testdata/testoutput21-16    2012-10-21 06:35:52 UTC (rev 1150)
@@ -85,6 +85,6 @@
 Compiled pattern loaded from testsaved32BE-1
 Study data loaded from testsaved32BE-1
 Error -28 from pcre16_fullinfo(0)
-Running in 16-bit mode but pattern was compiled in 0-bit mode
+Running in 16-bit mode but pattern was compiled in 32-bit mode


/-- End of testinput21 --/

Modified: code/trunk/testdata/testoutput21-32
===================================================================
--- code/trunk/testdata/testoutput21-32    2012-10-20 21:33:38 UTC (rev 1149)
+++ code/trunk/testdata/testoutput21-32    2012-10-21 06:35:52 UTC (rev 1150)
@@ -19,7 +19,7 @@
 Compiled pattern loaded from testsaved16BE-1
 Study data loaded from testsaved16BE-1
 Error -28 from pcre32_fullinfo(0)
-Running in 32-bit mode but pattern was compiled in 0-bit mode
+Running in 32-bit mode but pattern was compiled in 16-bit mode


<!testsaved32LE-1
Compiled pattern loaded from testsaved32LE-1

Modified: code/trunk/testdata/testoutput22-16
===================================================================
--- code/trunk/testdata/testoutput22-16    2012-10-20 21:33:38 UTC (rev 1149)
+++ code/trunk/testdata/testoutput22-16    2012-10-21 06:35:52 UTC (rev 1150)
@@ -66,6 +66,6 @@
 Compiled pattern loaded from testsaved32BE-2
 Study data loaded from testsaved32BE-2
 Error -28 from pcre16_fullinfo(0)
-Running in 16-bit mode but pattern was compiled in 0-bit mode
+Running in 16-bit mode but pattern was compiled in 32-bit mode


/-- End of testinput22 --/

Modified: code/trunk/testdata/testoutput22-32
===================================================================
--- code/trunk/testdata/testoutput22-32    2012-10-20 21:33:38 UTC (rev 1149)
+++ code/trunk/testdata/testoutput22-32    2012-10-21 06:35:52 UTC (rev 1150)
@@ -12,7 +12,7 @@
 Compiled pattern loaded from testsaved16BE-2
 Study data loaded from testsaved16BE-2
 Error -28 from pcre32_fullinfo(0)
-Running in 32-bit mode but pattern was compiled in 0-bit mode
+Running in 32-bit mode but pattern was compiled in 16-bit mode


<!testsaved32LE-2
Compiled pattern loaded from testsaved32LE-2