diff options
Diffstat (limited to 'grep.c')
-rw-r--r-- | grep.c | 7 |
1 files changed, 2 insertions, 5 deletions
@@ -112,8 +112,7 @@ static void grep_file(FILE *file) | |||
112 | 112 | ||
113 | /* if we were told to print 'before' lines and there is at least | 113 | /* if we were told to print 'before' lines and there is at least |
114 | * one line in the circular buffer, print them */ | 114 | * one line in the circular buffer, print them */ |
115 | if (lines_before && before_buf[prevpos] != NULL) | 115 | if (lines_before && before_buf[prevpos] != NULL) { |
116 | { | ||
117 | int first_buf_entry_line_num = linenum - lines_before; | 116 | int first_buf_entry_line_num = linenum - lines_before; |
118 | 117 | ||
119 | /* advance to the first entry in the circular buffer, and | 118 | /* advance to the first entry in the circular buffer, and |
@@ -133,7 +132,6 @@ static void grep_file(FILE *file) | |||
133 | idx = (idx + 1) % lines_before; | 132 | idx = (idx + 1) % lines_before; |
134 | first_buf_entry_line_num++; | 133 | first_buf_entry_line_num++; |
135 | } | 134 | } |
136 | |||
137 | } | 135 | } |
138 | 136 | ||
139 | /* make a note that we need to print 'after' lines */ | 137 | /* make a note that we need to print 'after' lines */ |
@@ -145,8 +143,7 @@ static void grep_file(FILE *file) | |||
145 | #ifdef BB_FEATURE_GREP_CONTEXT | 143 | #ifdef BB_FEATURE_GREP_CONTEXT |
146 | else { /* no match */ | 144 | else { /* no match */ |
147 | /* Add the line to the circular 'before' buffer */ | 145 | /* Add the line to the circular 'before' buffer */ |
148 | if(lines_before) | 146 | if(lines_before) { |
149 | { | ||
150 | if(before_buf[curpos]) | 147 | if(before_buf[curpos]) |
151 | free(before_buf[curpos]); | 148 | free(before_buf[curpos]); |
152 | before_buf[curpos] = strdup(line); | 149 | before_buf[curpos] = strdup(line); |