@@ -75,7 +75,7 @@ PCRE2_SPTR name_table;
7575
7676int crlf_is_newline ;
7777int errornumber ;
78- int find_all ;
78+ int find_all , caseless_match ;
7979int i ;
8080int rc ;
8181int utf8 ;
@@ -93,16 +93,21 @@ pcre2_match_data *match_data;
9393
9494
9595/**************************************************************************
96- * First, sort out the command line. There is only one possible option at *
97- * the moment, "-g" to request repeated matching to find all occurrences, *
98- * like Perl's /g option. We set the variable find_all to a non-zero value *
99- * if the -g option is present. *
96+ * First, sort out the command line. Options: *
97+ * - "-g" to request repeated matching to find all occurrences, *
98+ * like Perl's /g option. We set the variable find_all to a non-zero *
99+ * value if the -g option is present. *
100+ * - "-i" to request caseless matching, like Perl's /i option. We set the *
101+ * variable caseless_match to PCRE2_CASELESS if the -i option is *
102+ * present. *
100103**************************************************************************/
101104
102105find_all = 0 ;
106+ caseless_match = 0 ;
103107for (i = 1 ; i < argc ; i ++ )
104108 {
105109 if (strcmp (argv [i ], "-g" ) == 0 ) find_all = 1 ;
110+ else if (strcmp (argv [i ], "-i" ) == 0 ) caseless_match = PCRE2_CASELESS ;
106111 else if (argv [i ][0 ] == '-' )
107112 {
108113 printf ("Unrecognised option %s\n" , argv [i ]);
@@ -138,7 +143,7 @@ subject_length = (PCRE2_SIZE)strlen((char *)subject);
138143re = pcre2_compile (
139144 pattern , /* the pattern */
140145 PCRE2_ZERO_TERMINATED , /* indicates pattern is zero-terminated */
141- 0 , /* default options */
146+ caseless_match , /* possibly enable caseless */
142147 & errornumber , /* for error number */
143148 & erroroffset , /* for error offset */
144149 NULL ); /* use default compile context */
0 commit comments