[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r8250 - Extractor/src/plugins/pdf
From: |
gnunet |
Subject: |
[GNUnet-SVN] r8250 - Extractor/src/plugins/pdf |
Date: |
Mon, 16 Feb 2009 00:17:04 -0700 |
Author: grothoff
Date: 2009-02-16 00:17:04 -0700 (Mon, 16 Feb 2009)
New Revision: 8250
Modified:
Extractor/src/plugins/pdf/Dict.cc
Extractor/src/plugins/pdf/Dict.h
Extractor/src/plugins/pdf/Error.cc
Extractor/src/plugins/pdf/Error.h
Extractor/src/plugins/pdf/Function.cc
Extractor/src/plugins/pdf/Object.cc
Extractor/src/plugins/pdf/Object.h
Extractor/src/plugins/pdf/Page.cc
Extractor/src/plugins/pdf/Page.h
Extractor/src/plugins/pdf/Params.cc
Extractor/src/plugins/pdf/Params.h
Extractor/src/plugins/pdf/Stream.cc
Extractor/src/plugins/pdf/Stream.h
Extractor/src/plugins/pdf/gfile.cc
Extractor/src/plugins/pdf/gfile.h
Extractor/src/plugins/pdf/pdfextractor.cc
Log:
code clean up
Modified: Extractor/src/plugins/pdf/Dict.cc
===================================================================
--- Extractor/src/plugins/pdf/Dict.cc 2009-02-16 06:46:16 UTC (rev 8249)
+++ Extractor/src/plugins/pdf/Dict.cc 2009-02-16 07:17:04 UTC (rev 8250)
@@ -54,7 +54,7 @@
++length;
}
-inline DictEntry *Dict::find(char *key) {
+inline DictEntry *Dict::find(const char *key) {
int i;
for (i = 0; i < length; ++i) {
@@ -64,19 +64,19 @@
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();
Modified: Extractor/src/plugins/pdf/Dict.h
===================================================================
--- Extractor/src/plugins/pdf/Dict.h 2009-02-16 06:46:16 UTC (rev 8249)
+++ Extractor/src/plugins/pdf/Dict.h 2009-02-16 07:17:04 UTC (rev 8250)
@@ -46,12 +46,12 @@
void add(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 <key> 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);
@@ -71,7 +71,7 @@
int length; // number of entries in dictionary
int ref; // reference count
- DictEntry *find(char *key);
+ DictEntry *find(const char *key);
};
#endif
Modified: Extractor/src/plugins/pdf/Error.cc
===================================================================
--- Extractor/src/plugins/pdf/Error.cc 2009-02-16 06:46:16 UTC (rev 8249)
+++ Extractor/src/plugins/pdf/Error.cc 2009-02-16 07:17:04 UTC (rev 8250)
@@ -17,5 +17,5 @@
#include <stdarg.h>
#include "Error.h"
-void error(int pos, char *msg, ...) {
+void error(int pos, const char *msg, ...) {
}
Modified: Extractor/src/plugins/pdf/Error.h
===================================================================
--- Extractor/src/plugins/pdf/Error.h 2009-02-16 06:46:16 UTC (rev 8249)
+++ Extractor/src/plugins/pdf/Error.h 2009-02-16 07:17:04 UTC (rev 8250)
@@ -18,6 +18,6 @@
#include <stdio.h>
#include "config.h"
-extern void error(int pos, char *msg, ...);
+extern void error(int pos, const char *msg, ...);
#endif
Modified: Extractor/src/plugins/pdf/Function.cc
===================================================================
--- Extractor/src/plugins/pdf/Function.cc 2009-02-16 06:46:16 UTC (rev
8249)
+++ Extractor/src/plugins/pdf/Function.cc 2009-02-16 07:17:04 UTC (rev
8250)
@@ -719,7 +719,7 @@
// 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",
Modified: Extractor/src/plugins/pdf/Object.cc
===================================================================
--- Extractor/src/plugins/pdf/Object.cc 2009-02-16 06:46:16 UTC (rev 8249)
+++ Extractor/src/plugins/pdf/Object.cc 2009-02-16 07:17:04 UTC (rev 8250)
@@ -24,7 +24,7 @@
// Object
//------------------------------------------------------------------------
-char *objTypeNames[numObjTypes] = {
+const char *objTypeNames[numObjTypes] = {
"boolean",
"integer",
"real",
@@ -141,77 +141,10 @@
type = objNone;
}
-char *Object::getTypeName() {
+const char *Object::getTypeName() {
return objTypeNames[type];
}
-void Object::print(FILE *f) {
- Object obj;
- int i;
-
- switch (type) {
- case objBool:
- fprintf(f, "%s", booln ? "true" : "false");
- break;
- case objInt:
- fprintf(f, "%d", intg);
- break;
- case objReal:
- fprintf(f, "%g", real);
- break;
- case objString:
- fprintf(f, "(");
- fwrite(string->getCString(), 1, string->getLength(), stdout);
- fprintf(f, ")");
- break;
- case objName:
- fprintf(f, "/%s", name);
- break;
- case objNull:
- fprintf(f, "null");
- break;
- case objArray:
- fprintf(f, "[");
- for (i = 0; i < arrayGetLength(); ++i) {
- if (i > 0)
- fprintf(f, " ");
- arrayGetNF(i, &obj);
- obj.print(f);
- obj.free();
- }
- fprintf(f, "]");
- break;
- case objDict:
- fprintf(f, "<<");
- for (i = 0; i < dictGetLength(); ++i) {
- fprintf(f, " /%s ", dictGetKey(i));
- dictGetValNF(i, &obj);
- obj.print(f);
- obj.free();
- }
- fprintf(f, " >>");
- break;
- case objStream:
- fprintf(f, "<stream>");
- break;
- case objRef:
- fprintf(f, "%d %d R", ref.num, ref.gen);
- break;
- case objCmd:
- fprintf(f, "%s", cmd);
- break;
- case objError:
- fprintf(f, "<error>");
- break;
- case objEOF:
- fprintf(f, "<EOF>");
- break;
- case objNone:
- fprintf(f, "<none>");
- break;
- }
-}
-
void Object::memCheck(FILE *f) {
#ifdef DEBUG_MEM
int i;
Modified: Extractor/src/plugins/pdf/Object.h
===================================================================
--- Extractor/src/plugins/pdf/Object.h 2009-02-16 06:46:16 UTC (rev 8249)
+++ Extractor/src/plugins/pdf/Object.h 2009-02-16 07:17:04 UTC (rev 8250)
@@ -136,11 +136,11 @@
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.
@@ -167,15 +167,15 @@
// 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);
+ GBool dictIs(const char *dictType);
+ Object *dictLookup(const char *key, Object *obj);
+ Object *dictLookupNF(const char *key, Object *obj);
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();
@@ -186,8 +186,7 @@
Dict *streamGetDict();
// Output.
- char *getTypeName();
- void print(FILE *f = stdout);
+ const char *getTypeName();
// Memory testing.
static void memCheck(FILE *f);
@@ -244,16 +243,16 @@
inline void Object::dictAdd(char *key, Object *val)
{ if (type == objDict) dict->add(key, val); }
-inline GBool Object::dictIs(char *dictType)
+inline GBool Object::dictIs(const char *dictType)
{ return (type == objDict) && 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)
{ if (type != objDict) return obj->initNull(); return dict->lookup(key,
obj); }
-inline Object *Object::dictLookupNF(char *key, Object *obj)
+inline Object *Object::dictLookupNF(const char *key, Object *obj)
{ if (type != objDict) return obj->initNull(); return dict->lookupNF(key,
obj); }
inline char *Object::dictGetKey(int i)
@@ -271,10 +270,10 @@
#include "Stream.h"
-inline GBool Object::streamIs(char *dictType)
+inline GBool Object::streamIs(const char *dictType)
{ return (type == objStream) && 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()
Modified: Extractor/src/plugins/pdf/Page.cc
===================================================================
--- Extractor/src/plugins/pdf/Page.cc 2009-02-16 06:46:16 UTC (rev 8249)
+++ Extractor/src/plugins/pdf/Page.cc 2009-02-16 07:17:04 UTC (rev 8250)
@@ -124,7 +124,7 @@
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;
Modified: Extractor/src/plugins/pdf/Page.h
===================================================================
--- Extractor/src/plugins/pdf/Page.h 2009-02-16 06:46:16 UTC (rev 8249)
+++ Extractor/src/plugins/pdf/Page.h 2009-02-16 07:17:04 UTC (rev 8250)
@@ -78,7 +78,7 @@
private:
- GBool readBox(Dict *dict, char *key, PDFRectangle *box);
+ GBool readBox(Dict *dict, const char *key, PDFRectangle *box);
PDFRectangle mediaBox;
PDFRectangle cropBox;
Modified: Extractor/src/plugins/pdf/Params.cc
===================================================================
--- Extractor/src/plugins/pdf/Params.cc 2009-02-16 06:46:16 UTC (rev 8249)
+++ Extractor/src/plugins/pdf/Params.cc 2009-02-16 07:17:04 UTC (rev 8250)
@@ -19,7 +19,8 @@
DevFontMapEntry *devFontMap = NULL;
static int devFontMapLen, devFontMapSize;
-void initParams(char *userConfigFile, char *sysConfigFile) {
+void initParams(const char *userConfigFile,
+ const char *sysConfigFile) {
GString *fileName;
FILE *f;
char buf[256];
Modified: Extractor/src/plugins/pdf/Params.h
===================================================================
--- Extractor/src/plugins/pdf/Params.h 2009-02-16 06:46:16 UTC (rev 8249)
+++ Extractor/src/plugins/pdf/Params.h 2009-02-16 07:17:04 UTC (rev 8250)
@@ -31,7 +31,8 @@
// <userConfigFile> exists, read it; else if <sysConfigFile> exists,
// read it. <userConfigFile> is relative to the user's home
// directory; <sysConfigFile> should be an absolute path.
-extern void initParams(char *userConfigFile, char *sysConfigFile);
+extern void initParams(const char *userConfigFile,
+ const char *sysConfigFile);
// Free memory used for font path and font map.
extern void freeParams();
Modified: Extractor/src/plugins/pdf/Stream.cc
===================================================================
--- Extractor/src/plugins/pdf/Stream.cc 2009-02-16 06:46:16 UTC (rev 8249)
+++ Extractor/src/plugins/pdf/Stream.cc 2009-02-16 07:17:04 UTC (rev 8250)
@@ -85,7 +85,7 @@
return buf;
}
-GString *Stream::getPSFilter(int psLevel, char *indent) {
+GString *Stream::getPSFilter(int psLevel, const char *indent) {
return new GString();
}
@@ -930,7 +930,7 @@
return buf;
}
-GString *ASCIIHexStream::getPSFilter(int psLevel, char *indent) {
+GString *ASCIIHexStream::getPSFilter(int psLevel, const char *indent) {
GString *s;
if (psLevel < 2) {
@@ -1011,7 +1011,7 @@
return b[index];
}
-GString *ASCII85Stream::getPSFilter(int psLevel, char *indent) {
+GString *ASCII85Stream::getPSFilter(int psLevel, const char *indent) {
GString *s;
if (psLevel < 2) {
@@ -1197,7 +1197,7 @@
return code;
}
-GString *LZWStream::getPSFilter(int psLevel, char *indent) {
+GString *LZWStream::getPSFilter(int psLevel, const char *indent) {
GString *s;
if (psLevel < 2 || pred) {
@@ -1234,7 +1234,7 @@
eof = gFalse;
}
-GString *RunLengthStream::getPSFilter(int psLevel, char *indent) {
+GString *RunLengthStream::getPSFilter(int psLevel, const char *indent) {
GString *s;
if (psLevel < 2) {
@@ -2388,7 +2388,7 @@
#endif
-GString *CCITTFaxStream::getPSFilter(int psLevel, char *indent) {
+GString *CCITTFaxStream::getPSFilter(int psLevel, const char *indent) {
GString *s;
char s1[50];
@@ -3829,7 +3829,7 @@
return (c1 << 8) + c2;
}
-GString *DCTStream::getPSFilter(int psLevel, char *indent) {
+GString *DCTStream::getPSFilter(int psLevel, const char *indent) {
GString *s;
if (psLevel < 2) {
@@ -4026,7 +4026,7 @@
return c;
}
-GString *FlateStream::getPSFilter(int psLevel, char *indent) {
+GString *FlateStream::getPSFilter(int psLevel, const char *indent) {
GString *s;
if (psLevel < 3 || pred) {
@@ -4455,7 +4455,7 @@
}
GBool ASCIIHexEncoder::fillBuf() {
- static char *hex = "0123456789abcdef";
+ static const char *hex = "0123456789abcdef";
int c;
if (eof) {
Modified: Extractor/src/plugins/pdf/Stream.h
===================================================================
--- Extractor/src/plugins/pdf/Stream.h 2009-02-16 06:46:16 UTC (rev 8249)
+++ Extractor/src/plugins/pdf/Stream.h 2009-02-16 07:17:04 UTC (rev 8250)
@@ -88,7 +88,7 @@
virtual void setPos(Guint pos, int dir = 0) = 0;
// Get PostScript command for the filter(s).
- virtual GString *getPSFilter(int psLevel, char *indent);
+ virtual GString *getPSFilter(int psLevel, const char *indent);
// Does this stream type potentially contain non-printable chars?
virtual GBool isBinary(GBool last = gTrue) = 0;
@@ -382,7 +382,7 @@
virtual int getChar()
{ int c = lookChar(); buf = EOF; return c; }
virtual int lookChar();
- virtual GString *getPSFilter(int psLevel, char *indent);
+ virtual GString *getPSFilter(int psLevel, const char *indent);
virtual GBool isBinary(GBool last = gTrue);
private:
@@ -405,7 +405,7 @@
virtual int getChar()
{ int ch = lookChar(); ++index; return ch; }
virtual int lookChar();
- virtual GString *getPSFilter(int psLevel, char *indent);
+ virtual GString *getPSFilter(int psLevel, const char *indent);
virtual GBool isBinary(GBool last = gTrue);
private:
@@ -431,7 +431,7 @@
virtual int getChar();
virtual int lookChar();
virtual int getRawChar();
- virtual GString *getPSFilter(int psLevel, char *indent);
+ virtual GString *getPSFilter(int psLevel, const char *indent);
virtual GBool isBinary(GBool last = gTrue);
private:
@@ -475,7 +475,7 @@
{ return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); }
virtual int lookChar()
{ return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); }
- virtual GString *getPSFilter(int psLevel, char *indent);
+ virtual GString *getPSFilter(int psLevel, const char *indent);
virtual GBool isBinary(GBool last = gTrue);
private:
@@ -506,7 +506,7 @@
virtual int getChar()
{ int c = lookChar(); buf = EOF; return c; }
virtual int lookChar();
- virtual GString *getPSFilter(int psLevel, char *indent);
+ virtual GString *getPSFilter(int psLevel, const char *indent);
virtual GBool isBinary(GBool last = gTrue);
private:
@@ -578,7 +578,7 @@
virtual void reset();
virtual int getChar();
virtual int lookChar();
- virtual GString *getPSFilter(int psLevel, char *indent);
+ virtual GString *getPSFilter(int psLevel, const char *indent);
virtual GBool isBinary(GBool last = gTrue);
Stream *getRawStream() { return str; }
@@ -679,7 +679,7 @@
virtual int getChar();
virtual int lookChar();
virtual int getRawChar();
- virtual GString *getPSFilter(int psLevel, char *indent);
+ virtual GString *getPSFilter(int psLevel, const char *indent);
virtual GBool isBinary(GBool last = gTrue);
private:
@@ -728,7 +728,7 @@
virtual void reset() {}
virtual int getChar() { return EOF; }
virtual int lookChar() { return EOF; }
- virtual GString *getPSFilter(int psLevel, char *indent) { return NULL; }
+ virtual GString *getPSFilter(int psLevel, const char *indent) { return
NULL; }
virtual GBool isBinary(GBool last = gTrue) { return gFalse; }
};
@@ -745,7 +745,7 @@
virtual void reset();
virtual int getChar();
virtual int lookChar();
- virtual GString *getPSFilter(int psLevel, char *indent) { return NULL; }
+ virtual GString *getPSFilter(int psLevel, const char *indent) { return NULL;
}
virtual GBool isBinary(GBool last = gTrue);
virtual GBool isEncoder() { return gTrue; }
@@ -770,7 +770,7 @@
{ return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); }
virtual int lookChar()
{ return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); }
- virtual GString *getPSFilter(int psLevel, char *indent) { return NULL; }
+ virtual GString *getPSFilter(int psLevel, const char *indent) { return NULL;
}
virtual GBool isBinary(GBool last = gTrue) { return gFalse; }
virtual GBool isEncoder() { return gTrue; }
@@ -800,7 +800,7 @@
{ return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); }
virtual int lookChar()
{ return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); }
- virtual GString *getPSFilter(int psLevel, char *indent) { return NULL; }
+ virtual GString *getPSFilter(int psLevel, const char *indent) { return NULL;
}
virtual GBool isBinary(GBool last = gTrue) { return gFalse; }
virtual GBool isEncoder() { return gTrue; }
@@ -830,7 +830,7 @@
{ return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr++ & 0xff); }
virtual int lookChar()
{ return (bufPtr >= bufEnd && !fillBuf()) ? EOF : (*bufPtr & 0xff); }
- virtual GString *getPSFilter(int psLevel, char *indent) { return NULL; }
+ virtual GString *getPSFilter(int psLevel, const char *indent) { return NULL;
}
virtual GBool isBinary(GBool last = gTrue) { return gTrue; }
virtual GBool isEncoder() { return gTrue; }
Modified: Extractor/src/plugins/pdf/gfile.cc
===================================================================
--- Extractor/src/plugins/pdf/gfile.cc 2009-02-16 06:46:16 UTC (rev 8249)
+++ Extractor/src/plugins/pdf/gfile.cc 2009-02-16 07:17:04 UTC (rev 8250)
@@ -75,7 +75,7 @@
return new GString();
}
-GString *appendToPath(GString *path, char *fileName) {
+GString *appendToPath(GString *path, const char *fileName) {
#if defined(WIN32)
//---------- Win32 ----------
GString *tmp;
Modified: Extractor/src/plugins/pdf/gfile.h
===================================================================
--- Extractor/src/plugins/pdf/gfile.h 2009-02-16 06:46:16 UTC (rev 8249)
+++ Extractor/src/plugins/pdf/gfile.h 2009-02-16 07:17:04 UTC (rev 8250)
@@ -33,7 +33,7 @@
// Append a file name to a path string. <path> may be an empty
// string, denoting the current directory). Returns <path>.
-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 <fileName>, returns an empty string.
Modified: Extractor/src/plugins/pdf/pdfextractor.cc
===================================================================
--- Extractor/src/plugins/pdf/pdfextractor.cc 2009-02-16 06:46:16 UTC (rev
8249)
+++ Extractor/src/plugins/pdf/pdfextractor.cc 2009-02-16 07:17:04 UTC (rev
8250)
@@ -60,12 +60,12 @@
static struct EXTRACTOR_Keywords * printInfoString(Dict *infoDict,
- char *key,
+ const char *key,
EXTRACTOR_KeywordType type,
struct EXTRACTOR_Keywords
* next) {
Object obj;
GString *s1;
- char * s;
+ const char * s;
if (infoDict->lookup(key, &obj)->isString()) {
s1 = obj.getString();
@@ -74,12 +74,12 @@
(((unsigned char)s[1]) & 0xff) == 0xff) {
char * result;
- result = EXTRACTOR_common_convert_to_utf8((const char*) &s[2],
s1->getLength() - 2, "UTF-16BE");
+ result = EXTRACTOR_common_convert_to_utf8(&s[2], s1->getLength() - 2,
"UTF-16BE");
next = addKeyword(type,
result,
next);
} else {
- unsigned int len = (NULL == s) ? 0 : strlen(s);
+ size_t len = strlen(s);
while(0 < len) {
/*
@@ -119,7 +119,7 @@
}
static struct EXTRACTOR_Keywords * printInfoDate(Dict *infoDict,
- char *key,
+ const char *key,
EXTRACTOR_KeywordType type,
struct EXTRACTOR_Keywords *
next) {
Object obj;
@@ -154,7 +154,7 @@
/* which mime-types should not be subjected to
the PDF extractor? (no use trying!) */
- static char * blacklist[] = {
+ static const char * blacklist[] = {
"image/jpeg",
"image/gif",
"image/png",
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r8250 - Extractor/src/plugins/pdf,
gnunet <=