diff options
Diffstat (limited to 'findutils/grep.c')
-rw-r--r-- | findutils/grep.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/findutils/grep.c b/findutils/grep.c index 003dae98e..c0193bce3 100644 --- a/findutils/grep.c +++ b/findutils/grep.c | |||
@@ -56,7 +56,7 @@ static void print_matched_line(char *line, int linenum) | |||
56 | if (print_line_num) | 56 | if (print_line_num) |
57 | printf("%i:", linenum); | 57 | printf("%i:", linenum); |
58 | 58 | ||
59 | printf("%s", line); | 59 | puts(line); |
60 | } | 60 | } |
61 | 61 | ||
62 | static void grep_file(FILE *file) | 62 | static void grep_file(FILE *file) |
@@ -67,6 +67,8 @@ static void grep_file(FILE *file) | |||
67 | int nmatches = 0; | 67 | int nmatches = 0; |
68 | 68 | ||
69 | while ((line = get_line_from_file(file)) != NULL) { | 69 | while ((line = get_line_from_file(file)) != NULL) { |
70 | if (line[strlen(line)-1] == '\n') | ||
71 | line[strlen(line)-1] = '\0'; | ||
70 | linenum++; | 72 | linenum++; |
71 | ret = regexec(®ex, line, 0, NULL, 0); | 73 | ret = regexec(®ex, line, 0, NULL, 0); |
72 | if (ret == 0 && !invert_search) { /* match */ | 74 | if (ret == 0 && !invert_search) { /* match */ |
@@ -144,7 +146,7 @@ extern int grep_main(int argc, char **argv) | |||
144 | /* compile the regular expression | 146 | /* compile the regular expression |
145 | * we're not going to mess with sub-expressions, and we need to | 147 | * we're not going to mess with sub-expressions, and we need to |
146 | * treat newlines right. */ | 148 | * treat newlines right. */ |
147 | reflags = REG_NOSUB | REG_NEWLINE; | 149 | reflags = REG_NOSUB; |
148 | if (ignore_case) | 150 | if (ignore_case) |
149 | reflags |= REG_ICASE; | 151 | reflags |= REG_ICASE; |
150 | xregcomp(®ex, argv[optind], reflags); | 152 | xregcomp(®ex, argv[optind], reflags); |