Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nx-libs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dimbor
nx-libs
Commits
dff2e0a0
Commit
dff2e0a0
authored
Apr 03, 2019
by
Ulrich Sibiller
Committed by
Mike Gabriel
May 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Font.c: factor out font checks
parent
d94e9ba2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
95 deletions
+37
-95
Font.c
nx-X11/programs/Xserver/hw/nxagent/Font.c
+37
-95
No files found.
nx-X11/programs/Xserver/hw/nxagent/Font.c
View file @
dff2e0a0
...
@@ -1443,128 +1443,68 @@ static Bool nxagentGetFontServerPath(char * fontServerPath, int size)
...
@@ -1443,128 +1443,68 @@ static Bool nxagentGetFontServerPath(char * fontServerPath, int size)
return
True
;
return
True
;
}
}
void
nxagentVerify
DefaultFontPath
(
void
)
void
nxagentVerify
SingleFontPath
(
char
**
dest
,
const
char
*
fontDir
,
const
char
*
fontPath
)
{
{
struct
stat
dirStat
;
struct
stat
dirStat
;
static
char
*
fontPath
;
char
*
newdest
=
NULL
;
#ifdef TEST
fprintf
(
stderr
,
"nxagentVerifyDefaultFontPath: Going to search for one or more valid font paths.
\n
"
);
#endif
/*
* Set the default font path as the first choice.
*/
if
((
fontPath
=
strdup
(
defaultFontPath
))
==
NULL
)
{
#ifdef WARNING
fprintf
(
stderr
,
"nxagentVerifyDefaultFontPath: WARNING! Unable to allocate memory for a new font path. "
"Using the default font path [%s].
\n
"
,
validateString
(
defaultFontPath
));
#endif
if
(
!
dest
||
!*
dest
)
return
;
return
;
}
if
(
stat
(
NXAGENT_DEFAULT_FONT_DIR
,
&
dirStat
)
==
0
&&
if
(
stat
(
fontDir
,
&
dirStat
)
==
0
&&
S_ISDIR
(
dirStat
.
st_mode
)
!=
0
)
S_ISDIR
(
dirStat
.
st_mode
)
!=
0
)
{
{
/*
* Let's use the old "/usr/share/nx/fonts" style.
*/
#ifdef TEST
#ifdef TEST
fprintf
(
stderr
,
"
nxagentVerifyDefaultFontPath: Assuming fonts in directory [%s].
\n
"
,
fprintf
(
stderr
,
"
%s: Assuming fonts in directory [%s].
\n
"
,
__func__
,
validateString
(
NXAGENT_DEFAULT_FONT_DIR
));
validateString
(
fontDir
));
#endif
#endif
if
(
*
fontPath
!=
'\0'
)
if
(
*
*
dest
!=
'\0'
)
{
{
fontPath
=
realloc
(
fontPath
,
strlen
(
fontPath
)
+
strlen
(
NXAGENT_DEFAULT_FONT_PATH
)
+
2
);
newdest
=
realloc
(
*
dest
,
strlen
(
*
dest
)
+
strlen
(
fontPath
)
+
2
);
strcat
(
fontPath
,
","
);
if
(
newdest
==
NULL
)
return
;
strcat
(
newdest
,
","
);
}
}
else
else
{
{
fontPath
=
realloc
(
fontPath
,
strlen
(
fontPath
)
+
strlen
(
NXAGENT_DEFAULT_FONT_PATH
)
+
1
);
newdest
=
realloc
(
*
dest
,
strlen
(
*
dest
)
+
strlen
(
fontPath
)
+
1
);
if
(
newdest
==
NULL
)
return
;
}
}
strcat
(
fontPath
,
NXAGENT_DEFAULT_FONT_PATH
);
strcat
(
newdest
,
fontPath
);
*
dest
=
newdest
;
}
}
}
if
(
stat
(
NXAGENT_ALTERNATE_FONT_DIR
,
&
dirStat
)
==
0
&&
void
nxagentVerifyDefaultFontPath
(
void
)
S_ISDIR
(
dirStat
.
st_mode
)
!=
0
)
{
{
static
char
*
fontPath
;
/*
* Let's use the new "/usr/share/X11/fonts" path.
*/
#ifdef TEST
fprintf
(
stderr
,
"nxagentVerifyDefaultFontPath: Assuming fonts in directory [%s].
\n
"
,
validateString
(
NXAGENT_ALTERNATE_FONT_DIR
));
#endif
if
(
*
fontPath
!=
'\0'
)
#ifdef TEST
{
fprintf
(
stderr
,
"nxagentVerifyDefaultFontPath: Going to search for one or more valid font paths.
\n
"
);
fontPath
=
realloc
(
fontPath
,
strlen
(
fontPath
)
+
strlen
(
NXAGENT_ALTERNATE_FONT_PATH
)
+
2
);
#endif
strcat
(
fontPath
,
","
);
}
else
{
fontPath
=
realloc
(
fontPath
,
strlen
(
fontPath
)
+
strlen
(
NXAGENT_ALTERNATE_FONT_PATH
)
+
1
);
}
strcat
(
fontPath
,
NXAGENT_ALTERNATE_FONT_PATH
);
/*
}
* Set the default font path as the first choice.
*/
if
(
stat
(
NXAGENT_ALTERNATE_FONT_DIR_2
,
&
dirStat
)
==
0
&&
if
((
fontPath
=
strdup
(
defaultFontPath
))
==
NULL
)
S_ISDIR
(
dirStat
.
st_mode
)
!=
0
)
{
{
/*
#ifdef WARNING
* Let's use the "/usr/share/fonts/X11" path.
fprintf
(
stderr
,
"nxagentVerifyDefaultFontPath: WARNING! Unable to allocate memory for a new font path. "
*/
"Using the default font path [%s].
\n
"
,
validateString
(
defaultFontPath
));
#ifdef TEST
fprintf
(
stderr
,
"nxagentVerifyDefaultFontPath: Assuming fonts in directory [%s].
\n
"
,
validateString
(
NXAGENT_ALTERNATE_FONT_DIR_2
));
#endif
#endif
if
(
*
fontPath
!=
'\0'
)
return
;
{
fontPath
=
realloc
(
fontPath
,
strlen
(
fontPath
)
+
strlen
(
NXAGENT_ALTERNATE_FONT_PATH_2
)
+
2
);
strcat
(
fontPath
,
","
);
}
else
{
fontPath
=
realloc
(
fontPath
,
strlen
(
fontPath
)
+
strlen
(
NXAGENT_ALTERNATE_FONT_PATH_2
)
+
1
);
}
strcat
(
fontPath
,
NXAGENT_ALTERNATE_FONT_PATH_2
);
}
}
if
(
stat
(
NXAGENT_ALTERNATE_FONT_DIR_3
,
&
dirStat
)
==
0
&&
nxagentVerifySingleFontPath
(
&
fontPath
,
NXAGENT_DEFAULT_FONT_DIR
,
NXAGENT_DEFAULT_FONT_PATH
);
S_ISDIR
(
dirStat
.
st_mode
)
!=
0
)
nxagentVerifySingleFontPath
(
&
fontPath
,
NXAGENT_ALTERNATE_FONT_DIR
,
NXAGENT_ALTERNATE_FONT_PATH
);
{
nxagentVerifySingleFontPath
(
&
fontPath
,
NXAGENT_ALTERNATE_FONT_DIR_2
,
NXAGENT_ALTERNATE_FONT_PATH_2
);
/*
nxagentVerifySingleFontPath
(
&
fontPath
,
NXAGENT_ALTERNATE_FONT_DIR_3
,
NXAGENT_ALTERNATE_FONT_PATH_3
);
* Let's use the "/usr/X11R6/lib/X11/fonts" path.
*/
#ifdef TEST
fprintf
(
stderr
,
"nxagentVerifyDefaultFontPath: Assuming fonts in directory [%s].
\n
"
,
validateString
(
NXAGENT_ALTERNATE_FONT_DIR_3
));
#endif
if
(
*
fontPath
!=
'\0'
)
{
fontPath
=
realloc
(
fontPath
,
strlen
(
fontPath
)
+
strlen
(
NXAGENT_ALTERNATE_FONT_PATH_3
)
+
2
);
strcat
(
fontPath
,
","
);
}
else
{
fontPath
=
realloc
(
fontPath
,
strlen
(
fontPath
)
+
strlen
(
NXAGENT_ALTERNATE_FONT_PATH_3
)
+
1
);
}
strcat
(
fontPath
,
NXAGENT_ALTERNATE_FONT_PATH_3
);
}
if
(
*
fontPath
==
'\0'
)
if
(
*
fontPath
==
'\0'
)
{
{
#ifdef WARNING
#ifdef WARNING
...
@@ -1576,6 +1516,8 @@ void nxagentVerifyDefaultFontPath(void)
...
@@ -1576,6 +1516,8 @@ void nxagentVerifyDefaultFontPath(void)
}
}
else
else
{
{
/* do _not_ free defaultFontPath here - it's either set at compile time or
part of argv */
defaultFontPath
=
fontPath
;
defaultFontPath
=
fontPath
;
#ifdef TEST
#ifdef TEST
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment