fofi/FoFiType1.cc | 8 +++++--- poppler/CharCodeToUnicode.cc | 6 ++++-- poppler/GlobalParams.cc | 6 ++++-- poppler/PDFDoc.cc | 4 +++- poppler/UnicodeMap.cc | 21 ++++++++++++++++++--- 5 files changed, 34 insertions(+), 11 deletions(-)
New commits: commit 9ce71fb35fdd66c55872956432160a5c76a62080 Author: Jakub Wilk <[email protected]> Date: Sat May 1 19:50:54 2010 +0100 Use strtok_r instead strtok strtok is not thread safe diff --git a/fofi/FoFiType1.cc b/fofi/FoFiType1.cc index 5bfeaed..25bdc0e 100644 --- a/fofi/FoFiType1.cc +++ b/fofi/FoFiType1.cc @@ -15,6 +15,7 @@ // // Copyright (C) 2005, 2008 Albert Astals Cid <[email protected]> // Copyright (C) 2005 Kristian Høgsberg <[email protected]> +// Copyright (C) 2010 Jakub Wilk <[email protected]> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -192,6 +193,7 @@ void FoFiType1::parse() { char buf[256]; char c; int n, code, i, j; + char *tokptr; for (i = 1, line = (char *)file; i <= 100 && line && (!name || !encoding); @@ -202,7 +204,7 @@ void FoFiType1::parse() { strncpy(buf, line, 255); buf[255] = '\0'; if ((p = strchr(buf+9, '/')) && - (p = strtok(p+1, " \t\n\r"))) { + (p = strtok_r(p+1, " \t\n\r", &tokptr))) { name = copyString(p); } line = getNextLine(line); @@ -270,8 +272,8 @@ void FoFiType1::parse() { } } } else { - if (strtok(buf, " \t") && - (p = strtok(NULL, " \t\n\r")) && !strcmp(p, "def")) { + if (strtok_r(buf, " \t", &tokptr) && + (p = strtok_r(NULL, " \t\n\r", &tokptr)) && !strcmp(p, "def")) { break; } } diff --git a/poppler/CharCodeToUnicode.cc b/poppler/CharCodeToUnicode.cc index 80fd4c5..1835ddd 100644 --- a/poppler/CharCodeToUnicode.cc +++ b/poppler/CharCodeToUnicode.cc @@ -19,6 +19,7 @@ // Copyright (C) 2008 Michael Vrable <[email protected]> // Copyright (C) 2008 Vasile Gaburici <[email protected]> // Copyright (C) 2010 William Bader <[email protected]> +// Copyright (C) 2010 Jakub Wilk <[email protected]> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -125,6 +126,7 @@ CharCodeToUnicode *CharCodeToUnicode::parseUnicodeToUnicode( Unicode *uBuf = (Unicode *)gmallocn(uBufSize, sizeof(Unicode)); CharCodeToUnicode *ctu; int line, n, i; + char *tokptr; if (!(f = fopen(fileName->getCString(), "r"))) { gfree(uBuf); @@ -143,14 +145,14 @@ CharCodeToUnicode *CharCodeToUnicode::parseUnicodeToUnicode( line = 0; while (getLine(buf, sizeof(buf), f)) { ++line; - if (!(tok = strtok(buf, " \t\r\n")) || + if (!(tok = strtok_r(buf, " \t\r\n", &tokptr)) || sscanf(tok, "%x", &u0) != 1) { error(-1, "Bad line (%d) in unicodeToUnicode file '%s'", line, fileName->getCString()); continue; } n = 0; - while ((tok = strtok(NULL, " \t\r\n"))) { + while ((tok = strtok_r(NULL, " \t\r\n", &tokptr))) { if (n >= uBufSize) { uBufSize += 8; diff --git a/poppler/GlobalParams.cc b/poppler/GlobalParams.cc index bf79585..293d7f3 100644 --- a/poppler/GlobalParams.cc +++ b/poppler/GlobalParams.cc @@ -24,6 +24,7 @@ // Copyright (C) 2009 Kovid Goyal <[email protected]> // Copyright (C) 2010 Hib Eris <[email protected]> // Copyright (C) 2010 Patrick Spendrin <[email protected]> +// Copyright (C) 2010 Jakub Wilk <[email protected]> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -786,6 +787,7 @@ void GlobalParams::parseNameToUnicode(GooString *name) { char buf[256]; int line; Unicode u; + char *tokptr; if (!(f = fopen(name->getCString(), "r"))) { error(-1, "Couldn't open 'nameToUnicode' file '%s'", @@ -794,8 +796,8 @@ void GlobalParams::parseNameToUnicode(GooString *name) { } line = 1; while (getLine(buf, sizeof(buf), f)) { - tok1 = strtok(buf, " \t\r\n"); - tok2 = strtok(NULL, " \t\r\n"); + tok1 = strtok_r(buf, " \t\r\n", &tokptr); + tok2 = strtok_r(NULL, " \t\r\n", &tokptr); if (tok1 && tok2) { sscanf(tok1, "%x", &u); nameToUnicode->add(tok2, u); diff --git a/poppler/PDFDoc.cc b/poppler/PDFDoc.cc index 2d1477d..b650480 100644 --- a/poppler/PDFDoc.cc +++ b/poppler/PDFDoc.cc @@ -22,6 +22,7 @@ // Copyright (C) 2009 Kovid Goyal <[email protected]> // Copyright (C) 2009 Axel Struebing <[email protected]> // Copyright (C) 2010 Hib Eris <[email protected]> +// Copyright (C) 2010 Jakub Wilk <[email protected]> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -294,6 +295,7 @@ GBool PDFDoc::checkFooter() { void PDFDoc::checkHeader() { char hdrBuf[headerSearchSize+1]; char *p; + char *tokptr; int i; pdfMajorVersion = 0; @@ -312,7 +314,7 @@ void PDFDoc::checkHeader() { return; } str->moveStart(i); - if (!(p = strtok(&hdrBuf[i+5], " \t\n\r"))) { + if (!(p = strtok_r(&hdrBuf[i+5], " \t\n\r", &tokptr))) { error(-1, "May not be a PDF file (continuing anyway)"); return; } diff --git a/poppler/UnicodeMap.cc b/poppler/UnicodeMap.cc index 381e4ca..fda0758 100644 --- a/poppler/UnicodeMap.cc +++ b/poppler/UnicodeMap.cc @@ -6,6 +6,20 @@ // //======================================================================== +//======================================================================== +// +// Modified under the Poppler project - http://poppler.freedesktop.org +// +// All changes made under the Poppler project to this file are licensed +// under GPL version 2 or later +// +// Copyright (C) 2010 Jakub Wilk <[email protected]> +// +// To see a description of the changes please see the Changelog file that +// came with your tarball or type make ChangeLog if you are building from git +// +//======================================================================== + #include <config.h> #ifdef USE_GCC_PRAGMAS @@ -43,6 +57,7 @@ UnicodeMap *UnicodeMap::parse(GooString *encodingNameA) { char buf[256]; int line, nBytes, i, x; char *tok1, *tok2, *tok3; + char *tokptr; if (!(f = globalParams->getUnicodeMapFile(encodingNameA))) { error(-1, "Couldn't find unicodeMap file for the '%s' encoding", @@ -58,9 +73,9 @@ UnicodeMap *UnicodeMap::parse(GooString *encodingNameA) { line = 1; while (getLine(buf, sizeof(buf), f)) { - if ((tok1 = strtok(buf, " \t\r\n")) && - (tok2 = strtok(NULL, " \t\r\n"))) { - if (!(tok3 = strtok(NULL, " \t\r\n"))) { + if ((tok1 = strtok_r(buf, " \t\r\n", &tokptr)) && + (tok2 = strtok_r(NULL, " \t\r\n", &tokptr))) { + if (!(tok3 = strtok_r(NULL, " \t\r\n", &tokptr))) { tok3 = tok2; tok2 = tok1; }
_______________________________________________ poppler mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/poppler
