From 8dc4af74d0919afe9ac5ebfb7776af28e725b971 Mon Sep 17 00:00:00 2001 From: mike Date: Wed, 14 May 2003 18:22:54 +0000 Subject: [PATCH] Mirror 1.1.x changes. git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/branches/branch-1.2@3723 7a7537e8-13f0-0310-91df-b6672ffda945 --- CHANGES-1.1.txt | 5 +++ pdftops/BuiltinFont.cxx | 6 ++-- pdftops/BuiltinFont.h | 10 +++--- pdftops/CMap.cxx | 4 +-- pdftops/CMap.h | 4 +-- pdftops/CompactFontTables.h | 2 +- pdftops/Dict.cxx | 14 ++++---- pdftops/Dict.h | 14 ++++---- pdftops/DisplayFontTable.h | 6 ++-- pdftops/Error.cxx | 2 +- pdftops/Error.h | 2 +- pdftops/FontEncodingTables.cxx | 14 ++++---- pdftops/FontEncodingTables.h | 14 ++++---- pdftops/FontFile.cxx | 65 +++++++++++++++++----------------- pdftops/FontFile.h | 58 +++++++++++++++--------------- pdftops/Function.cxx | 2 +- pdftops/GfxFont.cxx | 26 +++++++------- pdftops/GfxFont.h | 24 ++++++------- pdftops/GfxState.cxx | 4 +-- pdftops/GfxState.h | 2 +- pdftops/GlobalParams.cxx | 36 +++++++++---------- pdftops/GlobalParams.h | 34 +++++++++--------- pdftops/JBIG2Stream.cxx | 2 +- pdftops/JBIG2Stream.h | 2 +- pdftops/Makefile | 6 ++-- pdftops/NameToCharCode.cxx | 8 ++--- pdftops/NameToCharCode.h | 6 ++-- pdftops/NameToUnicodeTable.h | 2 +- pdftops/Object.cxx | 4 +-- pdftops/Object.h | 42 +++++++++++----------- pdftops/PSOutputDev.cxx | 44 +++++++++++------------ pdftops/PSOutputDev.h | 24 ++++++------- pdftops/Page.cxx | 2 +- pdftops/Page.h | 2 +- pdftops/Stream.cxx | 20 +++++------ pdftops/Stream.h | 28 +++++++-------- pdftops/UnicodeMap.cxx | 4 +-- pdftops/UnicodeMap.h | 4 +-- pdftops/gfile.cxx | 16 ++++----- pdftops/gfile.h | 14 ++++---- pdftops/gmem.c | 2 +- pdftops/gmem.h | 2 +- pdftops/parseargs.c | 2 +- 43 files changed, 296 insertions(+), 288 deletions(-) diff --git a/CHANGES-1.1.txt b/CHANGES-1.1.txt index a8c9a9dc09..64a676faba 100644 --- a/CHANGES-1.1.txt +++ b/CHANGES-1.1.txt @@ -1,6 +1,11 @@ CHANGES-1.1.txt --------------- +CHANGES IN CUPS V1.1.19 + + - Fixed compiler warnings in pdftops filter (STR #96) + + CHANGES IN CUPS V1.1.19rc5 - Jobs with banner pages that were printed to implicit diff --git a/pdftops/BuiltinFont.cxx b/pdftops/BuiltinFont.cxx index 2af7afe857..0525ab8ae5 100644 --- a/pdftops/BuiltinFont.cxx +++ b/pdftops/BuiltinFont.cxx @@ -39,7 +39,7 @@ BuiltinFontWidths::~BuiltinFontWidths() { gfree(tab); } -GBool BuiltinFontWidths::getWidth(char *name, Gushort *width) { +GBool BuiltinFontWidths::getWidth(const char *name, Gushort *width) { int h; BuiltinFontWidth *p; @@ -53,8 +53,8 @@ GBool BuiltinFontWidths::getWidth(char *name, Gushort *width) { return gFalse; } -int BuiltinFontWidths::hash(char *name) { - char *p; +int BuiltinFontWidths::hash(const char *name) { + const char *p; unsigned int h; h = 0; diff --git a/pdftops/BuiltinFont.h b/pdftops/BuiltinFont.h index 3c036d7f3e..3bae15db5f 100644 --- a/pdftops/BuiltinFont.h +++ b/pdftops/BuiltinFont.h @@ -23,8 +23,8 @@ class BuiltinFontWidths; //------------------------------------------------------------------------ struct BuiltinFont { - char *name; - char **defaultBaseEnc; + const char *name; + const char **defaultBaseEnc; short ascent; short descent; short bbox[4]; @@ -34,7 +34,7 @@ struct BuiltinFont { //------------------------------------------------------------------------ struct BuiltinFontWidth { - char *name; + const char *name; Gushort width; BuiltinFontWidth *next; }; @@ -44,11 +44,11 @@ public: BuiltinFontWidths(BuiltinFontWidth *widths, int sizeA); ~BuiltinFontWidths(); - GBool getWidth(char *name, Gushort *width); + GBool getWidth(const char *name, Gushort *width); private: - int hash(char *name); + int hash(const char *name); BuiltinFontWidth **tab; int size; diff --git a/pdftops/CMap.cxx b/pdftops/CMap.cxx index 67542fb644..28dc3eae2b 100644 --- a/pdftops/CMap.cxx +++ b/pdftops/CMap.cxx @@ -154,7 +154,7 @@ CMap::CMap(GString *collectionA, GString *cMapNameA, int wModeA) { refCnt = 1; } -void CMap::useCMap(CMapCache *cache, char *useName) { +void CMap::useCMap(CMapCache *cache, const char *useName) { GString *useNameStr; CMap *subCMap; @@ -279,7 +279,7 @@ GBool CMap::match(GString *collectionA, GString *cMapNameA) { return !collection->cmp(collectionA) && !cMapName->cmp(cMapNameA); } -CID CMap::getCID(char *s, int len, int *nUsed) { +CID CMap::getCID(const char *s, int len, int *nUsed) { CMapVectorEntry *vec; int n, i; diff --git a/pdftops/CMap.h b/pdftops/CMap.h index af40b99d71..df44a2be86 100644 --- a/pdftops/CMap.h +++ b/pdftops/CMap.h @@ -47,7 +47,7 @@ public: // Return the CID corresponding to the character code starting at // , which contains bytes. Sets * to the number of // bytes used by the char code. - CID getCID(char *s, int len, int *nUsed); + CID getCID(const char *s, int len, int *nUsed); // Return the writing mode (0=horizontal, 1=vertical). int getWMode() { return wMode; } @@ -56,7 +56,7 @@ private: CMap(GString *collectionA, GString *cMapNameA); CMap(GString *collectionA, GString *cMapNameA, int wModeA); - void useCMap(CMapCache *cache, char *useName); + void useCMap(CMapCache *cache, const char *useName); void copyVector(CMapVectorEntry *dest, CMapVectorEntry *src); void addCodeSpace(CMapVectorEntry *vec, Guint start, Guint end, Guint nBytes); diff --git a/pdftops/CompactFontTables.h b/pdftops/CompactFontTables.h index 28e16e775e..4e26793493 100644 --- a/pdftops/CompactFontTables.h +++ b/pdftops/CompactFontTables.h @@ -9,7 +9,7 @@ #ifndef COMPACTFONTINFO_H #define COMPACTFONTINFO_H -static char *type1CStdStrings[391] = { +static const char *type1CStdStrings[391] = { ".notdef", "space", "exclam", diff --git a/pdftops/Dict.cxx b/pdftops/Dict.cxx index c9ec7f010e..c773637a86 100644 --- a/pdftops/Dict.cxx +++ b/pdftops/Dict.cxx @@ -34,13 +34,13 @@ Dict::~Dict() { int i; for (i = 0; i < length; ++i) { - gfree(entries[i].key); + gfree((void *)entries[i].key); entries[i].val.free(); } gfree(entries); } -void Dict::add(char *key, Object *val) { +void Dict::add(const char *key, Object *val) { if (length + 1 > size) { size += 8; entries = (DictEntry *)grealloc(entries, size * sizeof(DictEntry)); @@ -50,7 +50,7 @@ void Dict::add(char *key, Object *val) { ++length; } -inline DictEntry *Dict::find(char *key) { +inline DictEntry *Dict::find(const char *key) { int i; for (i = 0; i < length; ++i) { @@ -60,25 +60,25 @@ inline DictEntry *Dict::find(char *key) { return NULL; } -GBool Dict::is(char *type) { +GBool Dict::is(const char *type) { DictEntry *e; return (e = find("Type")) && e->val.isName(type); } -Object *Dict::lookup(char *key, Object *obj) { +Object *Dict::lookup(const char *key, Object *obj) { DictEntry *e; return (e = find(key)) ? e->val.fetch(xref, obj) : obj->initNull(); } -Object *Dict::lookupNF(char *key, Object *obj) { +Object *Dict::lookupNF(const char *key, Object *obj) { DictEntry *e; return (e = find(key)) ? e->val.copy(obj) : obj->initNull(); } -char *Dict::getKey(int i) { +const char *Dict::getKey(int i) { return entries[i].key; } diff --git a/pdftops/Dict.h b/pdftops/Dict.h index f63c98e007..5de03897b6 100644 --- a/pdftops/Dict.h +++ b/pdftops/Dict.h @@ -22,7 +22,7 @@ //------------------------------------------------------------------------ struct DictEntry { - char *key; + const char *key; Object val; }; @@ -43,18 +43,18 @@ public: int getLength() { return length; } // Add an entry. NB: does not copy key. - void add(char *key, Object *val); + void add(const char *key, Object *val); // Check if dictionary is of specified type. - GBool is(char *type); + GBool is(const char *type); // Look up an entry and return the value. Returns a null object // if is not in the dictionary. - Object *lookup(char *key, Object *obj); - Object *lookupNF(char *key, Object *obj); + Object *lookup(const char *key, Object *obj); + Object *lookupNF(const char *key, Object *obj); // Iterative accessors. - char *getKey(int i); + const char *getKey(int i); Object *getVal(int i, Object *obj); Object *getValNF(int i, Object *obj); @@ -71,7 +71,7 @@ private: int length; // number of entries in dictionary int ref; // reference count - DictEntry *find(char *key); + DictEntry *find(const char *key); }; #endif diff --git a/pdftops/DisplayFontTable.h b/pdftops/DisplayFontTable.h index 3c2379f3d7..f3803dd854 100644 --- a/pdftops/DisplayFontTable.h +++ b/pdftops/DisplayFontTable.h @@ -7,9 +7,9 @@ //======================================================================== static struct { - char *name; - char *xlfd; - char *encoding; + const char *name; + const char *xlfd; + const char *encoding; } displayFontTab[] = { {"Courier", "-*-courier-medium-r-normal-*-%s-*-*-*-*-*-iso8859-1", "Latin1"}, {"Courier-Bold", "-*-courier-bold-r-normal-*-%s-*-*-*-*-*-iso8859-1", "Latin1"}, diff --git a/pdftops/Error.cxx b/pdftops/Error.cxx index a871c36ea7..5f6ea93786 100644 --- a/pdftops/Error.cxx +++ b/pdftops/Error.cxx @@ -18,7 +18,7 @@ #include "GlobalParams.h" #include "Error.h" -void CDECL error(int pos, char *msg, ...) { +void CDECL error(int pos, const char *msg, ...) { va_list args; // NB: this can be called before the globalParams object is created diff --git a/pdftops/Error.h b/pdftops/Error.h index cc51e5febf..ce2aeade93 100644 --- a/pdftops/Error.h +++ b/pdftops/Error.h @@ -18,6 +18,6 @@ #include #include "config.h" -extern void CDECL error(int pos, char *msg, ...); +extern void CDECL error(int pos, const char *msg, ...); #endif diff --git a/pdftops/FontEncodingTables.cxx b/pdftops/FontEncodingTables.cxx index 14a84d4301..289d0c8d61 100644 --- a/pdftops/FontEncodingTables.cxx +++ b/pdftops/FontEncodingTables.cxx @@ -10,7 +10,7 @@ #include #include "FontEncodingTables.h" -char *macRomanEncoding[256] = { +const char *macRomanEncoding[256] = { NULL, NULL, NULL, @@ -269,7 +269,7 @@ char *macRomanEncoding[256] = { "caron" }; -char *macExpertEncoding[256] = { +const char *macExpertEncoding[256] = { NULL, NULL, NULL, @@ -528,7 +528,7 @@ char *macExpertEncoding[256] = { NULL }; -char *winAnsiEncoding[256] = { +const char *winAnsiEncoding[256] = { NULL, NULL, NULL, @@ -787,7 +787,7 @@ char *winAnsiEncoding[256] = { "ydieresis" }; -char *standardEncoding[256] = { +const char *standardEncoding[256] = { NULL, NULL, NULL, @@ -1046,7 +1046,7 @@ char *standardEncoding[256] = { NULL }; -char *expertEncoding[256] = { +const char *expertEncoding[256] = { NULL, NULL, NULL, @@ -1305,7 +1305,7 @@ char *expertEncoding[256] = { "Ydieresissmall" }; -char *symbolEncoding[256] = { +const char *symbolEncoding[256] = { NULL, NULL, NULL, @@ -1564,7 +1564,7 @@ char *symbolEncoding[256] = { NULL }; -char *zapfDingbatsEncoding[256] = { +const char *zapfDingbatsEncoding[256] = { NULL, NULL, NULL, diff --git a/pdftops/FontEncodingTables.h b/pdftops/FontEncodingTables.h index 8b0a1e7e99..a417b324e4 100644 --- a/pdftops/FontEncodingTables.h +++ b/pdftops/FontEncodingTables.h @@ -9,12 +9,12 @@ #ifndef FONTENCODINGTABLES_H #define FONTENCODINGTABLES_H -extern char *macRomanEncoding[]; -extern char *macExpertEncoding[]; -extern char *winAnsiEncoding[]; -extern char *standardEncoding[]; -extern char *expertEncoding[]; -extern char *symbolEncoding[]; -extern char *zapfDingbatsEncoding[]; +extern const char *macRomanEncoding[]; +extern const char *macExpertEncoding[]; +extern const char *winAnsiEncoding[]; +extern const char *standardEncoding[]; +extern const char *expertEncoding[]; +extern const char *symbolEncoding[]; +extern const char *zapfDingbatsEncoding[]; #endif diff --git a/pdftops/FontFile.cxx b/pdftops/FontFile.cxx index d287be0f37..91700e0f61 100644 --- a/pdftops/FontFile.cxx +++ b/pdftops/FontFile.cxx @@ -29,7 +29,7 @@ //------------------------------------------------------------------------ -static inline char *nextLine(char *line, char *end) { +static inline const char *nextLine(const char *line, const char *end) { while (line < end && *line != '\n' && *line != '\r') ++line; while (line < end && *line == '\n' || *line == '\r') @@ -37,7 +37,7 @@ static inline char *nextLine(char *line, char *end) { return line; } -static char hexChars[17] = "0123456789ABCDEF"; +static const char hexChars[17] = "0123456789ABCDEF"; //------------------------------------------------------------------------ // FontFile @@ -53,8 +53,9 @@ FontFile::~FontFile() { // Type1FontFile //------------------------------------------------------------------------ -Type1FontFile::Type1FontFile(char *file, int len) { - char *line, *line1, *p, *p2; +Type1FontFile::Type1FontFile(const char *file, int len) { + const char *line, *line1; + char *p, *p2; GBool haveEncoding; char buf[256]; char c; @@ -188,7 +189,7 @@ struct Type1CPrivateDict { GBool nominalWidthXFP; }; -Type1CFontFile::Type1CFontFile(char *fileA, int lenA) { +Type1CFontFile::Type1CFontFile(const char *fileA, int lenA) { Guchar *nameIdxPtr, *idxPtr0, *idxPtr1; file = fileA; @@ -228,15 +229,15 @@ Type1CFontFile::~Type1CFontFile() { } } -char *Type1CFontFile::getName() { +const char *Type1CFontFile::getName() { return name->getCString(); } -char **Type1CFontFile::getEncoding() { +const char **Type1CFontFile::getEncoding() { if (!encoding) { readNameAndEncoding(); } - return encoding; + return (const char **)encoding; } void Type1CFontFile::readNameAndEncoding() { @@ -595,7 +596,7 @@ void Type1CFontFile::convertToType1(FontFileOutputFunc outputFuncA, } } -void Type1CFontFile::convertToCIDType0(char *psName, +void Type1CFontFile::convertToCIDType0(const char *psName, FontFileOutputFunc outputFuncA, void *outputStreamA) { Type1CTopDict dict; @@ -883,7 +884,7 @@ void Type1CFontFile::convertToCIDType0(char *psName, gfree(fdSelect); } -void Type1CFontFile::convertToType0(char *psName, +void Type1CFontFile::convertToType0(const char *psName, FontFileOutputFunc outputFuncA, void *outputStreamA) { Type1CTopDict dict; @@ -1405,7 +1406,7 @@ Gushort *Type1CFontFile::readCharset(int charset, int nGlyphs) { return glyphNames; } -void Type1CFontFile::eexecWrite(char *s) { +void Type1CFontFile::eexecWrite(const char *s) { Guchar *p; Guchar x; @@ -1422,7 +1423,7 @@ void Type1CFontFile::eexecWrite(char *s) { } } -void Type1CFontFile::eexecCvtGlyph(char *glyphName, Guchar *s, int n) { +void Type1CFontFile::eexecCvtGlyph(const char *glyphName, Guchar *s, int n) { char eBuf[256]; cvtGlyph(s, n); @@ -2098,7 +2099,7 @@ void Type1CFontFile::eexecWriteCharstring(Guchar *s, int n) { } } -void Type1CFontFile::getDeltaInt(char *buf, char *key, double *opA, +void Type1CFontFile::getDeltaInt(char *buf, const char *key, double *opA, int n) { int x, i; @@ -2113,7 +2114,7 @@ void Type1CFontFile::getDeltaInt(char *buf, char *key, double *opA, sprintf(buf, "] def\n"); } -void Type1CFontFile::getDeltaReal(char *buf, char *key, double *opA, +void Type1CFontFile::getDeltaReal(char *buf, const char *key, double *opA, int n) { double x; int i; @@ -2318,7 +2319,7 @@ struct TTFontTableHdr { }; struct T42Table { - char *tag; // 4-byte tag + const char *tag; // 4-byte tag GBool required; // required by the TrueType spec? }; @@ -2344,7 +2345,7 @@ static T42Table t42Tables[nT42Tables] = { // Glyph names in some arbitrary standard that Apple uses for their // TrueType fonts. -static char *macGlyphNames[258] = { +static const char *macGlyphNames[258] = { ".notdef", "null", "CR", @@ -2618,7 +2619,7 @@ struct TrueTypeLoca { int length; }; -TrueTypeFontFile::TrueTypeFontFile(char *fileA, int lenA) { +TrueTypeFontFile::TrueTypeFontFile(const char *fileA, int lenA) { int pos, i, idx, n, length; Guint size, startPos, endPos; @@ -2704,11 +2705,11 @@ TrueTypeFontFile::~TrueTypeFontFile() { gfree(tableHdrs); } -char *TrueTypeFontFile::getName() { +const char *TrueTypeFontFile::getName() { return NULL; } -char **TrueTypeFontFile::getEncoding() { +const char **TrueTypeFontFile::getEncoding() { int cmap[256]; int nCmaps, cmapPlatform, cmapEncoding, cmapFmt; int cmapLen, cmapOffset, cmapFirst; @@ -2719,7 +2720,7 @@ char **TrueTypeFontFile::getEncoding() { int stringIdx, stringPos, n; if (encoding) { - return encoding; + return (const char **)encoding; } //----- construct the (char code) -> (glyph idx) mapping @@ -2877,10 +2878,10 @@ char **TrueTypeFontFile::getEncoding() { } } - return encoding; + return (const char **)encoding; } -void TrueTypeFontFile::convertToType42(char *name, char **encodingA, +void TrueTypeFontFile::convertToType42(const char *name, const char **encodingA, CharCodeToUnicode *toUnicode, GBool pdfFontHasEncoding, FontFileOutputFunc outputFunc, @@ -2913,7 +2914,7 @@ void TrueTypeFontFile::convertToType42(char *name, char **encodingA, (*outputFunc)(outputStream, "FontName currentdict end definefont pop\n", 40); } -void TrueTypeFontFile::convertToCIDType2(char *name, Gushort *cidMap, +void TrueTypeFontFile::convertToCIDType2(const char *name, Gushort *cidMap, int nCIDs, FontFileOutputFunc outputFunc, void *outputStream) { @@ -3021,7 +3022,7 @@ void TrueTypeFontFile::convertToCIDType2(char *name, Gushort *cidMap, 56); } -void TrueTypeFontFile::convertToType0(char *name, Gushort *cidMap, +void TrueTypeFontFile::convertToType0(const char *name, Gushort *cidMap, int nCIDs, FontFileOutputFunc outputFunc, void *outputStream) { @@ -3157,7 +3158,7 @@ double TrueTypeFontFile::getFixed(int pos) { return (double)x + (double)y / 65536; } -int TrueTypeFontFile::seekTable(char *tag) { +int TrueTypeFontFile::seekTable(const char *tag) { int i; for (i = 0; i < nTables; ++i) { @@ -3168,7 +3169,7 @@ int TrueTypeFontFile::seekTable(char *tag) { return -1; } -int TrueTypeFontFile::seekTableIdx(char *tag) { +int TrueTypeFontFile::seekTableIdx(const char *tag) { int i; for (i = 0; i < nTables; ++i) { @@ -3179,10 +3180,10 @@ int TrueTypeFontFile::seekTableIdx(char *tag) { return -1; } -void TrueTypeFontFile::cvtEncoding(char **encodingA, GBool pdfFontHasEncoding, +void TrueTypeFontFile::cvtEncoding(const char **encodingA, GBool pdfFontHasEncoding, FontFileOutputFunc outputFunc, void *outputStream) { - char *name; + const char *name; char buf[64]; int i; @@ -3206,7 +3207,7 @@ void TrueTypeFontFile::cvtEncoding(char **encodingA, GBool pdfFontHasEncoding, (*outputFunc)(outputStream, "readonly def\n", 13); } -void TrueTypeFontFile::cvtCharStrings(char **encodingA, +void TrueTypeFontFile::cvtCharStrings(const char **encodingA, CharCodeToUnicode *toUnicode, GBool pdfFontHasEncoding, FontFileOutputFunc outputFunc, @@ -3214,7 +3215,7 @@ void TrueTypeFontFile::cvtCharStrings(char **encodingA, int unicodeCmap, macRomanCmap, msSymbolCmap; int nCmaps, cmapPlatform, cmapEncoding, cmapFmt, cmapOffset; T42FontIndexMode mode; - char *name; + const char *name; char buf[64], buf2[16]; Unicode u; int pos, i, j, k; @@ -3607,7 +3608,7 @@ void TrueTypeFontFile::cvtSfnts(FontFileOutputFunc outputFunc, gfree(locaTable); } -void TrueTypeFontFile::dumpString(char *s, int length, +void TrueTypeFontFile::dumpString(const char *s, int length, FontFileOutputFunc outputFunc, void *outputStream) { char buf[64]; @@ -3635,7 +3636,7 @@ void TrueTypeFontFile::dumpString(char *s, int length, (*outputFunc)(outputStream, "00>\n", 4); } -Guint TrueTypeFontFile::computeTableChecksum(char *data, int length) { +Guint TrueTypeFontFile::computeTableChecksum(const char *data, int length) { Guint checksum, word; int i; diff --git a/pdftops/FontFile.h b/pdftops/FontFile.h index 80d6b1d8e2..f40e998e66 100644 --- a/pdftops/FontFile.h +++ b/pdftops/FontFile.h @@ -24,7 +24,7 @@ class CharCodeToUnicode; //------------------------------------------------------------------------ -typedef void (*FontFileOutputFunc)(void *stream, char *data, int len); +typedef void (*FontFileOutputFunc)(void *stream, const char *data, int len); //------------------------------------------------------------------------ // FontFile @@ -38,11 +38,11 @@ public: // Returns the font name, as specified internally by the font file. // Returns NULL if no name is available. - virtual char *getName() = 0; + virtual const char *getName() = 0; // Returns the custom font encoding, or NULL if the encoding is not // available. - virtual char **getEncoding() = 0; + virtual const char **getEncoding() = 0; }; //------------------------------------------------------------------------ @@ -52,10 +52,10 @@ public: class Type1FontFile: public FontFile { public: - Type1FontFile(char *file, int len); + Type1FontFile(const char *file, int len); virtual ~Type1FontFile(); - virtual char *getName() { return name; } - virtual char **getEncoding() { return encoding; } + virtual const char *getName() { return name; } + virtual const char **getEncoding() { return (const char **)encoding; } private: @@ -73,11 +73,11 @@ struct Type1CPrivateDict; class Type1CFontFile: public FontFile { public: - Type1CFontFile(char *fileA, int lenA); + Type1CFontFile(const char *fileA, int lenA); virtual ~Type1CFontFile(); - virtual char *getName(); - virtual char **getEncoding(); + virtual const char *getName(); + virtual const char **getEncoding(); // Convert to a Type 1 font, suitable for embedding in a PostScript // file. The name will be used as the PostScript font name. @@ -86,13 +86,13 @@ public: // Convert to a Type 0 CIDFont, suitable for embedding in a // PostScript file. The name will be used as the PostScript font // name. - void convertToCIDType0(char *psName, + void convertToCIDType0(const char *psName, FontFileOutputFunc outputFuncA, void *outputStreamA); // Convert to a Type 0 (but non-CID) composite font, suitable for // embedding in a PostScript file. The name will be used as the // PostScript font name. - void convertToType0(char *psName, + void convertToType0(const char *psName, FontFileOutputFunc outputFuncA, void *outputStreamA); private: @@ -102,16 +102,16 @@ private: void readPrivateDict(Type1CPrivateDict *privateDict, int offset, int size); Gushort *readCharset(int charset, int nGlyphs); - void eexecWrite(char *s); - void eexecCvtGlyph(char *glyphName, Guchar *s, int n); + void eexecWrite(const char *s); + void eexecCvtGlyph(const char *glyphName, Guchar *s, int n); void cvtGlyph(Guchar *s, int n); void cvtGlyphWidth(GBool useOp); void eexecDumpNum(double x, GBool fpA); void eexecDumpOp1(int opA); void eexecDumpOp2(int opA); void eexecWriteCharstring(Guchar *s, int n); - void getDeltaInt(char *buf, char *key, double *opA, int n); - void getDeltaReal(char *buf, char *key, double *opA, int n); + void getDeltaInt(char *buf, const char *key, double *opA, int n); + void getDeltaReal(char *buf, const char *key, double *opA, int n); int getIndexLen(Guchar *indexPtr); Guchar *getIndexValPtr(Guchar *indexPtr, int i); Guchar *getIndexEnd(Guchar *indexPtr); @@ -119,7 +119,7 @@ private: double getNum(Guchar **ptr, GBool *fp); char *getString(int sid, char *buf); - char *file; + const char *file; int len; GString *name; @@ -153,22 +153,22 @@ struct TTFontTableHdr; class TrueTypeFontFile: public FontFile { public: - TrueTypeFontFile(char *fileA, int lenA); + TrueTypeFontFile(const char *fileA, int lenA); ~TrueTypeFontFile(); // This always returns NULL, since it's probably better to trust the // font name in the PDF file rather than the one in the TrueType // font file. - virtual char *getName(); + virtual const char *getName(); - virtual char **getEncoding(); + virtual const char **getEncoding(); // Convert to a Type 42 font, suitable for embedding in a PostScript // file. The name will be used as the PostScript font name (so we // don't need to depend on the 'name' table in the font). The // encoding is needed because the PDF Font object can modify the // encoding. - void convertToType42(char *name, char **encodingA, + void convertToType42(const char *name, const char **encodingA, CharCodeToUnicode *toUnicode, GBool pdfFontHasEncoding, FontFileOutputFunc outputFunc, void *outputStream); @@ -177,14 +177,14 @@ public: // PostScript file. The name will be used as the PostScript font // name (so we don't need to depend on the 'name' table in the // font). - void convertToCIDType2(char *name, Gushort *cidMap, int nCIDs, + void convertToCIDType2(const char *name, Gushort *cidMap, int nCIDs, FontFileOutputFunc outputFunc, void *outputStream); // Convert to a Type 0 (but non-CID) composite font, suitable for // embedding in a PostScript file. The name will be used as the // PostScript font name (so we don't need to depend on the 'name' // table in the font). - void convertToType0(char *name, Gushort *cidMap, int nCIDs, + void convertToType0(const char *name, Gushort *cidMap, int nCIDs, FontFileOutputFunc outputFunc, void *outputStream); // Write a TTF file, filling in any missing tables that are required @@ -194,7 +194,7 @@ public: private: - char *file; + const char *file; int len; char **encoding; @@ -212,19 +212,19 @@ private: int getShort(int pos); Guint getULong(int pos); double getFixed(int pos); - int seekTable(char *tag); - int seekTableIdx(char *tag); - void cvtEncoding(char **encodingA, GBool pdfFontHasEncoding, + int seekTable(const char *tag); + int seekTableIdx(const char *tag); + void cvtEncoding(const char **encodingA, GBool pdfFontHasEncoding, FontFileOutputFunc outputFunc, void *outputStream); - void cvtCharStrings(char **encodingA, CharCodeToUnicode *toUnicode, + void cvtCharStrings(const char **encodingA, CharCodeToUnicode *toUnicode, GBool pdfFontHasEncoding, FontFileOutputFunc outputFunc, void *outputStream); int getCmapEntry(int cmapFmt, int pos, int code); void cvtSfnts(FontFileOutputFunc outputFunc, void *outputStream, GString *name); - void dumpString(char *s, int length, + void dumpString(const char *s, int length, FontFileOutputFunc outputFunc, void *outputStream); - Guint computeTableChecksum(char *data, int length); + Guint computeTableChecksum(const char *data, int length); }; #endif diff --git a/pdftops/Function.cxx b/pdftops/Function.cxx index d91efb7bb3..6882941fde 100644 --- a/pdftops/Function.cxx +++ b/pdftops/Function.cxx @@ -720,7 +720,7 @@ enum PSOp { // Note: 'if' and 'ifelse' are parsed separately. // The rest are listed here in alphabetical order. // The index in this table is equivalent to the entry in PSOp. -char *psOpNames[] = { +const char *psOpNames[] = { "abs", "add", "and", diff --git a/pdftops/GfxFont.cxx b/pdftops/GfxFont.cxx index 1b11ca5ca0..376403c453 100644 --- a/pdftops/GfxFont.cxx +++ b/pdftops/GfxFont.cxx @@ -31,8 +31,8 @@ //------------------------------------------------------------------------ struct StdFontMapEntry { - char *altName; - char *properName; + const char *altName; + const char *properName; }; static StdFontMapEntry stdFontMap[] = { @@ -90,7 +90,7 @@ static StdFontMapEntry stdFontMap[] = { // GfxFont //------------------------------------------------------------------------ -GfxFont *GfxFont::makeFont(XRef *xref, char *tagA, Ref idA, Dict *fontDict) { +GfxFont *GfxFont::makeFont(XRef *xref, const char *tagA, Ref idA, Dict *fontDict) { GString *nameA; GfxFont *font; Object obj1; @@ -126,7 +126,7 @@ GfxFont *GfxFont::makeFont(XRef *xref, char *tagA, Ref idA, Dict *fontDict) { return font; } -GfxFont::GfxFont(char *tagA, Ref idA, GString *nameA) { +GfxFont::GfxFont(const char *tagA, Ref idA, GString *nameA) { ok = gFalse; tag = new GString(tagA); id = idA; @@ -373,18 +373,18 @@ char *GfxFont::readEmbFontFile(XRef *xref, int *len) { // Gfx8BitFont //------------------------------------------------------------------------ -Gfx8BitFont::Gfx8BitFont(XRef *xref, char *tagA, Ref idA, GString *nameA, +Gfx8BitFont::Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GString *nameA, GfxFontType typeA, Dict *fontDict): GfxFont(tagA, idA, nameA) { BuiltinFont *builtinFont; - char **baseEnc; + const char **baseEnc; GBool baseEncFromFontFile; char *buf; int len; FontFile *fontFile; int code, code2; - char *charName; + const char *charName; GBool missing, hex; Unicode toUnicode[256]; double mul; @@ -601,7 +601,7 @@ Gfx8BitFont::Gfx8BitFont(XRef *xref, char *tagA, Ref idA, GString *nameA, } else if (obj3.isName()) { if (code < 256) { if (encFree[code]) { - gfree(enc[code]); + gfree((void *)enc[code]); } enc[code] = copyString(obj3.getName()); encFree[code] = gTrue; @@ -777,7 +777,7 @@ Gfx8BitFont::~Gfx8BitFont() { for (i = 0; i < 256; ++i) { if (encFree[i] && enc[i]) { - gfree(enc[i]); + gfree((void *)enc[i]); } } ctu->decRefCnt(); @@ -789,7 +789,7 @@ Gfx8BitFont::~Gfx8BitFont() { } } -int Gfx8BitFont::getNextChar(char *s, int len, CharCode *code, +int Gfx8BitFont::getNextChar(const char *s, int len, CharCode *code, Unicode *u, int uSize, int *uLen, double *dx, double *dy, double *ox, double *oy) { CharCode c; @@ -837,7 +837,7 @@ static int cmpWidthExcepV(const void *w1, const void *w2) { ((GfxFontCIDWidthExcepV *)w2)->first; } -GfxCIDFont::GfxCIDFont(XRef *xref, char *tagA, Ref idA, GString *nameA, +GfxCIDFont::GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GString *nameA, Dict *fontDict): GfxFont(tagA, idA, nameA) { @@ -1153,7 +1153,7 @@ GfxCIDFont::~GfxCIDFont() { } } -int GfxCIDFont::getNextChar(char *s, int len, CharCode *code, +int GfxCIDFont::getNextChar(const char *s, int len, CharCode *code, Unicode *u, int uSize, int *uLen, double *dx, double *dy, double *ox, double *oy) { CID cid; @@ -1292,7 +1292,7 @@ GfxFontDict::~GfxFontDict() { gfree(fonts); } -GfxFont *GfxFontDict::lookup(char *tag) { +GfxFont *GfxFontDict::lookup(const char *tag) { int i; for (i = 0; i < numFonts; ++i) { diff --git a/pdftops/GfxFont.h b/pdftops/GfxFont.h index 80a9e45864..d564e1922c 100644 --- a/pdftops/GfxFont.h +++ b/pdftops/GfxFont.h @@ -84,9 +84,9 @@ class GfxFont { public: // Build a GfxFont object. - static GfxFont *makeFont(XRef *xref, char *tagA, Ref idA, Dict *fontDict); + static GfxFont *makeFont(XRef *xref, const char *tagA, Ref idA, Dict *fontDict); - GfxFont(char *tagA, Ref idA, GString *nameA); + GfxFont(const char *tagA, Ref idA, GString *nameA); virtual ~GfxFont(); @@ -99,7 +99,7 @@ public: Ref *getID() { return &id; } // Does this font match the tag? - GBool matches(char *tagA) { return !tag->cmp(tagA); } + GBool matches(const char *tagA) { return !tag->cmp(tagA); } // Get base font name. GString *getName() { return name; } @@ -151,7 +151,7 @@ public: // is the number of entries available in , and is set to // the number actually used. Returns the number of bytes used by // the char code. - virtual int getNextChar(char *s, int len, CharCode *code, + virtual int getNextChar(const char *s, int len, CharCode *code, Unicode *u, int uSize, int *uLen, double *dx, double *dy, double *ox, double *oy) = 0; @@ -184,23 +184,23 @@ protected: class Gfx8BitFont: public GfxFont { public: - Gfx8BitFont(XRef *xref, char *tagA, Ref idA, GString *nameA, + Gfx8BitFont(XRef *xref, const char *tagA, Ref idA, GString *nameA, GfxFontType typeA, Dict *fontDict); virtual ~Gfx8BitFont(); - virtual int getNextChar(char *s, int len, CharCode *code, + virtual int getNextChar(const char *s, int len, CharCode *code, Unicode *u, int uSize, int *uLen, double *dx, double *dy, double *ox, double *oy); // Return the encoding. - char **getEncoding() { return enc; } + const char **getEncoding() { return enc; } // Return the Unicode map. CharCodeToUnicode *getToUnicode(); // Return the character name associated with . - char *getCharName(int code) { return enc[code]; } + const char *getCharName(int code) { return enc[code]; } // Returns true if the PDF font specified an encoding. GBool getHasEncoding() { return hasEncoding; } @@ -219,7 +219,7 @@ public: private: - char *enc[256]; // char code --> char name + const char *enc[256]; // char code --> char name char encFree[256]; // boolean for each char name: if set, // the string is malloc'ed CharCodeToUnicode *ctu; // char code --> Unicode @@ -236,14 +236,14 @@ private: class GfxCIDFont: public GfxFont { public: - GfxCIDFont(XRef *xref, char *tagA, Ref idA, GString *nameA, + GfxCIDFont(XRef *xref, const char *tagA, Ref idA, GString *nameA, Dict *fontDict); virtual ~GfxCIDFont(); virtual GBool isCIDFont() { return gTrue; } - virtual int getNextChar(char *s, int len, CharCode *code, + virtual int getNextChar(const char *s, int len, CharCode *code, Unicode *u, int uSize, int *uLen, double *dx, double *dy, double *ox, double *oy); @@ -285,7 +285,7 @@ public: ~GfxFontDict(); // Get the specified font. - GfxFont *lookup(char *tag); + GfxFont *lookup(const char *tag); // Iterative access. int getNumFonts() { return numFonts; } diff --git a/pdftops/GfxState.cxx b/pdftops/GfxState.cxx index 9c3b5b4469..51e9326ac1 100644 --- a/pdftops/GfxState.cxx +++ b/pdftops/GfxState.cxx @@ -30,7 +30,7 @@ static inline double clip01(double x) { //------------------------------------------------------------------------ -static char *gfxColorSpaceModeNames[] = { +static const char *gfxColorSpaceModeNames[] = { "DeviceGray", "CalGray", "DeviceRGB", @@ -121,7 +121,7 @@ int GfxColorSpace::getNumColorSpaceModes() { return nGfxColorSpaceModes; } -char *GfxColorSpace::getColorSpaceModeName(int idx) { +const char *GfxColorSpace::getColorSpaceModeName(int idx) { return gfxColorSpaceModeNames[idx]; } diff --git a/pdftops/GfxState.h b/pdftops/GfxState.h index ffe25d3bd7..9283eb1ca6 100644 --- a/pdftops/GfxState.h +++ b/pdftops/GfxState.h @@ -97,7 +97,7 @@ public: static int getNumColorSpaceModes(); // Return the name of the th color space mode. - static char *getColorSpaceModeName(int idx); + static const char *getColorSpaceModeName(int idx); private: }; diff --git a/pdftops/GlobalParams.cxx b/pdftops/GlobalParams.cxx index dc8127a1ae..0f723f1f6c 100644 --- a/pdftops/GlobalParams.cxx +++ b/pdftops/GlobalParams.cxx @@ -70,7 +70,7 @@ DisplayFontParam::DisplayFontParam(GString *nameA, } } -DisplayFontParam::DisplayFontParam(char *nameA, char *xlfdA, char *encodingA) { +DisplayFontParam::DisplayFontParam(const char *nameA, const char *xlfdA, const char *encodingA) { name = new GString(nameA); kind = displayFontX; x.xlfd = new GString(xlfdA); @@ -125,7 +125,7 @@ PSFontParam::~PSFontParam() { // parsing //------------------------------------------------------------------------ -GlobalParams::GlobalParams(char *cfgFileName) { +GlobalParams::GlobalParams(const char *cfgFileName) { UnicodeMap *map; DisplayFontParam *dfp; GString *fileName; @@ -157,7 +157,7 @@ GlobalParams::GlobalParams(char *cfgFileName) { displayCIDFonts = new GHash(); displayNamedCIDFonts = new GHash(); #if HAVE_PAPER_H - char *paperName; + const char *paperName; const struct paper *paperType; paperinit(); if ((paperName = systempapername())) { @@ -644,7 +644,7 @@ void GlobalParams::parsePSFont(GList *tokens, GString *fileName, int line) { psFonts->add(param->pdfFontName, param); } -void GlobalParams::parsePSFont16(char *cmdName, GList *fontList, +void GlobalParams::parsePSFont16(const char *cmdName, GList *fontList, GList *tokens, GString *fileName, int line) { PSFontParam *param; int wMode; @@ -724,7 +724,7 @@ void GlobalParams::parseInitialZoom(GList *tokens, initialZoom = ((GString *)tokens->get(1))->copy(); } -void GlobalParams::parseFontRastControl(char *cmdName, FontRastControl *val, +void GlobalParams::parseFontRastControl(const char *cmdName, FontRastControl *val, GList *tokens, GString *fileName, int line) { GString *tok; @@ -741,7 +741,7 @@ void GlobalParams::parseFontRastControl(char *cmdName, FontRastControl *val, } } -void GlobalParams::parseCommand(char *cmdName, GString **val, +void GlobalParams::parseCommand(const char *cmdName, GString **val, GList *tokens, GString *fileName, int line) { if (tokens->getLength() != 2) { error(-1, "Bad '%s' config file command (%s:%d)", @@ -754,7 +754,7 @@ void GlobalParams::parseCommand(char *cmdName, GString **val, *val = ((GString *)tokens->get(1))->copy(); } -void GlobalParams::parseYesNo(char *cmdName, GBool *flag, +void GlobalParams::parseYesNo(const char *cmdName, GBool *flag, GList *tokens, GString *fileName, int line) { GString *tok; @@ -826,11 +826,11 @@ GlobalParams::~GlobalParams() { // accessors //------------------------------------------------------------------------ -CharCode GlobalParams::getMacRomanCharCode(char *charName) { +CharCode GlobalParams::getMacRomanCharCode(const char *charName) { return macRomanReverseMap->lookup(charName); } -Unicode GlobalParams::mapNameToUnicode(char *charName) { +Unicode GlobalParams::mapNameToUnicode(const char *charName) { return nameToUnicode->lookup(charName); } @@ -1076,7 +1076,7 @@ GBool GlobalParams::getTextKeepTinyChars() { } GString *GlobalParams::findFontFile(GString *fontName, - char *ext1, char *ext2) { + const char *ext1, const char *ext2) { GString *dir, *fileName; FILE *f; int i; @@ -1221,7 +1221,7 @@ void GlobalParams::addDisplayFont(DisplayFontParam *param) { globalParamsUnlock; } -void GlobalParams::setPSFile(char *file) { +void GlobalParams::setPSFile(const char *file) { globalParamsLock; if (psFile) { delete psFile; @@ -1239,7 +1239,7 @@ void GlobalParams::setPSImageableArea(int left, int bottom, int right, int top) globalParamsUnlock; } -GBool GlobalParams::setPSPaperSize(char *size) { +GBool GlobalParams::setPSPaperSize(const char *size) { globalParamsLock; if (!strcmp(size, "letter")) { psPaperWidth = 612; @@ -1332,14 +1332,14 @@ void GlobalParams::setPSASCIIHex(GBool hex) { globalParamsUnlock; } -void GlobalParams::setTextEncoding(char *encodingName) { +void GlobalParams::setTextEncoding(const char *encodingName) { globalParamsLock; delete textEncoding; textEncoding = new GString(encodingName); globalParamsUnlock; } -GBool GlobalParams::setTextEOL(char *s) { +GBool GlobalParams::setTextEOL(const char *s) { globalParamsLock; if (!strcmp(s, "unix")) { textEOL = eolUnix; @@ -1361,14 +1361,14 @@ void GlobalParams::setTextKeepTinyChars(GBool keep) { globalParamsUnlock; } -void GlobalParams::setInitialZoom(char *s) { +void GlobalParams::setInitialZoom(const char *s) { globalParamsLock; delete initialZoom; initialZoom = new GString(s); globalParamsUnlock; } -GBool GlobalParams::setT1libControl(char *s) { +GBool GlobalParams::setT1libControl(const char *s) { GBool ok; globalParamsLock; @@ -1377,7 +1377,7 @@ GBool GlobalParams::setT1libControl(char *s) { return ok; } -GBool GlobalParams::setFreeTypeControl(char *s) { +GBool GlobalParams::setFreeTypeControl(const char *s) { GBool ok; globalParamsLock; @@ -1386,7 +1386,7 @@ GBool GlobalParams::setFreeTypeControl(char *s) { return ok; } -GBool GlobalParams::setFontRastControl(FontRastControl *val, char *s) { +GBool GlobalParams::setFontRastControl(FontRastControl *val, const char *s) { if (!strcmp(s, "none")) { *val = fontRastNone; } else if (!strcmp(s, "plain")) { diff --git a/pdftops/GlobalParams.h b/pdftops/GlobalParams.h index a37b49ff97..6cb91b4c06 100644 --- a/pdftops/GlobalParams.h +++ b/pdftops/GlobalParams.h @@ -69,7 +69,7 @@ public: }; DisplayFontParam(GString *nameA, DisplayFontParamKind kindA); - DisplayFontParam(char *nameA, char *xlfdA, char *encodingA); + DisplayFontParam(const char *nameA, const char *xlfdA, const char *encodingA); ~DisplayFontParam(); }; @@ -125,15 +125,15 @@ public: // Initialize the global parameters by attempting to read a config // file. - GlobalParams(char *cfgFileName); + GlobalParams(const char *cfgFileName); ~GlobalParams(); //----- accessors - CharCode getMacRomanCharCode(char *charName); + CharCode getMacRomanCharCode(const char *charName); - Unicode mapNameToUnicode(char *charName); + Unicode mapNameToUnicode(const char *charName); FILE *getCIDToUnicodeFile(GString *collection); UnicodeMap *getResidentUnicodeMap(GString *encodingName); FILE *getUnicodeMapFile(GString *encodingName); @@ -157,7 +157,7 @@ public: GBool getPSASCIIHex(); EndOfLineKind getTextEOL(); GBool getTextKeepTinyChars(); - GString *findFontFile(GString *fontName, char *ext1, char *ext2); + GString *findFontFile(GString *fontName, const char *ext1, const char *ext2); GString *getInitialZoom(); FontRastControl getT1libControl(); FontRastControl getFreeTypeControl(); @@ -175,8 +175,8 @@ public: //----- functions to set parameters void addDisplayFont(DisplayFontParam *param); - void setPSFile(char *file); - GBool setPSPaperSize(char *size); + void setPSFile(const char *file); + GBool setPSPaperSize(const char *size); void setPSImageableArea(int left, int bottom, int right, int top); void setPSPaperWidth(int width); void setPSPaperHeight(int height); @@ -188,12 +188,12 @@ public: void setPSEmbedCIDTrueType(GBool embed); void setPSOPI(GBool opi); void setPSASCIIHex(GBool hex); - void setTextEncoding(char *encodingName); - GBool setTextEOL(char *s); + void setTextEncoding(const char *encodingName); + GBool setTextEOL(const char *s); void setTextKeepTinyChars(GBool keep); - void setInitialZoom(char *s); - GBool setT1libControl(char *s); - GBool setFreeTypeControl(char *s); + void setInitialZoom(const char *s); + GBool setT1libControl(const char *s); + GBool setFreeTypeControl(const char *s); void setMapNumericCharNames(GBool map); void setPrintCommands(GBool printCommandsA); void setErrQuiet(GBool errQuietA); @@ -213,20 +213,20 @@ private: void parsePSPaperSize(GList *tokens, GString *fileName, int line); void parsePSLevel(GList *tokens, GString *fileName, int line); void parsePSFont(GList *tokens, GString *fileName, int line); - void parsePSFont16(char *cmdName, GList *fontList, + void parsePSFont16(const char *cmdName, GList *fontList, GList *tokens, GString *fileName, int line); void parseTextEncoding(GList *tokens, GString *fileName, int line); void parseTextEOL(GList *tokens, GString *fileName, int line); void parseFontDir(GList *tokens, GString *fileName, int line); void parseInitialZoom(GList *tokens, GString *fileName, int line); - void parseFontRastControl(char *cmdName, FontRastControl *val, + void parseFontRastControl(const char *cmdName, FontRastControl *val, GList *tokens, GString *fileName, int line); - void parseCommand(char *cmdName, GString **val, + void parseCommand(const char *cmdName, GString **val, GList *tokens, GString *fileName, int line); - void parseYesNo(char *cmdName, GBool *flag, + void parseYesNo(const char *cmdName, GBool *flag, GList *tokens, GString *fileName, int line); UnicodeMap *getUnicodeMap2(GString *encodingName); - GBool setFontRastControl(FontRastControl *val, char *s); + GBool setFontRastControl(FontRastControl *val, const char *s); //----- static tables diff --git a/pdftops/JBIG2Stream.cxx b/pdftops/JBIG2Stream.cxx index 1334368f4c..25f8756d9f 100644 --- a/pdftops/JBIG2Stream.cxx +++ b/pdftops/JBIG2Stream.cxx @@ -1452,7 +1452,7 @@ int JBIG2Stream::lookChar() { return EOF; } -GString *JBIG2Stream::getPSFilter(char *indent) { +GString *JBIG2Stream::getPSFilter(const char *indent) { return NULL; } diff --git a/pdftops/JBIG2Stream.h b/pdftops/JBIG2Stream.h index b46a4db46e..05a4d28c32 100644 --- a/pdftops/JBIG2Stream.h +++ b/pdftops/JBIG2Stream.h @@ -39,7 +39,7 @@ public: virtual void reset(); virtual int getChar(); virtual int lookChar(); - virtual GString *getPSFilter(char *indent); + virtual GString *getPSFilter(const char *indent); virtual GBool isBinary(GBool last = gTrue); private: diff --git a/pdftops/Makefile b/pdftops/Makefile index 71fd531782..583c431090 100644 --- a/pdftops/Makefile +++ b/pdftops/Makefile @@ -1,5 +1,5 @@ # -# "$Id: Makefile,v 1.6.2.8 2003/01/07 18:27:10 mike Exp $" +# "$Id: Makefile,v 1.6.2.9 2003/05/14 18:22:50 mike Exp $" # # pdftops filter Makefile for the Common UNIX Printing System (CUPS). # @@ -10,6 +10,8 @@ include ../Makedefs +OPTIONS = -Wwrite-strings + # # Object files... # @@ -123,5 +125,5 @@ include Dependencies # -# End of "$Id: Makefile,v 1.6.2.8 2003/01/07 18:27:10 mike Exp $". +# End of "$Id: Makefile,v 1.6.2.9 2003/05/14 18:22:50 mike Exp $". # diff --git a/pdftops/NameToCharCode.cxx b/pdftops/NameToCharCode.cxx index f4292f4277..00998160b0 100644 --- a/pdftops/NameToCharCode.cxx +++ b/pdftops/NameToCharCode.cxx @@ -47,7 +47,7 @@ NameToCharCode::~NameToCharCode() { gfree(tab); } -void NameToCharCode::add(char *name, CharCode c) { +void NameToCharCode::add(const char *name, CharCode c) { NameToCharCodeEntry *oldTab; int h, i, oldSize; @@ -89,7 +89,7 @@ void NameToCharCode::add(char *name, CharCode c) { ++len; } -CharCode NameToCharCode::lookup(char *name) { +CharCode NameToCharCode::lookup(const char *name) { int h; h = hash(name); @@ -104,8 +104,8 @@ CharCode NameToCharCode::lookup(char *name) { return 0; } -int NameToCharCode::hash(char *name) { - char *p; +int NameToCharCode::hash(const char *name) { + const char *p; unsigned int h; h = 0; diff --git a/pdftops/NameToCharCode.h b/pdftops/NameToCharCode.h index 30147fb07f..d5ab3a3a1b 100644 --- a/pdftops/NameToCharCode.h +++ b/pdftops/NameToCharCode.h @@ -27,12 +27,12 @@ public: NameToCharCode(); ~NameToCharCode(); - void add(char *name, CharCode c); - CharCode lookup(char *name); + void add(const char *name, CharCode c); + CharCode lookup(const char *name); private: - int hash(char *name); + int hash(const char *name); NameToCharCodeEntry *tab; int size; diff --git a/pdftops/NameToUnicodeTable.h b/pdftops/NameToUnicodeTable.h index 4f28ffff9f..6c24d12b3a 100644 --- a/pdftops/NameToUnicodeTable.h +++ b/pdftops/NameToUnicodeTable.h @@ -8,7 +8,7 @@ static struct { Unicode u; - char *name; + const char *name; } nameToUnicodeTab[] = { {0x0021, "!"}, {0x0023, "#"}, diff --git a/pdftops/Object.cxx b/pdftops/Object.cxx index e25a70a8eb..8d01b958c9 100644 --- a/pdftops/Object.cxx +++ b/pdftops/Object.cxx @@ -24,7 +24,7 @@ // Object //------------------------------------------------------------------------ -char *objTypeNames[numObjTypes] = { +const char *objTypeNames[numObjTypes] = { "boolean", "integer", "real", @@ -134,7 +134,7 @@ void Object::free() { type = objNone; } -char *Object::getTypeName() { +const char *Object::getTypeName() { return objTypeNames[type]; } diff --git a/pdftops/Object.h b/pdftops/Object.h index 64fff65378..61b7f6f103 100644 --- a/pdftops/Object.h +++ b/pdftops/Object.h @@ -89,7 +89,7 @@ public: { initObj(objReal); real = realA; return this; } Object *initString(GString *stringA) { initObj(objString); string = stringA; return this; } - Object *initName(char *nameA) + Object *initName(const char *nameA) { initObj(objName); name = copyString(nameA); return this; } Object *initNull() { initObj(objNull); return this; } @@ -98,7 +98,7 @@ public: Object *initStream(Stream *streamA); Object *initRef(int numA, int genA) { initObj(objRef); ref.num = numA; ref.gen = genA; return this; } - Object *initCmd(char *cmdA) + Object *initCmd(const char *cmdA) { initObj(objCmd); cmd = copyString(cmdA); return this; } Object *initError() { initObj(objError); return this; } @@ -134,11 +134,11 @@ public: GBool isNone() { return type == objNone; } // Special type checking. - GBool isName(char *nameA) + GBool isName(const char *nameA) { return type == objName && !strcmp(name, nameA); } - GBool isDict(char *dictType); - GBool isStream(char *dictType); - GBool isCmd(char *cmdA) + GBool isDict(const char *dictType); + GBool isStream(const char *dictType); + GBool isCmd(const char *cmdA) { return type == objCmd && !strcmp(cmd, cmdA); } // Accessors. NB: these assume object is of correct type. @@ -164,16 +164,16 @@ public: // Dict accessors. int dictGetLength(); - void dictAdd(char *key, Object *val); - GBool dictIs(char *dictType); - Object *dictLookup(char *key, Object *obj); - Object *dictLookupNF(char *key, Object *obj); - char *dictGetKey(int i); + void dictAdd(const char *key, Object *val); + GBool dictIs(const char *dictType); + Object *dictLookup(const char *key, Object *obj); + Object *dictLookupNF(const char *key, Object *obj); + const char *dictGetKey(int i); Object *dictGetVal(int i, Object *obj); Object *dictGetValNF(int i, Object *obj); // Stream accessors. - GBool streamIs(char *dictType); + GBool streamIs(const char *dictType); void streamReset(); void streamClose(); int streamGetChar(); @@ -184,7 +184,7 @@ public: Dict *streamGetDict(); // Output. - char *getTypeName(); + const char *getTypeName(); void print(FILE *f = stdout); // Memory testing. @@ -239,22 +239,22 @@ inline Object *Object::arrayGetNF(int i, Object *obj) inline int Object::dictGetLength() { return dict->getLength(); } -inline void Object::dictAdd(char *key, Object *val) +inline void Object::dictAdd(const char *key, Object *val) { dict->add(key, val); } -inline GBool Object::dictIs(char *dictType) +inline GBool Object::dictIs(const char *dictType) { return dict->is(dictType); } -inline GBool Object::isDict(char *dictType) +inline GBool Object::isDict(const char *dictType) { return type == objDict && dictIs(dictType); } -inline Object *Object::dictLookup(char *key, Object *obj) +inline Object *Object::dictLookup(const char *key, Object *obj) { return dict->lookup(key, obj); } -inline Object *Object::dictLookupNF(char *key, Object *obj) +inline Object *Object::dictLookupNF(const char *key, Object *obj) { return dict->lookupNF(key, obj); } -inline char *Object::dictGetKey(int i) +inline const char *Object::dictGetKey(int i) { return dict->getKey(i); } inline Object *Object::dictGetVal(int i, Object *obj) @@ -269,10 +269,10 @@ inline Object *Object::dictGetValNF(int i, Object *obj) #include "Stream.h" -inline GBool Object::streamIs(char *dictType) +inline GBool Object::streamIs(const char *dictType) { return stream->getDict()->is(dictType); } -inline GBool Object::isStream(char *dictType) +inline GBool Object::isStream(const char *dictType) { return type == objStream && streamIs(dictType); } inline void Object::streamReset() diff --git a/pdftops/PSOutputDev.cxx b/pdftops/PSOutputDev.cxx index c216b41e06..386c84ef46 100644 --- a/pdftops/PSOutputDev.cxx +++ b/pdftops/PSOutputDev.cxx @@ -44,7 +44,7 @@ // PostScript prolog and setup //------------------------------------------------------------------------ -static char *prolog[] = { +static const char *prolog[] = { "/xpdf 75 dict def xpdf begin", "% PDF special state", "/pdfDictSize 14 def", @@ -353,7 +353,7 @@ static char *prolog[] = { NULL }; -static char *cmapProlog[] = { +static const char *cmapProlog[] = { "/CIDInit /ProcSet findresource begin", "10 dict begin", " begincmap", @@ -403,11 +403,11 @@ static char *cmapProlog[] = { //------------------------------------------------------------------------ struct PSSubstFont { - char *psName; // PostScript name + const char *psName; // PostScript name double mWidth; // width of 'm' character }; -static char *psFonts[] = { +static const char *psFonts[] = { "Courier", "Courier-Bold", "Courier-Oblique", @@ -494,11 +494,11 @@ extern "C" { typedef void (*SignalFunc)(int); } -static void outputToFile(void *stream, char *data, int len) { +static void outputToFile(void *stream, const char *data, int len) { fwrite(data, 1, len, (FILE *)stream); } -PSOutputDev::PSOutputDev(char *fileName, XRef *xrefA, Catalog *catalog, +PSOutputDev::PSOutputDev(const char *fileName, XRef *xrefA, Catalog *catalog, int firstPage, int lastPage, PSOutMode modeA) { FILE *f; PSFileType fileTypeA; @@ -566,7 +566,7 @@ void PSOutputDev::init(PSOutputFunc outputFuncA, void *outputStreamA, PDFRectangle *box; Dict *resDict; Annots *annots; - char **p; + const char **p; int pg; Object obj1, obj2; int i; @@ -872,10 +872,10 @@ void PSOutputDev::setupFont(GfxFont *font, Dict *parentResDict) { GString *name; PSFontParam *fontParam; GString *psNameStr; - char *psName; + const char *psName; char type3Name[64], buf[16]; UnicodeMap *uMap; - char *charName; + const char *charName; double xs, ys; int code; double w1, w2; @@ -1086,9 +1086,9 @@ void PSOutputDev::setupFont(GfxFont *font, Dict *parentResDict) { } } writePS("/"); - writePSName(charName ? charName : (char *)".notdef"); + writePSName(charName ? charName : ".notdef"); } - writePS((i == 256-8) ? (char *)"]\n" : (char *)"\n"); + writePS((i == 256-8) ? "]\n" : "\n"); } writePS("pdfMakeFont\n"); } @@ -1098,7 +1098,7 @@ void PSOutputDev::setupFont(GfxFont *font, Dict *parentResDict) { } } -void PSOutputDev::setupEmbeddedType1Font(Ref *id, char *psName) { +void PSOutputDev::setupEmbeddedType1Font(Ref *id, const char *psName) { static char hexChar[17] = "0123456789abcdef"; Object refObj, strObj, obj1, obj2; Dict *dict; @@ -1223,7 +1223,7 @@ void PSOutputDev::setupEmbeddedType1Font(Ref *id, char *psName) { //~ This doesn't handle .pfb files or binary eexec data (which only //~ happens in pfb files?). -void PSOutputDev::setupExternalType1Font(GString *fileName, char *psName) { +void PSOutputDev::setupExternalType1Font(GString *fileName, const char *psName) { FILE *fontFile; int c; int i; @@ -1264,7 +1264,7 @@ void PSOutputDev::setupExternalType1Font(GString *fileName, char *psName) { } void PSOutputDev::setupEmbeddedType1CFont(GfxFont *font, Ref *id, - char *psName) { + const char *psName) { char *fontBuf; int fontLen; Type1CFontFile *t1cFile; @@ -1302,7 +1302,7 @@ void PSOutputDev::setupEmbeddedType1CFont(GfxFont *font, Ref *id, } void PSOutputDev::setupEmbeddedTrueTypeFont(GfxFont *font, Ref *id, - char *psName) { + const char *psName) { char *fontBuf; int fontLen; TrueTypeFontFile *ttFile; @@ -1344,7 +1344,7 @@ void PSOutputDev::setupEmbeddedTrueTypeFont(GfxFont *font, Ref *id, writePS("%%EndResource\n"); } -void PSOutputDev::setupExternalTrueTypeFont(GfxFont *font, char *psName) { +void PSOutputDev::setupExternalTrueTypeFont(GfxFont *font, const char *psName) { GString *fileName; char *fontBuf; int fontLen; @@ -1390,7 +1390,7 @@ void PSOutputDev::setupExternalTrueTypeFont(GfxFont *font, char *psName) { } void PSOutputDev::setupEmbeddedCIDType0Font(GfxFont *font, Ref *id, - char *psName) { + const char *psName) { char *fontBuf; int fontLen; Type1CFontFile *t1cFile; @@ -1434,7 +1434,7 @@ void PSOutputDev::setupEmbeddedCIDType0Font(GfxFont *font, Ref *id, } void PSOutputDev::setupEmbeddedCIDTrueTypeFont(GfxFont *font, Ref *id, - char *psName) { + const char *psName) { char *fontBuf; int fontLen; TrueTypeFontFile *ttFile; @@ -1481,7 +1481,7 @@ void PSOutputDev::setupEmbeddedCIDTrueTypeFont(GfxFont *font, Ref *id, writePS("%%EndResource\n"); } -void PSOutputDev::setupType3Font(GfxFont *font, char *psName, +void PSOutputDev::setupType3Font(GfxFont *font, const char *psName, Dict *parentResDict) { Dict *resDict; Dict *charProcs; @@ -3254,7 +3254,7 @@ void PSOutputDev::writePSChar(char c) { } } -void PSOutputDev::writePS(char *s) { +void PSOutputDev::writePS(const char *s) { if (t3String) { t3String->append(s); } else { @@ -3300,8 +3300,8 @@ void PSOutputDev::writePSString(GString *s) { writePSChar(')'); } -void PSOutputDev::writePSName(char *s) { - char *p; +void PSOutputDev::writePSName(const char *s) { + const char *p; char c; p = s; diff --git a/pdftops/PSOutputDev.h b/pdftops/PSOutputDev.h index 70836cb4e0..2ab12fc90c 100644 --- a/pdftops/PSOutputDev.h +++ b/pdftops/PSOutputDev.h @@ -45,13 +45,13 @@ enum PSFileType { psGeneric // write to a generic stream }; -typedef void (*PSOutputFunc)(void *stream, char *data, int len); +typedef void (*PSOutputFunc)(void *stream, const char *data, int len); class PSOutputDev: public OutputDev { public: // Open a PostScript output file, and write the prolog. - PSOutputDev(char *fileName, XRef *xrefA, Catalog *catalog, + PSOutputDev(const char *fileName, XRef *xrefA, Catalog *catalog, int firstPage, int lastPage, PSOutMode modeA); // Open a PSOutputDev that will write to a generic stream. @@ -156,14 +156,14 @@ private: void setupResources(Dict *resDict); void setupFonts(Dict *resDict); void setupFont(GfxFont *font, Dict *parentResDict); - void setupEmbeddedType1Font(Ref *id, char *psName); - void setupExternalType1Font(GString *fileName, char *psName); - void setupEmbeddedType1CFont(GfxFont *font, Ref *id, char *psName); - void setupEmbeddedTrueTypeFont(GfxFont *font, Ref *id, char *psName); - void setupExternalTrueTypeFont(GfxFont *font, char *psName); - void setupEmbeddedCIDType0Font(GfxFont *font, Ref *id, char *psName); - void setupEmbeddedCIDTrueTypeFont(GfxFont *font, Ref *id, char *psName); - void setupType3Font(GfxFont *font, char *psName, Dict *parentResDict); + void setupEmbeddedType1Font(Ref *id, const char *psName); + void setupExternalType1Font(GString *fileName, const char *psName); + void setupEmbeddedType1CFont(GfxFont *font, Ref *id, const char *psName); + void setupEmbeddedTrueTypeFont(GfxFont *font, Ref *id, const char *psName); + void setupExternalTrueTypeFont(GfxFont *font, const char *psName); + void setupEmbeddedCIDType0Font(GfxFont *font, Ref *id, const char *psName); + void setupEmbeddedCIDTrueTypeFont(GfxFont *font, Ref *id, const char *psName); + void setupType3Font(GfxFont *font, const char *psName, Dict *parentResDict); void setupImages(Dict *resDict); void setupImage(Ref id, Stream *str); void addProcessColor(double c, double m, double y, double k); @@ -187,10 +187,10 @@ private: GBool getFileSpec(Object *fileSpec, Object *fileName); #endif void writePSChar(char c); - void writePS(char *s); + void writePS(const char *s); void writePSFmt(const char *fmt, ...); void writePSString(GString *s); - void writePSName(char *s); + void writePSName(const char *s); GString *filterPSName(GString *name); PSLevel level; // PostScript level (1, 2, separation) diff --git a/pdftops/Page.cxx b/pdftops/Page.cxx index badf32f1ed..32dd4551c8 100644 --- a/pdftops/Page.cxx +++ b/pdftops/Page.cxx @@ -122,7 +122,7 @@ PageAttrs::~PageAttrs() { resources.free(); } -GBool PageAttrs::readBox(Dict *dict, char *key, PDFRectangle *box) { +GBool PageAttrs::readBox(Dict *dict, const char *key, PDFRectangle *box) { PDFRectangle tmp; Object obj1, obj2; GBool ok; diff --git a/pdftops/Page.h b/pdftops/Page.h index 9714b35773..9537c8381e 100644 --- a/pdftops/Page.h +++ b/pdftops/Page.h @@ -78,7 +78,7 @@ public: private: - GBool readBox(Dict *dict, char *key, PDFRectangle *box); + GBool readBox(Dict *dict, const char *key, PDFRectangle *box); PDFRectangle mediaBox; PDFRectangle cropBox; diff --git a/pdftops/Stream.cxx b/pdftops/Stream.cxx index f0206a41df..dc6e078438 100644 --- a/pdftops/Stream.cxx +++ b/pdftops/Stream.cxx @@ -84,7 +84,7 @@ char *Stream::getLine(char *buf, int size) { return buf; } -GString *Stream::getPSFilter(char *indent) { +GString *Stream::getPSFilter(const char *indent) { return new GString(); } @@ -132,7 +132,7 @@ Stream *Stream::addFilters(Object *dict) { return str; } -Stream *Stream::makeFilter(char *name, Stream *str, Object *params) { +Stream *Stream::makeFilter(const char *name, Stream *str, Object *params) { int pred; // parameters int colors; int bits; @@ -880,7 +880,7 @@ int ASCIIHexStream::lookChar() { return buf; } -GString *ASCIIHexStream::getPSFilter(char *indent) { +GString *ASCIIHexStream::getPSFilter(const char *indent) { GString *s; if (!(s = str->getPSFilter(indent))) { @@ -958,7 +958,7 @@ int ASCII85Stream::lookChar() { return b[index]; } -GString *ASCII85Stream::getPSFilter(char *indent) { +GString *ASCII85Stream::getPSFilter(const char *indent) { GString *s; if (!(s = str->getPSFilter(indent))) { @@ -1137,7 +1137,7 @@ int LZWStream::getCode() { return code; } -GString *LZWStream::getPSFilter(char *indent) { +GString *LZWStream::getPSFilter(const char *indent) { GString *s; if (pred) { @@ -1174,7 +1174,7 @@ void RunLengthStream::reset() { eof = gFalse; } -GString *RunLengthStream::getPSFilter(char *indent) { +GString *RunLengthStream::getPSFilter(const char *indent) { GString *s; if (!(s = str->getPSFilter(indent))) { @@ -1724,7 +1724,7 @@ short CCITTFaxStream::lookBits(int n) { return (inputBuf >> (inputBits - n)) & (0xffff >> (16 - n)); } -GString *CCITTFaxStream::getPSFilter(char *indent) { +GString *CCITTFaxStream::getPSFilter(const char *indent) { GString *s; char s1[50]; @@ -3086,7 +3086,7 @@ int DCTStream::read16() { return (c1 << 8) + c2; } -GString *DCTStream::getPSFilter(char *indent) { +GString *DCTStream::getPSFilter(const char *indent) { GString *s; if (!(s = str->getPSFilter(indent))) { @@ -3276,7 +3276,7 @@ int FlateStream::getRawChar() { return c; } -GString *FlateStream::getPSFilter(char *indent) { +GString *FlateStream::getPSFilter(const char *indent) { return NULL; } @@ -3684,7 +3684,7 @@ void ASCIIHexEncoder::close() { } GBool ASCIIHexEncoder::fillBuf() { - static char *hex = "0123456789abcdef"; + static const char hex[] = "0123456789abcdef"; int c; if (eof) { diff --git a/pdftops/Stream.h b/pdftops/Stream.h index e505081541..e49012dbaa 100644 --- a/pdftops/Stream.h +++ b/pdftops/Stream.h @@ -87,7 +87,7 @@ public: virtual void setPos(Guint pos, int dir = 0) = 0; // Get PostScript command for the filter(s). - virtual GString *getPSFilter(char *indent); + virtual GString *getPSFilter(const char *indent); // Does this stream type potentially contain non-printable chars? virtual GBool isBinary(GBool last = gTrue) = 0; @@ -107,7 +107,7 @@ public: private: - Stream *makeFilter(char *name, Stream *str, Object *params); + Stream *makeFilter(const char *name, Stream *str, Object *params); int ref; // reference count }; @@ -370,7 +370,7 @@ public: virtual int getChar() { int c = lookChar(); buf = EOF; return c; } virtual int lookChar(); - virtual GString *getPSFilter(char *indent); + virtual GString *getPSFilter(const char *indent); virtual GBool isBinary(GBool last = gTrue); private: @@ -393,7 +393,7 @@ public: virtual int getChar() { int ch = lookChar(); ++index; return ch; } virtual int lookChar(); - virtual GString *getPSFilter(char *indent); + virtual GString *getPSFilter(const char *indent); virtual GBool isBinary(GBool last = gTrue); private: @@ -419,7 +419,7 @@ public: virtual int getChar(); virtual int lookChar(); virtual int getRawChar(); - virtual GString *getPSFilter(char *indent); + virtual GString *getPSFilter(const char *indent); virtual GBool isBinary(GBool last = gTrue); private: @@ -463,7 +463,7 @@ public: { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); } virtual int lookChar() { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); } - virtual GString *getPSFilter(char *indent); + virtual GString *getPSFilter(const char *indent); virtual GBool isBinary(GBool last = gTrue); private: @@ -494,7 +494,7 @@ public: virtual int getChar() { int c = lookChar(); buf = EOF; return c; } virtual int lookChar(); - virtual GString *getPSFilter(char *indent); + virtual GString *getPSFilter(const char *indent); virtual GBool isBinary(GBool last = gTrue); private: @@ -564,7 +564,7 @@ public: virtual void reset(); virtual int getChar(); virtual int lookChar(); - virtual GString *getPSFilter(char *indent); + virtual GString *getPSFilter(const char *indent); virtual GBool isBinary(GBool last = gTrue); Stream *getRawStream() { return str; } @@ -663,7 +663,7 @@ public: virtual int getChar(); virtual int lookChar(); virtual int getRawChar(); - virtual GString *getPSFilter(char *indent); + virtual GString *getPSFilter(const char *indent); virtual GBool isBinary(GBool last = gTrue); private: @@ -712,7 +712,7 @@ public: virtual void reset() {} virtual int getChar() { return EOF; } virtual int lookChar() { return EOF; } - virtual GString *getPSFilter(char *indent) { return NULL; } + virtual GString *getPSFilter(const char *indent) { return NULL; } virtual GBool isBinary(GBool last = gTrue) { return gFalse; } }; @@ -730,7 +730,7 @@ public: virtual void close(); virtual int getChar(); virtual int lookChar(); - virtual GString *getPSFilter(char *indent) { return NULL; } + virtual GString *getPSFilter(const char *indent) { return NULL; } virtual GBool isBinary(GBool last = gTrue) { return gFalse; } virtual GBool isEncoder() { return gTrue; } @@ -756,7 +756,7 @@ public: { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); } virtual int lookChar() { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); } - virtual GString *getPSFilter(char *indent) { return NULL; } + virtual GString *getPSFilter(const char *indent) { return NULL; } virtual GBool isBinary(GBool last = gTrue) { return gFalse; } virtual GBool isEncoder() { return gTrue; } @@ -787,7 +787,7 @@ public: { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); } virtual int lookChar() { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); } - virtual GString *getPSFilter(char *indent) { return NULL; } + virtual GString *getPSFilter(const char *indent) { return NULL; } virtual GBool isBinary(GBool last = gTrue) { return gFalse; } virtual GBool isEncoder() { return gTrue; } @@ -818,7 +818,7 @@ public: { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); } virtual int lookChar() { return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); } - virtual GString *getPSFilter(char *indent) { return NULL; } + virtual GString *getPSFilter(const char *indent) { return NULL; } virtual GBool isBinary(GBool last = gTrue) { return gFalse; } virtual GBool isEncoder() { return gTrue; } diff --git a/pdftops/UnicodeMap.cxx b/pdftops/UnicodeMap.cxx index f010ea5eb2..a2c0d1d3a9 100644 --- a/pdftops/UnicodeMap.cxx +++ b/pdftops/UnicodeMap.cxx @@ -118,7 +118,7 @@ UnicodeMap::UnicodeMap(GString *encodingNameA) { refCnt = 1; } -UnicodeMap::UnicodeMap(char *encodingNameA, GBool unicodeOutA, +UnicodeMap::UnicodeMap(const char *encodingNameA, GBool unicodeOutA, UnicodeMapRange *rangesA, int lenA) { encodingName = new GString(encodingNameA); unicodeOut = unicodeOutA; @@ -130,7 +130,7 @@ UnicodeMap::UnicodeMap(char *encodingNameA, GBool unicodeOutA, refCnt = 1; } -UnicodeMap::UnicodeMap(char *encodingNameA, GBool unicodeOutA, +UnicodeMap::UnicodeMap(const char *encodingNameA, GBool unicodeOutA, UnicodeMapFunc funcA) { encodingName = new GString(encodingNameA); unicodeOut = unicodeOutA; diff --git a/pdftops/UnicodeMap.h b/pdftops/UnicodeMap.h index 447215df9b..ea5038c81e 100644 --- a/pdftops/UnicodeMap.h +++ b/pdftops/UnicodeMap.h @@ -49,12 +49,12 @@ public: static UnicodeMap *parse(GString *encodingNameA); // Create a resident UnicodeMap. - UnicodeMap(char *encodingNameA, GBool unicodeOutA, + UnicodeMap(const char *encodingNameA, GBool unicodeOutA, UnicodeMapRange *rangesA, int lenA); // Create a resident UnicodeMap that uses a function instead of a // list of ranges. - UnicodeMap(char *encodingNameA, GBool unicodeOutA, + UnicodeMap(const char *encodingNameA, GBool unicodeOutA, UnicodeMapFunc funcA); ~UnicodeMap(); diff --git a/pdftops/gfile.cxx b/pdftops/gfile.cxx index 8be546b37f..9be53cef67 100644 --- a/pdftops/gfile.cxx +++ b/pdftops/gfile.cxx @@ -108,7 +108,7 @@ GString *getCurrentDir() { return new GString(); } -GString *appendToPath(GString *path, char *fileName) { +GString *appendToPath(GString *path, const char *fileName) { #if defined(VMS) //---------- VMS ---------- //~ this should handle everything necessary for file @@ -274,7 +274,7 @@ GString *appendToPath(GString *path, char *fileName) { #endif } -GString *grabPath(char *fileName) { +GString *grabPath(const char *fileName) { #ifdef VMS //---------- VMS ---------- char *p; @@ -323,7 +323,7 @@ GString *grabPath(char *fileName) { #endif } -GBool isAbsolutePath(char *path) { +GBool isAbsolutePath(const char *path) { #ifdef VMS //---------- VMS ---------- return strchr(path, ':') || @@ -429,7 +429,7 @@ GString *makePathAbsolute(GString *path) { #endif } -time_t getModTime(char *fileName) { +time_t getModTime(const char *fileName) { #ifdef WIN32 //~ should implement this, but it's (currently) only used in xpdf return 0; @@ -443,7 +443,7 @@ time_t getModTime(char *fileName) { #endif } -GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) { +GBool openTempFile(GString **name, FILE **f, const char *mode, const char *ext) { #if defined(WIN32) //---------- Win32 ---------- char *s; @@ -528,7 +528,7 @@ GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) { #endif } -GBool executeCommand(char *cmd) { +GBool executeCommand(const char *cmd) { #ifdef VMS return system(cmd) ? gTrue : gFalse; #else @@ -569,7 +569,7 @@ char *getLine(char *buf, int size, FILE *f) { // GDir and GDirEntry //------------------------------------------------------------------------ -GDirEntry::GDirEntry(char *dirPath, char *nameA, GBool doStat) { +GDirEntry::GDirEntry(const char *dirPath, const char *nameA, GBool doStat) { #ifdef VMS char *p; #elif defined(WIN32) @@ -608,7 +608,7 @@ GDirEntry::~GDirEntry() { delete name; } -GDir::GDir(char *name, GBool doStatA) { +GDir::GDir(const char *name, GBool doStatA) { path = new GString(name); doStat = doStatA; #if defined(WIN32) diff --git a/pdftops/gfile.h b/pdftops/gfile.h index 82f1d7a98e..f5d592de3a 100644 --- a/pdftops/gfile.h +++ b/pdftops/gfile.h @@ -60,14 +60,14 @@ extern GString *getCurrentDir(); // Append a file name to a path string. may be an empty // string, denoting the current directory). Returns . -extern GString *appendToPath(GString *path, char *fileName); +extern GString *appendToPath(GString *path, const char *fileName); // Grab the path from the front of the file name. If there is no // directory component in , returns an empty string. -extern GString *grabPath(char *fileName); +extern GString *grabPath(const char *fileName); // Is this an absolute path or file name? -extern GBool isAbsolutePath(char *path); +extern GBool isAbsolutePath(const char *path); // Make this path absolute by prepending current directory (if path is // relative) or prepending user's directory (if path starts with '~'). @@ -83,10 +83,10 @@ extern time_t getModTime(char *fileName); // should be done to the returned file pointer; the file may be // reopened later for reading, but not for writing. The string // should be "w" or "wb". Returns true on success. -extern GBool openTempFile(GString **name, FILE **f, char *mode, char *ext); +extern GBool openTempFile(GString **name, FILE **f, const char *mode, const char *ext); // Execute . Returns true on success. -extern GBool executeCommand(char *cmd); +extern GBool executeCommand(const char *cmd); // Just like fgets, but handles Unix, Mac, and/or DOS end-of-line // conventions. @@ -99,7 +99,7 @@ extern char *getLine(char *buf, int size, FILE *f); class GDirEntry { public: - GDirEntry(char *dirPath, char *nameA, GBool doStat); + GDirEntry(const char *dirPath, const char *nameA, GBool doStat); ~GDirEntry(); GString *getName() { return name; } GBool isDir() { return dir; } @@ -113,7 +113,7 @@ private: class GDir { public: - GDir(char *name, GBool doStatA = gTrue); + GDir(const char *name, GBool doStatA = gTrue); ~GDir(); GDirEntry *getNextEntry(); void rewind(); diff --git a/pdftops/gmem.c b/pdftops/gmem.c index 5faa3ef243..35bcc46f84 100644 --- a/pdftops/gmem.c +++ b/pdftops/gmem.c @@ -195,7 +195,7 @@ void gMemReport(FILE *f) { } #endif -char *copyString(char *s) { +char *copyString(const char *s) { char *s1; s1 = (char *)gmalloc(strlen(s) + 1); diff --git a/pdftops/gmem.h b/pdftops/gmem.h index 587e7fa43c..03fab6033d 100644 --- a/pdftops/gmem.h +++ b/pdftops/gmem.h @@ -44,7 +44,7 @@ extern void gMemReport(FILE *f); /* * Allocate memory and copy a string into it. */ -extern char *copyString(char *s); +extern char *copyString(const char *s); #ifdef __cplusplus } diff --git a/pdftops/parseargs.c b/pdftops/parseargs.c index 9f579436ad..52108113af 100644 --- a/pdftops/parseargs.c +++ b/pdftops/parseargs.c @@ -41,7 +41,7 @@ GBool parseArgs(ArgDesc *args, int *argc, char *argv[]) { void printUsage(char *program, char *otherArgs, ArgDesc *args) { ArgDesc *arg; - char *typ; + const char *typ; int w, w1; w = 0; -- 2.47.3