diff options
-rw-r--r-- | src/grijp.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/grijp.c b/src/grijp.c index 29a13b1..2a039b8 100644 --- a/src/grijp.c +++ b/src/grijp.c @@ -20,6 +20,7 @@ static char *gpats; static bool fixed = false; static bool extended = false; static bool icase = false; +static bool binary = false; static size_t npat = 0; static void **patterns = NULL; // can hold `char*` or `regex_t*` @@ -37,7 +38,7 @@ static void usage(FILE *f) { // Returns pointer to argument array containing patterns and then the file names static char** parse_options(int argc, char **argv) { int opt; - while ((opt = getopt(argc, argv, "FiEhV")) != -1) { + while ((opt = getopt(argc, argv, "FiEUhV")) != -1) { switch (opt) { case 'F': fixed = true; @@ -48,6 +49,9 @@ static char** parse_options(int argc, char **argv) { case 'E': extended = true; break; + case 'U': + binary = true; + break; case 'h': usage(stdout); @@ -104,7 +108,7 @@ static void compile_regexps() { } static int process_regex(char *fname, bool isstdin) { - FILE *stream = isstdin ? stdin : fopen(fname, "rb"); + FILE *stream = isstdin ? stdin : fopen(fname, binary ? "rb" : "r"); char *line = NULL; size_t linen = 0; @@ -127,7 +131,7 @@ static int process_regex(char *fname, bool isstdin) { } static int process_fixed(char *fname, bool isstdin) { - FILE *stream = isstdin ? stdin : fopen(fname, "rb"); + FILE *stream = isstdin ? stdin : fopen(fname, binary ? "rb" : "r"); char *line = NULL; size_t linen = 0; |