[util] Undo treat as single-paragraph text provided on cmdline
Reverts d92ee726ce
except that it does so even in batch mode.
Am going to add a --single-par mode that will affect all input
modes.
Part of https://github.com/harfbuzz/harfbuzz/issues/3129
Fixes https://github.com/harfbuzz/harfbuzz/issues/3298
This commit is contained in:
parent
903a6baece
commit
b58afe586f
|
@ -82,6 +82,8 @@ struct text_options_t
|
||||||
private:
|
private:
|
||||||
FILE *in_fp = nullptr;
|
FILE *in_fp = nullptr;
|
||||||
GString *gs = nullptr;
|
GString *gs = nullptr;
|
||||||
|
char *line = nullptr;
|
||||||
|
unsigned line_len = UINT_MAX;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct shape_text_options_t : text_options_t
|
struct shape_text_options_t : text_options_t
|
||||||
|
@ -273,18 +275,38 @@ text_options_t::get_line (unsigned int *len)
|
||||||
{
|
{
|
||||||
if (text)
|
if (text)
|
||||||
{
|
{
|
||||||
if (text_len == -2)
|
if (!line)
|
||||||
|
{
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text_len == -1)
|
const char *ret = line;
|
||||||
text_len = strlen (text);
|
const char *p = (const char *) memchr (line, '\n', line_len);
|
||||||
|
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 = text_len;
|
*len = ret_len;
|
||||||
text_len = -2;
|
return ret;
|
||||||
return text;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_string_set_size (gs, 0);
|
g_string_set_size (gs, 0);
|
||||||
|
|
Loading…
Reference in New Issue