Commit 1cf60015 authored by Kristian Høgsberg's avatar Kristian Høgsberg

2006-09-19 Kristian Høgsberg <krh@redhat.com>

	* poppler/GlobalParams.cc: Add scanEncodingDirs() to automatically
	scan in any encodings found under ${datadir}/poppler.

	* m4/define-dir.m4: New file, adds AC_DEFINE_DIR macro.
parent 821c883f
2006-09-19 Kristian Høgsberg <krh@redhat.com>
* poppler/GlobalParams.cc: Add scanEncodingDirs() to automatically
scan in any encodings found under ${datadir}/poppler.
* m4/define-dir.m4: New file, adds AC_DEFINE_DIR macro.
2006-09-13 Kristian Høgsberg <krh@redhat.com>
* poppler/Makefile.am (libpoppler_la_LIBADD): Add cairo libs to
......
......@@ -34,20 +34,8 @@ AC_ARG_ENABLE(fixedpoint,
[ --enable-fixedpoint use fixed point (instead of floating point) arithmetic],
AC_DEFINE(USE_FIXEDPOINT, [1], [Use fixed point arithmetic]))
dnl ##### Path to xpdfrc.
dnl This ugly kludge to get the sysconfdir path is needed because
dnl autoconf doesn't actually set the prefix variable until later.
if test "$sysconfdir" = '${prefix}/etc'; then
if test "x$prefix" = xNONE; then
system_xpdfrc="$ac_default_prefix/etc/xpdfrc"
else
system_xpdfrc="$prefix/etc/xpdfrc"
fi
else
system_xpdfrc="$sysconfdir/xpdfrc"
fi
AC_DEFINE_UNQUOTED(SYSTEM_XPDFRC, "$system_xpdfrc",
[Full path for the system-wide xpdfrc file.])
AC_DEFINE_DIR(SYSTEM_XPDFRC, "{sysconfdir}/xpdfrc", [System wide config file])
AC_DEFINE_DIR(POPPLER_DATADIR, "{datadir}/poppler", [Poppler data dir])
dnl ##### Checks for header files.
AC_PATH_XTRA
......
......@@ -576,15 +576,15 @@ GDirEntry::GDirEntry(char *dirPath, char *nameA, GBool doStat) {
char *p;
#elif defined(WIN32)
int fa;
GooString *s;
#elif defined(ACORN)
#else
struct stat st;
GooString *s;
#endif
name = new GooString(nameA);
dir = gFalse;
fullPath = new GooString(dirPath);
appendToPath(fullPath, nameA);
if (doStat) {
#ifdef VMS
if (!strcmp(nameA, "-") ||
......@@ -592,21 +592,19 @@ GDirEntry::GDirEntry(char *dirPath, char *nameA, GBool doStat) {
dir = gTrue;
#elif defined(ACORN)
#else
s = new GooString(dirPath);
appendToPath(s, nameA);
#ifdef WIN32
fa = GetFileAttributes(s->getCString());
fa = GetFileAttributes(fullPath->getCString());
dir = (fa != 0xFFFFFFFF && (fa & FILE_ATTRIBUTE_DIRECTORY));
#else
if (stat(s->getCString(), &st) == 0)
if (stat(fullPath->getCString(), &st) == 0)
dir = S_ISDIR(st.st_mode);
#endif
delete s;
#endif
}
}
GDirEntry::~GDirEntry() {
delete fullPath;
delete name;
}
......@@ -678,10 +676,10 @@ GDirEntry *GDir::getNextEntry() {
struct dirent *ent;
e = NULL;
if (dir) {
ent = readdir(dir);
if (ent && !strcmp(ent->d_name, ".")) {
do {
ent = readdir(dir);
}
while (ent && (!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")));
if (ent) {
e = new GDirEntry(path->getCString(), ent->d_name, doStat);
}
......
......@@ -104,11 +104,13 @@ public:
GDirEntry(char *dirPath, char *nameA, GBool doStat);
~GDirEntry();
GooString *getName() { return name; }
GooString *getFullPath() { return fullPath; }
GBool isDir() { return dir; }
private:
GooString *name; // dir/file name
GooString *fullPath;
GBool dir; // is it a directory?
};
......
dnl @synopsis AC_DEFINE_DIR(VARNAME, DIR [, DESCRIPTION])
dnl
dnl This macro sets VARNAME to the expansion of the DIR variable,
dnl taking care of fixing up ${prefix} and such.
dnl
dnl VARNAME is then offered as both an output variable and a C
dnl preprocessor symbol.
dnl
dnl Example:
dnl
dnl AC_DEFINE_DIR([DATADIR], [datadir], [Where data are placed to.])
dnl
dnl @category Misc
dnl @author Stepan Kasal <kasal@ucw.cz>
dnl @author Andreas Schwab <schwab@suse.de>
dnl @author Guido Draheim <guidod@gmx.de>
dnl @author Alexandre Oliva
dnl @version 2005-07-29
dnl @license AllPermissive
AC_DEFUN([AC_DEFINE_DIR], [
prefix_NONE=
exec_prefix_NONE=
test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn
dnl refers to ${prefix}. Thus we have to use `eval' twice.
eval ac_define_dir="\"[$]$2\""
eval ac_define_dir="\"$ac_define_dir\""
AC_SUBST($1, "$ac_define_dir")
AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3])
test "$prefix_NONE" && prefix=NONE
test "$exec_prefix_NONE" && exec_prefix=NONE
])
......@@ -436,6 +436,8 @@ GlobalParams::GlobalParams(char *cfgFileName) {
delete fileName;
fclose(f);
}
scanEncodingDirs();
}
void GlobalParams::parseFile(GooString *fileName, FILE *f) {
......@@ -485,7 +487,11 @@ void GlobalParams::parseFile(GooString *fileName, FILE *f) {
fileName->getCString(), line);
}
} else if (!cmd->cmp("nameToUnicode")) {
parseNameToUnicode(tokens, fileName, line);
if (tokens->getLength() != 2)
error(-1, "Bad 'nameToUnicode' config file command (%s:%d)",
fileName->getCString(), line);
else
parseNameToUnicode((GooString *) tokens->get(1));
} else if (!cmd->cmp("cidToUnicode")) {
parseCIDToUnicode(tokens, fileName, line);
} else if (!cmd->cmp("unicodeToUnicode")) {
......@@ -603,27 +609,53 @@ void GlobalParams::parseFile(GooString *fileName, FILE *f) {
}
}
void GlobalParams::parseNameToUnicode(GooList *tokens, GooString *fileName,
int line) {
GooString *name;
void GlobalParams::scanEncodingDirs() {
GDir *dir;
GDirEntry *entry;
dir = new GDir(POPPLER_DATADIR "/nameToUnicode", gFalse);
while (entry = dir->getNextEntry(), entry != NULL) {
parseNameToUnicode(entry->getFullPath());
delete entry;
}
delete dir;
dir = new GDir(POPPLER_DATADIR "/cidToUnicode", gFalse);
while (entry = dir->getNextEntry(), entry != NULL) {
addCIDToUnicode(entry->getName(), entry->getFullPath());
delete entry;
}
delete dir;
dir = new GDir(POPPLER_DATADIR "/unicodeMap", gFalse);
while (entry = dir->getNextEntry(), entry != NULL) {
addUnicodeMap(entry->getName(), entry->getFullPath());
delete entry;
}
delete dir;
dir = new GDir(POPPLER_DATADIR "/cMap", gFalse);
while (entry = dir->getNextEntry(), entry != NULL) {
addCMapDir(entry->getName(), entry->getFullPath());
toUnicodeDirs->append(entry->getFullPath()->copy());
delete entry;
}
delete dir;
}
void GlobalParams::parseNameToUnicode(GooString *name) {
char *tok1, *tok2;
FILE *f;
char buf[256];
int line2;
int line;
Unicode u;
if (tokens->getLength() != 2) {
error(-1, "Bad 'nameToUnicode' config file command (%s:%d)",
fileName->getCString(), line);
return;
}
name = (GooString *)tokens->get(1);
if (!(f = fopen(name->getCString(), "r"))) {
error(-1, "Couldn't open 'nameToUnicode' file '%s'",
name->getCString());
return;
}
line2 = 1;
line = 1;
while (getLine(buf, sizeof(buf), f)) {
tok1 = strtok(buf, " \t\r\n");
tok2 = strtok(NULL, " \t\r\n");
......@@ -632,28 +664,31 @@ void GlobalParams::parseNameToUnicode(GooList *tokens, GooString *fileName,
nameToUnicode->add(tok2, u);
} else {
error(-1, "Bad line in 'nameToUnicode' file (%s:%d)",
name->getCString(), line2);
name->getCString(), line);
}
++line2;
++line;
}
fclose(f);
}
void GlobalParams::addCIDToUnicode(GooString *collection,
GooString *fileName) {
GooString *old;
if ((old = (GooString *)cidToUnicodes->remove(collection))) {
delete old;
}
cidToUnicodes->add(collection->copy(), fileName->copy());
}
void GlobalParams::parseCIDToUnicode(GooList *tokens, GooString *fileName,
int line) {
GooString *collection, *name, *old;
if (tokens->getLength() != 3) {
error(-1, "Bad 'cidToUnicode' config file command (%s:%d)",
fileName->getCString(), line);
return;
}
collection = (GooString *)tokens->get(1);
name = (GooString *)tokens->get(2);
if ((old = (GooString *)cidToUnicodes->remove(collection))) {
delete old;
}
cidToUnicodes->add(collection->copy(), name->copy());
addCIDToUnicode((GooString *)tokens->get(1), (GooString *)tokens->get(2));
}
void GlobalParams::parseUnicodeToUnicode(GooList *tokens, GooString *fileName,
......@@ -673,34 +708,30 @@ void GlobalParams::parseUnicodeToUnicode(GooList *tokens, GooString *fileName,
unicodeToUnicodes->add(font->copy(), file->copy());
}
void GlobalParams::addUnicodeMap(GooString *encodingName, GooString *fileName)
{
GooString *old;
if ((old = (GooString *)unicodeMaps->remove(encodingName))) {
delete old;
}
unicodeMaps->add(encodingName->copy(), fileName->copy());
}
void GlobalParams::parseUnicodeMap(GooList *tokens, GooString *fileName,
int line) {
GooString *encodingName, *name, *old;
if (tokens->getLength() != 3) {
error(-1, "Bad 'unicodeMap' config file command (%s:%d)",
fileName->getCString(), line);
return;
}
encodingName = (GooString *)tokens->get(1);
name = (GooString *)tokens->get(2);
if ((old = (GooString *)unicodeMaps->remove(encodingName))) {
delete old;
}
unicodeMaps->add(encodingName->copy(), name->copy());
addUnicodeMap((GooString *)tokens->get(1), (GooString *)tokens->get(2));
}
void GlobalParams::parseCMapDir(GooList *tokens, GooString *fileName, int line) {
GooString *collection, *dir;
void GlobalParams::addCMapDir(GooString *collection, GooString *dir) {
GooList *list;
if (tokens->getLength() != 3) {
error(-1, "Bad 'cMapDir' config file command (%s:%d)",
fileName->getCString(), line);
return;
}
collection = (GooString *)tokens->get(1);
dir = (GooString *)tokens->get(2);
if (!(list = (GooList *)cMapDirs->lookup(collection))) {
list = new GooList();
cMapDirs->add(collection->copy(), list);
......@@ -708,6 +739,15 @@ void GlobalParams::parseCMapDir(GooList *tokens, GooString *fileName, int line)
list->append(dir->copy());
}
void GlobalParams::parseCMapDir(GooList *tokens, GooString *fileName, int line) {
if (tokens->getLength() != 3) {
error(-1, "Bad 'cMapDir' config file command (%s:%d)",
fileName->getCString(), line);
return;
}
addCMapDir((GooString *)tokens->get(1), (GooString *)tokens->get(2));
}
void GlobalParams::parseToUnicodeDir(GooList *tokens, GooString *fileName,
int line) {
if (tokens->getLength() != 2) {
......
......@@ -220,7 +220,7 @@ public:
private:
void parseFile(GooString *fileName, FILE *f);
void parseNameToUnicode(GooList *tokens, GooString *fileName, int line);
void parseNameToUnicode(GooString *name);
void parseCIDToUnicode(GooList *tokens, GooString *fileName, int line);
void parseUnicodeToUnicode(GooList *tokens, GooString *fileName, int line);
void parseUnicodeMap(GooList *tokens, GooString *fileName, int line);
......@@ -244,6 +244,11 @@ private:
GBool parseYesNo2(char *token, GBool *flag);
UnicodeMap *getUnicodeMap2(GooString *encodingName);
void scanEncodingDirs();
void addCIDToUnicode(GooString *collection, GooString *fileName);
void addUnicodeMap(GooString *encodingName, GooString *fileName);
void addCMapDir(GooString *collection, GooString *dir);
//----- static tables
NameToCharCode * // mapping from char name to
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment