Switch fontconfig from libxml2 to expat

This commit is contained in:
Keith Packard 2002-02-18 22:29:28 +00:00
parent 2eb26602ff
commit c2e7c611cb
7 changed files with 1402 additions and 773 deletions

View File

@ -25,7 +25,8 @@ INCLUDES=$(FREETYPE2INCLUDES) $(LIBXML2INCLUDES) -I..
DEFINES=-DFC_FALLBACK_FONTS='"$(FALLBACK_FONTS)"' DEFINES=-DFC_FALLBACK_FONTS='"$(FALLBACK_FONTS)"'
REQUIREDLIBS=$(LDPRELIBS) $(FREETYPE2LIB) $(LIBXML2LIB) EXPATLIB=-lexpat
REQUIREDLIBS=$(LDPRELIBS) $(FREETYPE2LIB) $(EXPATLIB)
SRCS=fcblanks.c fccache.c fccfg.c fccharset.c fcdbg.c fcdefault.c fcdir.c \ SRCS=fcblanks.c fccache.c fccfg.c fccharset.c fcdbg.c fcdefault.c fcdir.c \
fcfreetype.c fcfs.c fcinit.c fclist.c fcmatch.c fcmatrix.c fcname.c \ fcfreetype.c fcfs.c fcinit.c fclist.c fcmatch.c fcmatrix.c fcname.c \

View File

@ -1,5 +1,5 @@
/* /*
* $XFree86: $ * $XFree86: xc/lib/fontconfig/src/fccharset.c,v 1.2 2002/02/15 06:01:28 keithp Exp $
* *
* Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc. * Copyright © 2001 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -646,12 +646,12 @@ FcCharSetParseValue (FcChar8 *string, FcChar32 *value)
} }
static FcBool static FcBool
FcCharSetUnparseValue (FcNameBuf *buf, FcChar32 value) FcCharSetUnparseValue (FcStrBuf *buf, FcChar32 value)
{ {
int i; int i;
if (value == 0) if (value == 0)
{ {
return FcNameBufChar (buf, ' '); return FcStrBufChar (buf, ' ');
} }
else else
{ {
@ -664,7 +664,7 @@ FcCharSetUnparseValue (FcNameBuf *buf, FcChar32 value)
value /= 85; value /= 85;
} }
for (i = 0; i < 5; i++) for (i = 0; i < 5; i++)
if (!FcNameBufChar (buf, *s++)) if (!FcStrBufChar (buf, *s++))
return FcFalse; return FcFalse;
} }
return FcTrue; return FcTrue;
@ -704,7 +704,7 @@ bail0:
} }
FcBool FcBool
FcNameUnparseCharSet (FcNameBuf *buf, const FcCharSet *c) FcNameUnparseCharSet (FcStrBuf *buf, const FcCharSet *c)
{ {
FcCharSetIter ci; FcCharSetIter ci;
int i; int i;
@ -729,7 +729,7 @@ FcNameUnparseCharSet (FcNameBuf *buf, const FcCharSet *c)
FcCharSetIter ci, checki; FcCharSetIter ci, checki;
/* null terminate for parser */ /* null terminate for parser */
FcNameBufChar (buf, '\0'); FcStrBufChar (buf, '\0');
/* step back over null for life after test */ /* step back over null for life after test */
buf->len--; buf->len--;
check = FcNameParseCharSet (buf->buf + len); check = FcNameParseCharSet (buf->buf + len);

View File

