/[pcre]/code/trunk/pcretest.c
ViewVC logotype

Diff of /code/trunk/pcretest.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1121 by chpe, Tue Oct 16 15:57:31 2012 UTC revision 1122 by ph10, Wed Oct 17 17:31:19 2012 UTC
# Line 484  argument, the casting might be incorrect Line 484  argument, the casting might be incorrect
484  #endif /* SUPPORT_PCRE32 */  #endif /* SUPPORT_PCRE32 */
485    
486    
487  /* ----- Both modes are supported; a runtime test is needed, except for  /* ----- More than one mode is supported; a runtime test is needed, except for
488  pcre_config(), and the JIT stack functions, when it doesn't matter which  pcre_config(), and the JIT stack functions, when it doesn't matter which
489  version is called. ----- */  version is called. ----- */
490    
# Line 494  enum { Line 494  enum {
494    PCRE32_MODE    PCRE32_MODE
495  };  };
496    
497  #if (defined (SUPPORT_PCRE8) + defined (SUPPORT_PCRE16) + defined (SUPPORT_PCRE32)) >= 2  #if (defined (SUPPORT_PCRE8) + defined (SUPPORT_PCRE16) + \
498         defined (SUPPORT_PCRE32)) >= 2
499    
500  #define CHAR_SIZE (1 << pcre_mode)  #define CHAR_SIZE (1 << pcre_mode)
501    
502    /* There doesn't seem to be an easy way of writing these macros that can cope
503    with the 3 pairs of bit sizes plus all three bit sizes. So just handle all the
504    cases separately. */
505    
506    /* ----- All three modes supported ----- */
507    
508    #if defined(SUPPORT_PCRE8) && defined(SUPPORT_PCRE16) && defined(SUPPORT_PCRE32)
509    
510  #define PCHARS(lv, p, offset, len, f) \  #define PCHARS(lv, p, offset, len, f) \
511    if (pcre_mode == PCRE32_MODE) \    if (pcre_mode == PCRE32_MODE) \
512      PCHARS32(lv, p, offset, len, f); \      PCHARS32(lv, p, offset, len, f); \
# Line 696  enum { Line 705  enum {
705    else \    else \
706      PCRE_STUDY8(extra, re, options, error)      PCRE_STUDY8(extra, re, options, error)
707    
708    
709    /* ----- 32-bit and 16-bit but not 8-bit supported ----- */
710    
711    #elif defined(SUPPORT_PCRE32) && defined(SUPPORT_PCRE16)
712    #define PCHARS(lv, p, offset, len, f) \
713      if (pcre_mode == PCRE32_MODE) \
714        PCHARS32(lv, p, offset, len, f); \
715      else \
716        PCHARS16(lv, p, offset, len, f)
717    
718    #define PCHARSV(p, offset, len, f) \
719      if (pcre_mode == PCRE32_MODE) \
720        PCHARSV32(p, offset, len, f); \
721      else \
722        PCHARSV16(p, offset, len, f)
723    
724    #define READ_CAPTURE_NAME(p, cn8, cn16, cn32, re) \
725      if (pcre_mode == PCRE32_MODE) \
726        READ_CAPTURE_NAME32(p, cn8, cn16, cn32, re); \
727      else \
728        READ_CAPTURE_NAME16(p, cn8, cn16, cn32, re)
729    
730    #define SET_PCRE_CALLOUT(callout) \
731      if (pcre_mode == PCRE32_MODE) \
732        SET_PCRE_CALLOUT32(callout); \
733      else \
734        SET_PCRE_CALLOUT16(callout)
735    
736    #define STRLEN(p) (pcre_mode == PCRE32_MODE ? STRLEN32(p) : STRLEN16(p)
737    
738    #define PCRE_ASSIGN_JIT_STACK(extra, callback, userdata) \
739      if (pcre_mode == PCRE32_MODE) \
740        PCRE_ASSIGN_JIT_STACK32(extra, callback, userdata); \
741      else \
742        PCRE_ASSIGN_JIT_STACK16(extra, callback, userdata)
743    
744    #define PCRE_COMPILE(re, pat, options, error, erroffset, tables) \
745      if (pcre_mode == PCRE32_MODE) \
746        PCRE_COMPILE32(re, pat, options, error, erroffset, tables); \
747      else \
748        PCRE_COMPILE16(re, pat, options, error, erroffset, tables)
749    
750    #define PCRE_CONFIG pcre_config
751    
752    #define PCRE_COPY_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \
753        namesptr, cbuffer, size) \
754      if (pcre_mode == PCRE32_MODE) \
755        PCRE_COPY_NAMED_SUBSTRING32(rc, re, bptr, offsets, count, \
756          namesptr, cbuffer, size); \
757      else \
758        PCRE_COPY_NAMED_SUBSTRING16(rc, re, bptr, offsets, count, \
759          namesptr, cbuffer, size)
760    
761    #define PCRE_COPY_SUBSTRING(rc, bptr, offsets, count, i, cbuffer, size) \
762      if (pcre_mode == PCRE32_MODE) \
763        PCRE_COPY_SUBSTRING32(rc, bptr, offsets, count, i, cbuffer, size); \
764      else \
765        PCRE_COPY_SUBSTRING16(rc, bptr, offsets, count, i, cbuffer, size)
766    
767    #define PCRE_DFA_EXEC(count, re, extra, bptr, len, start_offset, options, \
768        offsets, size_offsets, workspace, size_workspace) \
769      if (pcre_mode == PCRE32_MODE) \
770        PCRE_DFA_EXEC32(count, re, extra, bptr, len, start_offset, options, \
771          offsets, size_offsets, workspace, size_workspace); \
772      else \
773        PCRE_DFA_EXEC16(count, re, extra, bptr, len, start_offset, options, \
774          offsets, size_offsets, workspace, size_workspace)
775    
776    #define PCRE_EXEC(count, re, extra, bptr, len, start_offset, options, \
777        offsets, size_offsets) \
778      if (pcre_mode == PCRE32_MODE) \
779        PCRE_EXEC32(count, re, extra, bptr, len, start_offset, options, \
780          offsets, size_offsets); \
781      else \
782        PCRE_EXEC16(count, re, extra, bptr, len, start_offset, options, \
783          offsets, size_offsets)
784    
785    #define PCRE_FREE_STUDY(extra) \
786      if (pcre_mode == PCRE32_MODE) \
787        PCRE_FREE_STUDY32(extra); \
788      else \
789        PCRE_FREE_STUDY16(extra)
790    
791    #define PCRE_FREE_SUBSTRING(substring) \
792      if (pcre_mode == PCRE32_MODE) \
793        PCRE_FREE_SUBSTRING32(substring); \
794      else \
795        PCRE_FREE_SUBSTRING16(substring)
796    
797    #define PCRE_FREE_SUBSTRING_LIST(listptr) \
798      if (pcre_mode == PCRE32_MODE) \
799        PCRE_FREE_SUBSTRING_LIST32(listptr); \
800      else \
801        PCRE_FREE_SUBSTRING_LIST16(listptr)
802    
803    #define PCRE_GET_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \
804        getnamesptr, subsptr) \
805      if (pcre_mode == PCRE32_MODE) \
806        PCRE_GET_NAMED_SUBSTRING32(rc, re, bptr, offsets, count, \
807          getnamesptr, subsptr); \
808      else \
809        PCRE_GET_NAMED_SUBSTRING16(rc, re, bptr, offsets, count, \
810          getnamesptr, subsptr)
811    
812    #define PCRE_GET_STRINGNUMBER(n, rc, ptr) \
813      if (pcre_mode == PCRE32_MODE) \
814        PCRE_GET_STRINGNUMBER32(n, rc, ptr); \
815      else \
816        PCRE_GET_STRINGNUMBER16(n, rc, ptr)
817    
818    #define PCRE_GET_SUBSTRING(rc, bptr, use_offsets, count, i, subsptr) \
819      if (pcre_mode == PCRE32_MODE) \
820        PCRE_GET_SUBSTRING32(rc, bptr, use_offsets, count, i, subsptr); \
821      else \
822        PCRE_GET_SUBSTRING16(rc, bptr, use_offsets, count, i, subsptr)
823    
824    #define PCRE_GET_SUBSTRING_LIST(rc, bptr, offsets, count, listptr) \
825      if (pcre_mode == PCRE32_MODE) \
826        PCRE_GET_SUBSTRING_LIST32(rc, bptr, offsets, count, listptr); \
827      else \
828        PCRE_GET_SUBSTRING_LIST16(rc, bptr, offsets, count, listptr)
829    
830    #define PCRE_JIT_STACK_ALLOC(startsize, maxsize) \
831      (pcre_mode == PCRE32_MODE ? \
832         PCRE_JIT_STACK_ALLOC32(startsize, maxsize) \
833        : PCRE_JIT_STACK_ALLOC16(startsize, maxsize)
834    
835    #define PCRE_JIT_STACK_FREE(stack) \
836      if (pcre_mode == PCRE32_MODE) \
837        PCRE_JIT_STACK_FREE32(stack); \
838      else \
839        PCRE_JIT_STACK_FREE16(stack)
840    
841    #define PCRE_MAKETABLES \
842      (pcre_mode == PCRE32_MODE ? pcre32_maketables() : pcre16_maketables())
843    
844    #define PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, tables) \
845      if (pcre_mode == PCRE32_MODE) \
846        PCRE_PATTERN_TO_HOST_BYTE_ORDER32(rc, re, extra, tables); \
847      else \
848        PCRE_PATTERN_TO_HOST_BYTE_ORDER16(rc, re, extra, tables)
849    
850    #define PCRE_PRINTINT(re, outfile, debug_lengths) \
851      if (pcre_mode == PCRE32_MODE) \
852        PCRE_PRINTINT32(re, outfile, debug_lengths); \
853      else \
854        PCRE_PRINTINT16(re, outfile, debug_lengths)
855    
856    #define PCRE_STUDY(extra, re, options, error) \
857      if (pcre_mode == PCRE32_MODE) \
858        PCRE_STUDY32(extra, re, options, error); \
859      else \
860        PCRE_STUDY16(extra, re, options, error)
861    
862    
863    /* ----- 32-bit and 8-bit but not 16-bit supported ----- */
864    
865    #elif defined(SUPPORT_PCRE32) && defined(SUPPORT_PCRE8)
866    
867    #define PCHARS(lv, p, offset, len, f) \
868      if (pcre_mode == PCRE32_MODE) \
869        PCHARS32(lv, p, offset, len, f); \
870      else \
871        PCHARS8(lv, p, offset, len, f)
872    
873    #define PCHARSV(p, offset, len, f) \
874      if (pcre_mode == PCRE32_MODE) \
875        PCHARSV32(p, offset, len, f); \
876      else \
877        PCHARSV8(p, offset, len, f)
878    
879    #define READ_CAPTURE_NAME(p, cn8, cn16, cn32, re) \
880      if (pcre_mode == PCRE32_MODE) \
881        READ_CAPTURE_NAME32(p, cn8, cn16, cn32, re); \
882      else \
883        READ_CAPTURE_NAME8(p, cn8, cn16, cn32, re)
884    
885    #define SET_PCRE_CALLOUT(callout) \
886      if (pcre_mode == PCRE32_MODE) \
887        SET_PCRE_CALLOUT32(callout); \
888      else \
889        SET_PCRE_CALLOUT8(callout)
890    
891    #define STRLEN(p) (pcre_mode == PCRE32_MODE ? STRLEN32(p) : STRLEN8(p))
892    
893    #define PCRE_ASSIGN_JIT_STACK(extra, callback, userdata) \
894      if (pcre_mode == PCRE32_MODE) \
895        PCRE_ASSIGN_JIT_STACK32(extra, callback, userdata); \
896      else \
897        PCRE_ASSIGN_JIT_STACK8(extra, callback, userdata)
898    
899    #define PCRE_COMPILE(re, pat, options, error, erroffset, tables) \
900      if (pcre_mode == PCRE32_MODE) \
901        PCRE_COMPILE32(re, pat, options, error, erroffset, tables); \
902      else \
903        PCRE_COMPILE8(re, pat, options, error, erroffset, tables)
904    
905    #define PCRE_CONFIG pcre_config
906    
907    #define PCRE_COPY_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \
908        namesptr, cbuffer, size) \
909      if (pcre_mode == PCRE32_MODE) \
910        PCRE_COPY_NAMED_SUBSTRING32(rc, re, bptr, offsets, count, \
911          namesptr, cbuffer, size); \
912      else \
913        PCRE_COPY_NAMED_SUBSTRING8(rc, re, bptr, offsets, count, \
914          namesptr, cbuffer, size)
915    
916    #define PCRE_COPY_SUBSTRING(rc, bptr, offsets, count, i, cbuffer, size) \
917      if (pcre_mode == PCRE32_MODE) \
918        PCRE_COPY_SUBSTRING32(rc, bptr, offsets, count, i, cbuffer, size); \
919      else \
920        PCRE_COPY_SUBSTRING8(rc, bptr, offsets, count, i, cbuffer, size)
921    
922    #define PCRE_DFA_EXEC(count, re, extra, bptr, len, start_offset, options, \
923        offsets, size_offsets, workspace, size_workspace) \
924      if (pcre_mode == PCRE32_MODE) \
925        PCRE_DFA_EXEC32(count, re, extra, bptr, len, start_offset, options, \
926          offsets, size_offsets, workspace, size_workspace); \
927      else \
928        PCRE_DFA_EXEC8(count, re, extra, bptr, len, start_offset, options, \
929          offsets, size_offsets, workspace, size_workspace)
930    
931    #define PCRE_EXEC(count, re, extra, bptr, len, start_offset, options, \
932        offsets, size_offsets) \
933      if (pcre_mode == PCRE32_MODE) \
934        PCRE_EXEC32(count, re, extra, bptr, len, start_offset, options, \
935          offsets, size_offsets); \
936      else \
937        PCRE_EXEC8(count, re, extra, bptr, len, start_offset, options, \
938          offsets, size_offsets)
939    
940    #define PCRE_FREE_STUDY(extra) \
941      if (pcre_mode == PCRE32_MODE) \
942        PCRE_FREE_STUDY32(extra); \
943      else \
944        PCRE_FREE_STUDY8(extra)
945    
946    #define PCRE_FREE_SUBSTRING(substring) \
947      if (pcre_mode == PCRE32_MODE) \
948        PCRE_FREE_SUBSTRING32(substring); \
949      else \
950        PCRE_FREE_SUBSTRING8(substring)
951    
952    #define PCRE_FREE_SUBSTRING_LIST(listptr) \
953      if (pcre_mode == PCRE32_MODE) \
954        PCRE_FREE_SUBSTRING_LIST32(listptr); \
955      else \
956        PCRE_FREE_SUBSTRING_LIST8(listptr)
957    
958    #define PCRE_GET_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \
959        getnamesptr, subsptr) \
960      if (pcre_mode == PCRE32_MODE) \
961        PCRE_GET_NAMED_SUBSTRING32(rc, re, bptr, offsets, count, \
962          getnamesptr, subsptr); \
963      else \
964        PCRE_GET_NAMED_SUBSTRING8(rc, re, bptr, offsets, count, \
965          getnamesptr, subsptr)
966    
967    #define PCRE_GET_STRINGNUMBER(n, rc, ptr) \
968      if (pcre_mode == PCRE32_MODE) \
969        PCRE_GET_STRINGNUMBER32(n, rc, ptr); \
970      else \
971        PCRE_GET_STRINGNUMBER8(n, rc, ptr)
972    
973    #define PCRE_GET_SUBSTRING(rc, bptr, use_offsets, count, i, subsptr) \
974      if (pcre_mode == PCRE32_MODE) \
975        PCRE_GET_SUBSTRING32(rc, bptr, use_offsets, count, i, subsptr); \
976      else \
977        PCRE_GET_SUBSTRING8(rc, bptr, use_offsets, count, i, subsptr)
978    
979    #define PCRE_GET_SUBSTRING_LIST(rc, bptr, offsets, count, listptr) \
980      if (pcre_mode == PCRE32_MODE) \
981        PCRE_GET_SUBSTRING_LIST32(rc, bptr, offsets, count, listptr); \
982      else \
983        PCRE_GET_SUBSTRING_LIST8(rc, bptr, offsets, count, listptr)
984    
985    #define PCRE_JIT_STACK_ALLOC(startsize, maxsize) \
986      (pcre_mode == PCRE32_MODE ? \
987         PCRE_JIT_STACK_ALLOC32(startsize, maxsize) \
988          : PCRE_JIT_STACK_ALLOC8(startsize, maxsize))
989    
990    #define PCRE_JIT_STACK_FREE(stack) \
991      if (pcre_mode == PCRE32_MODE) \
992        PCRE_JIT_STACK_FREE32(stack); \
993      else \
994        PCRE_JIT_STACK_FREE8(stack)
995    
996    #define PCRE_MAKETABLES \
997      (pcre_mode == PCRE32_MODE ? pcre32_maketables() : pcre_maketables())
998    
999    #define PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, tables) \
1000      if (pcre_mode == PCRE32_MODE) \
1001        PCRE_PATTERN_TO_HOST_BYTE_ORDER32(rc, re, extra, tables); \
1002      else \
1003        PCRE_PATTERN_TO_HOST_BYTE_ORDER8(rc, re, extra, tables)
1004    
1005    #define PCRE_PRINTINT(re, outfile, debug_lengths) \
1006      if (pcre_mode == PCRE32_MODE) \
1007        PCRE_PRINTINT32(re, outfile, debug_lengths); \
1008      else \
1009        PCRE_PRINTINT8(re, outfile, debug_lengths)
1010    
1011    #define PCRE_STUDY(extra, re, options, error) \
1012      if (pcre_mode == PCRE32_MODE) \
1013        PCRE_STUDY32(extra, re, options, error); \
1014      else \
1015        PCRE_STUDY8(extra, re, options, error)
1016    
1017    
1018    /* ----- 16-bit and 8-bit but not 32-bit supported ----- */
1019    
1020    #else
1021    #define PCHARS(lv, p, offset, len, f) \
1022      if (pcre_mode == PCRE16_MODE) \
1023        PCHARS16(lv, p, offset, len, f); \
1024      else \
1025        PCHARS8(lv, p, offset, len, f)
1026    
1027    #define PCHARSV(p, offset, len, f) \
1028      if (pcre_mode == PCRE16_MODE) \
1029        PCHARSV16(p, offset, len, f); \
1030      else \
1031        PCHARSV8(p, offset, len, f)
1032    
1033    #define READ_CAPTURE_NAME(p, cn8, cn16, cn32, re) \
1034      if (pcre_mode == PCRE16_MODE) \
1035        READ_CAPTURE_NAME16(p, cn8, cn16, cn32, re); \
1036      else \
1037        READ_CAPTURE_NAME8(p, cn8, cn16, cn32, re)
1038    
1039    #define SET_PCRE_CALLOUT(callout) \
1040      if (pcre_mode == PCRE16_MODE) \
1041        SET_PCRE_CALLOUT16(callout); \
1042      else \
1043        SET_PCRE_CALLOUT8(callout)
1044    
1045    #define STRLEN(p) (pcre_mode == PCRE16_MODE ? STRLEN16(p) : STRLEN8(p))
1046    
1047    #define PCRE_ASSIGN_JIT_STACK(extra, callback, userdata) \
1048      if (pcre_mode == PCRE16_MODE) \
1049        PCRE_ASSIGN_JIT_STACK16(extra, callback, userdata); \
1050      else \
1051        PCRE_ASSIGN_JIT_STACK8(extra, callback, userdata)
1052    
1053    #define PCRE_COMPILE(re, pat, options, error, erroffset, tables) \
1054      if (pcre_mode == PCRE16_MODE) \
1055        PCRE_COMPILE16(re, pat, options, error, erroffset, tables); \
1056      else \
1057        PCRE_COMPILE8(re, pat, options, error, erroffset, tables)
1058    
1059    #define PCRE_CONFIG pcre_config
1060    
1061    #define PCRE_COPY_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \
1062        namesptr, cbuffer, size) \
1063      if (pcre_mode == PCRE16_MODE) \
1064        PCRE_COPY_NAMED_SUBSTRING16(rc, re, bptr, offsets, count, \
1065          namesptr, cbuffer, size); \
1066      else \
1067        PCRE_COPY_NAMED_SUBSTRING8(rc, re, bptr, offsets, count, \
1068          namesptr, cbuffer, size)
1069    
1070    #define PCRE_COPY_SUBSTRING(rc, bptr, offsets, count, i, cbuffer, size) \
1071      if (pcre_mode == PCRE16_MODE) \
1072        PCRE_COPY_SUBSTRING16(rc, bptr, offsets, count, i, cbuffer, size); \
1073      else \
1074        PCRE_COPY_SUBSTRING8(rc, bptr, offsets, count, i, cbuffer, size)
1075    
1076    #define PCRE_DFA_EXEC(count, re, extra, bptr, len, start_offset, options, \
1077        offsets, size_offsets, workspace, size_workspace) \
1078      if (pcre_mode == PCRE16_MODE) \
1079        PCRE_DFA_EXEC16(count, re, extra, bptr, len, start_offset, options, \
1080          offsets, size_offsets, workspace, size_workspace); \
1081      else \
1082        PCRE_DFA_EXEC8(count, re, extra, bptr, len, start_offset, options, \
1083          offsets, size_offsets, workspace, size_workspace)
1084    
1085    #define PCRE_EXEC(count, re, extra, bptr, len, start_offset, options, \
1086        offsets, size_offsets) \
1087      if (pcre_mode == PCRE16_MODE) \
1088        PCRE_EXEC16(count, re, extra, bptr, len, start_offset, options, \
1089          offsets, size_offsets); \
1090      else \
1091        PCRE_EXEC8(count, re, extra, bptr, len, start_offset, options, \
1092          offsets, size_offsets)
1093    
1094    #define PCRE_FREE_STUDY(extra) \
1095      if (pcre_mode == PCRE16_MODE) \
1096        PCRE_FREE_STUDY16(extra); \
1097      else \
1098        PCRE_FREE_STUDY8(extra)
1099    
1100    #define PCRE_FREE_SUBSTRING(substring) \
1101      if (pcre_mode == PCRE16_MODE) \
1102        PCRE_FREE_SUBSTRING16(substring); \
1103      else \
1104        PCRE_FREE_SUBSTRING8(substring)
1105    
1106    #define PCRE_FREE_SUBSTRING_LIST(listptr) \
1107      if (pcre_mode == PCRE16_MODE) \
1108        PCRE_FREE_SUBSTRING_LIST16(listptr); \
1109      else \
1110        PCRE_FREE_SUBSTRING_LIST8(listptr)
1111    
1112    #define PCRE_GET_NAMED_SUBSTRING(rc, re, bptr, offsets, count, \
1113        getnamesptr, subsptr) \
1114      if (pcre_mode == PCRE16_MODE) \
1115        PCRE_GET_NAMED_SUBSTRING16(rc, re, bptr, offsets, count, \
1116          getnamesptr, subsptr); \
1117      else \
1118        PCRE_GET_NAMED_SUBSTRING8(rc, re, bptr, offsets, count, \
1119          getnamesptr, subsptr)
1120    
1121    #define PCRE_GET_STRINGNUMBER(n, rc, ptr) \
1122      if (pcre_mode == PCRE16_MODE) \
1123        PCRE_GET_STRINGNUMBER16(n, rc, ptr); \
1124      else \
1125        PCRE_GET_STRINGNUMBER8(n, rc, ptr)
1126    
1127    #define PCRE_GET_SUBSTRING(rc, bptr, use_offsets, count, i, subsptr) \
1128      if (pcre_mode == PCRE16_MODE) \
1129        PCRE_GET_SUBSTRING16(rc, bptr, use_offsets, count, i, subsptr); \
1130      else \
1131        PCRE_GET_SUBSTRING8(rc, bptr, use_offsets, count, i, subsptr)
1132    
1133    #define PCRE_GET_SUBSTRING_LIST(rc, bptr, offsets, count, listptr) \
1134      if (pcre_mode == PCRE16_MODE) \
1135        PCRE_GET_SUBSTRING_LIST16(rc, bptr, offsets, count, listptr); \
1136      else \
1137        PCRE_GET_SUBSTRING_LIST8(rc, bptr, offsets, count, listptr)
1138    
1139    #define PCRE_JIT_STACK_ALLOC(startsize, maxsize) \
1140      (pcre_mode == PCRE16_MODE ? \
1141          PCRE_JIT_STACK_ALLOC16(startsize, maxsize) \
1142          : PCRE_JIT_STACK_ALLOC8(startsize, maxsize))
1143    
1144    #define PCRE_JIT_STACK_FREE(stack) \
1145      if (pcre_mode == PCRE16_MODE) \
1146        PCRE_JIT_STACK_FREE16(stack); \
1147      else \
1148        PCRE_JIT_STACK_FREE8(stack)
1149    
1150    #define PCRE_MAKETABLES \
1151      (pcre_mode == PCRE16_MODE ? pcre16_maketables() : pcre_maketables())
1152    
1153    #define PCRE_PATTERN_TO_HOST_BYTE_ORDER(rc, re, extra, tables) \
1154      if (pcre_mode == PCRE16_MODE) \
1155        PCRE_PATTERN_TO_HOST_BYTE_ORDER16(rc, re, extra, tables); \
1156      else \
1157        PCRE_PATTERN_TO_HOST_BYTE_ORDER8(rc, re, extra, tables)
1158    
1159    #define PCRE_PRINTINT(re, outfile, debug_lengths) \
1160      if (pcre_mode == PCRE16_MODE) \
1161        PCRE_PRINTINT16(re, outfile, debug_lengths); \
1162      else \
1163        PCRE_PRINTINT8(re, outfile, debug_lengths)
1164    
1165    #define PCRE_STUDY(extra, re, options, error) \
1166      if (pcre_mode == PCRE16_MODE) \
1167        PCRE_STUDY16(extra, re, options, error); \
1168      else \
1169        PCRE_STUDY8(extra, re, options, error)
1170    
1171    #endif
1172    
1173    /* ----- End of cases where more than one mode is supported ----- */
1174    
1175    
1176  /* ----- Only 8-bit mode is supported ----- */  /* ----- Only 8-bit mode is supported ----- */
1177    
1178  #elif defined SUPPORT_PCRE8  #elif defined SUPPORT_PCRE8
# Line 1298  return sys_errlist[n]; Line 1775  return sys_errlist[n];
1775  *       Print newline configuration              *  *       Print newline configuration              *
1776  *************************************************/  *************************************************/
1777    
1778  /*  /*
1779  Arguments:  Arguments:
1780    rc         the return code from PCRE_CONFIG_NEWLINE    rc         the return code from PCRE_CONFIG_NEWLINE
1781    isc        TRUE if called from "-C newline"    isc        TRUE if called from "-C newline"
1782  Returns:     nothing  Returns:     nothing
1783  */  */
1784    
# Line 1317  switch(rc) Line 1794  switch(rc)
1794    case (CHAR_CR<<8 | CHAR_LF): s = "CRLF"; break;    case (CHAR_CR<<8 | CHAR_LF): s = "CRLF"; break;
1795    case -1: s = "ANY"; break;    case -1: s = "ANY"; break;
1796    case -2: s = "ANYCRLF"; break;    case -2: s = "ANYCRLF"; break;
1797    
1798    default:    default:
1799    printf("a non-standard value: 0x%04x\n", rc);    printf("a non-standard value: 0x%04x\n", rc);
1800    return;    return;
1801    }    }
1802    
1803  printf("%s\n", s);  printf("%s\n", s);
1804  }  }
# Line 1387  for (j = 0; j < i; j++) Line 1864  for (j = 0; j < i; j++)
1864  /* Check that encoding was the correct unique one */  /* Check that encoding was the correct unique one */
1865    
1866  for (j = 0; j < utf8_table1_size; j++)  for (j = 0; j < utf8_table1_size; j++)
1867    if (d <= utf8_table1[j]) break;    if (d <= (pcre_uint32)utf8_table1[j]) break;
1868  if (j != i) return -(i+1);  if (j != i) return -(i+1);
1869    
1870  /* Valid value */  /* Valid value */
# Line 1421  register int i, j; Line 1898  register int i, j;
1898  if (cvalue > 0x7fffffffu)  if (cvalue > 0x7fffffffu)
1899    return -1;    return -1;
1900  for (i = 0; i < utf8_table1_size; i++)  for (i = 0; i < utf8_table1_size; i++)
1901    if (cvalue <= utf8_table1[i]) break;    if (cvalue <= (pcre_uint32)utf8_table1[i]) break;
1902  utf8bytes += i;  utf8bytes += i;
1903  for (j = i; j > 0; j--)  for (j = i; j > 0; j--)
1904   {   {
# Line 1924  if (length < 0) Line 2401  if (length < 0)
2401    
2402  while (length-- > 0)  while (length-- > 0)
2403    {    {
2404    pcre_uint32 c = *p++;    pcre_uint32 c = *p++;
2405    if (utf) c &= UTF32_MASK;    if (utf) c &= UTF32_MASK;
2406    yield += pchar(c, f);    yield += pchar(c, f);
2407    }    }
# Line 2756  int done = 0; Line 3233  int done = 0;
3233  int all_use_dfa = 0;  int all_use_dfa = 0;
3234  int verify_jit = 0;  int verify_jit = 0;
3235  int yield = 0;  int yield = 0;
3236    #ifdef SUPPORT_PCRE32
3237  int mask_utf32 = 0;  int mask_utf32 = 0;
3238    #endif
3239  int stack_size;  int stack_size;
3240  pcre_uint8 *dbuffer = NULL;  pcre_uint8 *dbuffer = NULL;
3241  size_t dbuffer_size = 1u << 14;  size_t dbuffer_size = 1u << 14;
# Line 2799  pcre_uint8 *gn8ptr; Line 3278  pcre_uint8 *gn8ptr;
3278  #endif  #endif
3279    
3280  /* Get buffers from malloc() so that valgrind will check their misuse when  /* Get buffers from malloc() so that valgrind will check their misuse when
3281  debugging. They grow automatically when very long lines are read. The 16-  debugging. They grow automatically when very long lines are read. The 16-
3282  and 32-bit buffers (buffer16, buffer32) are obtained only if needed. */  and 32-bit buffers (buffer16, buffer32) are obtained only if needed. */
3283    
3284  buffer = (pcre_uint8 *)malloc(buffer_size);  buffer = (pcre_uint8 *)malloc(buffer_size);
# Line 3009  while (argc > 1 && argv[op][0] == '-') Line 3488  while (argc > 1 && argv[op][0] == '-')
3488        else if (strcmp(argv[op + 1], "newline") == 0)        else if (strcmp(argv[op + 1], "newline") == 0)
3489          {          {
3490          (void)PCRE_CONFIG(PCRE_CONFIG_NEWLINE, &rc);          (void)PCRE_CONFIG(PCRE_CONFIG_NEWLINE, &rc);
3491          print_newline_config(rc, TRUE);          print_newline_config(rc, TRUE);
3492          }          }
3493        else if (strcmp(argv[op + 1], "ebcdic") == 0)        else if (strcmp(argv[op + 1], "ebcdic") == 0)
3494          {          {
3495  #ifdef EBCDIC  #ifdef EBCDIC
3496          printf("1\n");          printf("1\n");
3497          yield = 1;          yield = 1;
3498  #else  #else
3499          printf("0\n");          printf("0\n");
3500  #endif  #endif
3501          }          }
3502        else if (strcmp(argv[op + 1], "ebcdic-nl") == 0)        else if (strcmp(argv[op + 1], "ebcdic-nl") == 0)
3503          {          {
3504  #ifdef EBCDIC  #ifdef EBCDIC
3505          printf("0x%02x\n", CHAR_LF);          printf("0x%02x\n", CHAR_LF);
3506  #else  #else
3507          printf("0\n");          printf("0\n");
3508  #endif  #endif
3509          }          }
3510        else        else
3511          {          {
3512          printf("Unknown -C option: %s\n", argv[op + 1]);          printf("Unknown -C option: %s\n", argv[op + 1]);
3513          }          }
3514        goto EXIT;        goto EXIT;
3515        }        }
3516    
3517      /* No argument for -C: output all configuration information. */      /* No argument for -C: output all configuration information. */
3518    
3519      printf("PCRE version %s\n", version);      printf("PCRE version %s\n", version);
3520      printf("Compiled with\n");      printf("Compiled with\n");
3521    
3522  #ifdef EBCDIC  #ifdef EBCDIC
3523      printf("  EBCDIC code support: LF is 0x%02x\n", CHAR_LF);      printf("  EBCDIC code support: LF is 0x%02x\n", CHAR_LF);
3524  #endif  #endif
3525    
3526  /* At least one of SUPPORT_PCRE8 and SUPPORT_PCRE16 will be set. If both  /* At least one of SUPPORT_PCRE8 and SUPPORT_PCRE16 will be set. If both
3527  are set, either both UTFs are supported or both are not supported. */  are set, either both UTFs are supported or both are not supported. */
# Line 3075  are set, either both UTFs are supported Line 3554  are set, either both UTFs are supported
3554      else      else
3555        printf("  No just-in-time compiler support\n");        printf("  No just-in-time compiler support\n");
3556      (void)PCRE_CONFIG(PCRE_CONFIG_NEWLINE, &rc);      (void)PCRE_CONFIG(PCRE_CONFIG_NEWLINE, &rc);
3557      print_newline_config(rc, FALSE);      print_newline_config(rc, FALSE);
3558      (void)PCRE_CONFIG(PCRE_CONFIG_BSR, &rc);      (void)PCRE_CONFIG(PCRE_CONFIG_BSR, &rc);
3559      printf("  \\R matches %s\n", rc? "CR, LF, or CRLF only" :      printf("  \\R matches %s\n", rc? "CR, LF, or CRLF only" :
3560                                       "all Unicode newlines");                                       "all Unicode newlines");
# Line 4195  while (!done) Line 4674  while (!done)
4674         invalid input to pcre_exec, you must use \x?? or \x{} sequences. */         invalid input to pcre_exec, you must use \x?? or \x{} sequences. */
4675      if (use_utf)      if (use_utf)
4676        {        {
4677        char *q;        pcre_uint8 *q;
4678        pcre_uint32 c;        pcre_uint32 cc;
4679        int n = 1;        int n = 1;
4680    
4681        for (q = p; n > 0 && *q; q += n) n = utf82ord(q, &c);        for (q = p; n > 0 && *q; q += n) n = utf82ord(q, &cc);
4682        if (n <= 0)        if (n <= 0)
4683          {          {
4684          fprintf(outfile, "**Failed: invalid UTF-8 string cannot be used as input in UTF mode\n");          fprintf(outfile, "**Failed: invalid UTF-8 string cannot be used as input in UTF mode\n");
# Line 4210  while (!done) Line 4689  while (!done)
4689    
4690      /* Allocate a buffer to hold the data line. len+1 is an upper bound on      /* Allocate a buffer to hold the data line. len+1 is an upper bound on
4691         the number of pcre_uchar units that will be needed. */         the number of pcre_uchar units that will be needed. */
4692      if (dbuffer == NULL || len >= dbuffer_size)      if (dbuffer == NULL || (size_t)len >= dbuffer_size)
4693        {        {
4694        dbuffer_size *= 2;        dbuffer_size *= 2;
4695        dbuffer = (pcre_uint8 *)realloc(dbuffer, dbuffer_size * CHAR_SIZE);        dbuffer = (pcre_uint8 *)realloc(dbuffer, dbuffer_size * CHAR_SIZE);
# Line 4520  while (!done) Line 4999  while (!done)
4999    
5000        /* We now have a character value in c that may be greater than 255. In        /* We now have a character value in c that may be greater than 255. In
5001        16-bit or 32-bit mode, we always convert characters to UTF-8 so that        16-bit or 32-bit mode, we always convert characters to UTF-8 so that
5002        values greater than 255 can be passed to non-UTF 16- or 32-bit strings.        values greater than 255 can be passed to non-UTF 16- or 32-bit strings.
5003        In 8-bit       mode we convert to UTF-8 if we are in UTF mode. Values greater        In 8-bit       mode we convert to UTF-8 if we are in UTF mode. Values greater
5004        than 127       in UTF mode must have come from \x{...} or octal constructs        than 127       in UTF mode must have come from \x{...} or octal constructs
5005        because values from \x.. get this far only in non-UTF mode. */        because values from \x.. get this far only in non-UTF mode. */
# Line 4569  while (!done) Line 5048  while (!done)
5048            else            else
5049              *q16++ = c;              *q16++ = c;
5050            }            }
5051          else          else
5052  #endif  #endif
5053            {            {
5054            if (c > 0xffffu)            if (c > 0xffffu)
5055              {              {
5056              fprintf(outfile, "** Character value is greater than 0xffff "              fprintf(outfile, "** Character value is greater than 0xffff "
5057                "and UTF-16 mode is not enabled.\n", c);                "and UTF-16 mode is not enabled.\n");
5058              fprintf(outfile, "** Truncation will probably give the wrong "              fprintf(outfile, "** Truncation will probably give the wrong "
5059                "result.\n");                "result.\n");
5060              }              }
# Line 4619  while (!done) Line 5098  while (!done)
5098    
5099  #if defined SUPPORT_UTF && defined SUPPORT_PCRE32  #if defined SUPPORT_UTF && defined SUPPORT_PCRE32
5100      /* If we're requsted to test UTF-32 masking of high bits, change the data      /* If we're requsted to test UTF-32 masking of high bits, change the data
5101      string to have high bits set, unless the string is invalid UTF-32.      string to have high bits set, unless the string is invalid UTF-32.
5102      Since the JIT doesn't support this yet, only do it when not JITing. */      Since the JIT doesn't support this yet, only do it when not JITing. */
5103      if (use_utf && mask_utf32 && (study_options & PCRE_STUDY_ALLJIT) == 0 &&      if (use_utf && mask_utf32 && (study_options & PCRE_STUDY_ALLJIT) == 0 &&
5104          valid_utf32((pcre_uint32 *)dbuffer, len))          valid_utf32((pcre_uint32 *)dbuffer, len))

Legend:
Removed from v.1121  
changed lines
  Added in v.1122

  ViewVC Help
Powered by ViewVC 1.1.5