[util] Move text options into text_options_t
Remove now empty options.cc.
diff --git a/util/Makefile.sources b/util/Makefile.sources
index 56c4556..470fd3c 100644
--- a/util/Makefile.sources
+++ b/util/Makefile.sources
@@ -6,11 +6,11 @@
helper-cairo-ansi.hh \
helper-cairo.hh \
main-font-text.hh \
- options.cc \
options.hh \
output-options.hh \
shape-consumer.hh \
shape-options.hh \
+ text-options.hh \
view-cairo.hh \
view-options.hh \
$(NULL)
@@ -20,22 +20,22 @@
font-options.hh \
hb-shape.cc \
main-font-text.hh \
- options.cc \
options.hh \
output-options.hh \
shape-consumer.hh \
shape-format.hh \
shape-options.hh \
+ text-options.hh \
$(NULL)
HB_SUBSET_CLI_sources = \
face-options.hh \
hb-subset.cc \
main-font-text.hh \
- options.cc \
options.hh \
output-options.hh \
subset-options.hh \
+ text-options.hh \
$(NULL)
HB_OT_SHAPE_CLOSURE_sources = \
@@ -43,6 +43,6 @@
font-options.hh \
hb-ot-shape-closure.cc \
main-font-text.hh \
- options.cc \
options.hh \
+ text-options.hh \
$(NULL)
diff --git a/util/hb-ot-shape-closure.cc b/util/hb-ot-shape-closure.cc
index b9cab98..41d18b5 100644
--- a/util/hb-ot-shape-closure.cc
+++ b/util/hb-ot-shape-closure.cc
@@ -26,6 +26,7 @@
#include "shape-options.hh"
#include "font-options.hh"
+#include "text-options.hh"
#include "main-font-text.hh"
const unsigned DEFAULT_FONT_SIZE = FONT_SIZE_NONE;
diff --git a/util/hb-shape.cc b/util/hb-shape.cc
index 29f9917..d9c727f 100644
--- a/util/hb-shape.cc
+++ b/util/hb-shape.cc
@@ -25,9 +25,11 @@
* Google Author(s): Behdad Esfahbod
*/
+#include "output-options.hh"
+#include "font-options.hh"
+#include "text-options.hh"
#include "shape-consumer.hh"
#include "shape-format.hh"
-#include "output-options.hh"
#include "main-font-text.hh"
const unsigned DEFAULT_FONT_SIZE = FONT_SIZE_UPEM;
diff --git a/util/hb-subset.cc b/util/hb-subset.cc
index b5f3f7f..da808f9 100644
--- a/util/hb-subset.cc
+++ b/util/hb-subset.cc
@@ -30,6 +30,7 @@
#include "subset-options.hh"
#include "output-options.hh"
#include "face-options.hh"
+#include "text-options.hh"
#include "main-font-text.hh"
/*
diff --git a/util/hb-view.cc b/util/hb-view.cc
index ec148ec..5d2dfe5 100644
--- a/util/hb-view.cc
+++ b/util/hb-view.cc
@@ -27,6 +27,8 @@
#include "shape-consumer.hh"
#include "view-cairo.hh"
+#include "font-options.hh"
+#include "text-options.hh"
#include "main-font-text.hh"
const unsigned DEFAULT_FONT_SIZE = 256;
diff --git a/util/meson.build b/util/meson.build
index 3773e68..fdab620 100644
--- a/util/meson.build
+++ b/util/meson.build
@@ -1,21 +1,17 @@
hb_view_sources = [
'hb-view.cc',
- 'options.cc',
]
hb_shape_sources = [
'hb-shape.cc',
- 'options.cc',
]
hb_ot_shape_closure_sources = [
'hb-ot-shape-closure.cc',
- 'options.cc',
]
hb_subset_cli_sources = [
'hb-subset.cc',
- 'options.cc',
]
util_deps = [freetype_dep, cairo_dep, cairo_ft_dep, glib_dep]
diff --git a/util/options.hh b/util/options.hh
index 246a7c6..ff542f4 100644
--- a/util/options.hh
+++ b/util/options.hh
@@ -218,49 +218,6 @@
}
}
-// XXXXXXXXXXXX
-
-
-struct text_options_t
-{
- ~text_options_t ()
- {
- g_free (text_before);
- g_free (text_after);
- g_free (text);
- g_free (text_file);
- if (gs)
- g_string_free (gs, true);
- if (fp && fp != stdin)
- fclose (fp);
- }
-
- void add_options (option_parser_t *parser);
-
- void post_parse (GError **error G_GNUC_UNUSED)
- {
- if (text && text_file)
- g_set_error (error,
- G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,
- "Only one of text and text-file can be set");
- }
-
- const char *get_line (unsigned int *len, int eol = '\n');
-
- char *text_before = nullptr;
- char *text_after = nullptr;
-
- int text_len = -1;
- char *text = nullptr;
- char *text_file = nullptr;
-
- private:
- FILE *fp = nullptr;
- GString *gs = nullptr;
- char *line = nullptr;
- unsigned int line_len = UINT_MAX;
-};
-
/* fallback implementation for scalbn()/scalbnf() for pre-2013 MSVC */
#if defined (_MSC_VER) && (_MSC_VER < 1800)
diff --git a/util/options.cc b/util/text-options.hh
similarity index 74%
rename from util/options.cc
rename to util/text-options.hh
index 66ddaa8..ad72d73 100644
--- a/util/options.cc
+++ b/util/text-options.hh
@@ -1,30 +1,45 @@
-/*
- * Copyright © 2011,2012 Google, Inc.
- *
- * This is part of HarfBuzz, a text shaping library.
- *
- * Permission is hereby granted, without written agreement and without
- * license or royalty fees, to use, copy, modify, and distribute this
- * software and its documentation for any purpose, provided that the
- * above copyright notice and the following two paragraphs appear in
- * all copies of this software.
- *
- * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
- * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
- * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
- * DAMAGE.
- *
- * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
- * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- *
- * Google Author(s): Behdad Esfahbod
- */
-#include "options.hh"
+struct text_options_t
+{
+ ~text_options_t ()
+ {
+ g_free (text_before);
+ g_free (text_after);
+ g_free (text);
+ g_free (text_file);
+ if (gs)
+ g_string_free (gs, true);
+ if (fp && fp != stdin)
+ fclose (fp);
+ }
+
+ void add_options (option_parser_t *parser);
+
+ void post_parse (GError **error G_GNUC_UNUSED)
+ {
+ if (text && text_file)
+ g_set_error (error,
+ G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE,
+ "Only one of text and text-file can be set");
+ }
+
+ const char *get_line (unsigned int *len, int eol = '\n');
+
+ char *text_before = nullptr;
+ char *text_after = nullptr;
+
+ int text_len = -1;
+ char *text = nullptr;
+ char *text_file = nullptr;
+
+ private:
+ FILE *fp = nullptr;
+ GString *gs = nullptr;
+ char *line = nullptr;
+ unsigned int line_len = UINT_MAX;
+};
+
+
static gboolean
parse_text (const char *name G_GNUC_UNUSED,
const char *arg,
@@ -102,29 +117,11 @@
return true;
}
-void
-text_options_t::add_options (option_parser_t *parser)
-{
- GOptionEntry entries[] =
- {
- {"text", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_text, "Set input text", "string"},
- {"text-file", 0, 0, G_OPTION_ARG_STRING, &this->text_file, "Set input text file-name\n\n If no text is provided, standard input is used for input.\n", "filename"},
- {"unicodes", 'u', 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_unicodes, "Set input Unicode codepoints", "list of hex numbers"},
- {"text-before", 0, 0, G_OPTION_ARG_STRING, &this->text_before, "Set text context before each line", "string"},
- {"text-after", 0, 0, G_OPTION_ARG_STRING, &this->text_after, "Set text context after each line", "string"},
- {nullptr}
- };
- parser->add_group (entries,
- "text",
- "Text options:",
- "Options for the input text",
- this);
-}
-
const char *
text_options_t::get_line (unsigned int *len, int eol)
{
- if (text) {
+ if (text)
+ {
if (!line)
{
line = text;
@@ -141,11 +138,14 @@
const char *ret = line;
const char *p = (const char *) memchr (line, eol, line_len);
unsigned int ret_len;
- if (!p) {
+ if (!p)
+ {
ret_len = line_len;
line += ret_len;
line_len = 0;
- } else {
+ }
+ else
+ {
ret_len = p - ret;
line += ret_len + 1;
line_len -= ret_len + 1;
@@ -155,7 +155,8 @@
return ret;
}
- if (!fp) {
+ if (!fp)
+ {
if (!text_file)
fail (true, "At least one of text or text-file must be set");
@@ -189,3 +190,22 @@
*len = gs->len;
return !*len && feof (fp) ? nullptr : gs->str;
}
+
+void
+text_options_t::add_options (option_parser_t *parser)
+{
+ GOptionEntry entries[] =
+ {
+ {"text", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_text, "Set input text", "string"},
+ {"text-file", 0, 0, G_OPTION_ARG_STRING, &this->text_file, "Set input text file-name\n\n If no text is provided, standard input is used for input.\n", "filename"},
+ {"unicodes", 'u', 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_unicodes, "Set input Unicode codepoints", "list of hex numbers"},
+ {"text-before", 0, 0, G_OPTION_ARG_STRING, &this->text_before, "Set text context before each line", "string"},
+ {"text-after", 0, 0, G_OPTION_ARG_STRING, &this->text_after, "Set text context after each line", "string"},
+ {nullptr}
+ };
+ parser->add_group (entries,
+ "text",
+ "Text options:",
+ "Options for the input text",
+ this);
+}