From 2ad869a51804e5232f10c1c933e2822c205c3265 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 9 Jan 2011 13:39:00 -0800 Subject: 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 --- mkfontscale.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'mkfontscale.c') 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); -- cgit v1.2.3