diff options
author | Peter Pettersson <boretrk@hotmail.com> | 2021-11-23 00:00:32 +0100 |
---|---|---|
committer | Peter Pettersson <boretrk@hotmail.com> | 2022-01-20 00:25:44 +0100 |
commit | 5388e0c1181b206531456a4c76a235c513e4952c (patch) | |
tree | 8b972efab63be72920a49cc00f02721926173126 | |
parent | 258df9c18d4876ad59a2cfa9d78a313f867d633e (diff) | |
download | libgit2-5388e0c1181b206531456a4c76a235c513e4952c.tar.gz |
diff_driver: split global_drivers array into separate elements
C99 doesn't allow structures with flexible length array to be
placed in an array.
-rw-r--r-- | src/diff_driver.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/diff_driver.c b/src/diff_driver.c index a20723fcc..5f25fdb44 100644 --- a/src/diff_driver.c +++ b/src/diff_driver.c @@ -51,11 +51,9 @@ struct git_diff_driver_registry { #define FORCE_DIFFABLE (GIT_DIFF_FORCE_TEXT | GIT_DIFF_FORCE_BINARY) -static git_diff_driver global_drivers[3] = { - { DIFF_DRIVER_AUTO, 0, 0, }, - { DIFF_DRIVER_BINARY, GIT_DIFF_FORCE_BINARY, 0 }, - { DIFF_DRIVER_TEXT, GIT_DIFF_FORCE_TEXT, 0 }, -}; +static git_diff_driver diff_driver_auto = { DIFF_DRIVER_AUTO, 0, 0 }; +static git_diff_driver diff_driver_binary = { DIFF_DRIVER_BINARY, GIT_DIFF_FORCE_BINARY, 0 }; +static git_diff_driver diff_driver_text = { DIFF_DRIVER_TEXT, GIT_DIFF_FORCE_TEXT, 0 }; git_diff_driver_registry *git_diff_driver_registry_new(void) { @@ -266,7 +264,7 @@ static int git_diff_driver_load( switch (git_config__get_bool_force(cfg, name.ptr, -1)) { case true: /* if diff.<driver>.binary is true, just return the binary driver */ - *out = &global_drivers[DIFF_DRIVER_BINARY]; + *out = &diff_driver_binary; goto done; case false: /* if diff.<driver>.binary is false, force binary checks off */ @@ -374,9 +372,9 @@ int git_diff_driver_lookup( else if (GIT_ATTR_IS_UNSPECIFIED(values[0])) /* just use the auto value */; else if (GIT_ATTR_IS_FALSE(values[0])) - *out = &global_drivers[DIFF_DRIVER_BINARY]; + *out = &diff_driver_binary; else if (GIT_ATTR_IS_TRUE(values[0])) - *out = &global_drivers[DIFF_DRIVER_TEXT]; + *out = &diff_driver_text; /* otherwise look for driver information in config and build driver */ else if ((error = git_diff_driver_load(out, repo, values[0])) < 0) { @@ -387,7 +385,7 @@ int git_diff_driver_lookup( } if (!*out) - *out = &global_drivers[DIFF_DRIVER_AUTO]; + *out = &diff_driver_auto; return error; } |