diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-01-09 13:39:00 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-01-13 19:25:39 -0800 |
commit | 2ad869a51804e5232f10c1c933e2822c205c3265 (patch) | |
tree | 9805318dd81600c9ad2863cd3408788472f253d3 | |
parent | ed14fe953f8f6fee90fcf28cd6775037b5f6e228 (diff) |
Make fscanf format string constant so it can be checked at compile time
Clears gcc warning of:
mkfontscale.c:714: warning: format not a string literal, argument types not checked
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r-- | mkfontscale.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/mkfontscale.c b/mkfontscale.c index 8134db8..46e9eed 100644 --- a/mkfontscale.c +++ b/mkfontscale.c @@ -61,6 +61,11 @@ #define MAXFONTNAMELEN 1024 #endif +/* Two levels of macro calls are needed so that we stringify the value + of MAXFONT... and not the string "MAXFONT..." */ +#define QUOTE(x) #x +#define STRINGIFY(x) QUOTE(x) + static char *encodings_array[] = { "ascii-0", "iso8859-1", "iso8859-2", "iso8859-3", "iso8859-4", "iso8859-5", @@ -681,10 +686,6 @@ readFontScale(HashTablePtr entries, char *dirname) FILE *in; int rc, count, i; char file[MAXFONTFILENAMELEN], font[MAXFONTNAMELEN]; - char format[100]; - - snprintf(format, 100, "%%%ds %%%d[^\n]\n", - MAXFONTFILENAMELEN, MAXFONTNAMELEN); if(dirname[n - 1] == '/') filename = dsprintf("%sfonts.scale", dirname); @@ -709,7 +710,10 @@ readFontScale(HashTablePtr entries, char *dirname) } for(i = 0; i < count; i++) { - rc = fscanf(in, format, file, font); + rc = fscanf(in, + "%" STRINGIFY(MAXFONTFILENAMELEN) "s " + "%" STRINGIFY(MAXFONTNAMELEN) "[^\n]\n", + file, font); if(rc != 2) break; putHash(entries, font, file, 100); |