From d99fb4f4acd14fcdbda968abd907547dcc7af40c Mon Sep 17 00:00:00 2001 From: Martin Kretzschmar Date: Wed, 18 Sep 2002 18:58:15 +0000 Subject: [PATCH] Completely synched with Xpdf 0.90 doc changes (version numbers), typo fixes --- pdf/goo/GString.cc | 4 +- pdf/goo/GString.h | 4 +- pdf/goo/gfile.cc | 157 ++++++++++++++++++++++++++----------- pdf/goo/gfile.h | 20 +++-- pdf/goo/gmem.c | 43 +++++++--- pdf/xpdf/CMapInfo.h | 4 +- pdf/xpdf/FontFile.h | 2 +- pdf/xpdf/Object.h | 3 - pdf/xpdf/PSOutputDev.cc | 6 +- pdf/xpdf/XOutputFontInfo.h | 2 +- pdf/xpdf/xpdf-ltk.h | 5 +- pdf/xpdf/xpdf.cc | 2 +- 12 files changed, 174 insertions(+), 78 deletions(-) diff --git a/pdf/goo/GString.cc b/pdf/goo/GString.cc index e0890912..6225932c 100644 --- a/pdf/goo/GString.cc +++ b/pdf/goo/GString.cc @@ -44,7 +44,7 @@ GString::GString() { s[0] = '\0'; } -GString::GString(char *s1) { +GString::GString(const char *s1) { int n = strlen(s1); s = NULL; @@ -52,7 +52,7 @@ GString::GString(char *s1) { memcpy(s, s1, n + 1); } -GString::GString(char *s1, int length1) { +GString::GString(const char *s1, int length1) { s = NULL; resize(length = length1); memcpy(s, s1, length * sizeof(char)); diff --git a/pdf/goo/GString.h b/pdf/goo/GString.h index 904f425a..6fa24a62 100644 --- a/pdf/goo/GString.h +++ b/pdf/goo/GString.h @@ -24,11 +24,11 @@ public: GString(); // Create a string from a C string. - GString(char *s1); + GString(const char *s1); // Create a string from chars at . This string // can contain null characters. - GString (char *s1, int length1); + GString (const char *s1, int length1); // Copy a string. GString(GString *str); diff --git a/pdf/goo/gfile.cc b/pdf/goo/gfile.cc index f6aac95f..b57d9c8b 100644 --- a/pdf/goo/gfile.cc +++ b/pdf/goo/gfile.cc @@ -8,22 +8,27 @@ // //======================================================================== -#ifdef WIN32 extern "C" { -#include -#include -} +#ifdef WIN32 +# include +# ifndef _MSC_VER +# include +# endif #else // !WIN32 -#include -#include -#include -#ifndef VMS -#include -#endif +# ifndef ACORN +# include +# include +# endif +# include +# include +# if !defined(VMS) && !defined(ACORN) +# include +# endif +# if defined(VMS) && (__DECCXX_VER < 50200000) +# include +# endif #endif // WIN32 -#if defined(VMS) && (__DECCXX_VER < 50200000) -#include -#endif +} #include "GString.h" #include "gfile.h" @@ -51,6 +56,10 @@ GString *getHomeDir() { ret = new GString("."); return ret; +#elif defined(ACORN) + //---------- RISCOS ---------- + return new GString("@"); + #else //---------- Unix ---------- char *s; @@ -77,14 +86,16 @@ GString *getCurrentDir() { char buf[PATH_MAX+1]; #if defined(__EMX__) - if (!_getcwd2(buf, sizeof(buf))) + if (_getcwd2(buf, sizeof(buf))) #elif defined(WIN32) - if (!GetCurrentDirectory(sizeof(buf), buf)) + if (GetCurrentDirectory(sizeof(buf), buf)) +#elif defined(ACORN) + if (strcpy(buf, "@")) #else - if (!getcwd(buf, sizeof(buf))) + if (getcwd(buf, sizeof(buf))) #endif - return new GString(); - return new GString(buf); + return new GString(buf); + return new GString(); } GString *appendToPath(GString *path, char *fileName) { @@ -143,8 +154,25 @@ GString *appendToPath(GString *path, char *fileName) { path->append(buf); return path; -#else - //---------- Unix and OS/2+EMX ---------- +#elif defined(ACORN) + //---------- RISCOS ---------- + char *p; + int i; + + path->append("."); + i = path->getLength(); + path->append(fileName); + for (p = path->getCString() + i; *p; ++p) { + if (*p == '/') { + *p = '.'; + } else if (*p == '.') { + *p = '/'; + } + } + return path; + +#elif defined(__EMX__) + //---------- OS/2+EMX ---------- int i; // appending "." does nothing @@ -154,51 +182,65 @@ GString *appendToPath(GString *path, char *fileName) { // appending ".." goes up one directory if (!strcmp(fileName, "..")) { for (i = path->getLength() - 2; i >= 0; --i) { -#ifdef __EMX__ if (path->getChar(i) == '/' || path->getChar(i) == '\\' || path->getChar(i) == ':') -#else - if (path->getChar(i) == '/') -#endif break; } if (i <= 0) { -#ifdef __EMX__ - if (path->getChar[0] == '/' || path->getChar[0] == '\\') { + if (path->getChar(0) == '/' || path->getChar(0) == '\\') { path->del(1, path->getLength() - 1); - } else if (path->getLength() >= 2 && path->getChar[1] == ':') { + } else if (path->getLength() >= 2 && path->getChar(1) == ':') { path->del(2, path->getLength() - 2); } else { path->clear(); path->append(".."); } + } else { + if (path->getChar(i-1) == ':') + ++i; + path->del(i, path->getLength() - i); + } + return path; + } + + // otherwise, append "/" and new path component + if (path->getLength() > 0 && + path->getChar(path->getLength() - 1) != '/' && + path->getChar(path->getLength() - 1) != '\\') + path->append('/'); + path->append(fileName); + return path; + #else + //---------- Unix ---------- + int i; + + // appending "." does nothing + if (!strcmp(fileName, ".")) + return path; + + // appending ".." goes up one directory + if (!strcmp(fileName, "..")) { + for (i = path->getLength() - 2; i >= 0; --i) { + if (path->getChar(i) == '/') + break; + } + if (i <= 0) { if (path->getChar(0) == '/') { path->del(1, path->getLength() - 1); } else { path->clear(); path->append(".."); } -#endif } else { -#ifdef __EMX__ - if (path->getChar(i) == ':') - ++i; -#endif path->del(i, path->getLength() - i); } return path; } // otherwise, append "/" and new path component -#ifdef __EMX__ - if (path->getLength() > 0 && - path->getChar(path->getLength() - 1) != '/' && - path->getChar(path->getLength() - 1) != '\\') -#else if (path->getLength() > 0 && path->getChar(path->getLength() - 1) != '/') -#endif path->append('/'); path->append(fileName); return path; @@ -228,6 +270,14 @@ GString *grabPath(char *fileName) { return new GString(fileName, p + 1 - fileName); return new GString(); +#elif defined(ACORN) + //---------- RISCOS ---------- + char *p; + + if ((p = strrchr(fileName, '.'))) + return new GString(fileName, p - fileName); + return new GString(); + #else //---------- Unix ---------- char *p; @@ -248,6 +298,10 @@ GBool isAbsolutePath(char *path) { //---------- OS/2+EMX and Win32 ---------- return path[0] == '/' || path[0] == '\\' || path[1] == ':'; +#elif defined(ACORN) + //---------- RISCOS ---------- + return path[0] == '$'; + #else //---------- Unix ---------- return path[0] == '/'; @@ -274,7 +328,7 @@ GString *makePathAbsolute(GString *path) { } return path; -#elif WIN32 +#elif defined(WIN32) //---------- Win32 ---------- char buf[_MAX_PATH]; char *fp; @@ -288,6 +342,11 @@ GString *makePathAbsolute(GString *path) { path->append(buf); return path; +#elif defined(ACORN) + //---------- RISCOS ---------- + path->insert(0, '@'); + return path; + #else //---------- Unix and OS/2+EMX ---------- struct passwd *pw; @@ -324,7 +383,9 @@ GString *makePathAbsolute(GString *path) { } } else if (!isAbsolutePath(path->getCString())) { if (getcwd(buf, sizeof(buf))) { +#ifndef __EMX__ path->insert(0, '/'); +#endif path->insert(0, buf); } } @@ -339,9 +400,10 @@ GString *makePathAbsolute(GString *path) { GDirEntry::GDirEntry(char *dirPath, char *name1, GBool doStat) { #ifdef VMS char *p; -#elif WIN32 +#elif defined(WIN32) int fa; GString *s; +#elif defined(ACORN) #else struct stat st; GString *s; @@ -354,6 +416,7 @@ GDirEntry::GDirEntry(char *dirPath, char *name1, GBool doStat) { if (!strcmp(name1, "-") || ((p = strrchr(name1, '.')) && !strncmp(p, ".DIR;", 5))) dir = gTrue; +#elif defined(ACORN) #else s = new GString(dirPath); appendToPath(s, name1); @@ -376,28 +439,30 @@ GDirEntry::~GDirEntry() { GDir::GDir(char *name, GBool doStat1) { path = new GString(name); doStat = doStat1; -#ifdef WIN32 +#if defined(WIN32) GString *tmp; tmp = path->copy(); tmp->append("/*.*"); hnd = FindFirstFile(tmp->getCString(), &ffd); delete tmp; +#elif defined(ACORN) #else dir = opendir(name); -#endif #ifdef VMS needParent = strchr(name, '[') != NULL; #endif +#endif } GDir::~GDir() { delete path; -#ifdef WIN32 +#if defined(WIN32) if (hnd) { FindClose(hnd); hnd = NULL; } +#elif defined(ACORN) #else if (dir) closedir(dir); @@ -409,12 +474,13 @@ GDirEntry *GDir::getNextEntry() { GDirEntry *e; e = NULL; -#ifdef WIN32 +#if defined(WIN32) e = new GDirEntry(path->getCString(), ffd.cFileName, doStat); if (hnd && !FindNextFile(hnd, &ffd)) { FindClose(hnd); hnd = NULL; } +#elif defined(ACORN) #else if (dir) { #ifdef VMS @@ -445,11 +511,12 @@ void GDir::rewind() { tmp = path->copy(); tmp->append("/*.*"); hnd = FindFirstFile(tmp->getCString(), &ffd); +#elif defined(ACORN) #else if (dir) rewinddir(dir); -#endif #ifdef VMS needParent = strchr(path->getCString(), '[') != NULL; #endif +#endif } diff --git a/pdf/goo/gfile.h b/pdf/goo/gfile.h index f1923cde..bb4dbe09 100644 --- a/pdf/goo/gfile.h +++ b/pdf/goo/gfile.h @@ -11,10 +11,16 @@ #ifndef GFILE_H #define GFILE_H +extern "C" { #include #include -#ifdef WIN32 -# include +#if defined(WIN32) +# ifdef _MSC_VER +# include +# else +# include +# endif +#elif defined(ACORN) #else # include # include @@ -37,6 +43,7 @@ # endif # endif #endif +} #include "gtypes.h" class GString; @@ -94,14 +101,15 @@ private: GString *path; // directory path GBool doStat; // call stat() for each entry? -#ifdef VMS - GBool needParent; // need to return an entry for [-] -#endif -#ifdef WIN32 +#if defined(WIN32) WIN32_FIND_DATA ffd; HANDLE hnd; +#elif defined(ACORN) #else DIR *dir; // the DIR structure from opendir() +#ifdef VMS + GBool needParent; // need to return an entry for [-] +#endif #endif }; diff --git a/pdf/goo/gmem.c b/pdf/goo/gmem.c index 4ae54812..cac386bc 100644 --- a/pdf/goo/gmem.c +++ b/pdf/goo/gmem.c @@ -13,6 +13,7 @@ #include "gmem.h" #ifdef DEBUG_MEM + typedef struct _GMemHdr { int size; int index; @@ -26,24 +27,38 @@ typedef struct _GMemHdr { #define gMemDeadVal 0xdeadbeefdeadbeef #else #define gMemDeadVal 0xdeadbeef +#endif /* round data size so trailer will be aligned */ #define gMemDataSize(size) \ ((((size) + gMemTrlSize - 1) / gMemTrlSize) * gMemTrlSize) -#endif +#define gMemNLists 64 +#define gMemListShift 4 +#define gMemListMask (gMemNLists - 1) +static GMemHdr *gMemList[gMemNLists] = { + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL +}; -static GMemHdr *gMemList = NULL; static int gMemIndex = 0; static int gMemAlloc = 0; -#endif + +#endif /* DEBUG_MEM */ void *gmalloc(int size) { -#if DEBUG_MEM +#ifdef DEBUG_MEM int size1; char *mem; GMemHdr *hdr; void *data; + int lst; long *trl, *p; if (size == 0) @@ -58,8 +73,9 @@ void *gmalloc(int size) { trl = (long *)(mem + gMemHdrSize + size1); hdr->size = size; hdr->index = gMemIndex++; - hdr->next = gMemList; - gMemList = hdr; + lst = ((int)hdr >> gMemListShift) & gMemListMask; + hdr->next = gMemList[lst]; + gMemList[lst] = hdr; ++gMemAlloc; for (p = (long *)data; p <= trl; ++p) *p = gMemDeadVal; @@ -78,7 +94,7 @@ void *gmalloc(int size) { } void *grealloc(void *p, int size) { -#if DEBUG_MEM +#ifdef DEBUG_MEM GMemHdr *hdr; void *q; int oldSize; @@ -123,11 +139,13 @@ void gfree(void *p) { int size; GMemHdr *hdr; GMemHdr *prevHdr, *q; + int lst; long *trl, *clr; if (p) { hdr = (GMemHdr *)((char *)p - gMemHdrSize); - for (prevHdr = NULL, q = gMemList; q; prevHdr = q, q = q->next) { + lst = ((int)hdr >> gMemListShift) & gMemListMask; + for (prevHdr = NULL, q = gMemList[lst]; q; prevHdr = q, q = q->next) { if (q == hdr) break; } @@ -135,7 +153,7 @@ void gfree(void *p) { if (prevHdr) prevHdr->next = hdr->next; else - gMemList = hdr->next; + gMemList[lst] = hdr->next; --gMemAlloc; size = gMemDataSize(hdr->size); trl = (long *)((char *)hdr + gMemHdrSize + size); @@ -159,14 +177,17 @@ void gfree(void *p) { #ifdef DEBUG_MEM void gMemReport(FILE *f) { GMemHdr *p; + int lst; fprintf(f, "%d memory allocations in all\n", gMemIndex); if (gMemAlloc > 0) { fprintf(f, "%d memory blocks left allocated:\n", gMemAlloc); fprintf(f, " index size\n"); fprintf(f, "-------- --------\n"); - for (p = gMemList; p; p = p->next) - fprintf(f, "%8d %8d\n", p->index, p->size); + for (lst = 0; lst < gMemNLists; ++lst) { + for (p = gMemList[lst]; p; p = p->next) + fprintf(f, "%8d %8d\n", p->index, p->size); + } } else { fprintf(f, "No memory blocks left allocated\n"); } diff --git a/pdf/xpdf/CMapInfo.h b/pdf/xpdf/CMapInfo.h index 7a1d8e4a..4842ee10 100644 --- a/pdf/xpdf/CMapInfo.h +++ b/pdf/xpdf/CMapInfo.h @@ -1367,7 +1367,7 @@ static GfxFontEncoding16 japan1278EUCVEnc16 = { 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1 }, - { 0x0000, 0x0000, 0x0000( 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, + { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, @@ -2062,7 +2062,7 @@ static GfxFontEncoding16 japan1278HEnc16 = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, - 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000( 0x0000, + 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, diff --git a/pdf/xpdf/FontFile.h b/pdf/xpdf/FontFile.h index 29f8ffb2..ec625ef2 100644 --- a/pdf/xpdf/FontFile.h +++ b/pdf/xpdf/FontFile.h @@ -18,7 +18,7 @@ #include "GString.h" #include "FontEncoding.h" -//-----------------------------------------------)------------------------ +//------------------------------------------------------------------------ // FontFile //------------------------------------------------------------------------ diff --git a/pdf/xpdf/Object.h b/pdf/xpdf/Object.h index b3625759..789cd5fa 100644 --- a/pdf/xpdf/Object.h +++ b/pdf/xpdf/Object.h @@ -22,7 +22,6 @@ class Array; class Dict; class Stream; -class XRef; //------------------------------------------------------------------------ // Ref @@ -293,6 +292,4 @@ inline void Object::streamSetPos(int pos) inline Dict *Object::streamGetDict() { return stream->getDict(); } -#include "XRef.h" - #endif diff --git a/pdf/xpdf/PSOutputDev.cc b/pdf/xpdf/PSOutputDev.cc index fa7c13ea..edff5cdd 100644 --- a/pdf/xpdf/PSOutputDev.cc +++ b/pdf/xpdf/PSOutputDev.cc @@ -481,12 +481,12 @@ void PSOutputDev::setupFont(GfxFont *font) { writePS("/F%d_%d /%s %g\n", font->getID().num, font->getID().gen, psName, scale); for (i = 0; i < 256; i += 8) { - writePS((i == 0) ? (char *)"[ " : (char *)" "); + writePS((i == 0) ? "[ " : " "); for (j = 0; j < 8; ++j) { charName = font->getCharName(i+j); - writePS("/%s", charName ? charName : (char *)".notdef"); + writePS("/%s", charName ? charName : ".notdef"); } - writePS((i == 256-8) ? (char *)"]\n" : (char *)"\n"); + writePS((i == 256-8) ? "]\n" : "\n"); } writePS("pdfMakeFont\n"); } diff --git a/pdf/xpdf/XOutputFontInfo.h b/pdf/xpdf/XOutputFontInfo.h index c33453a0..864cb7b6 100644 --- a/pdf/xpdf/XOutputFontInfo.h +++ b/pdf/xpdf/XOutputFontInfo.h @@ -511,7 +511,7 @@ static char *isoLatin2EncodingNames[isoLatin2EncodingSize] = { "zacute", "hungarumlaut", "zcaron", - "zdotaccenp", + "zdotaccent", "Racute", "Aacute", "Acircumflex", diff --git a/pdf/xpdf/xpdf-ltk.h b/pdf/xpdf/xpdf-ltk.h index bc06ee89..3c2f053f 100644 --- a/pdf/xpdf/xpdf-ltk.h +++ b/pdf/xpdf/xpdf-ltk.h @@ -17,7 +17,10 @@ LTKWindow *makeWindow(LTKApp *a) { new LTKEmpty() ) ), - new LTKBox(NULL, 14, 1, 0, 0, 0, 0, ltkBorderNone, 1, 0, + new LTKBox(NULL, 15, 1, 0, 0, 0, 0, ltkBorderNone, 1, 0, + new LTKBox(NULL, 1, 1, 2, 2, 2, 2, ltkBorderNone, 0, 0, + new LTKButton(NULL, 0, backArrow_bits, backArrow_width, backArrow_height, ltkButtonClick, &backCbk) + ), new LTKBox(NULL, 1, 1, 2, 2, 2, 2, ltkBorderNone, 0, 0, new LTKButton(NULL, 0, dblLeftArrow_bits, dblLeftArrow_width, dblLeftArrow_height, ltkButtonClick, &prevTenPageCbk) ), diff --git a/pdf/xpdf/xpdf.cc b/pdf/xpdf/xpdf.cc index dd31b941..4e5a2a8c 100644 --- a/pdf/xpdf/xpdf.cc +++ b/pdf/xpdf/xpdf.cc @@ -779,7 +779,7 @@ static void displayPage(int page1, int zoom1, int rotate1, GBool addToHist) { } else { dpi = zoomDPI[zoom - minZoom]; } - doc->displayPage(out, page, (double)dpi, rotate, gTrue); + doc->displayPage(out, page, dpi, rotate, gTrue); updateScrollbars(); // update page number display -- 2.43.5