Lines Matching +full:detect +full:- +full:newline
12 width. This demonstration program uses the 8-bit library. The default is to
14 "(*UTF)", both it and the subject are treated as UTF-8 strings, where
17 In Unix-like environments, if PCRE2 is installed in your standard system
20 cc -Wall pcre2demo.c -lpcre2-8 -o pcre2demo
23 with support for the pkg-config mechanism. If you have pkg-config, you can
26 cc -Wall pcre2demo.c `pkg-config --cflags --libs libpcre2-8` -o pcre2demo
28 If you do not have pkg-config, you may have to use something like this:
30 cc -Wall pcre2demo.c -I/usr/local/include -L/usr/local/lib \
31 -R/usr/local/lib -lpcre2-8 -o pcre2demo
35 systems (Solaris is one) use the -R option.
39 If you want to statically link this program against a non-dll .a file, you must
49 program to process 16-bit characters. Even in a fully 16-bit environment, where
50 string-handling functions such as strcmp() and printf() work with 16-bit
64 * such as custom memory managers and non-standard newline definitions. *
86 uint32_t newline; in main() local
97 * the moment, "-g" to request repeated matching to find all occurrences, * in main()
98 * like Perl's /g option. We set the variable find_all to a non-zero value * in main()
99 * if the -g option is present. * in main()
105 if (strcmp(argv[i], "-g") == 0) find_all = 1; in main()
106 else if (argv[i][0] == '-') in main()
117 if (argc - i != 2) in main()
124 cast to PCRE2_SPTR because we are working in 8-bit code units. The subject in main()
140 PCRE2_ZERO_TERMINATED, /* indicates pattern is zero-terminated */ in main()
221 assertions. However, there is an option to re-enable the old behaviour. If that in main()
224 program, we show how to detect this case, but it shouldn't arise because the in main()
230 "From end to start the match was: %.*s\n", (int)(ovector[0] - ovector[1]), in main()
244 PCRE2_SIZE substring_length = ovector[2*i+1] - ovector[2*i]; in main()
283 and the substring itself. In the 8-bit library the number is held in two in main()
290 printf("(%d) %*s: %.*s\n", n, name_entry_size - 3, tabptr + 2, in main()
291 (int)(ovector[2*n+1] - ovector[2*n]), subject + ovector[2*n]); in main()
298 * If the "-g" option was given on the command line, we want to continue * in main()
317 * In UTF-8 mode, which can be set by (*UTF) in the pattern, this may be * in main()
321 * newline convention is such that CRLF is a valid newline, we must * in main()
322 * advance by two characters rather than one. The newline convention can * in main()
326 if (!find_all) /* Check for -g */ in main()
333 /* Before running the loop, check for UTF-8 and whether CRLF is a valid newline in main()
340 /* Now find the newline convention and see whether CRLF is a valid newline in main()
343 (void)pcre2_pattern_info(re, PCRE2_INFO_NEWLINE, &newline); in main()
344 crlf_is_newline = newline == PCRE2_NEWLINE_ANY || in main()
345 newline == PCRE2_NEWLINE_CRLF || in main()
346 newline == PCRE2_NEWLINE_ANYCRLF; in main()
357 same point to see if a non-empty match can be found. */ in main()
369 the same substring. We must detect this case and arrange to move the start on in main()
380 if (utf8) /* If UTF-8, it may be more */ in main()
401 Otherwise, it means we have failed to find a non-empty-string match at a in main()
402 point where there was a previous empty-string match. In this case, we do what in main()
407 There are two complications: (a) When CRLF is a valid newline sequence, and in main()
416 if (crlf_is_newline && /* If CRLF is a newline & */ in main()
417 start_offset < subject_length - 1 && /* we are at CRLF, */ in main()
422 { /* advance a whole UTF-8 */ in main()
454 demonstration program, we just detect this case and give up. */ in main()
459 "From end to start the match was: %.*s\n", (int)(ovector[0] - ovector[1]), in main()
473 size_t substring_length = ovector[2*i+1] - ovector[2*i]; in main()
484 printf("(%d) %*s: %.*s\n", n, name_entry_size - 3, tabptr + 2, in main()
485 (int)(ovector[2*n+1] - ovector[2*n]), subject + ovector[2*n]); in main()