From 67accef4d3e245c1dea341e633d82b14aa03432a Mon Sep 17 00:00:00 2001 From: Patrick Lam Date: Thu, 22 Sep 2005 23:45:53 +0000 Subject: [PATCH] Fix more gcc4 warnings: - Cast sizeof to int, to shut up signedness warnings in comparison. - Add consts where appropriate. reviewed by: Patrick Lam --- doc/edit-sgml.c | 4 +- fc-case/fc-case.c | 8 +-- fc-glyphname/fc-glyphname.c | 21 +++--- fc-lang/fc-lang.c | 20 ++++-- src/fccharset.c | 3 +- src/fcdefault.c | 6 +- src/fcfreetype.c | 43 ++++++----- src/fcinit.c | 2 +- src/fcmatch.c | 18 ++--- src/fcpat.c | 3 +- src/fcxml.c | 138 ++++++++++++++++++------------------ 11 files changed, 142 insertions(+), 124 deletions(-) diff --git a/doc/edit-sgml.c b/doc/edit-sgml.c index 3542a5a..77cc807 100644 --- a/doc/edit-sgml.c +++ b/doc/edit-sgml.c @@ -77,7 +77,7 @@ static void ReplaceDispose (Replace *r); static void -Bail (char *format, char *arg); +Bail (const char *format, const char *arg); static Replace * ReplaceRead (FILE *f); @@ -249,7 +249,7 @@ ReplaceDispose (Replace *r) } static void -Bail (char *format, char *arg) +Bail (const char *format, const char *arg) { fprintf (stderr, "fatal: "); fprintf (stderr, format, arg); diff --git a/fc-case/fc-case.c b/fc-case/fc-case.c index 588ccf3..f7f8277 100644 --- a/fc-case/fc-case.c +++ b/fc-case/fc-case.c @@ -31,11 +31,11 @@ typedef enum _caseFoldClass { CaseFoldCommon, CaseFoldFull, CaseFoldSimple, CaseFoldTurkic } CaseFoldClass; typedef struct _caseFoldClassMap { - char *name; + const char *name; CaseFoldClass class; } CaseFoldClassMap; -static CaseFoldClassMap caseFoldClassMap[] = { +static const CaseFoldClassMap caseFoldClassMap[] = { { "C", CaseFoldCommon }, { "F", CaseFoldFull }, { "S", CaseFoldSimple }, @@ -51,7 +51,7 @@ typedef struct _caseFoldRaw { } CaseFoldRaw; static void -panic (char *reason) +panic (const char *reason) { fprintf (stderr, "fc-case: panic %s\n", reason); exit (1); @@ -148,7 +148,7 @@ foldExtends (FcCaseFold *fold, CaseFoldRaw *raw) return 0; } -static char * +static const char * case_fold_method_name (FcChar16 method) { switch (method) { diff --git a/fc-glyphname/fc-glyphname.c b/fc-glyphname/fc-glyphname.c index 2c69c2b..05a22ae 100644 --- a/fc-glyphname/fc-glyphname.c +++ b/fc-glyphname/fc-glyphname.c @@ -25,7 +25,7 @@ #include "fcint.h" static int -rawindex (FcGlyphName *gn); +rawindex (const FcGlyphName *gn); static void scan (FILE *f, char *filename); @@ -43,7 +43,7 @@ static void insert (FcGlyphName *gn, FcGlyphName **table, FcChar32 h); static void -dump (FcGlyphName **table, char *name); +dump (FcGlyphName * const *table, const char *name); static FcGlyphName * FcAllocGlyphName (FcChar32 ucs, FcChar8 *name) @@ -59,9 +59,13 @@ FcAllocGlyphName (FcChar32 ucs, FcChar8 *name) } static void -fatal (char *file, int lineno, char *msg) +fatal (const char *file, int lineno, const char *msg) { - fprintf (stderr, "%s:%d: %s\n", file, lineno, msg); + if (lineno) + fprintf (stderr, "%s:%d: %s\n", file, lineno, msg); + else + fprintf (stderr, "%s: %s\n", file, msg); + exit (1); } @@ -77,7 +81,7 @@ FcGlyphName *ucs_to_name[MAX_GLYPHNAME*2]; int hash, rehash; static int -rawindex (FcGlyphName *gn) +rawindex (const FcGlyphName *gn) { int i; @@ -211,7 +215,7 @@ insert (FcGlyphName *gn, FcGlyphName **table, FcChar32 h) } static void -dump (FcGlyphName **table, char *name) +dump (FcGlyphName * const *table, const char *name) { int i; @@ -235,11 +239,12 @@ main (int argc, char **argv) int i; i = 0; - while (*++argv) + while (argv[i+1]) { if (i == MAX_GLYPHFILE) fatal (*argv, 0, "Too many glyphname files"); - files[i++] = *argv; + files[i] = argv[i+1]; + i++; } files[i] = 0; qsort (files, i, sizeof (char *), compare_string); diff --git a/fc-lang/fc-lang.c b/fc-lang/fc-lang.c index 5b6c63e..27508c0 100644 --- a/fc-lang/fc-lang.c +++ b/fc-lang/fc-lang.c @@ -60,9 +60,12 @@ FcConfigHome (void) } static void -fatal (char *file, int lineno, char *msg) +fatal (const char *file, int lineno, const char *msg) { - fprintf (stderr, "%s:%d: %s\n", file, lineno, msg); + if (lineno) + fprintf (stderr, "%s:%d: %s\n", file, lineno, msg); + else + fprintf (stderr, "%s:%d: %s\n", file, lineno, msg); exit (1); } @@ -226,6 +229,7 @@ main (int argc, char **argv) FILE *f; int ncountry = 0; int i = 0; + int argi; FcCharLeaf **leaves; int total_leaves = 0; int l, sl, tl; @@ -237,16 +241,18 @@ main (int argc, char **argv) int setRangeEnd[26]; FcChar8 setRangeChar; - while (*++argv) + argi = 1; + while (argv[argi]) { - if (!strcmp (*argv, "-d")) + if (!strcmp (argv[argi], "-d")) { - dir = *++argv; + argi++; + dir = argv[argi++]; continue; } if (i == MAX_LANG) - fatal (*argv, 0, "Too many languages"); - files[i++] = *argv; + fatal (argv[0], 0, "Too many languages"); + files[i++] = argv[argi++]; } files[i] = 0; qsort (files, i, sizeof (char *), compare); diff --git a/src/fccharset.c b/src/fccharset.c index d0fee82..6b3aa5e 100644 --- a/src/fccharset.c +++ b/src/fccharset.c @@ -347,6 +347,7 @@ FcCharSetIterStart (const FcCharSet *fcs, FcCharSetIter *iter) FcCharSetDump (fcs); #endif iter->ucs4 = 0; + iter->pos = 0; FcCharSetIterSet (fcs, iter); } @@ -992,7 +993,7 @@ FcCharSetHash (FcCharSet *fcs) int i; /* hash in leaves */ - for (i = 0; i < fcs->num * sizeof (FcCharLeaf *) / sizeof (FcChar32); i++) + for (i = 0; i < fcs->num * (int) (sizeof (FcCharLeaf *) / sizeof (FcChar32)); i++) hash = ((hash << 1) | (hash >> 31)) ^ (FcChar32)(FcCharSetGetLeaf(fcs, i)->map); /* hash in numbers */ for (i = 0; i < fcs->num; i++) diff --git a/src/fcdefault.c b/src/fcdefault.c index 0e84311..5e648dc 100644 --- a/src/fcdefault.c +++ b/src/fcdefault.c @@ -26,7 +26,7 @@ #include static struct { - char *field; + const char *field; FcBool value; } FcBoolDefaults[] = { { FC_HINTING, FcTrue }, /* !FT_LOAD_NO_HINTING */ @@ -35,7 +35,7 @@ static struct { { FC_GLOBAL_ADVANCE, FcTrue }, /* !FC_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH */ }; -#define NUM_FC_BOOL_DEFAULTS (sizeof FcBoolDefaults / sizeof FcBoolDefaults[0]) +#define NUM_FC_BOOL_DEFAULTS (int) (sizeof FcBoolDefaults / sizeof FcBoolDefaults[0]) void FcDefaultSubstitute (FcPattern *pattern) @@ -127,7 +127,7 @@ FcDefaultSubstitute (FcPattern *pattern) after = territory + strlen (territory); } territory_len = after - territory; - if (lang_len + 1 + territory_len + 1 <= sizeof (lang_local)) + if (lang_len + 1 + territory_len + 1 <= (int) sizeof (lang_local)) { strncpy (lang_local, lang, lang_len); lang_local[lang_len] = '-'; diff --git a/src/fcfreetype.c b/src/fcfreetype.c index 979a173..f3eeb8a 100644 --- a/src/fcfreetype.c +++ b/src/fcfreetype.c @@ -95,7 +95,7 @@ static const struct { { 20, (const FcChar8 *) "zh-tw" }, }; -#define NUM_CODE_PAGE_RANGE (sizeof FcCodePageRange / sizeof FcCodePageRange[0]) +#define NUM_CODE_PAGE_RANGE (int) (sizeof FcCodePageRange / sizeof FcCodePageRange[0]) FcBool FcFreeTypeIsExclusiveLang (const FcChar8 *lang) @@ -135,18 +135,18 @@ static const FcFtEncoding fcFtEncoding[] = { { TT_PLATFORM_ISO, TT_ISO_ID_8859_1, "ISO-8859-1" }, }; -#define NUM_FC_FT_ENCODING (sizeof (fcFtEncoding) / sizeof (fcFtEncoding[0])) +#define NUM_FC_FT_ENCODING (int) (sizeof (fcFtEncoding) / sizeof (fcFtEncoding[0])) typedef struct { FT_UShort platform_id; FT_UShort language_id; - char *lang; + const char lang[8]; } FcFtLanguage; #define TT_LANGUAGE_DONT_CARE 0xffff static const FcFtLanguage fcFtLanguage[] = { - { TT_PLATFORM_APPLE_UNICODE, TT_LANGUAGE_DONT_CARE, 0 }, + { TT_PLATFORM_APPLE_UNICODE, TT_LANGUAGE_DONT_CARE, "" }, { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_ENGLISH, "en" }, { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_FRENCH, "fr" }, { TT_PLATFORM_MACINTOSH, TT_MAC_LANGID_GERMAN, "de" }, @@ -545,7 +545,7 @@ static const FcFtLanguage fcFtLanguage[] = { { TT_PLATFORM_MICROSOFT, TT_MS_LANGID_PAPIAMENTU_NETHERLANDS_ANTILLES,"pap" }, }; -#define NUM_FC_FT_LANGUAGE (sizeof (fcFtLanguage) / sizeof (fcFtLanguage[0])) +#define NUM_FC_FT_LANGUAGE (int) (sizeof (fcFtLanguage) / sizeof (fcFtLanguage[0])) typedef struct { FT_UShort language_id; @@ -560,7 +560,7 @@ static const FcMacRomanFake fcMacRomanFake[] = { static FcChar8 * FcFontCapabilities(FT_Face face); -#define NUM_FC_MAC_ROMAN_FAKE (sizeof (fcMacRomanFake) / sizeof (fcMacRomanFake[0])) +#define NUM_FC_MAC_ROMAN_FAKE (int) (sizeof (fcMacRomanFake) / sizeof (fcMacRomanFake[0])) #if HAVE_ICONV && HAVE_ICONV_H #define USE_ICONV 1 @@ -749,7 +749,12 @@ FcSfntNameLanguage (FT_SfntName *sname) if (fcFtLanguage[i].platform_id == sname->platform_id && (fcFtLanguage[i].language_id == TT_LANGUAGE_DONT_CARE || fcFtLanguage[i].language_id == sname->language_id)) - return (FcChar8 *) fcFtLanguage[i].lang; + { + if (fcFtLanguage[i].lang[0] == '\0') + return NULL; + else + return (FcChar8 *) fcFtLanguage[i].lang; + } return 0; } @@ -781,7 +786,7 @@ static const struct { (const FcChar8 *) "hanyang" } }; -#define NUM_NOTICE_FOUNDRIES (sizeof (FcNoticeFoundries) / sizeof (FcNoticeFoundries[0])) +#define NUM_NOTICE_FOUNDRIES (int) (sizeof (FcNoticeFoundries) / sizeof (FcNoticeFoundries[0])) static const FcChar8 * FcNoticeFoundry(const FT_String *notice) @@ -850,7 +855,7 @@ static const struct { { (const FT_Char *) "Y&Y", (const FcChar8 *) "y&y"} }; -#define NUM_VENDOR_FOUNDRIES (sizeof (FcVendorFoundries) / sizeof (FcVendorFoundries[0])) +#define NUM_VENDOR_FOUNDRIES (int) (sizeof (FcVendorFoundries) / sizeof (FcVendorFoundries[0])) static const FcChar8 * FcVendorFoundry(const FT_Char vendor[4]) @@ -916,7 +921,7 @@ static const FcStringConst weightConsts[] = { { (FC8) "heavy", FC_WEIGHT_HEAVY }, }; -#define NUM_WEIGHT_CONSTS (sizeof (weightConsts) / sizeof (weightConsts[0])) +#define NUM_WEIGHT_CONSTS (int) (sizeof (weightConsts) / sizeof (weightConsts[0])) #define FcIsWeight(s) FcStringIsConst(s,weightConsts,NUM_WEIGHT_CONSTS) #define FcContainsWeight(s) FcStringContainsConst (s,weightConsts,NUM_WEIGHT_CONSTS) @@ -933,7 +938,7 @@ static const FcStringConst widthConsts[] = { { (FC8) "expanded", FC_WIDTH_EXPANDED }, /* must be after *expanded */ }; -#define NUM_WIDTH_CONSTS (sizeof (widthConsts) / sizeof (widthConsts[0])) +#define NUM_WIDTH_CONSTS (int) (sizeof (widthConsts) / sizeof (widthConsts[0])) #define FcIsWidth(s) FcStringIsConst(s,widthConsts,NUM_WIDTH_CONSTS) #define FcContainsWidth(s) FcStringContainsConst (s,widthConsts,NUM_WIDTH_CONSTS) @@ -943,7 +948,7 @@ static const FcStringConst slantConsts[] = { { (FC8) "oblique", FC_SLANT_OBLIQUE }, }; -#define NUM_SLANT_CONSTS (sizeof (slantConsts) / sizeof (slantConsts[0])) +#define NUM_SLANT_CONSTS (int) (sizeof (slantConsts) / sizeof (slantConsts[0])) #define FcIsSlant(s) FcStringIsConst(s,slantConsts,NUM_SLANT_CONSTS) #define FcContainsSlant(s) FcStringContainsConst (s,slantConsts,NUM_SLANT_CONSTS) @@ -970,7 +975,7 @@ FcGetPixelSize (FT_Face face, int i) } static FcBool -FcStringInPatternElement (FcPattern *pat, char *elt, FcChar8 *string) +FcStringInPatternElement (FcPattern *pat, const char *elt, FcChar8 *string) { int e; FcChar8 *old; @@ -1075,7 +1080,7 @@ FcFreeTypeQuery (const FcChar8 *file, { FcChar8 *utf8; FcChar8 *lang; - char *elt = 0, *eltlang = 0; + const char *elt = 0, *eltlang = 0; int *np = 0, *nlangp = 0; if (FT_Get_Sfnt_Name (face, snamei, &sname) != 0) @@ -2125,13 +2130,13 @@ static const FcFontDecode fcFontDecoders[] = { { ft_encoding_apple_roman, &AppleRoman, (1 << 16) - 1 }, }; -#define NUM_DECODE (sizeof (fcFontDecoders) / sizeof (fcFontDecoders[0])) +#define NUM_DECODE (int) (sizeof (fcFontDecoders) / sizeof (fcFontDecoders[0])) static const FcChar32 prefer_unicode[] = { 0x20ac, /* EURO SIGN */ }; -#define NUM_PREFER_UNICODE (sizeof (prefer_unicode) / sizeof (prefer_unicode[0])) +#define NUM_PREFER_UNICODE (int) (sizeof (prefer_unicode) / sizeof (prefer_unicode[0])) FcChar32 FcFreeTypeUcs4ToPrivate (FcChar32 ucs4, const FcCharMap *map) @@ -2272,7 +2277,7 @@ FcFreeTypeGlyphNameIndex (FT_Face face, FcChar8 *name) FT_UInt gindex; FcChar8 name_buf[FC_GLYPHNAME_MAXLEN + 2]; - for (gindex = 0; gindex < face->num_glyphs; gindex++) + for (gindex = 0; gindex < (FT_UInt) face->num_glyphs; gindex++) { if (FT_Get_Glyph_Name (face, gindex, name_buf, FC_GLYPHNAME_MAXLEN+1) == 0) if (!strcmp ((char *) name, (char *) name_buf)) @@ -2326,7 +2331,7 @@ FcFreeTypeCharIndex (FT_Face face, FcChar32 ucs4) if (fcFontDecoders[decode].map) { charcode = FcFreeTypeUcs4ToPrivate (ucs4, fcFontDecoders[decode].map); - if (charcode == ~0) + if (charcode == ~0U) continue; } else @@ -2586,7 +2591,7 @@ FcFreeTypeCharSetAndSpacing (FT_Face face, FcBlanks *blanks, int *spacing) { FcChar8 name_buf[FC_GLYPHNAME_MAXLEN + 2]; - for (glyph = 0; glyph < face->num_glyphs; glyph++) + for (glyph = 0; glyph < (FT_UInt) face->num_glyphs; glyph++) { if (FT_Get_Glyph_Name (face, glyph, name_buf, FC_GLYPHNAME_MAXLEN+1) == 0) { diff --git a/src/fcinit.c b/src/fcinit.c index 8a9bdbd..151c429 100644 --- a/src/fcinit.c +++ b/src/fcinit.c @@ -161,7 +161,7 @@ FcInitBringUptoDate (void) } static struct { - char *name; + char name[16]; int alloc_count; int alloc_mem; int free_count; diff --git a/src/fcmatch.c b/src/fcmatch.c index b2b2c8d..a359a8b 100644 --- a/src/fcmatch.c +++ b/src/fcmatch.c @@ -28,7 +28,7 @@ #include static double -FcCompareNumber (char *object, FcValue *value1, FcValue *value2) +FcCompareNumber (const char *object, FcValue *value1, FcValue *value2) { double v1, v2, v; @@ -59,7 +59,7 @@ FcCompareNumber (char *object, FcValue *value1, FcValue *value2) } static double -FcCompareString (char *object, FcValue *v1, FcValue *v2) +FcCompareString (const char *object, FcValue *v1, FcValue *v2) { FcValue value1 = FcValueCanonicalize(v1), value2 = FcValueCanonicalize(v2); if (value2.type != FcTypeString || value1.type != FcTypeString) @@ -68,7 +68,7 @@ FcCompareString (char *object, FcValue *v1, FcValue *v2) } static double -FcCompareFamily (char *object, FcValue *v1, FcValue *v2) +FcCompareFamily (const char *object, FcValue *v1, FcValue *v2) { FcValue value1 = FcValueCanonicalize(v1), value2 = FcValueCanonicalize(v2); if (value2.type != FcTypeString || value1.type != FcTypeString) @@ -77,7 +77,7 @@ FcCompareFamily (char *object, FcValue *v1, FcValue *v2) } static double -FcCompareLang (char *object, FcValue *v1, FcValue *v2) +FcCompareLang (const char *object, FcValue *v1, FcValue *v2) { FcLangResult result; FcValue value1 = FcValueCanonicalize(v1), value2 = FcValueCanonicalize(v2); @@ -124,7 +124,7 @@ FcCompareLang (char *object, FcValue *v1, FcValue *v2) } static double -FcCompareBool (char *object, FcValue *value1, FcValue *value2) +FcCompareBool (const char *object, FcValue *value1, FcValue *value2) { if (value2->type != FcTypeBool || value1->type != FcTypeBool) return -1.0; @@ -132,7 +132,7 @@ FcCompareBool (char *object, FcValue *value1, FcValue *value2) } static double -FcCompareCharSet (char *object, FcValue *v1, FcValue *v2) +FcCompareCharSet (const char *object, FcValue *v1, FcValue *v2) { FcValue value1 = FcValueCanonicalize(v1), value2 = FcValueCanonicalize(v2); @@ -142,7 +142,7 @@ FcCompareCharSet (char *object, FcValue *v1, FcValue *v2) } static double -FcCompareSize (char *object, FcValue *value1, FcValue *value2) +FcCompareSize (const char *object, FcValue *value1, FcValue *value2) { double v1, v2, v; @@ -175,8 +175,8 @@ FcCompareSize (char *object, FcValue *value1, FcValue *value2) } typedef struct _FcMatcher { - char *object; - double (*compare) (char *object, FcValue *value1, FcValue *value2); + const char *object; + double (*compare) (const char *object, FcValue *value1, FcValue *value2); int strong, weak; } FcMatcher; diff --git a/src/fcpat.c b/src/fcpat.c index 84154ea..cfb6f45 100644 --- a/src/fcpat.c +++ b/src/fcpat.c @@ -331,7 +331,7 @@ typedef union _FcValueListAlign { static int FcValueListFrozenCount[FcTypeLangSet + 1]; static int FcValueListFrozenBytes[FcTypeLangSet + 1]; -static char *FcValueListFrozenName[] = { +static char FcValueListFrozenName[][8] = { "Void", "Integer", "Double", @@ -1203,6 +1203,7 @@ FcPatternDuplicate (const FcPattern *orig) int i; FcValueListPtr l; + printf("pattern duplicate %x\n", (int)orig); // XXX new = FcPatternCreate (); if (!new) goto bail0; diff --git a/src/fcxml.c b/src/fcxml.c index 7a48628..950bc9a 100644 --- a/src/fcxml.c +++ b/src/fcxml.c @@ -323,72 +323,72 @@ typedef enum _FcElement { FcElementUnknown } FcElement; +static struct { + const char name[16]; + FcElement element; +} fcElementMap[] = { + { "fontconfig", FcElementFontconfig }, + { "dir", FcElementDir }, + { "cache", FcElementCache }, + { "include", FcElementInclude }, + { "config", FcElementConfig }, + { "match", FcElementMatch }, + { "alias", FcElementAlias }, + + { "blank", FcElementBlank }, + { "rescan", FcElementRescan }, + + { "prefer", FcElementPrefer }, + { "accept", FcElementAccept }, + { "default", FcElementDefault }, + { "family", FcElementFamily }, + + { "selectfont", FcElementSelectfont }, + { "acceptfont", FcElementAcceptfont }, + { "rejectfont", FcElementRejectfont }, + { "glob", FcElementGlob }, + { "pattern", FcElementPattern }, + { "patelt", FcElementPatelt }, + + { "test", FcElementTest }, + { "edit", FcElementEdit }, + { "int", FcElementInt }, + { "double", FcElementDouble }, + { "string", FcElementString }, + { "matrix", FcElementMatrix }, + { "bool", FcElementBool }, + { "charset", FcElementCharset }, + { "name", FcElementName }, + { "const", FcElementConst }, + { "or", FcElementOr }, + { "and", FcElementAnd }, + { "eq", FcElementEq }, + { "not_eq", FcElementNotEq }, + { "less", FcElementLess }, + { "less_eq", FcElementLessEq }, + { "more", FcElementMore }, + { "more_eq", FcElementMoreEq }, + { "contains", FcElementContains }, + { "not_contains", FcElementNotContains }, + { "plus", FcElementPlus }, + { "minus", FcElementMinus }, + { "times", FcElementTimes }, + { "divide", FcElementDivide }, + { "not", FcElementNot }, + { "if", FcElementIf }, + { "floor", FcElementFloor }, + { "ceil", FcElementCeil }, + { "round", FcElementRound }, + { "trunc", FcElementTrunc }, +}; +#define NUM_ELEMENT_MAPS (int) (sizeof fcElementMap / sizeof fcElementMap[0]) + static FcElement FcElementMap (const XML_Char *name) { - static struct { - char *name; - FcElement element; - } fcElementMap[] = { - { "fontconfig", FcElementFontconfig }, - { "dir", FcElementDir }, - { "cache", FcElementCache }, - { "include", FcElementInclude }, - { "config", FcElementConfig }, - { "match", FcElementMatch }, - { "alias", FcElementAlias }, - - { "blank", FcElementBlank }, - { "rescan", FcElementRescan }, - - { "prefer", FcElementPrefer }, - { "accept", FcElementAccept }, - { "default", FcElementDefault }, - { "family", FcElementFamily }, - - { "selectfont", FcElementSelectfont }, - { "acceptfont", FcElementAcceptfont }, - { "rejectfont", FcElementRejectfont }, - { "glob", FcElementGlob }, - { "pattern", FcElementPattern }, - { "patelt", FcElementPatelt }, - - { "test", FcElementTest }, - { "edit", FcElementEdit }, - { "int", FcElementInt }, - { "double", FcElementDouble }, - { "string", FcElementString }, - { "matrix", FcElementMatrix }, - { "bool", FcElementBool }, - { "charset", FcElementCharset }, - { "name", FcElementName }, - { "const", FcElementConst }, - { "or", FcElementOr }, - { "and", FcElementAnd }, - { "eq", FcElementEq }, - { "not_eq", FcElementNotEq }, - { "less", FcElementLess }, - { "less_eq", FcElementLessEq }, - { "more", FcElementMore }, - { "more_eq", FcElementMoreEq }, - { "contains", FcElementContains }, - { "not_contains",FcElementNotContains }, - { "plus", FcElementPlus }, - { "minus", FcElementMinus }, - { "times", FcElementTimes }, - { "divide", FcElementDivide }, - { "not", FcElementNot }, - { "if", FcElementIf }, - { "floor", FcElementFloor }, - { "ceil", FcElementCeil }, - { "round", FcElementRound }, - { "trunc", FcElementTrunc }, - - { 0, 0 } - }; int i; - for (i = 0; fcElementMap[i].name; i++) + for (i = 0; i < NUM_ELEMENT_MAPS; i++) if (!strcmp ((char *) name, fcElementMap[i].name)) return fcElementMap[i].element; return FcElementUnknown; @@ -461,9 +461,9 @@ typedef enum _FcConfigSeverity { } FcConfigSeverity; static void -FcConfigMessage (FcConfigParse *parse, FcConfigSeverity severe, char *fmt, ...) +FcConfigMessage (FcConfigParse *parse, FcConfigSeverity severe, const char *fmt, ...) { - char *s = "unknown"; + const char *s = "unknown"; va_list args; va_start (args, fmt); @@ -492,7 +492,7 @@ FcConfigMessage (FcConfigParse *parse, FcConfigSeverity severe, char *fmt, ...) } -static char * +static const char * FcTypeName (FcType type) { switch (type) { @@ -998,7 +998,7 @@ FcConfigCleanup (FcConfigParse *parse) } static const FcChar8 * -FcConfigGetAttribute (FcConfigParse *parse, char *attr) +FcConfigGetAttribute (FcConfigParse *parse, const char *attr) { FcChar8 **attrs; if (!parse->pstack) @@ -1125,7 +1125,7 @@ FcStrtod (char *s, char **end) int slen = strlen (s); int dlen = strlen (locale_data->decimal_point); - if (slen + dlen > sizeof (buf)) + if (slen + dlen > (int) sizeof (buf)) { if (end) *end = s; @@ -1591,7 +1591,7 @@ FcParseInclude (FcConfigParse *parse) } typedef struct _FcOpMap { - char *name; + char name[16]; FcOp op; } FcOpMap; @@ -1617,7 +1617,7 @@ static const FcOpMap fcCompareOps[] = { { "not_contains", FcOpNotContains } }; -#define NUM_COMPARE_OPS (sizeof fcCompareOps / sizeof fcCompareOps[0]) +#define NUM_COMPARE_OPS (int) (sizeof fcCompareOps / sizeof fcCompareOps[0]) static FcOp FcConfigLexCompare (const FcChar8 *compare) @@ -1717,7 +1717,7 @@ static const FcOpMap fcModeOps[] = { { "append_last", FcOpAppendLast }, }; -#define NUM_MODE_OPS (sizeof fcModeOps / sizeof fcModeOps[0]) +#define NUM_MODE_OPS (int) (sizeof fcModeOps / sizeof fcModeOps[0]) static FcOp FcConfigLexMode (const FcChar8 *mode) -- 2.39.2