Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/pdf/goo
diff options
context:
space:
mode:
authorMartin Kretzschmar <mkretzschmar@src.gnome.org>2002-09-18 22:20:42 (GMT)
committer Martin Kretzschmar <mkretzschmar@src.gnome.org>2002-09-18 22:20:42 (GMT)
commit2a393c134fe3fe8eb85bf818cb7ad6ae4396322a (patch)
treeeba8b0dcaba42d799ed8313faee15fb74a5a0cd2 /pdf/goo
parent7aac8dc8533347e21311b15186e0af82f1b22fd6 (diff)
Synched with Xpdf 1.01
Diffstat (limited to 'pdf/goo')
-rw-r--r--pdf/goo/GHash.cc240
-rw-r--r--pdf/goo/GHash.h67
-rw-r--r--pdf/goo/GList.cc91
-rw-r--r--pdf/goo/GList.h89
-rw-r--r--pdf/goo/GString.cc40
-rw-r--r--pdf/goo/GString.h19
-rw-r--r--pdf/goo/Makefile.am4
-rw-r--r--pdf/goo/gfile.cc96
-rw-r--r--pdf/goo/gfile.h19
-rw-r--r--pdf/goo/gmem.c19
-rw-r--r--pdf/goo/gmem.h2
-rw-r--r--pdf/goo/gmempp.cc3
-rw-r--r--pdf/goo/gtypes.h2
-rw-r--r--pdf/goo/parseargs.c2
-rw-r--r--pdf/goo/parseargs.h2
-rw-r--r--pdf/goo/vms_make.com4
16 files changed, 636 insertions, 63 deletions
diff --git a/pdf/goo/GHash.cc b/pdf/goo/GHash.cc
new file mode 100644
index 0000000..dc09f71
--- /dev/null
+++ b/pdf/goo/GHash.cc
@@ -0,0 +1,240 @@
+//========================================================================
+//
+// GHash.cc
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifdef __GNUC__
+#pragma implementation
+#endif
+
+#include <aconf.h>
+#include "gmem.h"
+#include "GString.h"
+#include "GHash.h"
+
+//------------------------------------------------------------------------
+
+struct GHashBucket {
+ GString *key;
+ void *val;
+ GHashBucket *next;
+};
+
+struct GHashIter {
+ int h;
+ GHashBucket *p;
+};
+
+//------------------------------------------------------------------------
+
+GHash::GHash(GBool deleteKeysA) {
+ int h;
+
+ deleteKeys = deleteKeysA;
+ size = 7;
+ tab = (GHashBucket **)gmalloc(size * sizeof(GHashBucket *));
+ for (h = 0; h < size; ++h) {
+ tab[h] = NULL;
+ }
+ len = 0;
+}
+
+GHash::~GHash() {
+ GHashBucket *p;
+ int h;
+
+ for (h = 0; h < size; ++h) {
+ while (tab[h]) {
+ p = tab[h];
+ tab[h] = p->next;
+ if (deleteKeys) {
+ delete p->key;
+ }
+ delete p;
+ }
+ }
+ gfree(tab);
+}
+
+void GHash::add(GString *key, void *val) {
+ GHashBucket **oldTab;
+ GHashBucket *p;
+ int oldSize, i, h;
+
+ // expand the table if necessary
+ if (len >= size) {
+ oldSize = size;
+ oldTab = tab;
+ size = 2*size + 1;
+ tab = (GHashBucket **)gmalloc(size * sizeof(GHashBucket *));
+ for (h = 0; h < size; ++h) {
+ tab[h] = NULL;
+ }
+ for (i = 0; i < oldSize; ++i) {
+ while (oldTab[i]) {
+ p = oldTab[i];
+ oldTab[i] = oldTab[i]->next;
+ h = hash(p->key);
+ p->next = tab[h];
+ tab[h] = p;
+ }
+ }
+ gfree(oldTab);
+ }
+
+ // add the new symbol
+ p = new GHashBucket;
+ p->key = key;
+ p->val = val;
+ h = hash(key);
+ p->next = tab[h];
+ tab[h] = p;
+ ++len;
+}
+
+void *GHash::lookup(GString *key) {
+ GHashBucket *p;
+ int h;
+
+ if (!(p = find(key, &h))) {
+ return NULL;
+ }
+ return p->val;
+}
+
+void *GHash::lookup(char *key) {
+ GHashBucket *p;
+ int h;
+
+ if (!(p = find(key, &h))) {
+ return NULL;
+ }
+ return p->val;
+}
+
+void *GHash::remove(GString *key) {
+ GHashBucket *p;
+ GHashBucket **q;
+ void *val;
+ int h;
+
+ if (!(p = find(key, &h))) {
+ return NULL;
+ }
+ q = &tab[h];
+ while (*q != p) {
+ q = &((*q)->next);
+ }
+ *q = p->next;
+ if (deleteKeys) {
+ delete p->key;
+ }
+ val = p->val;
+ delete p;
+ --len;
+ return val;
+}
+
+void *GHash::remove(char *key) {
+ GHashBucket *p;
+ GHashBucket **q;
+ void *val;
+ int h;
+
+ if (!(p = find(key, &h))) {
+ return NULL;
+ }
+ q = &tab[h];
+ while (*q != p) {
+ q = &((*q)->next);
+ }
+ *q = p->next;
+ if (deleteKeys) {
+ delete p->key;
+ }
+ val = p->val;
+ delete p;
+ --len;
+ return val;
+}
+
+void GHash::startIter(GHashIter **iter) {
+ *iter = new GHashIter;
+ (*iter)->h = -1;
+ (*iter)->p = NULL;
+}
+
+GBool GHash::getNext(GHashIter **iter, GString **key, void **val) {
+ if (!*iter) {
+ return gFalse;
+ }
+ if ((*iter)->p) {
+ (*iter)->p = (*iter)->p->next;
+ }
+ while (!(*iter)->p) {
+ if (++(*iter)->h == size) {
+ delete *iter;
+ *iter = NULL;
+ return gFalse;
+ }
+ (*iter)->p = tab[(*iter)->h];
+ }
+ *key = (*iter)->p->key;
+ *val = (*iter)->p->val;
+ return gTrue;
+}
+
+void GHash::killIter(GHashIter **iter) {
+ delete *iter;
+ *iter = NULL;
+}
+
+GHashBucket *GHash::find(GString *key, int *h) {
+ GHashBucket *p;
+
+ *h = hash(key);
+ for (p = tab[*h]; p; p = p->next) {
+ if (!p->key->cmp(key)) {
+ return p;
+ }
+ }
+ return NULL;
+}
+
+GHashBucket *GHash::find(char *key, int *h) {
+ GHashBucket *p;
+
+ *h = hash(key);
+ for (p = tab[*h]; p; p = p->next) {
+ if (!p->key->cmp(key)) {
+ return p;
+ }
+ }
+ return NULL;
+}
+
+int GHash::hash(GString *key) {
+ char *p;
+ unsigned int h;
+ int i;
+
+ h = 0;
+ for (p = key->getCString(), i = 0; i < key->getLength(); ++p, ++i) {
+ h = 17 * h + (int)(*p & 0xff);
+ }
+ return (int)(h % size);
+}
+
+int GHash::hash(char *key) {
+ char *p;
+ unsigned int h;
+
+ h = 0;
+ for (p = key; *p; ++p) {
+ h = 17 * h + (int)(*p & 0xff);
+ }
+ return (int)(h % size);
+}
diff --git a/pdf/goo/GHash.h b/pdf/goo/GHash.h
new file mode 100644
index 0000000..91d9700
--- /dev/null
+++ b/pdf/goo/GHash.h
@@ -0,0 +1,67 @@
+//========================================================================
+//
+// GHash.h
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifndef GHASH_H
+#define GHASH_H
+
+#ifdef __GNUC__
+#pragma interface
+#endif
+
+#include "gtypes.h"
+
+class GString;
+struct GHashBucket;
+struct GHashIter;
+
+//------------------------------------------------------------------------
+
+class GHash {
+public:
+
+ GHash(GBool deleteKeysA = gFalse);
+ ~GHash();
+ void add(GString *key, void *val);
+ void *lookup(GString *key);
+ void *lookup(char *key);
+ void *remove(GString *key);
+ void *remove(char *key);
+ int getLength() { return len; }
+ void startIter(GHashIter **iter);
+ GBool getNext(GHashIter **iter, GString **key, void **val);
+ void killIter(GHashIter **iter);
+
+private:
+
+ GHashBucket *find(GString *key, int *h);
+ GHashBucket *find(char *key, int *h);
+ int hash(GString *key);
+ int hash(char *key);
+
+ GBool deleteKeys; // set if key strings should be deleted
+ int size; // number of buckets
+ int len; // number of entries
+ GHashBucket **tab;
+};
+
+#define deleteGHash(hash, T) \
+ do { \
+ GHash *_hash = (hash); \
+ { \
+ GHashIter *_iter; \
+ GString *_key; \
+ void *_p; \
+ _hash->startIter(&_iter); \
+ while (_hash->getNext(&_iter, &_key, &_p)) { \
+ delete (T*)_p; \
+ } \
+ delete _hash; \
+ } \
+ } while(0)
+
+#endif
diff --git a/pdf/goo/GList.cc b/pdf/goo/GList.cc
new file mode 100644
index 0000000..f52bc26
--- /dev/null
+++ b/pdf/goo/GList.cc
@@ -0,0 +1,91 @@
+//========================================================================
+//
+// GList.cc
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifdef __GNUC__
+#pragma implementation
+#endif
+
+#include <aconf.h>
+#include <string.h>
+#include "gmem.h"
+#include "GList.h"
+
+//------------------------------------------------------------------------
+// GList
+//------------------------------------------------------------------------
+
+GList::GList() {
+ size = 8;
+ data = (void **)gmalloc(size * sizeof(void*));
+ length = 0;
+ inc = 0;
+}
+
+GList::GList(int sizeA) {
+ size = sizeA;
+ data = (void **)gmalloc(size * sizeof(void*));
+ length = 0;
+ inc = 0;
+}
+
+GList::~GList() {
+ gfree(data);
+}
+
+void GList::append(void *p) {
+ if (length >= size) {
+ expand();
+ }
+ data[length++] = p;
+}
+
+void GList::append(GList *list) {
+ int i;
+
+ while (length + list->length > size) {
+ expand();
+ }
+ for (i = 0; i < list->length; ++i) {
+ data[length++] = list->data[i];
+ }
+}
+
+void GList::insert(int i, void *p) {
+ if (length >= size) {
+ expand();
+ }
+ if (i < length) {
+ memmove(data+i+1, data+i, (length - i) * sizeof(void *));
+ }
+ data[i] = p;
+ ++length;
+}
+
+void *GList::del(int i) {
+ void *p;
+
+ p = data[i];
+ if (i < length - 1) {
+ memmove(data+i, data+i+1, (length - i - 1) * sizeof(void *));
+ }
+ --length;
+ if (size - length >= ((inc > 0) ? inc : size/2)) {
+ shrink();
+ }
+ return p;
+}
+
+void GList::expand() {
+ size += (inc > 0) ? inc : size;
+ data = (void **)grealloc(data, size * sizeof(void*));
+}
+
+void GList::shrink() {
+ size -= (inc > 0) ? inc : size/2;
+ data = (void **)grealloc(data, size * sizeof(void*));
+}
diff --git a/pdf/goo/GList.h b/pdf/goo/GList.h
new file mode 100644
index 0000000..0ef4fd7
--- /dev/null
+++ b/pdf/goo/GList.h
@@ -0,0 +1,89 @@
+//========================================================================
+//
+// GList.h
+//
+// Copyright 2001-2002 Glyph & Cog, LLC
+//
+//========================================================================
+
+#ifndef GLIST_H
+#define GLIST_H
+
+#ifdef __GNUC__
+#pragma interface
+#endif
+
+#include "gtypes.h"
+
+//------------------------------------------------------------------------
+// GList
+//------------------------------------------------------------------------
+
+class GList {
+public:
+
+ // Create an empty list.
+ GList();
+
+ // Create an empty list with space for <size1> elements.
+ GList(int sizeA);
+
+ // Destructor - does not free pointed-to objects.
+ ~GList();
+
+ //----- general
+
+ // Get the number of elements.
+ int getLength() { return length; }
+
+ //----- ordered list support
+
+ // Return the <i>th element.
+ // Assumes 0 <= i < length.
+ void *get(int i) { return data[i]; }
+
+ // Append an element to the end of the list.
+ void append(void *p);
+
+ // Append another list to the end of this one.
+ void append(GList *list);
+
+ // Insert an element at index <i>.
+ // Assumes 0 <= i <= length.
+ void insert(int i, void *p);
+
+ // Deletes and returns the element at index <i>.
+ // Assumes 0 <= i < length.
+ void *del(int i);
+
+ //----- control
+
+ // Set allocation increment to <inc>. If inc > 0, that many
+ // elements will be allocated every time the list is expanded.
+ // If inc <= 0, the list will be doubled in size.
+ void setAllocIncr(int incA) { inc = incA; }
+
+private:
+
+ void expand();
+ void shrink();
+
+ void **data; // the list elements
+ int size; // size of data array
+ int length; // number of elements on list
+ int inc; // allocation increment
+};
+
+#define deleteGList(list, T) \
+ do { \
+ GList *_list = (list); \
+ { \
+ int _i; \
+ for (_i = 0; _i < _list->getLength(); ++_i) { \
+ delete (T*)_list->get(_i); \
+ } \
+ delete _list; \
+ } \
+ } while (0)
+
+#endif
diff --git a/pdf/goo/GString.cc b/pdf/goo/GString.cc
index 7b8f271..3bf626a 100644
--- a/pdf/goo/GString.cc
+++ b/pdf/goo/GString.cc
@@ -4,7 +4,7 @@
//
// Simple variable-length string type.
//
-// Copyright 1996 Derek B. Noonburg
+// Copyright 1996-2002 Glyph & Cog, LLC
//
//========================================================================
@@ -12,6 +12,7 @@
#pragma implementation
#endif
+#include <aconf.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
@@ -45,18 +46,25 @@ GString::GString() {
s[0] = '\0';
}
-GString::GString(const char *s1) {
- int n = strlen(s1);
+GString::GString(const char *sA) {
+ int n = strlen(sA);
s = NULL;
resize(length = n);
- memcpy(s, s1, n + 1);
+ memcpy(s, sA, n + 1);
}
-GString::GString(const char *s1, int length1) {
+GString::GString(const char *sA, int lengthA) {
s = NULL;
- resize(length = length1);
- memcpy(s, s1, length * sizeof(char));
+ resize(length = lengthA);
+ memcpy(s, sA, length * sizeof(char));
+ s[length] = '\0';
+}
+
+GString::GString(GString *str, int idx, int lengthA) {
+ s = NULL;
+ resize(length = lengthA);
+ memcpy(s, str->getCString() + idx, length);
s[length] = '\0';
}
@@ -137,10 +145,10 @@ GString *GString::append(const char *str) {
return this;
}
-GString *GString::append(const char *str, int length1) {
- resize(length + length1);
- memcpy(s + length, str, length1);
- length += length1;
+GString *GString::append(const char *str, int lengthA) {
+ resize(length + lengthA);
+ memcpy(s + length, str, lengthA);
+ length += lengthA;
s[length] = '\0';
return this;
}
@@ -180,14 +188,14 @@ GString *GString::insert(int i, const char *str) {
return this;
}
-GString *GString::insert(int i, const char *str, int length1) {
+GString *GString::insert(int i, const char *str, int lengthA) {
int j;
- resize(length + length1);
+ resize(length + lengthA);
for (j = length; j >= i; --j)
- s[j+length1] = s[j];
- memcpy(s+i, str, length1);
- length += length1;
+ s[j+lengthA] = s[j];
+ memcpy(s+i, str, lengthA);
+ length += lengthA;
return this;
}
diff --git a/pdf/goo/GString.h b/pdf/goo/GString.h
index 4c3b95f..93796cb 100644
--- a/pdf/goo/GString.h
+++ b/pdf/goo/GString.h
@@ -4,7 +4,7 @@
//
// Simple variable-length string type.
//
-// Copyright 1996 Derek B. Noonburg
+// Copyright 1996-2002 Glyph & Cog, LLC
//
//========================================================================
@@ -24,11 +24,14 @@ public:
GString();
// Create a string from a C string.
- GString(const char *s1);
+ GString(const char *sA);
- // Create a string from <length1> chars at <s1>. This string
+ // Create a string from <lengthA> chars at <sA>. This string
// can contain null characters.
- GString (const char *s1, int length1);
+ GString(const char *sA, int lengthA);
+
+ // Create a string from <lengthA> chars at <idx> in <str>.
+ GString(GString *str, int idx, int lengthA);
// Copy a string.
GString(GString *str);
@@ -62,13 +65,13 @@ public:
GString *append(char c);
GString *append(GString *str);
GString *append(const char *str);
- GString *append(const char *str, int length1);
+ GString *append(const char *str, int lengthA);
// Insert a character or string.
GString *insert(int i, char c);
GString *insert(int i, GString *str);
GString *insert(int i, const char *str);
- GString *insert(int i, const char *str, int length1);
+ GString *insert(int i, const char *str, int lengthA);
// Delete a character or range of characters.
GString *del(int i, int n = 1);
@@ -81,8 +84,8 @@ public:
// These functions assume the strings do not contain null characters.
int cmp(GString *str) { return strcmp(s, str->getCString()); }
int cmpN(GString *str, int n) { return strncmp(s, str->getCString(), n); }
- int cmp(const char *s1) { return strcmp(s, s1); }
- int cmpN(const char *s1, int n) { return strncmp(s, s1, n); }
+ int cmp(const char *sA) { return strcmp(s, sA); }
+ int cmpN(const char *sA, int n) { return strncmp(s, sA, n); }
private:
diff --git a/pdf/goo/Makefile.am b/pdf/goo/Makefile.am
index a80aaef..ef84b8a 100644
--- a/pdf/goo/Makefile.am
+++ b/pdf/goo/Makefile.am
@@ -1,6 +1,8 @@
lib_LIBRARIES = libgoo.a
libgoo_a_SOURCES = \
+ GHash.cc \
+ GList.cc \
GString.cc \
gmempp.cc \
gfile.cc \
@@ -11,7 +13,7 @@ libgoo_a_SOURCES = \
gmem.h \
gtypes.h \
parseargs.h
-
+
EXTRA_DIST = \
vms_dirent.h \
vms_sys_dirent.h\
diff --git a/pdf/goo/gfile.cc b/pdf/goo/gfile.cc
index 25fa1c9..d6d2363 100644
--- a/pdf/goo/gfile.cc
+++ b/pdf/goo/gfile.cc
@@ -4,15 +4,18 @@
//
// Miscellaneous file and directory name manipulation.
//
-// Copyright 1996 Derek B. Noonburg
+// Copyright 1996-2002 Glyph & Cog, LLC
//
//========================================================================
-extern "C" {
+#include <aconf.h>
+
#ifdef WIN32
+ extern "C" {
# ifndef _MSC_VER
# include <kpathsea/win32lib.h>
# endif
+ }
#else // !WIN32
# if defined(MACOS)
# include <sys/stat.h>
@@ -30,7 +33,6 @@ extern "C" {
# include <unixlib.h>
# endif
#endif // WIN32
-}
#include "GString.h"
#include "gfile.h"
@@ -442,7 +444,26 @@ time_t getModTime(char *fileName) {
}
GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) {
-#if defined(VMS) || defined(__EMX__) || defined(WIN32) || defined(ACORN) || defined(MACOS)
+#if defined(WIN32)
+ //---------- Win32 ----------
+ char *s;
+ char buf[_MAX_PATH];
+ char *fp;
+
+ if (!(s = _tempnam(getenv("TEMP"), NULL))) {
+ return gFalse;
+ }
+ *name = new GString(s);
+ free(s);
+ if (ext) {
+ (*name)->append(ext);
+ }
+ if (!(*f = fopen((*name)->getCString(), mode))) {
+ delete (*name);
+ return gFalse;
+ }
+ return gTrue;
+#elif defined(VMS) || defined(__EMX__) || defined(ACORN) || defined(MACOS)
//---------- non-Unix ----------
char *s;
@@ -464,20 +485,26 @@ GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) {
return gTrue;
#else
//---------- Unix ----------
- char *s, *p;
+ char *s;
int fd;
if (ext) {
+#if HAVE_MKSTEMPS
+ if ((s = getenv("TMPDIR"))) {
+ *name = new GString(s);
+ } else {
+ *name = new GString("/tmp");
+ }
+ (*name)->append("/XXXXXX")->append(ext);
+ fd = mkstemps((*name)->getCString(), strlen(ext));
+#else
if (!(s = tmpnam(NULL))) {
return gFalse;
}
*name = new GString(s);
- s = (*name)->getCString();
- if ((p = strrchr(s, '.'))) {
- (*name)->del(p - s, (*name)->getLength() - (p - s));
- }
(*name)->append(ext);
fd = open((*name)->getCString(), O_WRONLY | O_CREAT | O_EXCL, 0600);
+#endif
} else {
#if HAVE_MKSTEMP
if ((s = getenv("TMPDIR"))) {
@@ -503,11 +530,48 @@ GBool openTempFile(GString **name, FILE **f, char *mode, char *ext) {
#endif
}
+GBool executeCommand(char *cmd) {
+#ifdef VMS
+ return system(cmd) ? gTrue : gFalse;
+#else
+ return system(cmd) ? gFalse : gTrue;
+#endif
+}
+
+char *getLine(char *buf, int size, FILE *f) {
+ int c, i;
+
+ i = 0;
+ while (i < size - 1) {
+ if ((c = fgetc(f)) == EOF) {
+ break;
+ }
+ buf[i++] = (char)c;
+ if (c == '\x0a') {
+ break;
+ }
+ if (c == '\x0d') {
+ c = fgetc(f);
+ if (c == '\x0a' && i < size - 1) {
+ buf[i++] = (char)c;
+ } else if (c != EOF) {
+ ungetc(c, f);
+ }
+ break;
+ }
+ }
+ buf[i] = '\0';
+ if (i == 0) {
+ return NULL;
+ }
+ return buf;
+}
+
//------------------------------------------------------------------------
// GDir and GDirEntry
//------------------------------------------------------------------------
-GDirEntry::GDirEntry(char *dirPath, char *name1, GBool doStat) {
+GDirEntry::GDirEntry(char *dirPath, char *nameA, GBool doStat) {
#ifdef VMS
char *p;
#elif defined(WIN32)
@@ -519,17 +583,17 @@ GDirEntry::GDirEntry(char *dirPath, char *name1, GBool doStat) {
GString *s;
#endif
- name = new GString(name1);
+ name = new GString(nameA);
dir = gFalse;
if (doStat) {
#ifdef VMS
- if (!strcmp(name1, "-") ||
- ((p = strrchr(name1, '.')) && !strncmp(p, ".DIR;", 5)))
+ if (!strcmp(nameA, "-") ||
+ ((p = strrchr(nameA, '.')) && !strncmp(p, ".DIR;", 5)))
dir = gTrue;
#elif defined(ACORN)
#else
s = new GString(dirPath);
- appendToPath(s, name1);
+ appendToPath(s, nameA);
#ifdef WIN32
fa = GetFileAttributes(s->getCString());
dir = (fa != 0xFFFFFFFF && (fa & FILE_ATTRIBUTE_DIRECTORY));
@@ -546,9 +610,9 @@ GDirEntry::~GDirEntry() {
delete name;
}
-GDir::GDir(char *name, GBool doStat1) {
+GDir::GDir(char *name, GBool doStatA) {
path = new GString(name);
- doStat = doStat1;
+ doStat = doStatA;
#if defined(WIN32)
GString *tmp;
diff --git a/pdf/goo/gfile.h b/pdf/goo/gfile.h
index 38b9998..193209c 100644
--- a/pdf/goo/gfile.h
+++ b/pdf/goo/gfile.h
@@ -4,7 +4,7 @@
//
// Miscellaneous file and directory name manipulation.
//
-// Copyright 1996 Derek B. Noonburg
+// Copyright 1996-2002 Glyph & Cog, LLC
//
//========================================================================
@@ -73,11 +73,11 @@ extern GBool isAbsolutePath(char *path);
// Make this path absolute by prepending current directory (if path is
// relative) or prepending user's directory (if path starts with '~').
-GString *makePathAbsolute(GString *path);
+extern GString *makePathAbsolute(GString *path);
// Get the modification time for <fileName>. Returns 0 if there is an
// error.
-time_t getModTime(char *fileName);
+extern time_t getModTime(char *fileName);
// Create a temporary file and open it for writing. If <ext> is not
// NULL, it will be used as the file name extension. Returns both the
@@ -85,7 +85,14 @@ 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 <mode> string
// should be "w" or "wb". Returns true on success.
-GBool openTempFile(GString **name, FILE **f, char *mode, char *ext);
+extern GBool openTempFile(GString **name, FILE **f, char *mode, char *ext);
+
+// Execute <command>. Returns true on success.
+extern GBool executeCommand(char *cmd);
+
+// Just like fgets, but handles Unix, Mac, and/or DOS end-of-line
+// conventions.
+extern char *getLine(char *buf, int size, FILE *f);
//------------------------------------------------------------------------
// GDir and GDirEntry
@@ -94,7 +101,7 @@ GBool openTempFile(GString **name, FILE **f, char *mode, char *ext);
class GDirEntry {
public:
- GDirEntry(char *dirPath, char *name1, GBool doStat);
+ GDirEntry(char *dirPath, char *nameA, GBool doStat);
~GDirEntry();
GString *getName() { return name; }
GBool isDir() { return dir; }
@@ -108,7 +115,7 @@ private:
class GDir {
public:
- GDir(char *name, GBool doStat1 = gTrue);
+ GDir(char *name, GBool doStatA = gTrue);
~GDir();
GDirEntry *getNextEntry();
void rewind();
diff --git a/pdf/goo/gmem.c b/pdf/goo/gmem.c
index cac386b..27ebb2b 100644
--- a/pdf/goo/gmem.c
+++ b/pdf/goo/gmem.c
@@ -3,9 +3,10 @@
*
* Memory routines with out-of-memory checking.
*
- * Copyright 1996 Derek B. Noonburg
+ * Copyright 1996-2002 Glyph & Cog, LLC
*/
+#include <aconf.h>
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
@@ -24,9 +25,9 @@ typedef struct _GMemHdr {
#define gMemTrlSize (sizeof(long))
#if gmemTrlSize==8
-#define gMemDeadVal 0xdeadbeefdeadbeef
+#define gMemDeadVal 0xdeadbeefdeadbeefUL
#else
-#define gMemDeadVal 0xdeadbeef
+#define gMemDeadVal 0xdeadbeefUL
#endif
/* round data size so trailer will be aligned */
@@ -59,7 +60,7 @@ void *gmalloc(int size) {
GMemHdr *hdr;
void *data;
int lst;
- long *trl, *p;
+ unsigned long *trl, *p;
if (size == 0)
return NULL;
@@ -70,14 +71,14 @@ void *gmalloc(int size) {
}
hdr = (GMemHdr *)mem;
data = (void *)(mem + gMemHdrSize);
- trl = (long *)(mem + gMemHdrSize + size1);
+ trl = (unsigned long *)(mem + gMemHdrSize + size1);
hdr->size = size;
hdr->index = gMemIndex++;
lst = ((int)hdr >> gMemListShift) & gMemListMask;
hdr->next = gMemList[lst];
gMemList[lst] = hdr;
++gMemAlloc;
- for (p = (long *)data; p <= trl; ++p)
+ for (p = (unsigned long *)data; p <= trl; ++p)
*p = gMemDeadVal;
return data;
#else
@@ -140,7 +141,7 @@ void gfree(void *p) {
GMemHdr *hdr;
GMemHdr *prevHdr, *q;
int lst;
- long *trl, *clr;
+ unsigned long *trl, *clr;
if (p) {
hdr = (GMemHdr *)((char *)p - gMemHdrSize);
@@ -156,12 +157,12 @@ void gfree(void *p) {
gMemList[lst] = hdr->next;
--gMemAlloc;
size = gMemDataSize(hdr->size);
- trl = (long *)((char *)hdr + gMemHdrSize + size);
+ trl = (unsigned long *)((char *)hdr + gMemHdrSize + size);
if (*trl != gMemDeadVal) {
fprintf(stderr, "Overwrite past end of block %d at address %p\n",
hdr->index, p);
}
- for (clr = (long *)hdr; clr <= trl; ++clr)
+ for (clr = (unsigned long *)hdr; clr <= trl; ++clr)
*clr = gMemDeadVal;
free(hdr);
} else {
diff --git a/pdf/goo/gmem.h b/pdf/goo/gmem.h
index 7ab5ddb..93ccb94 100644
--- a/pdf/goo/gmem.h
+++ b/pdf/goo/gmem.h
@@ -3,7 +3,7 @@
*
* Memory routines with out-of-memory checking.
*
- * Copyright 1996 Derek B. Noonburg
+ * Copyright 1996-2002 Glyph & Cog, LLC
*/
#ifndef GMEM_H
diff --git a/pdf/goo/gmempp.cc b/pdf/goo/gmempp.cc
index 6eb6494..ed94f7a 100644
--- a/pdf/goo/gmempp.cc
+++ b/pdf/goo/gmempp.cc
@@ -4,10 +4,11 @@
//
// Use gmalloc/gfree for C++ new/delete operators.
//
-// Copyright 1996 Derek B. Noonburg
+// Copyright 1996-2002 Glyph & Cog, LLC
//
//========================================================================
+#include <aconf.h>
#include "gmem.h"
#ifdef DEBUG_MEM
diff --git a/pdf/goo/gtypes.h b/pdf/goo/gtypes.h
index 6593267..1879b88 100644
--- a/pdf/goo/gtypes.h
+++ b/pdf/goo/gtypes.h
@@ -3,7 +3,7 @@
*
* Some useful simple types.
*
- * Copyright 1996 Derek B. Noonburg
+ * Copyright 1996-2002 Glyph & Cog, LLC
*/
#ifndef GTYPES_H
diff --git a/pdf/goo/parseargs.c b/pdf/goo/parseargs.c
index ceba887..ad8460a 100644
--- a/pdf/goo/parseargs.c
+++ b/pdf/goo/parseargs.c
@@ -3,7 +3,7 @@
*
* Command line argument parser.
*
- * Copyright 1996 Derek B. Noonburg
+ * Copyright 1996-2002 Glyph & Cog, LLC
*/
#include <stdio.h>
diff --git a/pdf/goo/parseargs.h b/pdf/goo/parseargs.h
index e0aa2be..2cc2df7 100644
--- a/pdf/goo/parseargs.h
+++ b/pdf/goo/parseargs.h
@@ -3,7 +3,7 @@
*
* Command line argument parser.
*
- * Copyright 1996 Derek B. Noonburg
+ * Copyright 1996-2002 Glyph & Cog, LLC
*/
#ifndef PARSEARGS_H
diff --git a/pdf/goo/vms_make.com b/pdf/goo/vms_make.com
index 454c1ff..e57c960 100644
--- a/pdf/goo/vms_make.com
+++ b/pdf/goo/vms_make.com
@@ -4,11 +4,11 @@ $! Goo library compile script for VMS.
$!
$! Written by Patrick Moreau, Martin P.J. Zinser.
$!
-$! Copyright 1996 Derek B. Noonburg
+$! Copyright 1996-2002 Glyph & Cog, LLC
$!
$!========================================================================
$!
-$ GOO_CXXOBJS = "GString.obj,gmempp.obj,gfile.obj"
+$ GOO_CXXOBJS = "GString.obj,gmempp.obj,gfile.obj,ghash.obj,glist.obj"
$ GOO_CCOBJS = "gmem.obj,parseargs.obj,vms_directory.obj,vms_unix_times.obj"
$!
$ if f$extract(1,3,f$getsyi("Version")) .lts. "7.0"