summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2014-05-27 21:50:29 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2014-05-27 21:50:29 -0700
commit5ee01f266fd315e5bee624ec9d54357ffa593dfc (patch)
tree6c7b39c8aa8577547e3066849fb8e4ae5376bf80
parente7aa5ea85d57b90c1ee3244facd2dfd4d3ff1cd5 (diff)
Combine repeated sequences of fprintf() calls into single calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--psgeom.c228
-rw-r--r--xkbprint.c83
2 files changed, 158 insertions, 153 deletions
diff --git a/psgeom.c b/psgeom.c
index e984e6c..090e38d 100644
--- a/psgeom.c
+++ b/psgeom.c
@@ -515,59 +515,59 @@ CrackXLFDName(const char *name, FontStuff *stuff)
static void
PSSetUpForLatin1(FILE *out, PSState *state)
{
- fprintf(out, "save\n");
- fprintf(out, "/ISOLatin1Encoding where {pop save true}{false} ifelse\n");
- fprintf(out, "/ISOLatin1Encoding [\n");
- fprintf(out, " /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n");
- fprintf(out, " /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n");
- fprintf(out, " /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n");
- fprintf(out, " /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n");
- fprintf(out, " /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n");
- fprintf(out, " /.notdef /.notdef /space /exclam /quotedbl /numbersign\n");
- fprintf(out, " /dollar /percent /ampersand /quoteright /parenleft\n");
- fprintf(out, " /parenright /asterisk /plus /comma /minus /period\n");
- fprintf(out, " /slash /zero /one /two /three /four /five /six /seven\n");
- fprintf(out, " /eight /nine /colon /semicolon /less /equal /greater\n");
- fprintf(out, " /question /at /A /B /C /D /E /F /G /H /I /J /K /L /M\n");
- fprintf(out, " /N /O /P /Q /R /S /T /U /V /W /X /Y /Z /bracketleft\n");
- fprintf(out, " /backslash /bracketright /asciicircum /underscore\n");
- fprintf(out, " /quoteleft /a /b /c /d /e /f /g /h /i /j /k /l /m\n");
- fprintf(out, " /n /o /p /q /r /s /t /u /v /w /x /y /z /braceleft\n");
- fprintf(out, " /bar /braceright /asciitilde /guilsinglright /fraction\n");
- fprintf(out, " /florin /quotesingle /quotedblleft /guilsinglleft /fi\n");
- fprintf(out, " /fl /endash /dagger /daggerdbl /bullet /quotesinglbase\n");
- fprintf(out, " /quotedblbase /quotedblright /ellipsis /trademark\n");
- fprintf(out, " /perthousand /grave /scaron /circumflex /Scaron /tilde\n");
- fprintf(out, " /breve /zcaron /dotaccent /dotlessi /Zcaron /ring\n");
- fprintf(out,
- " /hungarumlaut /ogonek /caron /emdash /space /exclamdown\n");
- fprintf(out, " /cent /sterling /currency /yen /brokenbar /section\n");
- fprintf(out, " /dieresis /copyright /ordfeminine /guillemotleft\n");
- fprintf(out, " /logicalnot /hyphen /registered /macron /degree\n");
- fprintf(out, " /plusminus /twosuperior /threesuperior /acute /mu\n");
- fprintf(out, " /paragraph /periodcentered /cedilla /onesuperior\n");
- fprintf(out, " /ordmasculine /guillemotright /onequarter /onehalf\n");
- fprintf(out, " /threequarters /questiondown /Agrave /Aacute\n");
- fprintf(out, " /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla\n");
- fprintf(out,
- " /Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute\n");
- fprintf(out, " /Icircumflex /Idieresis /Eth /Ntilde /Ograve /Oacute\n");
- fprintf(out, " /Ocircumflex /Otilde /Odieresis /multiply /Oslash\n");
- fprintf(out, " /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn\n");
- fprintf(out, " /germandbls /agrave /aacute /acircumflex /atilde\n");
- fprintf(out, " /adieresis /aring /ae /ccedilla /egrave /eacute\n");
- fprintf(out, " /ecircumflex /edieresis /igrave /iacute /icircumflex\n");
- fprintf(out, " /idieresis /eth /ntilde /ograve /oacute /ocircumflex\n");
- fprintf(out, " /otilde /odieresis /divide /oslash /ugrave /uacute\n");
- fprintf(out, " /ucircumflex /udieresis /yacute /thorn /ydieresis\n");
- fprintf(out, "] def {restore} if\n");
- fprintf(out, "/reencodeISO-1 {\n");
- fprintf(out, " dup length dict begin\n");
- fprintf(out, " {1 index /FID ne {def}{pop pop} ifelse} forall\n");
- fprintf(out, " /Encoding ISOLatin1Encoding def\n");
- fprintf(out, " currentdict\n");
- fprintf(out, " end\n");
- fprintf(out, "} def\n");
+ fprintf(out, "%s",
+ "save\n"
+ "/ISOLatin1Encoding where {pop save true}{false} ifelse\n"
+ "/ISOLatin1Encoding [\n"
+ " /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n"
+ " /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n"
+ " /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n"
+ " /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n"
+ " /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef\n"
+ " /.notdef /.notdef /space /exclam /quotedbl /numbersign\n"
+ " /dollar /percent /ampersand /quoteright /parenleft\n"
+ " /parenright /asterisk /plus /comma /minus /period\n"
+ " /slash /zero /one /two /three /four /five /six /seven\n"
+ " /eight /nine /colon /semicolon /less /equal /greater\n"
+ " /question /at /A /B /C /D /E /F /G /H /I /J /K /L /M\n"
+ " /N /O /P /Q /R /S /T /U /V /W /X /Y /Z /bracketleft\n"
+ " /backslash /bracketright /asciicircum /underscore\n"
+ " /quoteleft /a /b /c /d /e /f /g /h /i /j /k /l /m\n"
+ " /n /o /p /q /r /s /t /u /v /w /x /y /z /braceleft\n"
+ " /bar /braceright /asciitilde /guilsinglright /fraction\n"
+ " /florin /quotesingle /quotedblleft /guilsinglleft /fi\n"
+ " /fl /endash /dagger /daggerdbl /bullet /quotesinglbase\n"
+ " /quotedblbase /quotedblright /ellipsis /trademark\n"
+ " /perthousand /grave /scaron /circumflex /Scaron /tilde\n"
+ " /breve /zcaron /dotaccent /dotlessi /Zcaron /ring\n"
+ " /hungarumlaut /ogonek /caron /emdash /space /exclamdown\n"
+ " /cent /sterling /currency /yen /brokenbar /section\n"
+ " /dieresis /copyright /ordfeminine /guillemotleft\n"
+ " /logicalnot /hyphen /registered /macron /degree\n"
+ " /plusminus /twosuperior /threesuperior /acute /mu\n"
+ " /paragraph /periodcentered /cedilla /onesuperior\n"
+ " /ordmasculine /guillemotright /onequarter /onehalf\n"
+ " /threequarters /questiondown /Agrave /Aacute\n"
+ " /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla\n"
+ " /Egrave /Eacute /Ecircumflex /Edieresis /Igrave /Iacute\n"
+ " /Icircumflex /Idieresis /Eth /Ntilde /Ograve /Oacute\n"
+ " /Ocircumflex /Otilde /Odieresis /multiply /Oslash\n"
+ " /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn\n"
+ " /germandbls /agrave /aacute /acircumflex /atilde\n"
+ " /adieresis /aring /ae /ccedilla /egrave /eacute\n"
+ " /ecircumflex /edieresis /igrave /iacute /icircumflex\n"
+ " /idieresis /eth /ntilde /ograve /oacute /ocircumflex\n"
+ " /otilde /odieresis /divide /oslash /ugrave /uacute\n"
+ " /ucircumflex /udieresis /yacute /thorn /ydieresis\n"
+ "] def {restore} if\n"
+ "/reencodeISO-1 {\n"
+ " dup length dict begin\n"
+ " {1 index /FID ne {def}{pop pop} ifelse} forall\n"
+ " /Encoding ISOLatin1Encoding def\n"
+ " currentdict\n"
+ " end\n"
+ "} def\n"
+ );
}
static void
@@ -609,26 +609,28 @@ PSProlog(FILE *out, PSState *state)
register int i;
if (!state->args->wantEPS) {
- fprintf(out, "%%!PS-Adobe-2.0\n");
- fprintf(out, "%%%%Creator: xkbprint\n");
+ fprintf(out,
+ "%%!PS-Adobe-2.0\n"
+ "%%%%Creator: xkbprint\n");
if (state->geom->name != None)
fprintf(out, "%%%%Title: %s\n",
XkbAtomGetString(state->dpy, state->geom->name));
- fprintf(out, "%%%%BoundingBox: (atend)\n");
- fprintf(out, "%%%%Pages: 1\n");
- fprintf(out, "%%%%PageOrder: Ascend\n");
- fprintf(out, "%%%%DocumentFonts: (atend)\n");
- fprintf(out, "%%%%DocumentData: Clean7Bit\n");
- fprintf(out, "%%%%Orientation: Landscape\n");
- fprintf(out, "%%%%EndComments\n");
- fprintf(out, "%%%%BeginProlog\n");
- fprintf(out, "%% Resolution is 1/10mm -- need pt sizes for fonts\n");
- fprintf(out, "clippath pathbbox\n");
- fprintf(out, " /ury exch def /urx exch def\n");
- fprintf(out, " /llx exch def /lly exch def\n");
- fprintf(out, " newpath\n");
- fprintf(out, "/devwidth urx llx sub def\n");
- fprintf(out, "/devheight ury lly sub def\n");
+ fprintf(out,
+ "%%%%BoundingBox: (atend)\n"
+ "%%%%Pages: 1\n"
+ "%%%%PageOrder: Ascend\n"
+ "%%%%DocumentFonts: (atend)\n"
+ "%%%%DocumentData: Clean7Bit\n"
+ "%%%%Orientation: Landscape\n"
+ "%%%%EndComments\n"
+ "%%%%BeginProlog\n"
+ "%% Resolution is 1/10mm -- need pt sizes for fonts\n"
+ "clippath pathbbox\n"
+ " /ury exch def /urx exch def\n"
+ " /llx exch def /lly exch def\n"
+ " newpath\n"
+ "/devwidth urx llx sub def\n"
+ "/devheight ury lly sub def\n");
}
else {
int w, h;
@@ -667,27 +669,28 @@ PSProlog(FILE *out, PSState *state)
}
fprintf(out, "/kbdwidth %d def\n", state->geom->width_mm);
fprintf(out, "/kbdheight %d def\n", state->geom->height_mm);
- fprintf(out, "/pts { 254 mul 72 div } def\n");
- fprintf(out, "/mm10 { 72 mul 254 div } def\n");
- fprintf(out, "/landscape? {\n");
- fprintf(out, " devheight devwidth gt {\n");
- fprintf(out, " /pwidth devheight def /pheight devwidth def\n");
- fprintf(out, " 0 devheight translate\n");
- fprintf(out, " -90 rotate\n");
- fprintf(out, " } {\n");
- fprintf(out, " /pwidth devwidth def /pheight devheight def\n");
- fprintf(out, " } ifelse\n");
- fprintf(out, " 0 pheight translate\n");
- fprintf(out, " 1 -1 scale\n");
- fprintf(out, "} def\n");
- fprintf(out, "/centeroffset {\n");
- fprintf(out, " /S exch def\n");
- fprintf(out, " /HEIGHT exch def\n");
- fprintf(out, " /WIDTH exch def\n");
- fprintf(out, " S stringwidth /SH exch def /SW exch def\n");
- fprintf(out, " WIDTH SW sub 2 div\n");
- fprintf(out, " HEIGHT SH sub 2 div\n");
- fprintf(out, "} def\n");
+ fprintf(out, "%s",
+ "/pts { 254 mul 72 div } def\n"
+ "/mm10 { 72 mul 254 div } def\n"
+ "/landscape? {\n"
+ " devheight devwidth gt {\n"
+ " /pwidth devheight def /pheight devwidth def\n"
+ " 0 devheight translate\n"
+ " -90 rotate\n"
+ " } {\n"
+ " /pwidth devwidth def /pheight devheight def\n"
+ " } ifelse\n"
+ " 0 pheight translate\n"
+ " 1 -1 scale\n"
+ "} def\n"
+ "/centeroffset {\n"
+ " /S exch def\n"
+ " /HEIGHT exch def\n"
+ " /WIDTH exch def\n"
+ " S stringwidth /SH exch def /SW exch def\n"
+ " WIDTH SW sub 2 div\n"
+ " HEIGHT SH sub 2 div\n"
+ "} def\n");
PSSetUpForLatin1(out, state);
PSReencodeLatin1Font(out, DFLT_LABEL_FONT);
if (state->args->wantColor) {
@@ -750,9 +753,10 @@ PSPageSetup(FILE *out, PSState *state, Bool drawBorder)
fprintf(out, "%%%%BeginPageSetup\n");
fprintf(out, "%% Keyboard %d\n", state->nPages + 1);
if (state->nPages == 0) {
- fprintf(out, "/realwidth devwidth def\n");
- fprintf(out, "/realheight devheight def\n");
- fprintf(out, "/devheight realheight 3 div def\n");
+ fprintf(out,
+ "/realwidth devwidth def\n"
+ "/realheight devheight def\n"
+ "/devheight realheight 3 div def\n");
}
fprintf(out, "0 devheight dup 2 div add translate\n");
}
@@ -762,26 +766,30 @@ PSPageSetup(FILE *out, PSState *state, Bool drawBorder)
fprintf(out, "save\n");
fprintf(out, "landscape?\n");
if (state->args->scaleToFit) {
- fprintf(out, "%% Scale keyboard to fit on the page\n");
- fprintf(out, "/kbdscale pwidth 72 sub kbdwidth div def\n");
- fprintf(out, "/kbdscalewidth kbdwidth kbdscale mul def\n");
- fprintf(out, "/kbdscaleheight kbdheight kbdscale mul def\n");
- fprintf(out, "/kbx 36 def\n");
- fprintf(out, "/kby pheight kbdscaleheight sub 2 div def\n");
+ fprintf(out,
+ "%% Scale keyboard to fit on the page\n"
+ "/kbdscale pwidth 72 sub kbdwidth div def\n"
+ "/kbdscalewidth kbdwidth kbdscale mul def\n"
+ "/kbdscaleheight kbdheight kbdscale mul def\n"
+ "/kbx 36 def\n"
+ "/kby pheight kbdscaleheight sub 2 div def\n");
PSGSave(out, state);
- fprintf(out, "kbx kby translate\n");
- fprintf(out, "kbdscale kbdscale scale\n");
+ fprintf(out,
+ "kbx kby translate\n"
+ "kbdscale kbdscale scale\n");
}
else {
- fprintf(out, "%% Draw keyboard full size\n");
- fprintf(out, "/kbdscale 1 def\n");
- fprintf(out, "/kbdscalewidth kbdwidth mm10 def\n");
- fprintf(out, "/kbdscaleheight kbdheight mm10 def\n");
- fprintf(out, "/kbx pwidth kbdscalewidth sub 2 div def\n");
- fprintf(out, "/kby pheight kbdscaleheight sub 2 div def\n");
+ fprintf(out,
+ "%% Draw keyboard full size\n"
+ "/kbdscale 1 def\n"
+ "/kbdscalewidth kbdwidth mm10 def\n"
+ "/kbdscaleheight kbdheight mm10 def\n"
+ "/kbx pwidth kbdscalewidth sub 2 div def\n"
+ "/kby pheight kbdscaleheight sub 2 div def\n");
PSGSave(out, state);
- fprintf(out, "kbx kby translate\n");
- fprintf(out, "72 254 div dup scale\n");
+ fprintf(out,
+ "kbx kby translate\n"
+ "72 254 div dup scale\n");
}
if (drawBorder) {
if (state->args->wantColor) {
diff --git a/xkbprint.c b/xkbprint.c
index 1dd68dd..5df6472 100644
--- a/xkbprint.c
+++ b/xkbprint.c
@@ -81,53 +81,50 @@ static Bool synch;
static void
Usage(int argc, char *argv[])
{
- fprintf(stderr, "Usage: %s [options] input-file [ output-file ]\n",
- argv[0]);
- fprintf(stderr, "Legal options:\n");
- fprintf(stderr, "-?,-help Print this message\n");
- fprintf(stderr, "-color Use colors from geometry\n");
+ fprintf(stderr, "Usage: %s [options] input-file [ output-file ]\n%s",
+ argv[0],
+ "Legal options:\n"
+ "-?,-help Print this message\n"
+ "-color Use colors from geometry\n"
#ifdef DEBUG
- fprintf(stderr, "-d [flags] Report debugging information\n");
+ "-d [flags] Report debugging information\n"
#endif
- fprintf(stderr, "-dflts Compute defaults for missing components\n");
- fprintf(stderr, "-diffs Only show explicit key definitions\n");
- fprintf(stderr, "-eps Generate an EPS file\n");
- fprintf(stderr, "-fit Fit keyboard image on page (default)\n");
- fprintf(stderr, "-full Print keyboard image full sized\n");
- fprintf(stderr, "-grid <n> Print a grid with <n> mm resolution\n");
- fprintf(stderr,
- "-if <name> Specifies the name of an internal font to dump\n");
+ "-dflts Compute defaults for missing components\n"
+ "-diffs Only show explicit key definitions\n"
+ "-eps Generate an EPS file\n"
+ "-fit Fit keyboard image on page (default)\n"
+ "-full Print keyboard image full sized\n"
+ "-grid <n> Print a grid with <n> mm resolution\n"
+ "-if <name> Specifies the name of an internal font to dump\n"
#ifdef DEBUG
- fprintf(stderr, "-I[<dir>] Specifies a top level directory\n");
- fprintf(stderr, " for include directives. You can\n");
- fprintf(stderr, " specify multiple directories.\n");
+ "-I[<dir>] Specifies a top level directory\n"
+ " for include directives. You can\n"
+ " specify multiple directories.\n"
#endif
- fprintf(stderr, "-kc Also print keycodes, if possible\n");
- fprintf(stderr, "-label <what> Specifies the label to be drawn on keys\n");
- fprintf(stderr, " Legal values for <what> are:\n");
- fprintf(stderr, " none,name,code,symbols\n");
- fprintf(stderr, "-lc <locale> Use <locale> for fonts and symbols\n");
- fprintf(stderr, "-level1 Use level 1 PostScript (default)\n");
- fprintf(stderr, "-level2 Use level 2 PostScript\n");
- fprintf(stderr, "-lg <num> Use keyboard group <num> to print labels\n");
- fprintf(stderr, "-ll <num> Use shift level <num> to print labels\n");
- fprintf(stderr, "-mono Ignore colors from geometry (default)\n");
- fprintf(stderr, "-n <num> Print <num> copies (default 1)\n");
- fprintf(stderr, "-nkg <num> Number of groups to print on each key\n");
- fprintf(stderr, "-nokc Don't print keycodes, even if possible\n");
- fprintf(stderr,
- "-npk <num> Number of keyboards to print on each page\n");
- fprintf(stderr, "-ntg <num> Total number of groups to print\n");
- fprintf(stderr, "-o <file> Specifies output file name\n");
- fprintf(stderr,
- "-R[<DIR>] Specifies the root directory for relative\n");
- fprintf(stderr, " path names\n");
- fprintf(stderr, "-pict <what> Specifies use of pictographs instead of\n");
- fprintf(stderr, " keysym names where available, <what> can\n");
- fprintf(stderr,
- " be \"all\", \"none\" or \"common\" (default)\n");
- fprintf(stderr, "-synch Force synchronization\n");
- fprintf(stderr, "-w <lvl> Set warning level (0=none, 10=all)\n");
+ "-kc Also print keycodes, if possible\n"
+ "-label <what> Specifies the label to be drawn on keys\n"
+ " Legal values for <what> are:\n"
+ " none,name,code,symbols\n"
+ "-lc <locale> Use <locale> for fonts and symbols\n"
+ "-level1 Use level 1 PostScript (default)\n"
+ "-level2 Use level 2 PostScript\n"
+ "-lg <num> Use keyboard group <num> to print labels\n"
+ "-ll <num> Use shift level <num> to print labels\n"
+ "-mono Ignore colors from geometry (default)\n"
+ "-n <num> Print <num> copies (default 1)\n"
+ "-nkg <num> Number of groups to print on each key\n"
+ "-nokc Don't print keycodes, even if possible\n"
+ "-npk <num> Number of keyboards to print on each page\n"
+ "-ntg <num> Total number of groups to print\n"
+ "-o <file> Specifies output file name\n"
+ "-R[<DIR>] Specifies the root directory for relative\n"
+ " path names\n"
+ "-pict <what> Specifies use of pictographs instead of\n"
+ " keysym names where available, <what> can\n"
+ " be \"all\", \"none\" or \"common\" (default)\n"
+ "-synch Force synchronization\n"
+ "-w <lvl> Set warning level (0=none, 10=all)\n"
+ );
}
/***====================================================================***/