{"thread":{"id":"6758","subject":"[PATCH] diff.c: More logical file name quoting for renames in diffstat.","startedAt":"2007-02-10T14:39:00Z","lastAt":"2007-02-10T14:39:00Z","messageCount":1,"participants":["Alexandre Julliard"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"34103","messageId":"87ejoydqm3.fsf@wine.dyndns.org","threadId":"6758","inReplyTo":null,"subject":"[PATCH] diff.c: More logical file name quoting for renames in diffstat.","fromName":"Alexandre Julliard","fromEmail":"julliard@winehq.org","sentAt":"2007-02-10T14:39:00Z","receivedAt":"2007-02-10T14:39:00Z","isPatch":true,"sender":{"key":"julliard@winehq.org","avatar":null},"body":"Quote both file names separately when printing a rename, yielding\nsomething like\n\n  \"foo\" => \"bar\"\n\ninstead of the current\n\n  \"foo => bar\"\n\nSigned-off-by: Alexandre Julliard <julliard@winehq.org>\n---\n diff.c |   34 +++++++++++++++++++++++++++-------\n 1 files changed, 27 insertions(+), 7 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex e036aae..c6a9692 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -545,6 +545,24 @@ static char *pprint_rename(const char *a, const char *b)\n \tint pfx_length, sfx_length;\n \tint len_a = strlen(a);\n \tint len_b = strlen(b);\n+\tint qlen_a = quote_c_style(a, NULL, NULL, 0);\n+\tint qlen_b = quote_c_style(b, NULL, NULL, 0);\n+\n+\tif (qlen_a || qlen_b) {\n+\t\tif (qlen_a) len_a = qlen_a;\n+\t\tif (qlen_b) len_b = qlen_b;\n+\t\tname = xmalloc( len_a + len_b + 5 );\n+\t\tif (qlen_a)\n+\t\t\tquote_c_style(a, name, NULL, 0);\n+\t\telse\n+\t\t\tmemcpy(name, a, len_a);\n+\t\tmemcpy(name + len_a, \" => \", 4);\n+\t\tif (qlen_b)\n+\t\t\tquote_c_style(b, name + len_a + 4, NULL, 0);\n+\t\telse\n+\t\t\tmemcpy(name + len_a + 4, b, len_b + 1);\n+\t\treturn name;\n+\t}\n \n \t/* Find common prefix */\n \tpfx_length = 0;\n@@ -701,12 +719,14 @@ static void show_stats(struct diffstat_t* data, struct diff_options *options)\n \t\tstruct diffstat_file *file = data->files[i];\n \t\tint change = file->added + file->deleted;\n \n-\t\tlen = quote_c_style(file->name, NULL, NULL, 0);\n-\t\tif (len) {\n-\t\t\tchar *qname = xmalloc(len + 1);\n-\t\t\tquote_c_style(file->name, qname, NULL, 0);\n-\t\t\tfree(file->name);\n-\t\t\tfile->name = qname;\n+\t\tif (!file->is_renamed) {  /* renames are already quoted by pprint_rename */\n+\t\t\tlen = quote_c_style(file->name, NULL, NULL, 0);\n+\t\t\tif (len) {\n+\t\t\t\tchar *qname = xmalloc(len + 1);\n+\t\t\t\tquote_c_style(file->name, qname, NULL, 0);\n+\t\t\t\tfree(file->name);\n+\t\t\t\tfile->name = qname;\n+\t\t\t}\n \t\t}\n \n \t\tlen = strlen(file->name);\n@@ -838,7 +858,7 @@ static void show_numstat(struct diffstat_t* data, struct diff_options *options)\n \t\t\tprintf(\"-\\t-\\t\");\n \t\telse\n \t\t\tprintf(\"%d\\t%d\\t\", file->added, file->deleted);\n-\t\tif (options->line_termination &&\n+\t\tif (options->line_termination && !file->is_renamed &&\n \t\t    quote_c_style(file->name, NULL, NULL, 0))\n \t\t\tquote_c_style(file->name, NULL, stdout, 0);\n \t\telse\n-- \n1.5.0.rc4.31.g6289\n\n-- \nAlexandre Julliard\njulliard@winehq.org\n"}]}