From a75c1b125159f6cfb6b652a9ec40803f7c7e3f71 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 16 Sep 2011 01:16:41 -0400 Subject: [PATCH] Move code around --- util/options.cc | 27 +++++++++++++++++++++++++-- util/options.hh | 20 +------------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/util/options.cc b/util/options.cc index 4e7582743..ff596d040 100644 --- a/util/options.cc +++ b/util/options.cc @@ -121,9 +121,10 @@ option_parser_t::parse (int *argc, char ***argv) GError *parse_error = NULL; if (!g_option_context_parse (context, argc, argv, &parse_error)) { - if (parse_error != NULL) + if (parse_error != NULL) { fail (TRUE, "%s", parse_error->message); - else + //g_error_free (parse_error); + } else fail (TRUE, "Option parse error"); } } @@ -543,3 +544,25 @@ text_options_t::get_line (unsigned int *len) *len = ret_len; return ret; } + + +FILE * +output_options_t::get_file_handle (void) +{ + if (fp) + return fp; + + if (output_file) + fp = fopen (output_file, "wb"); + else { +#if HAVE_IO_H + _setmode (fileno (stdout), O_BINARY); +#endif + fp = stdout; + } + if (!fp) + fail (FALSE, "Cannot open output file `%s': %s", + g_filename_display_name (output_file), strerror (errno)); + + return fp; +} diff --git a/util/options.hh b/util/options.hh index 623e25a9d..c521e75d2 100644 --- a/util/options.hh +++ b/util/options.hh @@ -237,25 +237,7 @@ struct output_options_t : option_group_t output_file = NULL; /* STDOUT */ } - FILE *get_file_handle (void) - { - if (fp) - return fp; - - if (output_file) - fp = fopen (output_file, "wb"); - else { -#if HAVE_IO_H - _setmode (fileno (stdout), O_BINARY); -#endif - fp = stdout; - } - if (!fp) - fail (FALSE, "Cannot open output file `%s': %s", - g_filename_display_name (output_file), strerror (errno)); - - return fp; - } + FILE *get_file_handle (void); virtual void init (const font_options_t *font_opts) = 0; virtual void consume_line (hb_buffer_t *buffer,