diff options
Diffstat (limited to 'libXfont/src')
-rw-r--r-- | libXfont/src/FreeType/ftfuncs.c | 17 | ||||
-rw-r--r-- | libXfont/src/FreeType/xttcap.c | 61 | ||||
-rw-r--r-- | libXfont/src/FreeType/xttcap.h | 13 | ||||
-rw-r--r-- | libXfont/src/Makefile.am | 6 | ||||
-rw-r--r-- | libXfont/src/bitmap/bdfread.c | 16 | ||||
-rw-r--r-- | libXfont/src/builtins/buildfont | 2 | ||||
-rw-r--r-- | libXfont/src/fontfile/fontdir.c | 10 | ||||
-rw-r--r-- | libXfont/src/util/atom.c | 20 | ||||
-rw-r--r-- | libXfont/src/util/miscutil.c | 2 |
9 files changed, 63 insertions, 84 deletions
diff --git a/libXfont/src/FreeType/ftfuncs.c b/libXfont/src/FreeType/ftfuncs.c index 918e3f37e..44e5e0288 100644 --- a/libXfont/src/FreeType/ftfuncs.c +++ b/libXfont/src/FreeType/ftfuncs.c @@ -2050,7 +2050,7 @@ restrict_code_range_by_str(int count,unsigned short *refFirstCol, { int nRanges = 0; int result = 0; - fsRange *ranges = NULL; + fsRange *ranges = NULL, *oldRanges; char const *p, *q; p = q = str; @@ -2119,10 +2119,13 @@ restrict_code_range_by_str(int count,unsigned short *refFirstCol, fflush(stderr); #endif nRanges++; + oldRanges = ranges; ranges = realloc(ranges, nRanges*sizeof(*ranges)); - if (NULL == ranges) + if (NULL == ranges) { + free(oldRanges); break; - { + } + else { fsRange *r = ranges+nRanges-1; r->min_char_low = minpoint & 0xff; @@ -2204,7 +2207,7 @@ FreeTypeSetUpTTCap( char *fileName, FontScalablePtr vals, strcpy(*dynStrRealFileName+dirLen, p2+1); capHead = p1; } else { - *dynStrRealFileName = xstrdup(fileName); + *dynStrRealFileName = strdup(fileName); if( *dynStrRealFileName == NULL ) { result = AllocError; goto quit; @@ -2289,13 +2292,11 @@ FreeTypeSetUpTTCap( char *fileName, FontScalablePtr vals, } } else{ - *dynStrFTFileName = malloc(strlen(*dynStrRealFileName)+1); + *dynStrFTFileName = strdup(*dynStrRealFileName); if( *dynStrFTFileName == NULL ){ result = AllocError; goto quit; } - **dynStrFTFileName = '\0'; - strcat(*dynStrFTFileName,*dynStrRealFileName); } } /* @@ -2549,7 +2550,7 @@ FreeTypeSetUpTTCap( char *fileName, FontScalablePtr vals, if (SPropRecValList_search_record(&listPropRecVal, &contRecValue, "CodeRange")) { - *dynStrTTCapCodeRange = xstrdup(SPropContainer_value_str(contRecValue)); + *dynStrTTCapCodeRange = strdup(SPropContainer_value_str(contRecValue)); if( *dynStrTTCapCodeRange == NULL ) { result = AllocError; goto quit; diff --git a/libXfont/src/FreeType/xttcap.c b/libXfont/src/FreeType/xttcap.c index c2a412091..104dc89e4 100644 --- a/libXfont/src/FreeType/xttcap.c +++ b/libXfont/src/FreeType/xttcap.c @@ -1,7 +1,7 @@ /* ===EmacsMode: -*- Mode: C; tab-width:4; c-basic-offset: 4; -*- === */ /* ===FileName: === Copyright (c) 1998 Takuya SHIOZAKI, All Rights reserved. - Copyright (c) 1998 X-TrueType Server Project, All rights reserved. + Copyright (c) 1998 X-TrueType Server Project, All rights reserved. Copyright (c) 2003 After X-TT Project, All rights reserved. ===Notice @@ -133,7 +133,7 @@ get_record_type_by_name(SPropertyRecord const ** const refRefRecord, /*result*/ { Bool result = False; int i; - + *refRefRecord = NULL; for (i=0; i<numOfValidRecords; i++) { if (!strcasecmp(validRecords[i].strRecordName, strName)) { @@ -142,7 +142,7 @@ get_record_type_by_name(SPropertyRecord const ** const refRefRecord, /*result*/ break; } } - + return result; } @@ -161,7 +161,7 @@ SPropRecValList_add_record(SDynPropRecValList *pThisList, { int val; char *endPtr; - + val = strtol(strValue, &endPtr, 0); if ('\0' != *endPtr) { fprintf(stderr, @@ -178,7 +178,7 @@ SPropRecValList_add_record(SDynPropRecValList *pThisList, { double val; char *endPtr; - + val = strtod(strValue, &endPtr); if ('\0' != *endPtr) { fprintf(stderr, @@ -194,7 +194,7 @@ SPropRecValList_add_record(SDynPropRecValList *pThisList, case eRecTypeBool: { Bool val; - + if (!strcasecmp(strValue, "yes")) val = True; else if (!strcasecmp(strValue, "y")) @@ -233,15 +233,14 @@ SPropRecValList_add_record(SDynPropRecValList *pThisList, case eRecTypeString: { char *p; - - if (NULL == (p = malloc(strlen(strValue)+1))) { + + if (NULL == (p = strdup(strValue))) { fprintf(stderr, "truetype font property : " "cannot allocate memory.\n"); result = True; goto quit; } - strcpy(p, strValue); SPropContainer_value_str(&tmpContainerE) = p; } break; @@ -257,7 +256,7 @@ SPropRecValList_add_record(SDynPropRecValList *pThisList, { /* add to list */ SPropRecValListNodeP *newNode; - + if (NULL == (newNode = malloc(sizeof(*newNode)))) { fprintf(stderr, "truetype font property : " @@ -301,11 +300,11 @@ get_one_line(FILE *is, char *buf) Bool flInDoubleQuote = False; Bool flBackSlash = False; Bool flFirstElement = True; - + *buf = '\0'; for (;;) { int c = fgetc(is); - + if (ferror(is)) { fprintf(stderr, "truetype font property file : read error.\n"); result = True; @@ -446,7 +445,7 @@ parse_one_line(SDynPropRecValList *pThisList, FILE *is) Bool result = False; char *buf = NULL; char *recordHead, *valueHead = NULL; - + if (NULL == (buf = malloc(LEN_LINEBUF))) { fprintf(stderr, "truetype font property file : cannot allocate memory.\n"); @@ -483,7 +482,7 @@ parse_one_line(SDynPropRecValList *pThisList, FILE *is) } quit: free(buf); - abort: + abort: return result; } @@ -494,7 +493,7 @@ SPropRecValList_read_prop_file(SDynPropRecValList *pThisList, { Bool result = False; FILE *is; - + #if 1 if (!strcmp(strFileName, "-")) is = stdin; @@ -530,7 +529,7 @@ Bool /* True == Error, False == Success */ SPropRecValList_new(SDynPropRecValList *pThisList) { Bool result = False; - + pThisList->headNode = NULL; return result; @@ -582,7 +581,7 @@ SPropRecValList_search_record(SRefPropRecValList *pThisList, { Bool result = False; SPropRecValListNodeP *p; - + *refRecValue = NULL; for (p=pThisList->headNode; NULL!=p; p=p->nextNode) { if (!strcasecmp(p->containerE.refRecordType->strRecordName, @@ -605,7 +604,7 @@ SPropRecValList_add_by_font_cap(SDynPropRecValList *pThisList, Bool result = False; /* SPropertyRecord const *refRecordType; */ char const *term; - + if (NULL == (term = strrchr(strCapHead, ':'))) goto abort; @@ -646,7 +645,7 @@ SPropRecValList_add_by_font_cap(SDynPropRecValList *pThisList, char *duplicated = malloc((nextColon-strCapHead)+1); { char *value; - + memcpy(duplicated, strCapHead, nextColon-strCapHead); duplicated[nextColon-strCapHead] = '\0'; if (NULL != (value=strchr(duplicated, '='))) { @@ -654,7 +653,7 @@ SPropRecValList_add_by_font_cap(SDynPropRecValList *pThisList, value++; } else value = &duplicated[nextColon-strCapHead]; - + for (i=0; i<numOfCorrespondRelations; i++) { if (!strcasecmp(correspondRelations[i].capVariable, duplicated)) { @@ -676,30 +675,10 @@ SPropRecValList_add_by_font_cap(SDynPropRecValList *pThisList, } strCapHead = nextColon+1; } - + /* quit: */ abort: return result; } - -/************************************************************************** - Functions (xttmisc) - */ - -/* strdup clone with using the allocator of X server */ -char * -XttXstrdup(char const *str) -{ - char *result; - - result = malloc(strlen(str)+1); - - if (result) - strcpy(result, str); - - return result; -} - - /* end of file */ diff --git a/libXfont/src/FreeType/xttcap.h b/libXfont/src/FreeType/xttcap.h index 6a09cf610..2822540bb 100644 --- a/libXfont/src/FreeType/xttcap.h +++ b/libXfont/src/FreeType/xttcap.h @@ -1,8 +1,8 @@ /* ===EmacsMode: -*- Mode: C; tab-width:4; c-basic-offset: 4; -*- === */ /* ===FileName: === Copyright (c) 1998 Takuya SHIOZAKI, All Rights reserved. - Copyright (c) 1998 X-TrueType Server Project, All rights reserved. - Copyright (c) 2003 After X-TT Project, All rights reserved. + Copyright (c) 1998 X-TrueType Server Project, All rights reserved. + Copyright (c) 2003 After X-TT Project, All rights reserved. ===Notice Redistribution and use in source and binary forms, with or without @@ -116,15 +116,6 @@ SPropRecValList_dump(SRefPropRecValList *refList); #define SPropContainer_value_str(contRecVal)\ ((contRecVal)->uValue.dynStringValue) -/****************************************************** - Prototypes (xttmisc) - */ - -/* strdup clone */ -char * XttXstrdup(char const *str); -#undef xstrdup -#define xstrdup(s) XttXstrdup((char const*)s) - #endif /* !def _XTTCAP_H_ */ /* end of file */ diff --git a/libXfont/src/Makefile.am b/libXfont/src/Makefile.am index 26551bc04..cd09ab99f 100644 --- a/libXfont/src/Makefile.am +++ b/libXfont/src/Makefile.am @@ -1,6 +1,6 @@ -# +# # Copyright © 2003 Keith Packard, Noah Levitt -# +# # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that @@ -10,7 +10,7 @@ # specific, written prior permission. Keith Packard makes no # representations about the suitability of this software for any purpose. It # is provided "as is" without express or implied warranty. -# +# # KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO # EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR diff --git a/libXfont/src/bitmap/bdfread.c b/libXfont/src/bitmap/bdfread.c index e2770dc1c..914a0244e 100644 --- a/libXfont/src/bitmap/bdfread.c +++ b/libXfont/src/bitmap/bdfread.c @@ -69,6 +69,7 @@ from The Open Group. #define INDICES 256 #define MAXENCODING 0xFFFF #define BDFLINELEN 1024 +#define BDFLINESTR "%1023s" /* scanf specifier to read a BDFLINELEN string */ static Bool bdfPadToTerminal(FontPtr pFont); extern int bdfFileLineNum; @@ -338,7 +339,7 @@ bdfReadCharacters(FontFilePtr file, FontPtr pFont, bdfFileState *pState, char charName[100]; int ignore; - if (sscanf((char *) line, "STARTCHAR %s", charName) != 1) { + if (sscanf((char *) line, "STARTCHAR %99s", charName) != 1) { bdfError("bad character name in BDF file\n"); goto BAILOUT; /* bottom of function, free and return error */ } @@ -544,13 +545,18 @@ bdfReadHeader(FontFilePtr file, bdfFileState *pState) unsigned char lineBuf[BDFLINELEN]; line = bdfGetLine(file, lineBuf, BDFLINELEN); - if (!line || sscanf((char *) line, "STARTFONT %s", namebuf) != 1 || + if (!line || + sscanf((char *) line, "STARTFONT " BDFLINESTR, namebuf) != 1 || !bdfStrEqual(namebuf, "2.1")) { bdfError("bad 'STARTFONT'\n"); return (FALSE); } line = bdfGetLine(file, lineBuf, BDFLINELEN); - if (!line || sscanf((char *) line, "FONT %[^\n]", pState->fontName) != 1) { +#if MAXFONTNAMELEN != 1024 +# error "need to adjust sscanf length limit to be MAXFONTNAMELEN - 1" +#endif + if (!line || + sscanf((char *) line, "FONT %1023[^\n]", pState->fontName) != 1) { bdfError("bad 'FONT'\n"); return (FALSE); } @@ -633,7 +639,9 @@ bdfReadProperties(FontFilePtr file, FontPtr pFont, bdfFileState *pState) while (*line && isspace(*line)) line++; - switch (sscanf((char *) line, "%s%s%s", namebuf, secondbuf, thirdbuf)) { + switch (sscanf((char *) line, + BDFLINESTR BDFLINESTR BDFLINESTR, + namebuf, secondbuf, thirdbuf)) { default: bdfError("missing '%s' parameter value\n", namebuf); goto BAILOUT; diff --git a/libXfont/src/builtins/buildfont b/libXfont/src/builtins/buildfont index aa4602ff8..84c68c4f4 100644 --- a/libXfont/src/builtins/buildfont +++ b/libXfont/src/builtins/buildfont @@ -8,7 +8,7 @@ NAME=$2 echo 'static const char file_'$NAME'[] = {' bdftopcf -p1 -u1 $1 | compress -b 12 | - od -b -v -w8 | + od -b -v -w8 | sed 's/^[0-9]*\( *\)/\1\1\1\1/' | sed 's/\([0-9][0-9]*\)/'"'"'\\\1'"'"',/g' echo '};' diff --git a/libXfont/src/fontfile/fontdir.c b/libXfont/src/fontfile/fontdir.c index 97b2ba3b1..ef7ffa561 100644 --- a/libXfont/src/fontfile/fontdir.c +++ b/libXfont/src/fontfile/fontdir.c @@ -425,17 +425,13 @@ FontFileCountDashes (char *name, int namelen) return ndashes; } +/* exported in public API in <X11/fonts/fntfil.h> */ char * FontFileSaveString (char *s) { - char *n; - - n = malloc (strlen (s) + 1); - if (!n) - return 0; - strcpy (n, s); - return n; + return strdup(s); } +#define FontFileSaveString(s) strdup(s) FontEntryPtr FontFileFindNameInScalableDir(FontTablePtr table, FontNamePtr pat, diff --git a/libXfont/src/util/atom.c b/libXfont/src/util/atom.c index c47cb5c80..37811f91e 100644 --- a/libXfont/src/util/atom.c +++ b/libXfont/src/util/atom.c @@ -118,19 +118,23 @@ ResizeHashTable (void) static int ResizeReverseMap (void) { - int ret = TRUE; + AtomListPtr *newMap; + int newMapSize; + if (reverseMapSize == 0) - reverseMapSize = 1000; + newMapSize = 1000; else - reverseMapSize *= 2; - reverseMap = realloc (reverseMap, reverseMapSize * sizeof (AtomListPtr)); - if (!reverseMap) { + newMapSize = reverseMapSize * 2; + newMap = realloc (reverseMap, newMapSize * sizeof (AtomListPtr)); + if (newMap == NULL) { fprintf(stderr, "ResizeReverseMap(): Error: Couldn't reallocate" " reverseMap (%ld)\n", - reverseMapSize * (unsigned long)sizeof(AtomListPtr)); - ret = FALSE; + newMapSize * (unsigned long)sizeof(AtomListPtr)); + return FALSE; } - return ret; + reverseMap = newMap; + reverseMapSize = newMapSize; + return TRUE; } static int diff --git a/libXfont/src/util/miscutil.c b/libXfont/src/util/miscutil.c index 7173d3640..3d802d2f5 100644 --- a/libXfont/src/util/miscutil.c +++ b/libXfont/src/util/miscutil.c @@ -47,7 +47,7 @@ extern void BuiltinRegisterFpeFunctions(void); #ifndef NO_WEAK_SYMBOLS /* make sure everything initializes themselves at least once */ -weak long serverGeneration = 1; +weak unsigned long serverGeneration = 1; #endif weak void |