aboutsummaryrefslogtreecommitdiffstats
path: root/man3/regex.3
diff options
context:
space:
mode:
authorAlejandro Colomar <alx@kernel.org>2023-05-03 00:48:14 +0200
committerAlejandro Colomar <alx@kernel.org>2023-05-03 00:48:22 +0200
commitfe5dba139dc089eae4061fdc17f087e71f48b198 (patch)
tree54af56b1b0138bde9a21e99372ab68ce4d64564a /man3/regex.3
parent5a0d9ed151e6449d978fabdd654cacc17b20a235 (diff)
downloadman-pages-fe5dba139dc089eae4061fdc17f087e71f48b198.tar.gz
man*/, man.ignore.grep: srcfix; warn about blank lines
- Use the dummy character to avoid warnings in examples. - Re-enable the warning. Suggested-by: "G. Branden Robinson" <g.branden.robinson@gmail.com> Signed-off-by: Alejandro Colomar <alx@kernel.org>
Diffstat (limited to 'man3/regex.3')
-rw-r--r--man3/regex.318
1 files changed, 9 insertions, 9 deletions
diff --git a/man3/regex.3 b/man3/regex.3
index d245daf237..13e540b22e 100644
--- a/man3/regex.3
+++ b/man3/regex.3
@@ -365,40 +365,40 @@ Always reference them by name.
#include <stdio.h>
#include <stdlib.h>
#include <regex.h>
-
+\&
#define ARRAY_SIZE(arr) (sizeof((arr)) / sizeof((arr)[0]))
-
+\&
static const char *const str =
"1) John Driverhacker;\en2) John Doe;\en3) John Foo;\en";
static const char *const re = "John.*o";
-
+\&
int main(void)
{
static const char *s = str;
regex_t regex;
regmatch_t pmatch[1];
regoff_t off, len;
-
+\&
if (regcomp(&regex, re, REG_NEWLINE))
exit(EXIT_FAILURE);
-
+\&
printf("String = \e"%s\e"\en", str);
printf("Matches:\en");
-
+\&
for (unsigned int i = 0; ; i++) {
if (regexec(&regex, s, ARRAY_SIZE(pmatch), pmatch, 0))
break;
-
+\&
off = pmatch[0].rm_so + (s \- str);
len = pmatch[0].rm_eo \- pmatch[0].rm_so;
printf("#%zu:\en", i);
printf("offset = %jd; length = %jd\en", (intmax_t) off,
(intmax_t) len);
printf("substring = \e"%.*s\e"\en", len, s + pmatch[0].rm_so);
-
+\&
s += pmatch[0].rm_eo;
}
-
+\&
exit(EXIT_SUCCESS);
}
.EE