Johannes Sixt <[email protected]> writes:
>> I am not sure what negative impact you think the macro-ness would
>> have to the validity of the result from this test balloon. An old
>> compiler that does not understand designated initializer syntax
>> would fail to compile both the same way, no?
>>
>> struct strbuf buf0 = STRBUF_INIT;
>> struct strbuf buf1 = { .alloc = 0, .len = 0, .buf = strbuf_slopbuf };
>
> I said it is uninteresting, not that there is a negative impact. There
> is simply nothing gained for strbuf users: They would use STRBUF_INIT
> before and after the change and would not benefit from designated
> initializers.
>
> This change may serve well as a test balloon, but not as an example of
> the sort of changes that we would want to see later (of the kind
> "change FOO_INIT macro to use designated initializers"; they are just
> code churn).
Oh, absolutely.
Here is another possible test balloon, that may actually be useful
as an example. I think there is a topic in flight that touches this
array, unfortunately, so I probably would find another one that is
more stable for a real follow-up patch to the one from Peff.
diff.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/diff.c b/diff.c
index 00b4c86698..b3864a2e03 100644
--- a/diff.c
+++ b/diff.c
@@ -47,15 +47,15 @@ static long diff_algorithm;
static unsigned ws_error_highlight_default = WSEH_NEW;
static char diff_colors[][COLOR_MAXLEN] = {
- GIT_COLOR_RESET,
- GIT_COLOR_NORMAL, /* CONTEXT */
- GIT_COLOR_BOLD, /* METAINFO */
- GIT_COLOR_CYAN, /* FRAGINFO */
- GIT_COLOR_RED, /* OLD */
- GIT_COLOR_GREEN, /* NEW */
- GIT_COLOR_YELLOW, /* COMMIT */
- GIT_COLOR_BG_RED, /* WHITESPACE */
- GIT_COLOR_NORMAL, /* FUNCINFO */
+ [DIFF_RESET] = GIT_COLOR_RESET,
+ [DIFF_CONTEXT] = GIT_COLOR_NORMAL,
+ [DIFF_METAINFO] = GIT_COLOR_BOLD,
+ [DIFF_FRAGINFO] = GIT_COLOR_CYAN,
+ [DIFF_FILE_OLD] = GIT_COLOR_RED,
+ [DIFF_FILE_NEW] = GIT_COLOR_GREEN,
+ [DIFF_COMMIT] = GIT_COLOR_YELLOW,
+ [DIFF_WHITESPACE] = GIT_COLOR_BG_RED,
+ [DIFF_FUNCINFO] = GIT_COLOR_NORMAL,
};
static NORETURN void die_want_option(const char *option_name)