This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=77cd6c000d433c8ebe6dfcf51579ed0f985e45ee commit 77cd6c000d433c8ebe6dfcf51579ed0f985e45ee Author: Guillem Jover <[email protected]> AuthorDate: Fri May 10 00:18:47 2024 +0200 libdpkg: Refactor lax problem reporting into parse_lax_problem() function This function checks whether need to report a warning or an error depending on whether we are currently in one of the specific lax modes, as specified by the passed flags. --- lib/dpkg/parse.c | 12 ++++-------- lib/dpkg/parsedump.h | 4 ++++ lib/dpkg/parsehelp.c | 17 +++++++++++++++++ 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c index 2da543cc2..120831a86 100644 --- a/lib/dpkg/parse.c +++ b/lib/dpkg/parse.c @@ -684,14 +684,10 @@ parse_stanza(struct parsedb_state *ps, struct field_state *fs, fs->valuestart = ps->dataptr - 1; for (;;) { if (c == '\n' || c == MSDOS_EOF_CHAR) { - if (blank_line) { - if (ps->flags & pdb_lax_stanza_parser) - parse_warn(ps, _("blank line in value of field '%.*s'"), - fs->fieldlen, fs->fieldstart); - else - parse_error(ps, _("blank line in value of field '%.*s'"), - fs->fieldlen, fs->fieldstart); - } + if (blank_line) + parse_lax_problem(ps, pdb_lax_stanza_parser, + _("blank line in value of field '%.*s'"), + fs->fieldlen, fs->fieldstart); ps->lno++; if (parse_at_eof(ps)) diff --git a/lib/dpkg/parsedump.h b/lib/dpkg/parsedump.h index c43da7ff6..9eea5eee9 100644 --- a/lib/dpkg/parsedump.h +++ b/lib/dpkg/parsedump.h @@ -160,6 +160,10 @@ void parse_error(struct parsedb_state *ps, const char *fmt, ...) void parse_warn(struct parsedb_state *ps, const char *fmt, ...) DPKG_ATTR_PRINTF(2); void +parse_lax_problem(struct parsedb_state *ps, enum parsedbflags flags_lax, + const char *fmt, ...) + DPKG_ATTR_PRINTF(3); +void parse_problem(struct parsedb_state *ps, const char *fmt, ...) DPKG_ATTR_PRINTF(2); diff --git a/lib/dpkg/parsehelp.c b/lib/dpkg/parsehelp.c index b7f428059..a999b5e78 100644 --- a/lib/dpkg/parsehelp.c +++ b/lib/dpkg/parsehelp.c @@ -79,6 +79,23 @@ parse_warn(struct parsedb_state *ps, const char *fmt, ...) va_end(args); } +void +parse_lax_problem(struct parsedb_state *ps, enum parsedbflags flags_lax, + const char *fmt, ...) +{ + va_list args; + const char *str; + + va_start(args, fmt); + str = parse_error_msg(ps, fmt, args); + va_end(args); + + if (ps->flags & flags_lax) + warning("%s", str); + else + ohshit("%s", str); +} + void parse_problem(struct parsedb_state *ps, const char *fmt, ...) { -- Dpkg.Org's dpkg

