Treat - just as /dev/stdin and remove one extra file reader (#1065)
This commit is contained in:
parent
b2a1879187
commit
159ddb8729
|
@ -647,29 +647,20 @@ font_options_t::get_font (void) const
|
||||||
if (!font_file)
|
if (!font_file)
|
||||||
fail (true, "No font file set");
|
fail (true, "No font file set");
|
||||||
|
|
||||||
if (0 == strcmp (font_file, "-")) {
|
const char *font_path = font_file;
|
||||||
/* read it */
|
|
||||||
GString *gs = g_string_new (nullptr);
|
if (0 == strcmp (font_path, "-"))
|
||||||
char buf[BUFSIZ];
|
{
|
||||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||||
setmode (fileno (stdin), O_BINARY);
|
setmode (fileno (stdin), O_BINARY);
|
||||||
|
font_path = "STDIN";
|
||||||
|
#else
|
||||||
|
font_path = "/dev/stdin";
|
||||||
#endif
|
#endif
|
||||||
while (!feof (stdin)) {
|
|
||||||
size_t ret = fread (buf, 1, sizeof (buf), stdin);
|
|
||||||
if (ferror (stdin))
|
|
||||||
fail (false, "Failed reading font from standard input: %s",
|
|
||||||
strerror (errno));
|
|
||||||
g_string_append_len (gs, buf, ret);
|
|
||||||
}
|
|
||||||
unsigned int len = gs->len;
|
|
||||||
char *font_data = g_string_free (gs, false);
|
|
||||||
blob = hb_blob_create (font_data, len,
|
|
||||||
HB_MEMORY_MODE_WRITABLE, font_data,
|
|
||||||
(hb_destroy_func_t) g_free);
|
|
||||||
} else {
|
|
||||||
blob = hb_blob_create_from_file (font_file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blob = hb_blob_create_from_file (font_path);
|
||||||
|
|
||||||
if (blob == hb_blob_get_empty ())
|
if (blob == hb_blob_get_empty ())
|
||||||
fail (false, "No such file or directory");
|
fail (false, "No such file or directory");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue