From 92b85749f2b284a370fff3905c0a554bbbc7b323 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Wed, 28 Jul 2021 15:56:53 +0200 Subject: [PATCH] [util] Strip quotes when parsing features When running in batch mode, the quotes are not stripped by the shell and end up in the feature string. This breaks one of the AOTS tests. Alternatively, we can remove the quotes from the test files, not sure which is less hacky, though! --- test/shaping/data/aots/tests/gsub3_1_simple.tests | 2 +- util/options.cc | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/test/shaping/data/aots/tests/gsub3_1_simple.tests b/test/shaping/data/aots/tests/gsub3_1_simple.tests index b8a28d15a..5e65ba055 100644 --- a/test/shaping/data/aots/tests/gsub3_1_simple.tests +++ b/test/shaping/data/aots/tests/gsub3_1_simple.tests @@ -1 +1 @@ -#../fonts/gsub3_1_simple_f1.otf:--features="-test[1],test[3],test[5]=2,test[7]=3,-test[9],test[11]" --no-clusters --no-glyph-names --no-positions:U+0011,U+0012,U+0011,U+0012,U+0011,U+0012,U+0011,U+0012,U+0011,U+0012,U+0011,U+0012,U+0011:[17|18|17|20|17|21|17|22|17|18|17|20|17] +../fonts/gsub3_1_simple_f1.otf:--features="-test[1],test[3],test[5]=2,test[7]=3,-test[9],test[11]" --no-clusters --no-glyph-names --no-positions:U+0011,U+0012,U+0011,U+0012,U+0011,U+0012,U+0011,U+0012,U+0011,U+0012,U+0011,U+0012,U+0011:[17|18|17|20|17|21|17|22|17|18|17|20|17] diff --git a/util/options.cc b/util/options.cc index 42d3c6cc7..6b1a6d4a9 100644 --- a/util/options.cc +++ b/util/options.cc @@ -258,12 +258,20 @@ parse_features (const char *name G_GNUC_UNUSED, { shape_options_t *shape_opts = (shape_options_t *) data; char *s = (char *) arg; + size_t l = strlen (s); char *p; shape_opts->num_features = 0; g_free (shape_opts->features); shape_opts->features = nullptr; + /* if the string is quoted, strip the quotes */ + if (s[0] == s[l - 1] && (s[0] == '\"' || s[0] == '\'')) + { + s[l - 1] = '\0'; + s++; + } + if (!*s) return true;