{"thread":{"id":"13514","subject":"[PATCH] graph.c: fix padding","startedAt":"2008-05-14T14:22:38Z","lastAt":"2008-05-15T08:50:05Z","messageCount":2,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"76942","messageId":"alpine.DEB.1.00.0805141522060.30431@racer","threadId":"13514","inReplyTo":null,"subject":"[PATCH] graph.c: fix padding","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-05-14T14:22:38Z","receivedAt":"2008-05-14T14:22:38Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nThere were two instances of \"%*s\" which want to be \"%.*s\" instead.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n graph.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/graph.c b/graph.c\nindex 9d6ed30..f3e2eed 100644\n--- a/graph.c\n+++ b/graph.c\n@@ -422,7 +422,7 @@ static void graph_pad_horizontally(struct git_graph *graph, struct strbuf *sb)\n \t\treturn;\n \n \textra = graph->width - sb->len;\n-\tstrbuf_addf(sb, \"%*s\", (int) extra, \"\");\n+\tstrbuf_addf(sb, \"%.*s\", (int) extra, \"\");\n }\n \n static void graph_output_padding_line(struct git_graph *graph,\n@@ -496,7 +496,7 @@ static void graph_output_pre_commit_line(struct git_graph *graph,\n \t\tstruct column *col = &graph->columns[i];\n \t\tif (col->commit == graph->commit) {\n \t\t\tseen_this = 1;\n-\t\t\tstrbuf_addf(sb, \"| %*s\", graph->expansion_row, \"\");\n+\t\t\tstrbuf_addf(sb, \"| %.*s\", graph->expansion_row, \"\");\n \t\t} else if (seen_this) {\n \t\t\tstrbuf_addstr(sb, \"\\\\ \");\n \t\t} else {\n-- \n1.5.5.1.375.g1becb\n"},{"id":"77031","messageId":"alpine.DEB.1.00.0805150947060.30431@racer","threadId":"13514","inReplyTo":"alpine.DEB.1.00.0805141522060.30431@racer","subject":"Re: [PATCH] graph.c: fix padding","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-05-15T08:50:05Z","receivedAt":"2008-05-15T08:50:05Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 14 May 2008, Johannes Schindelin wrote:\n\n> There were two instances of \"%*s\" which want to be \"%.*s\" instead.\n> \n> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> ---\n>  graph.c |    4 ++--\n>  1 files changed, 2 insertions(+), 2 deletions(-)\n\nI am a moron.\n\nRemember when I implemented a custom strbuf_vaddf() implementation that \ndid not suffer these workarounds we have for \"broken vaddf()\" on AIX and \nWindows?\n\nWell, I completely forgot about it, but I still have it in my personal \ntree.\n\nAnd this implementation did not support \"%*s\", since there was no user for \nit before the addition of the --graph stuff.\n\nSo I have this in my tree now instead of the \"fix\" I am replying to:\n\n-- snipsnap --\n[PATCH] strbuf_vaddf(): support %*s, too\n\nThe recent addition of graph.c broke things with our custom implementation\nof strbuf_vaddf(), because \"%*s\" was not yet supported (because it did not\nhave any users before).\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n strbuf.c |    6 ++++++\n 1 files changed, 6 insertions(+), 0 deletions(-)\n\ndiff --git a/strbuf.c b/strbuf.c\nindex 466f999..8c11f15 100644\n--- a/strbuf.c\n+++ b/strbuf.c\n@@ -155,6 +155,12 @@ void strbuf_vaddf(struct strbuf *sb, const char *fmt, va_list ap)\n \t\t\tfill = *p++;\n \t\tif (isdigit(*p))\n \t\t\tsize = (int)strtol(p, &p, 10);\n+\t\telse if (*p == '*') {\n+\t\t\tsize = va_arg(ap, int);\n+\t\t\tif (!fill)\n+\t\t\t\tfill = ' ';\n+\t\t\tp++;\n+\t\t}\n \t\telse if (!prefixcmp(p, \".*\")) {\n \t\t\tmax_size = va_arg(ap, int);\n \t\t\tp += 2;\n-- \n1.5.5.1.375.g1becb\n"}]}