Clean up diff.c

Signed-off-by: Timo Hirvonen <tihirvon@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
maint
Timo Hirvonen 2006-06-24 20:20:32 +03:00 committed by Junio C Hamano
parent acb70149bc
commit d2543b8ee3
1 changed files with 6 additions and 12 deletions

18
diff.c
View File

@ -203,7 +203,7 @@ static void emit_rewrite_diff(const char *name_a,
static int fill_mmfile(mmfile_t *mf, struct diff_filespec *one) static int fill_mmfile(mmfile_t *mf, struct diff_filespec *one)
{ {
if (!DIFF_FILE_VALID(one)) { if (!DIFF_FILE_VALID(one)) {
mf->ptr = ""; /* does not matter */ mf->ptr = (char *)""; /* does not matter */
mf->size = 0; mf->size = 0;
return 0; return 0;
} }
@ -395,7 +395,7 @@ static void show_stats(struct diffstat_t* data)
} }


for (i = 0; i < data->nr; i++) { for (i = 0; i < data->nr; i++) {
char *prefix = ""; const char *prefix = "";
char *name = data->files[i]->name; char *name = data->files[i]->name;
int added = data->files[i]->added; int added = data->files[i]->added;
int deleted = data->files[i]->deleted; int deleted = data->files[i]->deleted;
@ -917,7 +917,7 @@ int diff_populate_filespec(struct diff_filespec *s, int size_only)
err_empty: err_empty:
err = -1; err = -1;
empty: empty:
s->data = ""; s->data = (char *)"";
s->size = 0; s->size = 0;
return err; return err;
} }
@ -1408,7 +1408,7 @@ int diff_setup_done(struct diff_options *options)
return 0; return 0;
} }


int opt_arg(const char *arg, int arg_short, const char *arg_long, int *val) static int opt_arg(const char *arg, int arg_short, const char *arg_long, int *val)
{ {
char c, *eq; char c, *eq;
int len; int len;
@ -1720,16 +1720,12 @@ static void diff_flush_raw(struct diff_filepair *p,
free((void*)path_two); free((void*)path_two);
} }


static void diff_flush_name(struct diff_filepair *p, static void diff_flush_name(struct diff_filepair *p, int line_termination)
int inter_name_termination,
int line_termination)
{ {
char *path = p->two->path; char *path = p->two->path;


if (line_termination) if (line_termination)
path = quote_one(p->two->path); path = quote_one(p->two->path);
else
path = p->two->path;
printf("%s%c", path, line_termination); printf("%s%c", path, line_termination);
if (p->two->path != path) if (p->two->path != path)
free(path); free(path);
@ -1950,9 +1946,7 @@ static void flush_one_pair(struct diff_filepair *p,
options, diff_output_format); options, diff_output_format);
break; break;
case DIFF_FORMAT_NAME: case DIFF_FORMAT_NAME:
diff_flush_name(p, diff_flush_name(p, line_termination);
inter_name_termination,
line_termination);
break; break;
case DIFF_FORMAT_NO_OUTPUT: case DIFF_FORMAT_NO_OUTPUT:
break; break;