michaelrsweet / pdfio

PDFio is a simple C library for reading and writing PDF files.
https://www.msweet.org/pdfio
Apache License 2.0
198 stars 44 forks source link

Fix text trailing parenthesis in pdfioStreamGetToken #37

Closed esnunes closed 1 year ago

esnunes commented 1 year ago

Problem

At the moment, when the pdfioStreamGetToken parses a text token, it isn't returning the trailing closing parenthesis, e.g.:

% expected token:
(my text)
% got token:
(my text

Solution

When parsing a text token, prevent the logic from early returning before adding the trailing closing parenthesis to the buffer.

michaelrsweet commented 1 year ago

This is an intentional part of the API - the trailing delimiter (if any) is excluded so you can just examine the rest of the string.

esnunes commented 1 year ago

I got it, thanks @michaelrsweet. Is this the only token that is not returned as-is? If that's the case, it would be great to have this documented, at first sight I thought it was a bug 😅

Thanks for the great library!

michaelrsweet commented 1 year ago

Regular strings and binary strings have prefixes ("(" and "<" respectively), but that's it. I'll make sure the documentation is updated accordingly...

michaelrsweet commented 1 year ago

[master 57d5894] Update pdfioStreamGetToken documentation (Issue #37)

(HTML documentation hasn't been regenerated yet, but the inline code comments have been)