mirror of
https://github.com/michaelrsweet/pdfio.git
synced 2024-12-26 21:38:21 +01:00
Make sure all output code paths set the locale information (Issue #61)
This commit is contained in:
parent
e882622233
commit
b117959725
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Makefile for PDFio.
|
# Makefile for PDFio.
|
||||||
#
|
#
|
||||||
# Copyright © 2021-2023 by Michael R Sweet.
|
# Copyright © 2021-2024 by Michael R Sweet.
|
||||||
#
|
#
|
||||||
# Licensed under Apache License v2.0. See the file "LICENSE" for more
|
# Licensed under Apache License v2.0. See the file "LICENSE" for more
|
||||||
# information.
|
# information.
|
||||||
@ -163,7 +163,9 @@ install: $(TARGETS)
|
|||||||
# Test everything
|
# Test everything
|
||||||
test: testpdfio testttf
|
test: testpdfio testttf
|
||||||
./testttf 2>test.log
|
./testttf 2>test.log
|
||||||
./testpdfio 2>test.log
|
./testpdfio 2>>test.log
|
||||||
|
LANG=fr_FR.UTF-8 ./testpdfio 2>>test.log
|
||||||
|
|
||||||
|
|
||||||
valgrind: testpdfio
|
valgrind: testpdfio
|
||||||
valgrind --leak-check=full ./testpdfio
|
valgrind --leak-check=full ./testpdfio
|
||||||
|
@ -264,6 +264,9 @@ pdfioFileCreate(
|
|||||||
if (!_pdfioFilePrintf(pdf, "%%PDF-%s\n%%PDF\303\254o\n", version))
|
if (!_pdfioFilePrintf(pdf, "%%PDF-%s\n%%PDF\303\254o\n", version))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
|
if (pdf->loc)
|
||||||
|
_pdfioFilePrintf(pdf, "%%decimal_point=\"%s\"\n", pdf->loc->decimal_point);
|
||||||
|
|
||||||
// Create the pages object...
|
// Create the pages object...
|
||||||
if ((dict = pdfioDictCreate(pdf)) == NULL)
|
if ((dict = pdfioDictCreate(pdf)) == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
@ -510,6 +513,7 @@ pdfioFileCreateOutput(
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pdf->loc = get_lconv();
|
||||||
pdf->filename = strdup("output.pdf");
|
pdf->filename = strdup("output.pdf");
|
||||||
pdf->version = strdup(version);
|
pdf->version = strdup(version);
|
||||||
pdf->mode = _PDFIO_MODE_WRITE;
|
pdf->mode = _PDFIO_MODE_WRITE;
|
||||||
@ -789,6 +793,7 @@ pdfioFileCreateTemporary(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pdf->loc = get_lconv();
|
||||||
pdf->filename = strdup(buffer);
|
pdf->filename = strdup(buffer);
|
||||||
|
|
||||||
if (i >= 1000)
|
if (i >= 1000)
|
||||||
@ -1591,6 +1596,8 @@ get_lconv(void)
|
|||||||
|
|
||||||
if ((loc = localeconv()) != NULL)
|
if ((loc = localeconv()) != NULL)
|
||||||
{
|
{
|
||||||
|
PDFIO_DEBUG("get_lconv: loc=%p, loc->decimal_point=\"%s\"\n", loc, loc->decimal_point);
|
||||||
|
|
||||||
if (!loc->decimal_point || !strcmp(loc->decimal_point, "."))
|
if (!loc->decimal_point || !strcmp(loc->decimal_point, "."))
|
||||||
loc = NULL;
|
loc = NULL;
|
||||||
}
|
}
|
||||||
|
@ -238,6 +238,7 @@ _pdfio_vsnprintf(pdfio_file_t *pdf, // I - PDF file
|
|||||||
if ((decptr = strstr(temp, dec)) != NULL)
|
if ((decptr = strstr(temp, dec)) != NULL)
|
||||||
{
|
{
|
||||||
// Convert locale decimal point to "."
|
// Convert locale decimal point to "."
|
||||||
|
PDFIO_DEBUG("_pdfio_vsnprintf: Before \"%s\"\n", temp);
|
||||||
tempptr = decptr + strlen(dec);
|
tempptr = decptr + strlen(dec);
|
||||||
if (tempptr > (decptr + 1))
|
if (tempptr > (decptr + 1))
|
||||||
memmove(decptr + 1, tempptr, strlen(tempptr) + 1);
|
memmove(decptr + 1, tempptr, strlen(tempptr) + 1);
|
||||||
@ -249,6 +250,8 @@ _pdfio_vsnprintf(pdfio_file_t *pdf, // I - PDF file
|
|||||||
|
|
||||||
if (*tempptr == '.')
|
if (*tempptr == '.')
|
||||||
*tempptr = '\0'; // Strip trailing decimal point
|
*tempptr = '\0'; // Strip trailing decimal point
|
||||||
|
|
||||||
|
PDFIO_DEBUG("_pdfio_vsnprintf: After \"%s\"\n", temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy to the output buffer
|
// Copy to the output buffer
|
||||||
@ -361,7 +364,7 @@ _pdfio_vsnprintf(pdfio_file_t *pdf, // I - PDF file
|
|||||||
*bufptr = '\0';
|
*bufptr = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "_pdfio_vsnprintf: %ld \"%s\"\n", (long)bytes, buffer);
|
PDFIO_DEBUG("_pdfio_vsnprintf: Returning %ld \"%s\"\n", (long)bytes, buffer);
|
||||||
|
|
||||||
return (bytes);
|
return (bytes);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// Test program for PDFio.
|
// Test program for PDFio.
|
||||||
//
|
//
|
||||||
// Copyright © 2021-2023 by Michael R Sweet.
|
// Copyright © 2021-2024 by Michael R Sweet.
|
||||||
//
|
//
|
||||||
// Licensed under Apache License v2.0. See the file "LICENSE" for more
|
// Licensed under Apache License v2.0. See the file "LICENSE" for more
|
||||||
// information.
|
// information.
|
||||||
@ -16,6 +16,7 @@
|
|||||||
#include "pdfio-private.h"
|
#include "pdfio-private.h"
|
||||||
#include "pdfio-content.h"
|
#include "pdfio-content.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <locale.h>
|
||||||
#ifndef M_PI
|
#ifndef M_PI
|
||||||
# define M_PI 3.14159265358979323846264338327950288
|
# define M_PI 3.14159265358979323846264338327950288
|
||||||
#endif // M_PI
|
#endif // M_PI
|
||||||
@ -61,6 +62,8 @@ main(int argc, // I - Number of command-line arguments
|
|||||||
int ret = 0; // Return value
|
int ret = 0; // Return value
|
||||||
|
|
||||||
|
|
||||||
|
fprintf(stderr, "testpdfio: Test locale is \"%s\".\n", setlocale(LC_ALL, getenv("LANG")));
|
||||||
|
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
{
|
{
|
||||||
int i; // Looping var
|
int i; // Looping var
|
||||||
|
Loading…
Reference in New Issue
Block a user