Fix more of the text output code (paren handling).

Update unit tests to write lines from README.md.
This commit is contained in:
Michael R Sweet
2021-05-31 21:34:53 -04:00
parent 05df5919cd
commit cc250e7201
2 changed files with 19 additions and 12 deletions

View File

@@ -1462,7 +1462,6 @@ write_string(pdfio_stream_t *st, // I - Stream
{
// ASCII string...
const char *start = s; // Start of fragment
int level = 0; // Paren level
if (!pdfioStreamPuts(st, "("))
return (false);
@@ -1500,16 +1499,16 @@ write_string(pdfio_stream_t *st, // I - Stream
ptr ++;
start = ptr + 1;
}
else if (*ptr == '\\' || (*ptr == ')' && level == 0) || *ptr < ' ')
else if (*ptr == '\\' || *ptr == '(' || *ptr == ')' || *ptr < ' ')
{
if (ptr > start)
{
if (!pdfioStreamWrite(st, start, (size_t)(ptr - start)))
return (false);
start = ptr + 1;
}
start = ptr + 1;
if (*ptr < ' ')
{
if (!pdfioStreamPrintf(st, "\\%03o", *ptr))
@@ -1518,10 +1517,6 @@ write_string(pdfio_stream_t *st, // I - Stream
else if (!pdfioStreamPrintf(st, "\\%c", *ptr))
return (false);
}
else if (*ptr == '(')
level ++;
else if (*ptr == ')')
level --;
}
if (ptr > start)