From d0f3e7f59719bdb6a2105ee85a8f3ee799741dab Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 10 Feb 2018 12:45:28 -0600 Subject: [PATCH] [util] Use setlinebuf() if present To work around mysterious bug on OS X. Fixes https://github.com/harfbuzz/harfbuzz/issues/727 --- configure.ac | 6 ++---- util/options.cc | 12 ++++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 12401f00..5a17cc1a 100644 --- a/configure.ac +++ b/configure.ac @@ -69,7 +69,7 @@ GTK_DOC_CHECK([1.15],[--flavour no-tmpl]) ]) # Functions and headers -AC_CHECK_FUNCS(atexit mprotect sysconf getpagesize mmap isatty newlocale strtod_l) +AC_CHECK_FUNCS(atexit mprotect sysconf getpagesize mmap isatty newlocale strtod_l setlinebuf) AC_CHECK_HEADERS(unistd.h sys/mman.h xlocale.h) # Compiler flags @@ -355,9 +355,7 @@ if $have_freetype; then AC_DEFINE(HAVE_FREETYPE, 1, [Have FreeType 2 library]) save_libs=$LIBS LIBS="$LIBS $FREETYPE_LIBS" - AC_CHECK_FUNCS(FT_Get_Var_Blend_Coordinates) - AC_CHECK_FUNCS(FT_Set_Var_Blend_Coordinates) - AC_CHECK_FUNCS(FT_Done_MM_Var) + AC_CHECK_FUNCS(FT_Get_Var_Blend_Coordinates FT_Set_Var_Blend_Coordinates FT_Done_MM_Var) LIBS=$save_libs fi AM_CONDITIONAL(HAVE_FREETYPE, $have_freetype) diff --git a/util/options.cc b/util/options.cc index d9486f8a..6d8064b9 100644 --- a/util/options.cc +++ b/util/options.cc @@ -780,7 +780,11 @@ text_options_t::get_line (unsigned int *len) gs = g_string_new (nullptr); } - setvbuf(fp, NULL, _IOLBF, BUFSIZ); //setlinebuf (fp); +#ifdef HAVE_SETLINEBUF + setlinebuf (fp); +#else + setvbuf(fp, NULL, _IOLBF, BUFSIZ); +#endif g_string_set_size (gs, 0); char buf[BUFSIZ]; @@ -819,7 +823,11 @@ output_options_t::get_file_handle (void) fail (false, "Cannot open output file `%s': %s", g_filename_display_name (output_file), strerror (errno)); - setvbuf(fp, NULL, _IOLBF, BUFSIZ); //setlinebuf (fp); +#ifdef HAVE_SETLINEBUF + setlinebuf (fp); +#else + setvbuf(fp, NULL, _IOLBF, BUFSIZ); +#endif return fp; } -- GitLab