[util/hb-shape] Treat as single-paragraph text other than provided by a file
Fixes https://github.com/harfbuzz/harfbuzz/issues/3129
This commit is contained in:
parent
8940409e3c
commit
d92ee726ce
|
@ -187,11 +187,11 @@ main (int argc, char **argv)
|
||||||
start_offset = argc == 2 && p[0] != '\0' && p[0] != ':' && p[1] == ':' && (p[2] == '\\' || p[2] == '/') ? 2 : 0;
|
start_offset = argc == 2 && p[0] != '\0' && p[0] != ':' && p[1] == ':' && (p[2] == '\\' || p[2] == '/') ? 2 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret |= main_func (argc, args, EOF);
|
ret |= main_func (argc, args);
|
||||||
fflush (stdout);
|
fflush (stdout);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return main_func (argc, argv, '\n');
|
return main_func (argc, argv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ main (int argc, char **argv)
|
||||||
args[argc++] = p = e;
|
args[argc++] = p = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
int result = main_func (argc, args, EOF);
|
int result = main_func (argc, args);
|
||||||
fprintf (stdout, result == 0 ? "success\n" : "failure\n");
|
fprintf (stdout, result == 0 ? "success\n" : "failure\n");
|
||||||
fflush (stdout);
|
fflush (stdout);
|
||||||
ret |= result;
|
ret |= result;
|
||||||
|
@ -163,5 +163,5 @@ main (int argc, char **argv)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return main_func (argc, argv, '\n');
|
return main_func (argc, argv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
template <typename consumer_t, typename font_options_t, typename text_options_t>
|
template <typename consumer_t, typename font_options_t, typename text_options_t>
|
||||||
int
|
int
|
||||||
main_font_text (int argc, char **argv, int eol = '\n')
|
main_font_text (int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
|
||||||
font_options_t font_opts;
|
font_options_t font_opts;
|
||||||
|
@ -60,7 +60,7 @@ main_font_text (int argc, char **argv, int eol = '\n')
|
||||||
|
|
||||||
unsigned int text_len;
|
unsigned int text_len;
|
||||||
const char *text;
|
const char *text;
|
||||||
while ((text = input.get_line (&text_len, eol)))
|
while ((text = input.get_line (&text_len)))
|
||||||
consumer.consume_line (text, text_len, input.text_before, input.text_after);
|
consumer.consume_line (text, text_len, input.text_before, input.text_after);
|
||||||
|
|
||||||
consumer.finish (&font_opts);
|
consumer.finish (&font_opts);
|
||||||
|
|
|
@ -23,7 +23,7 @@ struct text_options_t
|
||||||
"Only one of text and text-file can be set");
|
"Only one of text and text-file can be set");
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *get_line (unsigned int *len, int eol = '\n');
|
const char *get_line (unsigned int *len);
|
||||||
|
|
||||||
char *text_before = nullptr;
|
char *text_before = nullptr;
|
||||||
char *text_after = nullptr;
|
char *text_after = nullptr;
|
||||||
|
@ -35,8 +35,6 @@ struct text_options_t
|
||||||
private:
|
private:
|
||||||
FILE *fp = nullptr;
|
FILE *fp = nullptr;
|
||||||
GString *gs = nullptr;
|
GString *gs = nullptr;
|
||||||
char *line = nullptr;
|
|
||||||
unsigned int line_len = UINT_MAX;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,41 +116,22 @@ parse_unicodes (const char *name G_GNUC_UNUSED,
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
text_options_t::get_line (unsigned int *len, int eol)
|
text_options_t::get_line (unsigned int *len)
|
||||||
{
|
{
|
||||||
if (text)
|
if (text)
|
||||||
{
|
{
|
||||||
if (!line)
|
if (text_len == -2)
|
||||||
{
|
{
|
||||||
line = text;
|
|
||||||
line_len = text_len;
|
|
||||||
}
|
|
||||||
if (line_len == UINT_MAX)
|
|
||||||
line_len = strlen (line);
|
|
||||||
|
|
||||||
if (!line_len) {
|
|
||||||
*len = 0;
|
*len = 0;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *ret = line;
|
if (text_len == -1)
|
||||||
const char *p = (const char *) memchr (line, eol, line_len);
|
text_len = strlen (text);
|
||||||
unsigned int ret_len;
|
|
||||||
if (!p)
|
|
||||||
{
|
|
||||||
ret_len = line_len;
|
|
||||||
line += ret_len;
|
|
||||||
line_len = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret_len = p - ret;
|
|
||||||
line += ret_len + 1;
|
|
||||||
line_len -= ret_len + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
*len = ret_len;
|
*len = text_len;
|
||||||
return ret;
|
text_len = -2;
|
||||||
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fp)
|
if (!fp)
|
||||||
|
@ -177,7 +156,7 @@ text_options_t::get_line (unsigned int *len, int eol)
|
||||||
while (fgets (buf, sizeof (buf), fp))
|
while (fgets (buf, sizeof (buf), fp))
|
||||||
{
|
{
|
||||||
unsigned bytes = strlen (buf);
|
unsigned bytes = strlen (buf);
|
||||||
if (bytes && (int) (unsigned char) buf[bytes - 1] == eol)
|
if (bytes && buf[bytes - 1] == '\n')
|
||||||
{
|
{
|
||||||
bytes--;
|
bytes--;
|
||||||
g_string_append_len (gs, buf, bytes);
|
g_string_append_len (gs, buf, bytes);
|
||||||
|
|
Loading…
Reference in New Issue