summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
authorElliot Lee <sopwith@redhat.com>2000-06-19 17:15:45 +0000
committerElliot Lee <sopwith@src.gnome.org>2000-06-19 17:15:45 +0000
commite2dc9e117648e267953d7318bd3e0093cd5ab234 (patch)
tree4a582a231b2efca221ec86cf80e12dc7451e99d3 /pango
parentb9aaea84c9092c83906676aa97d8a7ea89a51f36 (diff)
downloadpango-e2dc9e117648e267953d7318bd3e0093cd5ab234.tar.gz
g_strcasecmp returns 0 when strings are equal - negate return value.
2000-06-11 Elliot Lee <sopwith@redhat.com> * pango/fonts.c (pango_font_description_compare): g_strcasecmp returns 0 when strings are equal - negate return value. 2000-06-09 Elliot Lee <sopwith@redhat.com> * pango/pango-coverage.[ch]: Return 'coverage' from pango_coverage_ref. 2000-06-08 Elliot Lee <sopwith@redhat.com> * pango/Makefile.am: Add DOTMODULESDIR define to make it easier to change location of .modules files. * pango/modules.c: Make use of aforesaid define. Also scan the DOTMODULESDIR directory for multiple config files instead of just pango.modules. Also fclose() opened files.
Diffstat (limited to 'pango')
-rw-r--r--pango/Makefile.am3
-rw-r--r--pango/fonts.c2
-rw-r--r--pango/modules.c87
-rw-r--r--pango/pango-coverage.c4
-rw-r--r--pango/pango-coverage.h2
5 files changed, 74 insertions, 24 deletions
diff --git a/pango/Makefile.am b/pango/Makefile.am
index 168f014e..5cd9e019 100644
--- a/pango/Makefile.am
+++ b/pango/Makefile.am
@@ -1,6 +1,7 @@
## Process this file with automake to create Makefile.in.
-INCLUDES=-DSYSCONFDIR=\"$(sysconfdir)\" -DLOCALSTATEDIR=\"$(localstatedir)\" -I$(top_srcdir)
+INCLUDES=-DDOTMODULEDIR=\"$(sysconfdir)/pango\" -DSYSCONFDIR=\"$(sysconfdir)\" \
+ -DLOCALSTATEDIR=\"$(localstatedir)\" -I$(top_srcdir)
lib_LTLIBRARIES = libpango.la libpangox.la
bin_PROGRAMS = pango-querymodules
diff --git a/pango/fonts.c b/pango/fonts.c
index 70650225..aedecad7 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -70,7 +70,7 @@ pango_font_description_compare (const PangoFontDescription *desc1,
desc1->weight == desc2->weight &&
desc1->stretch == desc2->stretch &&
desc1->size == desc2->size &&
- g_strcasecmp (desc1->family_name, desc2->family_name));
+ !g_strcasecmp (desc1->family_name, desc2->family_name));
}
/**
diff --git a/pango/modules.c b/pango/modules.c
index c109c3ef..66a75c2c 100644
--- a/pango/modules.c
+++ b/pango/modules.c
@@ -22,6 +22,8 @@
#include <ctype.h>
#include <stdio.h>
#include <string.h>
+#include <dirent.h>
+#include <limits.h>
#include <gmodule.h>
@@ -215,26 +217,11 @@ add_included_modules (void)
}
}
-static void
-read_modules (void)
+static gboolean /* Returns true if succeeded, false if failed */
+process_module_file(FILE *module_file)
{
- FILE *module_file;
char *line;
- /* FIXME FIXME FIXME - this is a potential security problem from leaving
- * pango.modules files scattered around to trojan modules.
- */
- module_file = fopen ("pango.modules", "r");
- if (!module_file)
- {
- module_file = fopen (LOCALSTATEDIR "/lib/pango/pango.modules", "r");
- if (!module_file)
- {
- fprintf(stderr, "Cannot load module file!\n");
- return; /* FIXME: Error */
- }
- }
-
while ((line = readline (module_file)))
{
PangoEnginePair *pair = g_new (PangoEnginePair, 1);
@@ -277,13 +264,13 @@ read_modules (void)
if (sscanf(q, "%d-%d:", &start, &end) != 2)
{
fprintf(stderr, "Error reading pango.modules");
- return;
+ return FALSE;
}
q = strchr (q, ':');
if (!q)
{
fprintf(stderr, "Error reading pango.modules");
- return;
+ return FALSE;
}
q++;
range->start = start;
@@ -311,7 +298,7 @@ read_modules (void)
if (i<3)
{
fprintf(stderr, "Error reading pango.modules");
- return;
+ return FALSE;
}
ranges = g_list_reverse (ranges);
@@ -333,6 +320,65 @@ read_modules (void)
engines = g_list_prepend (engines, pair);
}
+
+ return TRUE;
+}
+
+static void
+read_modules (void)
+{
+ FILE *module_file;
+ gboolean read_module_file = FALSE;
+
+ /* FIXME FIXME FIXME - this is a potential security problem from leaving
+ * pango.modules files scattered around to trojan modules.
+ */
+ module_file = fopen ("pango.modules", "r");
+ if(module_file)
+ {
+ read_module_file = read_module_file || process_module_file(module_file);
+ process_module_file(module_file);
+ fclose(module_file);
+ }
+ else
+ {
+ DIR *dirh;
+
+ dirh = opendir(DOTMODULEDIR);
+ if(dirh)
+ {
+ struct dirent *dent;
+
+ while((dent = readdir(dirh)))
+ {
+ char fullfn[PATH_MAX];
+ char *ctmp;
+
+ if(dent->d_name[0] == '.')
+ continue;
+
+ ctmp = strrchr(dent->d_name, '.');
+ if(!ctmp || strcmp(ctmp, ".modules") != 0)
+ continue;
+
+ g_snprintf(fullfn, sizeof(fullfn), DOTMODULEDIR "/%s", dent->d_name);
+ module_file = fopen(fullfn, "r");
+ if(module_file)
+ {
+ read_module_file = read_module_file || process_module_file(module_file);
+ fclose(module_file);
+ }
+ }
+ }
+
+ closedir(dirh);
+ }
+
+ if (!read_module_file)
+ {
+ fprintf(stderr, "Could not load any module files!\n");
+ /* FIXME: Error */
+ }
}
static void
@@ -377,6 +423,7 @@ build_map (PangoMapInfo *info)
init_modules();
info->map = map = g_new (PangoMap, 1);
+ map->n_submaps = 0;
for (i=0; i<256; i++)
{
map->submaps[i].is_leaf = TRUE;
diff --git a/pango/pango-coverage.c b/pango/pango-coverage.c
index 286c3977..4445705d 100644
--- a/pango/pango-coverage.c
+++ b/pango/pango-coverage.c
@@ -117,12 +117,14 @@ pango_coverage_copy (PangoCoverage *coverage)
*
* Increase the reference count on the #PangoCoverage by one
**/
-void
+PangoCoverage *
pango_coverage_ref (PangoCoverage *coverage)
{
g_return_if_fail (coverage != NULL);
coverage->ref_count++;
+
+ return coverage;
}
/**
diff --git a/pango/pango-coverage.h b/pango/pango-coverage.h
index 1310da66..d51c4bc0 100644
--- a/pango/pango-coverage.h
+++ b/pango/pango-coverage.h
@@ -38,7 +38,7 @@ typedef enum {
} PangoCoverageLevel;
PangoCoverage * pango_coverage_new (void);
-void pango_coverage_ref (PangoCoverage *coverage);
+PangoCoverage * pango_coverage_ref (PangoCoverage *coverage);
void pango_coverage_unref (PangoCoverage *coverage);
PangoCoverage * pango_coverage_copy (PangoCoverage *coverage);
PangoCoverageLevel pango_coverage_get (PangoCoverage *coverage,