• Home
  • Raw
  • Download

Lines Matching +full:detect +full:- +full:newline

2 .\"AUTOMATICALLY GENERATED BY PrepareRelease - do not EDIT!
4 PCRE2DEMO - A demonstration C program for PCRE2
27 .RS -7
40 width. This demonstration program uses the 8-bit library. The default is to
42 "(*UTF)", both it and the subject are treated as UTF-8 strings, where
45 In Unix-like environments, if PCRE2 is installed in your standard system
48 cc -Wall pcre2demo.c -lpcre2-8 -o pcre2demo
51 with support for the pkg-config mechanism. If you have pkg-config, you can
54 cc -Wall pcre2demo.c `pkg-config --cflags --libs libpcre2-8` -o pcre2demo
56 If you do not have pkg-config, you may have to use something like this:
58 cc -Wall pcre2demo.c -I/usr/local/include -L/usr/local/lib \e
59 -R/usr/local/lib -lpcre2-8 -o pcre2demo
63 systems (Solaris is one) use the -R option.
67 If you want to statically link this program against a non-dll .a file, you must
77 program to process 16-bit characters. Even in a fully 16-bit environment, where
78 string-handling functions such as strcmp() and printf() work with 16-bit
92 * such as custom memory managers and non-standard newline definitions. *
114 uint32_t newline;
125 * the moment, "-g" to request repeated matching to find all occurrences, *
126 * like Perl's /g option. We set the variable find_all to a non-zero value *
127 * if the -g option is present. *
133 if (strcmp(argv[i], "-g") == 0) find_all = 1;
134 else if (argv[i][0] == '-')
145 if (argc - i != 2)
152 cast to PCRE2_SPTR because we are working in 8-bit code units. The subject
168 PCRE2_ZERO_TERMINATED, /* indicates pattern is zero-terminated */
249 assertions. However, there is an option to re-enable the old behaviour. If that
252 program, we show how to detect this case, but it shouldn't arise because the
258 "From end to start the match was: %.*s\en", (int)(ovector[0] - ovector[1]),
272 PCRE2_SIZE substring_length = ovector[2*i+1] - ovector[2*i];
311 and the substring itself. In the 8-bit library the number is held in two
318 printf("(%d) %*s: %.*s\en", n, name_entry_size - 3, tabptr + 2,
319 (int)(ovector[2*n+1] - ovector[2*n]), subject + ovector[2*n]);
326 * If the "-g" option was given on the command line, we want to continue *
345 * In UTF-8 mode, which can be set by (*UTF) in the pattern, this may be *
349 * newline convention is such that CRLF is a valid newline, we must *
350 * advance by two characters rather than one. The newline convention can *
354 if (!find_all) /* Check for -g */
361 /* Before running the loop, check for UTF-8 and whether CRLF is a valid newline
368 /* Now find the newline convention and see whether CRLF is a valid newline
371 (void)pcre2_pattern_info(re, PCRE2_INFO_NEWLINE, &newline);
372 crlf_is_newline = newline == PCRE2_NEWLINE_ANY ||
373 newline == PCRE2_NEWLINE_CRLF ||
374 newline == PCRE2_NEWLINE_ANYCRLF;
385 same point to see if a non-empty match can be found. */
397 the same substring. We must detect this case and arrange to move the start on
408 if (utf8) /* If UTF-8, it may be more */
429 Otherwise, it means we have failed to find a non-empty-string match at a
430 point where there was a previous empty-string match. In this case, we do what
435 There are two complications: (a) When CRLF is a valid newline sequence, and
444 if (crlf_is_newline && /* If CRLF is a newline & */
445 start_offset < subject_length - 1 && /* we are at CRLF, */
450 { /* advance a whole UTF-8 */
482 demonstration program, we just detect this case and give up. */
487 "From end to start the match was: %.*s\en", (int)(ovector[0] - ovector[1]),
501 size_t substring_length = ovector[2*i+1] - ovector[2*i];
512 printf("(%d) %*s: %.*s\en", n, name_entry_size - 3, tabptr + 2,
513 (int)(ovector[2*n+1] - ovector[2*n]), subject + ovector[2*n]);