- Cast sizeof to int, to shut up signedness warnings in comparison.
- Add consts where appropriate.
reviewed by: Patrick Lam <plam@mit.edu>
ReplaceDispose (Replace *r);
static void
-Bail (char *format, char *arg);
+Bail (const char *format, const char *arg);
static Replace *
ReplaceRead (FILE *f);
}
static void
-Bail (char *format, char *arg)
+Bail (const char *format, const char *arg)
{
fprintf (stderr, "fatal: ");
fprintf (stderr, format, arg);
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 },
} CaseFoldRaw;
static void
-panic (char *reason)
+panic (const char *reason)
{
fprintf (stderr, "fc-case: panic %s\n", reason);
exit (1);
return 0;
}
-static char *
+static const char *
case_fold_method_name (FcChar16 method)
{
switch (method) {
#include "fcint.h"
static int
-rawindex (FcGlyphName *gn);
+rawindex (const FcGlyphName *gn);
static void
scan (FILE *f, char *filename);
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)
}
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);
}
int hash, rehash;
static int
-rawindex (FcGlyphName *gn)
+rawindex (const FcGlyphName *gn)
{
int i;
}
static void
-dump (FcGlyphName **table, char *name)
+dump (FcGlyphName * const *table, const char *name)
{
int i;
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);
}
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);
}
FILE *f;
int ncountry = 0;
int i = 0;
+ int argi;
FcCharLeaf **leaves;
int total_leaves = 0;
int l, sl, tl;
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);
FcCharSetDump (fcs);
#endif
iter->ucs4 = 0;
+ iter->pos = 0;
FcCharSetIterSet (fcs, iter);
}
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++)
#include <locale.h>
static struct {
- char *field;
+ const char *field;
FcBool value;
} FcBoolDefaults[] = {
{ FC_HINTING, FcTrue }, /* !FT_LOAD_NO_HINTING */
{ 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)
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] = '-';
{ 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)
{ 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" },
{ 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;
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
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;
}
(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)
{ (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])
{ (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)
{ (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)
{ (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)
}
static FcBool
-FcStringInPatternElement (FcPattern *pat, char *elt, FcChar8 *string)
+FcStringInPatternElement (FcPattern *pat, const char *elt, FcChar8 *string)
{
int e;
FcChar8 *old;
{
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)
{ 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)
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))
if (fcFontDecoders[decode].map)
{
charcode = FcFreeTypeUcs4ToPrivate (ucs4, fcFontDecoders[decode].map);
- if (charcode == ~0)
+ if (charcode == ~0U)
continue;
}
else
{
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)
{
}
static struct {
- char *name;
+ char name[16];
int alloc_count;
int alloc_mem;
int free_count;
#include <stdio.h>
static double
-FcCompareNumber (char *object, FcValue *value1, FcValue *value2)
+FcCompareNumber (const char *object, FcValue *value1, FcValue *value2)
{
double v1, v2, v;
}
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)
}
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)
}
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);
}
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;
}
static double
-FcCompareCharSet (char *object, FcValue *v1, FcValue *v2)
+FcCompareCharSet (const char *object, FcValue *v1, FcValue *v2)
{
FcValue value1 = FcValueCanonicalize(v1), value2 = FcValueCanonicalize(v2);
}
static double
-FcCompareSize (char *object, FcValue *value1, FcValue *value2)
+FcCompareSize (const char *object, FcValue *value1, FcValue *value2)
{
double v1, v2, v;
}
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;
static int FcValueListFrozenCount[FcTypeLangSet + 1];
static int FcValueListFrozenBytes[FcTypeLangSet + 1];
-static char *FcValueListFrozenName[] = {
+static char FcValueListFrozenName[][8] = {
"Void",
"Integer",
"Double",
int i;
FcValueListPtr l;
+ printf("pattern duplicate %x\n", (int)orig); // XXX
new = FcPatternCreate ();
if (!new)
goto bail0;
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;
} 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);
}
-static char *
+static const char *
FcTypeName (FcType type)
{
switch (type) {
}
static const FcChar8 *
-FcConfigGetAttribute (FcConfigParse *parse, char *attr)
+FcConfigGetAttribute (FcConfigParse *parse, const char *attr)
{
FcChar8 **attrs;
if (!parse->pstack)
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;
}
typedef struct _FcOpMap {
- char *name;
+ char name[16];
FcOp op;
} FcOpMap;
{ "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)
{ "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)