[util] Use setlinebuf() if present

To work around mysterious bug on OS X.

Fixes https://github.com/harfbuzz/harfbuzz/issues/727
This commit is contained in:
Behdad Esfahbod 2018-02-10 12:45:28 -06:00
parent ad575a5f47
commit d0f3e7f597
2 changed files with 12 additions and 6 deletions

View File

@ -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)

View File

@ -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;
}