aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--findutils/grep.c6
-rw-r--r--grep.c6
2 files changed, 8 insertions, 4 deletions
diff --git a/findutils/grep.c b/findutils/grep.c
index 05bf8b8cf..8d2c915be 100644
--- a/findutils/grep.c
+++ b/findutils/grep.c
@@ -141,8 +141,10 @@ extern int grep_main(int argc, char **argv)
if (argv[optind] == NULL)
usage(grep_usage);
- /* compile the regular expression */
- reflags = REG_NOSUB; /* we're not going to mess with sub-expressions */
+ /* compile the regular expression
+ * we're not going to mess with sub-expressions, and we need to
+ * treat newlines right. */
+ reflags = REG_NOSUB | REG_NEWLINE;
if (ignore_case)
reflags |= REG_ICASE;
if ((ret = regcomp(&regex, argv[optind], reflags)) != 0) {
diff --git a/grep.c b/grep.c
index 05bf8b8cf..8d2c915be 100644
--- a/grep.c
+++ b/grep.c
@@ -141,8 +141,10 @@ extern int grep_main(int argc, char **argv)
if (argv[optind] == NULL)
usage(grep_usage);
- /* compile the regular expression */
- reflags = REG_NOSUB; /* we're not going to mess with sub-expressions */
+ /* compile the regular expression
+ * we're not going to mess with sub-expressions, and we need to
+ * treat newlines right. */
+ reflags = REG_NOSUB | REG_NEWLINE;
if (ignore_case)
reflags |= REG_ICASE;
if ((ret = regcomp(&regex, argv[optind], reflags)) != 0) {