On 01/02/17 at 04:19pm, Stefan Klinger wrote: > In hook definition files, repeated assignment to Description, Exec, > Type, and When silently overwrote previous settings. This yields a > warning now. > > Signed-off-by: Stefan Klinger <[email protected]> > --- > lib/libalpm/hook.c | 15 ++++++++++++++- > test/pacman/tests/TESTS | 4 ++++ > test/pacman/tests/hook-description-reused.py | 23 +++++++++++++++++++++++ > test/pacman/tests/hook-exec-reused.py | 22 ++++++++++++++++++++++ > test/pacman/tests/hook-type-reused.py | 22 ++++++++++++++++++++++ > test/pacman/tests/hook-when-reused.py | 22 ++++++++++++++++++++++ > 6 files changed, 107 insertions(+), 1 deletion(-) > create mode 100644 test/pacman/tests/hook-description-reused.py > create mode 100644 test/pacman/tests/hook-exec-reused.py > create mode 100644 test/pacman/tests/hook-type-reused.py > create mode 100644 test/pacman/tests/hook-when-reused.py > > diff --git a/lib/libalpm/hook.c b/lib/libalpm/hook.c > index ccde225e..51e74484 100644 > --- a/lib/libalpm/hook.c > +++ b/lib/libalpm/hook.c > @@ -267,6 +267,7 @@ static int _alpm_hook_parse_cb(const char *file, int line, > struct _alpm_hook_t *hook = ctx->hook; > > #define error(...) _alpm_log(handle, ALPM_LOG_ERROR, __VA_ARGS__); return 1; > +#define warning(...) _alpm_log(handle, ALPM_LOG_WARNING, __VA_ARGS__); > > if(!section && !key) { > error(_("error while reading hook %s: %s\n"), file, > strerror(errno)); > @@ -296,6 +297,9 @@ static int _alpm_hook_parse_cb(const char *file, int line, > error(_("hook %s line %d: invalid value %s\n"), > file, line, value); > } > } else if(strcmp(key, "Type") == 0) { > + if(t->type != 0) { > + warning(_("hook %s line %d: overwriting > previous definition of Type\n"), file, line); > + }
We use tabs for indenting C files, not spaces.