@ -135,7 +135,10 @@ FcExprPrint (FcExpr *expr)
expr->u.mval->yx, expr->u.mval->yx,
expr->u.mval->yy); expr->u.mval->yy);
case FcOpBool: printf ("%s", expr->u.bval ? "true" : "false"); break; case FcOpBool: printf ("%s", expr->u.bval ? "true" : "false"); break;
case FcOpCharSet: printf ("charset\n"); break;
case FcOpNil: printf ("nil\n");
case FcOpField: printf ("%s", expr->u.field); break; case FcOpField: printf ("%s", expr->u.field); break;
case FcOpConst: printf ("%s", expr->u.constant); break;
case FcOpQuest: case FcOpQuest:
FcExprPrint (expr->u.tree.left); FcExprPrint (expr->u.tree.left);
printf (" quest "); printf (" quest ");
@ -143,6 +146,12 @@ FcExprPrint (FcExpr *expr)
printf (" colon "); printf (" colon ");
FcExprPrint (expr->u.tree.right->u.tree.right); FcExprPrint (expr->u.tree.right->u.tree.right);
break; break;
case FcOpAssign:
case FcOpAssignReplace:
case FcOpPrependFirst:
case FcOpPrepend:
case FcOpAppend:
case FcOpAppendLast:
case FcOpOr: case FcOpOr:
case FcOpAnd: case FcOpAnd:
case FcOpEqual: case FcOpEqual:
@ -156,9 +165,16 @@ FcExprPrint (FcExpr *expr)
case FcOpMinus: case FcOpMinus:
case FcOpTimes: case FcOpTimes:
case FcOpDivide: case FcOpDivide:
case FcOpComma:
FcExprPrint (expr->u.tree.left); FcExprPrint (expr->u.tree.left);
printf (" "); printf (" ");
switch (expr->op) { switch (expr->op) {
case FcOpAssign: printf ("Assign"); break;
case FcOpAssignReplace: printf ("AssignReplace"); break;
case FcOpPrependFirst: printf ("PrependFirst"); break;
case FcOpPrepend: printf ("Prepend"); break;
case FcOpAppend: printf ("Append"); break;
case FcOpAppendLast: printf ("AppendLast"); break;
case FcOpOr: printf ("Or"); break; case FcOpOr: printf ("Or"); break;
case FcOpAnd: printf ("And"); break; case FcOpAnd: printf ("And"); break;
case FcOpEqual: printf ("Equal"); break; case FcOpEqual: printf ("Equal"); break;
@ -172,6 +188,7 @@ FcExprPrint (FcExpr *expr)
case FcOpMinus: printf ("Minus"); break; case FcOpMinus: printf ("Minus"); break;
case FcOpTimes: printf ("Times"); break; case FcOpTimes: printf ("Times"); break;
case FcOpDivide: printf ("Divide"); break; case FcOpDivide: printf ("Divide"); break;
case FcOpComma: printf ("Comma"); break;
default: break; default: break;
} }
printf (" "); printf (" ");
@ -181,8 +198,7 @@ FcExprPrint (FcExpr *expr)
printf ("Not "); printf ("Not ");
FcExprPrint (expr->u.tree.left); FcExprPrint (expr->u.tree.left);
break; break;
default: case FcOpInvalid: printf ("Invalid"); break;
break;
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* $XFree86: $ * $XFree86: xc/lib/fontconfig/src/fcint.h,v 1.2 2002/02/15 06:01:28 keithp Exp $
* *
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -33,10 +33,8 @@
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <libxml/parserInternals.h>
#include <fontconfig/fontconfig.h> #include <fontconfig/fontconfig.h>
#include <fontconfig/fcprivate.h> #include <fontconfig/fcprivate.h>
#include <fontconfig/fcxml.h>
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
#endif #endif
@ -175,13 +173,13 @@ struct _FcCharSet {
FcCharNode node; FcCharNode node;
}; };
typedef struct _FcNameBuf { typedef struct _FcStrBuf {
FcChar8 *buf; FcChar8 *buf;
FcBool allocated; FcBool allocated;
FcBool failed; FcBool failed;
int len; int len;
int size; int size;
} FcNameBuf; } FcStrBuf;
typedef struct _FcFileCacheEnt { typedef struct _FcFileCacheEnt {
struct _FcFileCacheEnt *next; struct _FcFileCacheEnt *next;
@ -315,7 +313,7 @@ FcConfigCompareValue (const FcValue m,
/* fccharset.c */ /* fccharset.c */
FcBool FcBool
FcNameUnparseCharSet (FcNameBuf *buf, const FcCharSet *c); FcNameUnparseCharSet (FcStrBuf *buf, const FcCharSet *c);
FcCharSet * FcCharSet *
FcNameParseCharSet (FcChar8 *string); FcNameParseCharSet (FcChar8 *string);
@ -372,7 +370,7 @@ char *
FcConfigSaveField (const char *field); FcConfigSaveField (const char *field);
FcTest * FcTest *
FcTestCreate (FcQual qual, const char *field, FcOp compare, FcExpr *expr); FcTestCreate (FcQual qual, const FcChar8 *field, FcOp compare, FcExpr *expr);
void void
FcTestDestroy (FcTest *test); FcTestDestroy (FcTest *test);
@ -434,10 +432,10 @@ FcBool
FcNameBool (FcChar8 *v, FcBool *result); FcNameBool (FcChar8 *v, FcBool *result);
FcBool FcBool
FcNameBufChar (FcNameBuf *buf, FcChar8 c); FcStrBufChar (FcStrBuf *buf, FcChar8 c);
FcBool FcBool
FcNameBufString (FcNameBuf *buf, const FcChar8 *s); FcStrBufString (FcStrBuf *buf, const FcChar8 *s);
/* fcpat.c */ /* fcpat.c */
void void
@ -459,4 +457,22 @@ FcStrPlus (const FcChar8 *s1, const FcChar8 *s2);
void void
FcStrFree (FcChar8 *s); FcStrFree (FcChar8 *s);
void
FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size);
void
FcStrBufDestroy (FcStrBuf *buf);
FcChar8 *
FcStrBufDone (FcStrBuf *buf);
FcBool
FcStrBufChar (FcStrBuf *buf, FcChar8 c);
FcBool
FcStrBufString (FcStrBuf *buf, const FcChar8 *s);
FcBool
FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len);
#endif /* _FC_INT_H_ */ #endif /* _FC_INT_H_ */

View File

@ -1,5 +1,5 @@
/* /*
* $XFree86: xc/lib/Fc/xftname.c,v 1.10 2001/03/30 18:50:18 keithp Exp $ * $XFree86: xc/lib/fontconfig/src/fcname.c,v 1.2 2002/02/15 06:01:28 keithp Exp $
* *
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -418,86 +418,8 @@ bail1:
bail0: bail0:
return 0; return 0;
} }
static void
FcNameBufInit (FcNameBuf *buf, FcChar8 *init, int size)
{
buf->buf = init;
buf->allocated = FcFalse;
buf->failed = FcFalse;
buf->len = 0;
buf->size = size;
}
static void
FcNameBufDestroy (FcNameBuf *buf)
{
if (buf->allocated)
free (buf->buf);
}
static FcChar8 *
FcNameBufDone (FcNameBuf *buf)
{
FcChar8 *ret;
ret = malloc (buf->len + 1);
if (ret)
{
memcpy (ret, buf->buf, buf->len);
ret[buf->len] = '\0';
}
FcNameBufDestroy (buf);
return ret;
}
FcBool
FcNameBufChar (FcNameBuf *buf, FcChar8 c)
{
if (buf->len == buf->size)
{
FcChar8 *new;
int size;
if (buf->allocated)
{
size = buf->size * 2;
new = realloc (buf->buf, size);
}
else
{
size = buf->size + 1024;
new = malloc (size);
if (new)
{
buf->allocated = FcTrue;
memcpy (new, buf->buf, buf->len);
}
}
if (!new)
{
buf->failed = FcTrue;
return FcFalse;
}
buf->size = size;
buf->buf = new;
}
buf->buf[buf->len++] = c;
return FcTrue;
}
FcBool
FcNameBufString (FcNameBuf *buf, const FcChar8 *s)
{
FcChar8 c;
while ((c = *s++))
if (!FcNameBufChar (buf, c))
return FcFalse;
return FcTrue;
}
static FcBool static FcBool
FcNameUnparseString (FcNameBuf *buf, FcNameUnparseString (FcStrBuf *buf,
const FcChar8 *string, const FcChar8 *string,
const FcChar8 *escape) const FcChar8 *escape)
{ {
@ -506,17 +428,17 @@ FcNameUnparseString (FcNameBuf *buf,
{ {
if (escape && strchr ((char *) escape, (char) c)) if (escape && strchr ((char *) escape, (char) c))
{ {
if (!FcNameBufChar (buf, escape[0])) if (!FcStrBufChar (buf, escape[0]))
return FcFalse; return FcFalse;
} }
if (!FcNameBufChar (buf, c)) if (!FcStrBufChar (buf, c))
return FcFalse; return FcFalse;
} }
return FcTrue; return FcTrue;
} }
static FcBool static FcBool
FcNameUnparseValue (FcNameBuf *buf, FcNameUnparseValue (FcStrBuf *buf,
FcValue v, FcValue v,
FcChar8 *escape) FcChar8 *escape)
{ {
@ -546,7 +468,7 @@ FcNameUnparseValue (FcNameBuf *buf,
} }
static FcBool static FcBool
FcNameUnparseValueList (FcNameBuf *buf, FcNameUnparseValueList (FcStrBuf *buf,
FcValueList *v, FcValueList *v,
FcChar8 *escape) FcChar8 *escape)
{ {
@ -567,14 +489,14 @@ FcNameUnparseValueList (FcNameBuf *buf,
FcChar8 * FcChar8 *
FcNameUnparse (FcPattern *pat) FcNameUnparse (FcPattern *pat)
{ {
FcNameBuf buf; FcStrBuf buf;
FcChar8 buf_static[8192]; FcChar8 buf_static[8192];
int i; int i;
FcPatternElt *e; FcPatternElt *e;
const FcObjectTypeList *l; const FcObjectTypeList *l;
const FcObjectType *o; const FcObjectType *o;
FcNameBufInit (&buf, buf_static, sizeof (buf_static)); FcStrBufInit (&buf, buf_static, sizeof (buf_static));
e = FcPatternFind (pat, FC_FAMILY, FcFalse); e = FcPatternFind (pat, FC_FAMILY, FcFalse);
if (e) if (e)
{ {
@ -614,8 +536,8 @@ FcNameUnparse (FcPattern *pat)
} }
} }
} }
return FcNameBufDone (&buf); return FcStrBufDone (&buf);
bail0: bail0:
FcNameBufDestroy (&buf); FcStrBufDestroy (&buf);
return 0; return 0;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $XFree86: $ * $XFree86: xc/lib/fontconfig/src/fcstr.c,v 1.2 2002/02/15 06:01:28 keithp Exp $
* *
* Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
* *
@ -186,3 +186,93 @@ FcUtf8Len (FcChar8 *string,
*wchar = 1; *wchar = 1;
return FcTrue; return FcTrue;
} }
void
FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size)
{
buf->buf = init;
buf->allocated = FcFalse;
buf->failed = FcFalse;
buf->len = 0;
buf->size = size;
}
void
FcStrBufDestroy (FcStrBuf *buf)
{
if (buf->allocated)
{
free (buf->buf);
FcStrBufInit (buf, 0, 0);
}
}
FcChar8 *
FcStrBufDone (FcStrBuf *buf)
{
FcChar8 *ret;
ret = malloc (buf->len + 1);
if (ret)
{
memcpy (ret, buf->buf, buf->len);
ret[buf->len] = '\0';
}
FcStrBufDestroy (buf);
return ret;
}
FcBool
FcStrBufChar (FcStrBuf *buf, FcChar8 c)
{
if (buf->len == buf->size)
{
FcChar8 *new;
int size;
if (buf->allocated)
{
size = buf->size * 2;
new = realloc (buf->buf, size);
}
else
{
size = buf->size + 1024;
new = malloc (size);
if (new)
{
buf->allocated = FcTrue;
memcpy (new, buf->buf, buf->len);
}
}
if (!new)
{
buf->failed = FcTrue;
return FcFalse;
}
buf->size = size;
buf->buf = new;
}
buf->buf[buf->len++] = c;
return FcTrue;
}
FcBool
FcStrBufString (FcStrBuf *buf, const FcChar8 *s)
{
FcChar8 c;
while ((c = *s++))
if (!FcStrBufChar (buf, c))
return FcFalse;
return FcTrue;
}
FcBool
FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len)
{
while (len-- > 0)
if (!FcStrBufChar (buf, *s++))
return FcFalse;
return FcTrue;
}

File diff suppressed because it is too large Load Diff