未验证 提交 159ddb87 编写于 作者: E Ebrahim Byagowi 提交者: GitHub

Treat - just as /dev/stdin and remove one extra file reader (#1065)

上级 b2a18791
......@@ -647,29 +647,20 @@ font_options_t::get_font (void) const
if (!font_file)
fail (true, "No font file set");
if (0 == strcmp (font_file, "-")) {
/* read it */
GString *gs = g_string_new (nullptr);
char buf[BUFSIZ];
const char *font_path = font_file;
if (0 == strcmp (font_path, "-"))
{
#if defined(_WIN32) || defined(__CYGWIN__)
setmode (fileno (stdin), O_BINARY);
font_path = "STDIN";
#else
font_path = "/dev/stdin";
#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 ())
fail (false, "No such file or directory");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册