From 50379fbb1517387d91b3ec4cc55a7500dd09b436 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Wed, 28 Jul 2021 16:13:49 +0200 Subject: [PATCH] =?UTF-8?q?[util]=20Don=E2=80=99t=20split=20text=20at=20ne?= =?UTF-8?q?w=20lines=20in=20batch=20mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In batch mode (which is used for testing) we are probably not interested in splitting text into lines as we could have split the string into different tests. This fixes a bunch of AOTS tests that use newlines as input. --- .../data/aots/tests/lookupflag_ignore_attach.tests | 10 +++++----- util/hb-shape.cc | 2 +- util/main-font-text.hh | 4 ++-- util/options.cc | 6 +++--- util/options.hh | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/test/shaping/data/aots/tests/lookupflag_ignore_attach.tests b/test/shaping/data/aots/tests/lookupflag_ignore_attach.tests index 55ae5385e..6534fc09f 100644 --- a/test/shaping/data/aots/tests/lookupflag_ignore_attach.tests +++ b/test/shaping/data/aots/tests/lookupflag_ignore_attach.tests @@ -1,5 +1,5 @@ -#../fonts/lookupflag_ignore_attach_f1.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+000A,U+000B,U+000D,U+001A,U+000A:[10|15|10] -#../fonts/lookupflag_ignore_attach_f1.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+000A,U+000B,U+0015,U+000D,U+0016,U+0017,U+001D,U+001A,U+000A:[10|15|21|22|23|29|10] -#../fonts/lookupflag_ignore_attach_f1.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+000A,U+000B,U+0015,U+000D,U+0016,U+001B,U+001A,U+000A:[10|11|21|13|22|27|26|10] -#../fonts/lookupflag_ignore_attach_f1.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+000A,U+000B,U+001B,U+000D,U+0016,U+0017,U+001A,U+000A:[10|11|27|13|22|23|26|10] -#../fonts/lookupflag_ignore_attach_f1.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+000A,U+000B,U+001B,U+000D,U+000E,U+0017,U+001A,U+000A:[10|11|27|13|14|23|26|10] +../fonts/lookupflag_ignore_attach_f1.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+000A,U+000B,U+000D,U+001A,U+000A:[10|15|10] +../fonts/lookupflag_ignore_attach_f1.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+000A,U+000B,U+0015,U+000D,U+0016,U+0017,U+001D,U+001A,U+000A:[10|15|21|22|23|29|10] +../fonts/lookupflag_ignore_attach_f1.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+000A,U+000B,U+0015,U+000D,U+0016,U+001B,U+001A,U+000A:[10|11|21|13|22|27|26|10] +../fonts/lookupflag_ignore_attach_f1.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+000A,U+000B,U+001B,U+000D,U+0016,U+0017,U+001A,U+000A:[10|11|27|13|22|23|26|10] +../fonts/lookupflag_ignore_attach_f1.otf:--features="test" --no-clusters --no-glyph-names --no-positions:U+000A,U+000B,U+001B,U+000D,U+000E,U+0017,U+001A,U+000A:[10|11|27|13|14|23|26|10] diff --git a/util/hb-shape.cc b/util/hb-shape.cc index 01b3d4551..f34813325 100644 --- a/util/hb-shape.cc +++ b/util/hb-shape.cc @@ -165,7 +165,7 @@ main (int argc, char **argv) { size_t l = strlen (buf); if (l && buf[l - 1] == '\n') buf[l - 1] = '\0'; - main_font_text_t, FONT_SIZE_UPEM, 0> driver; + main_font_text_t, FONT_SIZE_UPEM, 0, EOF> driver; char *args[32]; argc = 0; char *p = buf, *e; diff --git a/util/main-font-text.hh b/util/main-font-text.hh index 36b654bc1..871a30465 100644 --- a/util/main-font-text.hh +++ b/util/main-font-text.hh @@ -47,7 +47,7 @@ locale_to_utf8 (char *s) return t; } -template +template struct main_font_text_t { main_font_text_t () @@ -77,7 +77,7 @@ struct main_font_text_t unsigned int text_len; const char *text; - while ((text = input.get_line (&text_len))) + while ((text = input.get_line (&text_len, eol))) consumer.consume_line (text, text_len, input.text_before, input.text_after); consumer.finish (&font_opts); diff --git a/util/options.cc b/util/options.cc index 6b1a6d4a9..2caaea363 100644 --- a/util/options.cc +++ b/util/options.cc @@ -771,7 +771,7 @@ font_options_t::get_font () const const char * -text_options_t::get_line (unsigned int *len) +text_options_t::get_line (unsigned int *len, char eol) { if (text) { if (!line) @@ -788,7 +788,7 @@ text_options_t::get_line (unsigned int *len) } const char *ret = line; - const char *p = (const char *) memchr (line, '\n', line_len); + const char *p = (const char *) memchr (line, eol, line_len); unsigned int ret_len; if (!p) { ret_len = line_len; @@ -824,7 +824,7 @@ text_options_t::get_line (unsigned int *len) char buf[BUFSIZ]; while (fgets (buf, sizeof (buf), fp)) { unsigned int bytes = strlen (buf); - if (bytes && buf[bytes - 1] == '\n') { + if (bytes && buf[bytes - 1] == eol) { bytes--; g_string_append_len (gs, buf, bytes); break; diff --git a/util/options.hh b/util/options.hh index 69465d0ce..846137297 100644 --- a/util/options.hh +++ b/util/options.hh @@ -548,7 +548,7 @@ struct text_options_t : option_group_t "Only one of text and text-file can be set"); } - const char *get_line (unsigned int *len); + const char *get_line (unsigned int *len, char eol); char *text_before; char *text_after;