From ee19666c39677570e3a5064fc535418d87693582 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 9 Feb 2025 05:14:36 +0000 Subject: [PATCH] [hb-shape/view] Allow --unicodes and --text if at least one is empty Useful for scripting. --- util/text-options.hh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/util/text-options.hh b/util/text-options.hh index 3043efc40..27169b063 100644 --- a/util/text-options.hh +++ b/util/text-options.hh @@ -110,6 +110,18 @@ parse_text (const char *name G_GNUC_UNUSED, { text_options_t *text_opts = (text_options_t *) data; + if (text_opts->text && !*arg) + { + // Empty --text provided but --unicodes called; ignore it. This is useful for scripting. + return true; + } + if (text_opts->text && !text_opts->text_len) + { + // Empty --unicodes provided as well as text; ignore it. This is useful for scripting. + g_free (text_opts->text); + text_opts->text = nullptr; + } + if (text_opts->text) { g_set_error (error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,