~ubuntu-branches/ubuntu/trusty/silversearcher-ag/trusty

« back to all changes in this revision

Viewing changes to src/print.c

  • Committer: Package Import Robot
  • Author(s): Hajime Mizuno
  • Date: 2014-01-29 23:23:00 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20140129232300-um66iqygxjyuy980
Tags: 0.19.2-1
* new upstream release
* debian/control
  - set Standards-Version: 3.9.5.
* debian/rules
  - add empty "override_dh_auto_test" to skip the test.
    because cram is required for testing, but package does not exist.
* debian/copyright
  - update copyright year to 2013-2014.

Show diffs side-by-side

added added

removed removed

Lines of Context:
155
155
                            }
156
156
                            printing_a_match = TRUE;
157
157
                        }
158
 
                        fputc(buf[j], out_fd);
 
158
                        /* Don't print the null terminator */
 
159
                        if (j < buf_len) {
 
160
                            fputc(buf[j], out_fd);
 
161
                        }
159
162
                    }
160
163
                    if (printing_a_match && opts.color) {
161
164
                        fprintf(out_fd, "%s", color_reset);
179
182
            if (!in_a_match) {
180
183
                lines_since_last_match++;
181
184
            }
 
185
            /* File doesn't end with a newline. Print one so the output is pretty. */
 
186
            if (i == buf_len && buf[i] != '\n') {
 
187
                fputc('\n', out_fd);
 
188
            }
182
189
        }
183
190
    }
184
191
 
212
219
}
213
220
 
214
221
const char* normalize_path(const char* path) {
215
 
    if (strlen(path) >= 3 && path[0] == '.' && path[1] == '/') {
 
222
    if (strlen(path) < 3) {
 
223
        return path;
 
224
    }
 
225
    if (path[0] == '.' && path[1] == '/') {
216
226
        return path + 2;
217
 
    } else {
218
 
        return path;
219
 
    }
 
227
    }
 
228
    if (path[0] == '/' && path[1] == '/') {
 
229
        return path + 1;
 
230
    }
 
231
    return path;
220
232
}