Commit 5b3af018 authored by Ulrich Sibiller's avatar Ulrich Sibiller

Font.c: scope improvements

parent 7f636648
...@@ -707,8 +707,6 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP ...@@ -707,8 +707,6 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
*/ */
char *searchFields[FIELDS+1]; char *searchFields[FIELDS+1];
char *fontNameFields[FIELDS+1]; char *fontNameFields[FIELDS+1];
int i;
int j;
int numSearchFields = 0; int numSearchFields = 0;
int numFontFields = 0; int numFontFields = 0;
int weight = 0; int weight = 0;
...@@ -748,7 +746,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP ...@@ -748,7 +746,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
} }
else else
{ {
for (i = 1 ; i < nxagentRemoteFontList.length ; i++) for (int i = 1 ; i < nxagentRemoteFontList.length ; i++)
{ {
numSearchFields = nxagentSplitString(nxagentRemoteFontList.list[i]->name, searchFields, FIELDS+1, "-"); numSearchFields = nxagentSplitString(nxagentRemoteFontList.list[i]->name, searchFields, FIELDS+1, "-");
...@@ -773,7 +771,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP ...@@ -773,7 +771,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
tempWeight = 0; tempWeight = 0;
for (j = 0; j < FIELDS; j++) for (int j = 0; j < FIELDS; j++)
{ {
if (strcasecmp(searchFields[fieldOrder[j]], fontNameFields[fieldOrder[j]]) == 0 || if (strcasecmp(searchFields[fieldOrder[j]], fontNameFields[fieldOrder[j]]) == 0 ||
strcmp(searchFields[fieldOrder[j]], "") == 0 || strcmp(searchFields[fieldOrder[j]], "") == 0 ||
...@@ -801,7 +799,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP ...@@ -801,7 +799,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
#endif #endif
} }
for (j = 0; j < numSearchFields; j++) for (int j = 0; j < numSearchFields; j++)
{ {
SAFE_free(searchFields[j]); SAFE_free(searchFields[j]);
} }
...@@ -818,7 +816,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP ...@@ -818,7 +816,7 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
fontStruct = nxagentLoadQueryFont(dpy, substFontBuf, pFont); fontStruct = nxagentLoadQueryFont(dpy, substFontBuf, pFont);
for (j = 0; j < numFontFields; j++) for (int j = 0; j < numFontFields; j++)
{ {
SAFE_free(fontNameFields[j]); SAFE_free(fontNameFields[j]);
} }
...@@ -828,13 +826,12 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP ...@@ -828,13 +826,12 @@ static XFontStruct *nxagentLoadBestQueryFont(Display* dpy, char *fontName, FontP
static void nxagentFontDisconnect(FontPtr pFont, XID param1, void * param2) static void nxagentFontDisconnect(FontPtr pFont, XID param1, void * param2)
{ {
nxagentPrivFont *privFont;
Bool *pBool = (Bool*)param2; Bool *pBool = (Bool*)param2;
if (pFont == NULL || !*pBool) if (pFont == NULL || !*pBool)
return; return;
privFont = nxagentFontPriv(pFont); nxagentPrivFont *privFont = nxagentFontPriv(pFont);
#ifdef NXAGENT_RECONNECT_FONT_DEBUG #ifdef NXAGENT_RECONNECT_FONT_DEBUG
fprintf(stderr, "nxagentFontDisconnect: pFont %p, XID %lx\n", fprintf(stderr, "nxagentFontDisconnect: pFont %p, XID %lx\n",
...@@ -931,13 +928,12 @@ static void nxagentCollectFailedFont(FontPtr fpt, XID id) ...@@ -931,13 +928,12 @@ static void nxagentCollectFailedFont(FontPtr fpt, XID id)
static void nxagentFontReconnect(FontPtr pFont, XID param1, void * param2) static void nxagentFontReconnect(FontPtr pFont, XID param1, void * param2)
{ {
int i; int i;
nxagentPrivFont *privFont;
Bool *pBool = (Bool*)param2; Bool *pBool = (Bool*)param2;
if (pFont == NULL) if (pFont == NULL)
return; return;
privFont = nxagentFontPriv(pFont); nxagentPrivFont *privFont = nxagentFontPriv(pFont);
#ifdef NXAGENT_RECONNECT_FONT_DEBUG #ifdef NXAGENT_RECONNECT_FONT_DEBUG
fprintf(stderr, "nxagentFontReconnect: pFont %p - XID %lx - name %s\n", fprintf(stderr, "nxagentFontReconnect: pFont %p - XID %lx - name %s\n",
...@@ -1622,26 +1618,17 @@ int nxagentFreeFont(XFontStruct *fs) ...@@ -1622,26 +1618,17 @@ int nxagentFreeFont(XFontStruct *fs)
int nxagentSplitString(char *string, char *fields[], int nfields, char *sep) int nxagentSplitString(char *string, char *fields[], int nfields, char *sep)
{ {
int seplen; int seplen = strlen(sep);
int fieldlen; int len = strlen(string);
int last;
int len;
int i;
char *current;
char *next;
seplen = strlen(sep);
len = strlen(string);
current = string; char *current = string;
i = 0; int i = 0;
last = 0; int last = 0;
for (;;) for (;;)
{ {
next = NULL; char *next = NULL;
if (current < string + len) if (current < string + len)
{ {
...@@ -1654,7 +1641,7 @@ int nxagentSplitString(char *string, char *fields[], int nfields, char *sep) ...@@ -1654,7 +1641,7 @@ int nxagentSplitString(char *string, char *fields[], int nfields, char *sep)
last = 1; last = 1;
} }
fieldlen = next - current; int fieldlen = next - current;
if (i < nfields) if (i < nfields)
{ {
...@@ -1681,8 +1668,6 @@ int nxagentSplitString(char *string, char *fields[], int nfields, char *sep) ...@@ -1681,8 +1668,6 @@ int nxagentSplitString(char *string, char *fields[], int nfields, char *sep)
char *nxagentMakeScalableFontName(const char *fontName, int scalableResolution) char *nxagentMakeScalableFontName(const char *fontName, int scalableResolution)
{ {
char *scalableFontName; char *scalableFontName;
const char *s;
int field;
/* FIXME: use str(n)dup()? */ /* FIXME: use str(n)dup()? */
if ((scalableFontName = malloc(strlen(fontName) + 1)) == NULL) if ((scalableFontName = malloc(strlen(fontName) + 1)) == NULL)
...@@ -1701,9 +1686,9 @@ char *nxagentMakeScalableFontName(const char *fontName, int scalableResolution) ...@@ -1701,9 +1686,9 @@ char *nxagentMakeScalableFontName(const char *fontName, int scalableResolution)
goto MakeScalableFontNameError; goto MakeScalableFontNameError;
} }
s = fontName; const char *s = fontName;
field = 0; int field = 0;
while (s != NULL) while (s != NULL)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment