[util/hb-shape] Fix use of EOF as end-of-line
EOF is -1, which was being treated as a valid char (255). Use int instead.
This commit is contained in:
parent
ee7473b8a4
commit
05cf81283b
|
@ -166,5 +166,5 @@ main (int argc, char **argv)
|
|||
return hb_test_run ();
|
||||
}
|
||||
#else
|
||||
int main () {}
|
||||
int main (int argc, char **argv) {}
|
||||
#endif
|
||||
|
|
|
@ -47,7 +47,7 @@ locale_to_utf8 (char *s)
|
|||
return t;
|
||||
}
|
||||
|
||||
template <typename consumer_t, int default_font_size, int subpixel_bits, char eol = '\n'>
|
||||
template <typename consumer_t, int default_font_size, int subpixel_bits, int eol = '\n'>
|
||||
struct main_font_text_t
|
||||
{
|
||||
main_font_text_t ()
|
||||
|
|
|
@ -797,7 +797,7 @@ font_options_t::get_font () const
|
|||
|
||||
|
||||
const char *
|
||||
text_options_t::get_line (unsigned int *len, char eol)
|
||||
text_options_t::get_line (unsigned int *len, int eol)
|
||||
{
|
||||
if (text) {
|
||||
if (!line)
|
||||
|
@ -848,9 +848,11 @@ text_options_t::get_line (unsigned int *len, char eol)
|
|||
|
||||
g_string_set_size (gs, 0);
|
||||
char buf[BUFSIZ];
|
||||
while (fgets (buf, sizeof (buf), fp)) {
|
||||
unsigned int bytes = strlen (buf);
|
||||
if (bytes && buf[bytes - 1] == eol) {
|
||||
while (fgets (buf, sizeof (buf), fp))
|
||||
{
|
||||
unsigned bytes = strlen (buf);
|
||||
if (bytes && (int) (unsigned char) buf[bytes - 1] == eol)
|
||||
{
|
||||
bytes--;
|
||||
g_string_append_len (gs, buf, bytes);
|
||||
break;
|
||||
|
@ -858,8 +860,7 @@ text_options_t::get_line (unsigned int *len, char eol)
|
|||
g_string_append_len (gs, buf, bytes);
|
||||
}
|
||||
if (ferror (fp))
|
||||
fail (false, "Failed reading text: %s",
|
||||
strerror (errno));
|
||||
fail (false, "Failed reading text: %s", strerror (errno));
|
||||
*len = gs->len;
|
||||
return !*len && feof (fp) ? nullptr : gs->str;
|
||||
}
|
||||
|
|
|
@ -563,7 +563,7 @@ struct text_options_t : option_group_t
|
|||
"Only one of text and text-file can be set");
|
||||
}
|
||||
|
||||
const char *get_line (unsigned int *len, char eol = '\n');
|
||||
const char *get_line (unsigned int *len, int eol = '\n');
|
||||
|
||||
char *text_before;
|
||||
char *text_after;
|
||||
|
|
Loading…
Reference in New Issue