aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2024-10-31 21:58:07 +0100
committerThomas Voss <mail@thomasvoss.com> 2024-10-31 21:58:07 +0100
commit34400f2d328c2adfbfe13170989758e6f52208af (patch)
treed208f8b7d40cae2af4f38a9a295cb50c27c45abc
parentc5cc1dab1d5610c0d96f72dc36ac6d4b4476c8ed (diff)
Add the -l option
-rw-r--r--src/flags.h1
-rw-r--r--src/main.c10
2 files changed, 9 insertions, 2 deletions
diff --git a/src/flags.h b/src/flags.h
index 306464c..fbd957d 100644
--- a/src/flags.h
+++ b/src/flags.h
@@ -5,6 +5,7 @@ typedef struct {
bool b : 1;
bool c : 1;
bool i : 1;
+ bool l : 1;
bool p : 1;
bool s : 1;
bool U : 1;
diff --git a/src/main.c b/src/main.c
index e679839..9e7e522 100644
--- a/src/main.c
+++ b/src/main.c
@@ -78,6 +78,7 @@ main(int argc, char **argv)
{'c', U8C("color"), CLI_NONE},
{'h', U8C("help"), CLI_NONE},
{'i', U8C("ignore-case"), CLI_NONE},
+ {'l', U8C("literal"), CLI_NONE},
{'p', U8C("predicate"), CLI_NONE},
{'s', U8C("strip-newline"), CLI_NONE},
{'U', U8C("no-unicode"), CLI_NONE},
@@ -101,6 +102,9 @@ main(int argc, char **argv)
case 'i':
flags.i = true;
break;
+ case 'l':
+ flags.l = true;
+ break;
case 'p':
flags.p = true;
break;
@@ -137,7 +141,7 @@ main(int argc, char **argv)
if (argc == 0) {
usage:
- usage("[-p | -s | -z] [-bciU] pattern [file ...]", "-h");
+ usage("[-p | -s | -z] [-bcilU] pattern [file ...]", "-h");
exit(EXIT_FATAL);
}
@@ -315,6 +319,8 @@ pattern_comp(u8view_t pat)
| PCRE2_UTF;
if (flags.i)
reopts |= PCRE2_CASELESS;
+ if (flags.l)
+ reopts |= PCRE2_LITERAL;
if (!flags.U)
reopts |= PCRE2_UCP;
@@ -432,4 +438,4 @@ getfstream(int globc, char **globv)
close(fds[W]);
return fdopen(fds[R], "r");
}
-#endif /* GIT_GRAB */
+#endif /* GIT_GRAB */ \ No newline at end of file