9 Commits

Author SHA1 Message Date
Michael R Sweet
8a81732f3b Add 1.6.2 release date. 2026-02-15 10:12:53 -05:00
Michael R Sweet
96840e97c5 Fix pdfioPageGetBoolean implementation. 2026-02-14 15:53:05 -05:00
Michael R Sweet
d6e4570c2e Update DLL exports. 2026-02-14 15:49:31 -05:00
Michael R Sweet
73e3805aea Fix Windows builds pt 4 (Issue #18) 2026-02-14 15:40:09 -05:00
Michael R Sweet
d4c3e5ac13 Fix Windows builds pt 3 (Issue #18) 2026-02-14 15:34:06 -05:00
Michael R Sweet
7d43cabbe0 Fix Windows builds pt 2 (Issue #18) 2026-02-14 15:31:27 -05:00
Michael R Sweet
baa9fca941 Fix Windows builds (Issue #18) 2026-02-14 15:29:14 -05:00
Michael R Sweet
d9444880c5 Add support for Unicode filenames on Windows (Issue #18) 2026-02-14 15:25:53 -05:00
Michael R Sweet
15f197d030 Fix conversions of Unicode characters above plane 0 (Issue #159) 2026-02-14 09:51:49 -05:00
8 changed files with 96 additions and 10 deletions

View File

@@ -9,6 +9,7 @@ v1.7.0 - YYYY-MM-DD
- Added support for basic compound stream filters for ASCII85Decode support
(Issue #11)
- Added support for LZWDecode filters (Issue #11)
- Added support for Unicode filenames on Windows (Issue #18)
- Added support for writing object streams (Issue #101)
- Added support for GIF files (Issue #145)
- Added support for WebP files (Issue #144)
@@ -17,7 +18,7 @@ v1.7.0 - YYYY-MM-DD
- Fixed a buffer overflow in the (still not enabled) AES-256 code.
v1.6.2 - YYYY-MM-DD
v1.6.2 - 2026-02-15
-------------------
- Increased the maximum length of a single string to 128k (Issue #146)
@@ -28,6 +29,7 @@ v1.6.2 - YYYY-MM-DD
- Fixed xref reconstruction for objects lacking a `Type` value.
- Fixed `pdfioPageOpenStream` for indirect `Contents` arrays.
- Fixed an error propagation bug when reading too-long values (Issue #146)
- Fixed a bug when converting Unicode characters above plane 0 (issue #159)
- Fixed a Clang warning.

View File

@@ -235,6 +235,7 @@ pdfio1.def: $(LIBOBJS) Makefile
echo "LIBRARY pdfio1" >$@
echo "VERSION $(PDFIO_VERSION_MAJOR).$(PDFIO_VERSION_MINOR)" >>$@
echo "EXPORTS" >>$@
echo "_pdfio_win32_open" >>$@
nm $(LIBOBJS) 2>/dev/null | grep "T _" | awk '{print $$3}' | \
grep -v '^_ttf' | sed -e '1,$$s/^_//' | sort >>$@

View File

@@ -1885,7 +1885,7 @@ pdfioFileCreateFontObjFromFile(
return (NULL);
}
if ((fd = open(filename, O_RDONLY | O_BINARY)) < 0)
if ((fd = open(filename, O_RDONLY | O_BINARY, 0)) < 0)
{
_pdfioFileError(pdf, "Unable to open font file '%s': %s", filename, strerror(errno));
return (NULL);
@@ -2021,7 +2021,7 @@ pdfioFileCreateICCObjFromFile(
return (NULL);
}
if ((fd = open(filename, O_RDONLY | O_BINARY)) < 0)
if ((fd = open(filename, O_RDONLY | O_BINARY, 0)) < 0)
{
_pdfioFileError(pdf, "Unable to open ICC profile '%s': %s", filename, strerror(errno));
return (NULL);
@@ -2180,7 +2180,7 @@ pdfioFileCreateImageObjFromFile(
return (NULL);
// Try opening the file...
if ((fd = open(filename, O_RDONLY | O_BINARY)) < 0)
if ((fd = open(filename, O_RDONLY | O_BINARY, 0)) < 0)
{
_pdfioFileError(pdf, "Unable to open image file '%s': %s", filename, strerror(errno));
return (NULL);

View File

@@ -1166,7 +1166,7 @@ pdfioFileOpen(
pdf->permissions = PDFIO_PERMISSION_ALL;
// Open the file...
if ((pdf->fd = open(filename, O_RDONLY | O_BINARY)) < 0)
if ((pdf->fd = open(filename, O_RDONLY | O_BINARY, 0)) < 0)
{
_pdfioFileError(pdf, "Unable to open file - %s", strerror(errno));
free(pdf->filename);
@@ -1414,8 +1414,88 @@ pdfioFileSetTitle(pdfio_file_t *pdf, // I - PDF file
}
#if _WIN32
//
// '_pdfioObjAdd()' - Add an object to a file.
// '_pdfio_win32_open()' - Open or create a file.
//
// This function handles mapping of UTF-8 filenames to UTF-16 on Windows.
//
int // O - File descriptor or -1 on error
_pdfio_win32_open(const char *filename, // I - UTF-8 filename
int oflag, // I - Open flags
int mode) // I - File permissions
{
wchar_t utf16name[1024], // UTF-16 filename
*utf16ptr; // Pointer into UTF-16 filename
int unich; // Unicode character
// Convert the UTF-8 string to UTF-16...
utf16ptr = utf16name;
while (*filename && utf16ptr < (utf16name + sizeof(utf16name) / sizeof(utf16name[0]) - 2))
{
if ((unich = *filename++) & 0x80)
{
if ((unich & 0xe0) == 0xc0 && (*filename & 0xc0) == 0x80)
{
// 2-byte UTF-8
unich = ((unich & 0x1f) << 6) | (*filename & 0x3f);
filename ++;
}
else if ((unich & 0xf0) == 0xe0 && (*filename & 0xc0) == 0x80 && (filename[1] & 0xc0) == 0x80)
{
// 3-byte UTF-8
unich = ((unich & 0x0f) << 12) | ((*filename & 0x3f) << 6) | (filename[1] & 0x3f);
filename += 2;
}
else if ((unich & 0xf8) == 0xf0 && (*filename & 0xc0) == 0x80 && (filename[1] & 0xc0) == 0x80 && (filename[2] & 0xc0) == 0x80)
{
// 4-byte UTF-8
unich = ((unich & 0x07) << 18) | ((*filename & 0x3f) << 12) | ((filename[1] & 0x3f) << 6) | (filename[2] & 0x3f);
filename += 3;
}
else
{
// Invalid UTF-8 char...
errno = EINVAL;
return (-1);
}
}
// Copy the unicode character...
if (unich > 0xffff)
{
// Two-word sequence...
*utf16ptr++ = 0xd800 | ((unich >> 10) & 0x03ff);
*utf16ptr++ = 0xdc00 | (unich & 0x03ff);
}
else
{
// One-word...
*utf16ptr++ = unich;
}
}
*utf16ptr = '\0';
if (*filename)
{
// Filename too long...
errno = EINVAL;
return (-1);
}
else
{
// Pass on to _wopen...
return (_wopen(utf16name, oflag, mode));
}
}
#endif // WIN32
//
// 'add_obj()' - Add an object to a file.
//
static pdfio_obj_t * // O - Object

View File

@@ -126,10 +126,10 @@ pdfioPageGetBoolean(pdfio_obj_t *page, // I - Page object
// Dictionary value
if (v && v->type == PDFIO_VALTYPE_ARRAY)
if (v && v->type == PDFIO_VALTYPE_BOOLEAN)
return (v->value.boolean);
else
return (NULL);
return (false);
}

View File

@@ -30,7 +30,7 @@
# define fileno _fileno
# define lseek(f,o,w) (off_t)_lseek((f),(long)(o),(w))
# define mkdir(d,p) _mkdir(d)
# define open _open
# define open _pdfio_win32_open
# define read(f,b,s) _read((f),(b),(unsigned)(s))
# define rmdir _rmdir
# define snprintf _snprintf
@@ -412,6 +412,7 @@ extern size_t _pdfio_strlcpy(char *dst, const char *src, size_t dstsize) _PDFIO
extern double _pdfio_strtod(pdfio_file_t *pdf, const char *s) _PDFIO_INTERNAL;
extern void _pdfio_utf16cpy(char *dst, const unsigned char *src, size_t srclen, size_t dstsize) _PDFIO_INTERNAL;
extern ssize_t _pdfio_vsnprintf(pdfio_file_t *pdf, char *buffer, size_t bufsize, const char *format, va_list ap) _PDFIO_INTERNAL;
extern int _pdfio_win32_open(const char *filename, int oflag, int mode) _PDFIO_INTERNAL;
extern bool _pdfioArrayDecrypt(pdfio_file_t *pdf, pdfio_obj_t *obj, pdfio_array_t *a, size_t depth) _PDFIO_INTERNAL;
extern void _pdfioArrayDebug(pdfio_array_t *a, FILE *fp) _PDFIO_INTERNAL;

View File

@@ -229,7 +229,7 @@ _pdfio_utf16cpy(
else
{
// 4-byte UTF-8
*dstptr++ = (char)(0xe0 | (ch >> 18));
*dstptr++ = (char)(0xf0 | (ch >> 18));
*dstptr++ = (char)(0x80 | ((ch >> 12) & 0x3f));
*dstptr++ = (char)(0x80 | ((ch >> 6) & 0x3f));
*dstptr++ = (char)(0x80 | (ch & 0x3f));

View File

@@ -1,6 +1,7 @@
LIBRARY pdfio1
VERSION 1.7
EXPORTS
_pdfio_win32_open
_pdfio_strlcpy
_pdfio_strtod
_pdfio_utf16cpy
@@ -64,6 +65,7 @@ _pdfioStreamOpen
_pdfioStringAllocBuffer
_pdfioStringFreeBuffer
_pdfioStringIsAllocated
_pdfioStringPrintf
_pdfioTokenClear
_pdfioTokenFlush
_pdfioTokenGet