• Home
  • Raw
  • Download

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

30 width. This demonstration program uses the 8-bit library. The default is to
32 "(*UTF)", both it and the subject are treated as UTF-8 strings, where
35 In Unix-like environments, if PCRE2 is installed in your standard system
38 cc -Wall pcre2demo.c -lpcre2-8 -o pcre2demo
41 with support for the pkg-config mechanism. If you have pkg-config, you can
44 cc -Wall pcre2demo.c `pkg-config --cflags --libs libpcre2-8` -o pcre2demo
46 If you do not have pkg-config, you may have to use something like this:
48 cc -Wall pcre2demo.c -I/usr/local/include -L/usr/local/lib \
49 -R/usr/local/lib -lpcre2-8 -o pcre2demo
53 systems (Solaris is one) use the -R option.
57 If you want to statically link this program against a non-dll .a file, you must
67 program to process 16-bit characters. Even in a fully 16-bit environment, where
68 string-handling functions such as strcmp() and printf() work with 16-bit
82 * such as custom memory managers and non-standard newline definitions. *
104 uint32_t newline;
115 * the moment, "-g" to request repeated matching to find all occurrences, *
116 * like Perl's /g option. We set the variable find_all to a non-zero value *
117 * if the -g option is present. *
123 if (strcmp(argv[i], "-g") == 0) find_all = 1;
124 else if (argv[i][0] == '-')
135 if (argc - i != 2)
142 cast to PCRE2_SPTR because we are working in 8-bit code units. The subject
158 PCRE2_ZERO_TERMINATED, /* indicates pattern is zero-terminated */
239 assertions. However, there is an option to re-enable the old behaviour. If that
242 program, we show how to detect this case, but it shouldn't arise because the
248 "From end to start the match was: %.*s\n", (int)(ovector[0] - ovector[1]),
262 PCRE2_SIZE substring_length = ovector[2*i+1] - ovector[2*i];
301 and the substring itself. In the 8-bit library the number is held in two
308 printf("(%d) %*s: %.*s\n", n, name_entry_size - 3, tabptr + 2,
309 (int)(ovector[2*n+1] - ovector[2*n]), subject + ovector[2*n]);
316 * If the "-g" option was given on the command line, we want to continue *
335 * In UTF-8 mode, which can be set by (*UTF) in the pattern, this may be *
339 * newline convention is such that CRLF is a valid newline, we must *
340 * advance by two characters rather than one. The newline convention can *
344 if (!find_all) /* Check for -g */
351 /* Before running the loop, check for UTF-8 and whether CRLF is a valid newline
358 /* Now find the newline convention and see whether CRLF is a valid newline
361 (void)pcre2_pattern_info(re, PCRE2_INFO_NEWLINE, &newline);
362 crlf_is_newline = newline == PCRE2_NEWLINE_ANY ||
363 newline == PCRE2_NEWLINE_CRLF ||
364 newline == PCRE2_NEWLINE_ANYCRLF;
375 same point to see if a non-empty match can be found. */
387 the same substring. We must detect this case and arrange to move the start on
398 if (utf8) /* If UTF-8, it may be more */
419 Otherwise, it means we have failed to find a non-empty-string match at a
420 point where there was a previous empty-string match. In this case, we do what
425 There are two complications: (a) When CRLF is a valid newline sequence, and
434 if (crlf_is_newline && /* If CRLF is a newline & */
435 start_offset < subject_length - 1 && /* we are at CRLF, */
440 { /* advance a whole UTF-8 */
472 demonstration program, we just detect this case and give up. */
477 "From end to start the match was: %.*s\n", (int)(ovector[0] - ovector[1]),
491 size_t substring_length = ovector[2*i+1] - ovector[2*i];
502 printf("(%d) %*s: %.*s\n", n, name_entry_size - 3, tabptr + 2,
503 (int)(ovector[2*n+1] - ovector[2*n]), subject + ovector[2*n]);