From 34400f2d328c2adfbfe13170989758e6f52208af Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Thu, 31 Oct 2024 21:58:07 +0100 Subject: Add the -l option --- src/flags.h | 1 + src/main.c | 10 ++++++++-- 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 -- cgit v1.2.3