diff options
-rw-r--r-- | psgeom.c | 82 |
1 files changed, 59 insertions, 23 deletions
@@ -265,7 +265,11 @@ PSShapeDef(FILE *out, PSState *state, XkbShapePtr shape) int o, p; XkbOutlinePtr ol; - fprintf(out, "/%s {\n", XkbAtomGetString(state->dpy, shape->name)); + { + char *a = XkbAtomGetString(state->dpy, shape->name); + fprintf(out, "/%s {\n", a); + XFree(a); + } fprintf(out, " gsave translate rotate /SOLID exch def\n"); for (o = 0, ol = shape->outlines; o < shape->num_outlines; o++, ol++) { XkbPointPtr pt; @@ -607,9 +611,11 @@ PSProlog(FILE *out, PSState *state) 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)); + if (state->geom->name != None) { + char *a = XkbAtomGetString(state->dpy, state->geom->name); + fprintf(out, "%%%%Title: %s\n", a); + XFree(a); + } fprintf(out, "%%%%BoundingBox: (atend)\n" "%%%%Pages: 1\n" @@ -652,9 +658,11 @@ PSProlog(FILE *out, PSState *state) fprintf(out, "%%!PS-Adobe-2.0 EPSF-2.0\n"); fprintf(out, "%%%%BoundingBox: 0 0 %d %d\n", w, h); fprintf(out, "%%%%Creator: xkbprint\n"); - if (state->geom->name != None) - fprintf(out, "%%%%Title: %s\n", - XkbAtomGetString(state->dpy, state->geom->name)); + if (state->geom->name != None) { + char *a = XkbAtomGetString(state->dpy, state->geom->name); + fprintf(out, "%%%%Title: %s\n", a); + XFree(a); + } fprintf(out, "%%%%Pages: 1\n"); fprintf(out, "%%%%EndComments\n"); fprintf(out, "%%%%BeginProlog\n"); @@ -841,8 +849,10 @@ PSPageTrailer(FILE *out, PSState *state) if ((!state->args->wantEPS) && ((state->kbPerPage == 1) || ((state->nPages & 1) == 1) || (state->nPages == state->totalKB))) { + char *a1 = NULL; + if ((name == NULL) && (geom->name != None)) - name = XkbAtomGetString(state->dpy, geom->name); + name = a1 = XkbAtomGetString(state->dpy, geom->name); baseline = 16; if ((name != NULL) || (state->args->label == LABEL_SYMBOLS)) { @@ -852,6 +862,7 @@ PSPageTrailer(FILE *out, PSState *state) if (state->args->label == LABEL_SYMBOLS) { char buf[40], *lbuf; const char *sName = NULL; + char *a2 = NULL; Atom sAtom; if (state->args->nLabelGroups == 1) @@ -874,7 +885,7 @@ PSPageTrailer(FILE *out, PSState *state) else sAtom = None; if (sAtom != None) - sName = XkbAtomGetString(state->dpy, sAtom); + sName = a2 = XkbAtomGetString(state->dpy, sAtom); if (sName == NULL) sName = "(unknown)"; @@ -888,6 +899,7 @@ PSPageTrailer(FILE *out, PSState *state) fprintf(out, "1 -1 scale (%s) show 1 -1 scale\n", lbuf); baseline += 16; free(lbuf); + XFree(a2); } if (name != NULL) { fprintf(out, "kbx kbdscalewidth 0 (%s) centeroffset pop add\n", @@ -896,10 +908,13 @@ PSPageTrailer(FILE *out, PSState *state) fprintf(out, " moveto\n"); fprintf(out, "1 -1 scale (%s) show 1 -1 scale\n", name); baseline += 16; + name = NULL; + XFree(a1); } if (state->args->label == LABEL_KEYCODE) { const char *sName = NULL; char *lbuf; + char *a3 = NULL; Atom sAtom; if (xkb->names != NULL) @@ -907,7 +922,7 @@ PSPageTrailer(FILE *out, PSState *state) else sAtom = None; if (sAtom != None) - sName = XkbAtomGetString(state->dpy, sAtom); + sName = a3 = XkbAtomGetString(state->dpy, sAtom); if (sName == NULL) sName = "(unknown)"; @@ -921,6 +936,7 @@ PSPageTrailer(FILE *out, PSState *state) fprintf(out, "1 -1 scale (%s) show 1 -1 scale\n", lbuf); baseline += 16; free(lbuf); + XFree(a3); } if (state->args->copies > 1) { for (p = 1; p < state->args->copies; p++) @@ -967,17 +983,18 @@ PSDoodad(FILE *out, PSState *state, XkbDoodadPtr doodad) { XkbDescPtr xkb; const char *name, *dname; + char *a1 = NULL, *a2 = NULL; int sz, leading; xkb = state->xkb; if (doodad->any.name != None) - dname = XkbAtomGetString(xkb->dpy, doodad->any.name); + dname = a1 = XkbAtomGetString(xkb->dpy, doodad->any.name); else dname = "NoName"; switch (doodad->any.type) { case XkbOutlineDoodad: case XkbSolidDoodad: - name = XkbAtomGetString(xkb->dpy, + name = a2 = XkbAtomGetString(xkb->dpy, XkbShapeDoodadShape(xkb->geom, &doodad->shape)->name); if (state->args->wantColor) { @@ -997,6 +1014,8 @@ PSDoodad(FILE *out, PSState *state, XkbDoodadPtr doodad) doodad->shape.angle, doodad->shape.left, doodad->shape.top, name, dname); } + name = NULL; + XFree(a2); break; case XkbTextDoodad: fprintf(out, "%% Doodad %s\n", dname); @@ -1041,7 +1060,7 @@ PSDoodad(FILE *out, PSState *state, XkbDoodadPtr doodad) PSGRestore(out, state); break; case XkbIndicatorDoodad: - name = XkbAtomGetString(xkb->dpy, + name = a2 = XkbAtomGetString(xkb->dpy, XkbIndicatorDoodadShape(xkb->geom, &doodad->indicator)-> name); @@ -1053,9 +1072,11 @@ PSDoodad(FILE *out, PSState *state, XkbDoodadPtr doodad) } fprintf(out, "false 0 %d %d %s %% Doodad %s\n", doodad->indicator.left, doodad->indicator.top, name, dname); + name = NULL; + XFree(a2); break; case XkbLogoDoodad: - name = XkbAtomGetString(xkb->dpy, + name = a2 = XkbAtomGetString(xkb->dpy, XkbLogoDoodadShape(xkb->geom, &doodad->logo)->name); if (state->args->wantColor) @@ -1063,8 +1084,11 @@ PSDoodad(FILE *out, PSState *state, XkbDoodadPtr doodad) fprintf(out, "false %d %d %d %s %% Doodad %s\n", doodad->shape.angle, doodad->shape.left, doodad->shape.top, name, dname); + name = NULL; + XFree(a2); break; } + XFree(a1); return; } @@ -1903,8 +1927,17 @@ PSSection(FILE *out, PSState *state, XkbSectionPtr section) xkb = state->xkb; dpy = xkb->dpy; - fprintf(out, "%% Begin Section '%s'\n", (section->name != None ? - XkbAtomGetString(dpy, section-> name) : "NoName")); + { + const char *section_name; + char *atom_name = NULL; + + if (section->name != None) + section_name = atom_name = XkbAtomGetString(dpy, section->name); + else + section_name = "NoName"; + fprintf(out, "%% Begin Section '%s'\n", section_name); + XFree(atom_name); + } PSGSave(out, state); fprintf(out, "%d %d translate\n", section->left, section->top); if (section->angle != 0) @@ -1925,7 +1958,6 @@ PSSection(FILE *out, PSState *state, XkbSectionPtr section) for (r = 0, row = section->rows; r < section->num_rows; r++, row++) { int k; XkbKeyPtr key; - XkbShapePtr shape; if (row->vertical) offset = row->top; @@ -1934,21 +1966,22 @@ PSSection(FILE *out, PSState *state, XkbSectionPtr section) fprintf(out, "%% Begin %s %d\n", row->vertical ? "column" : "row", r + 1); for (k = 0, key = row->keys; k < row->num_keys; k++, key++) { - shape = XkbKeyShape(xkb->geom, key); + XkbShapePtr shape = XkbKeyShape(xkb->geom, key); + char *shape_name = XkbAtomGetString(dpy, shape->name); + offset += key->gap; if (row->vertical) { if (state->args->wantColor) { if (key->color_ndx != state->white) { PSSetColor(out, state, key->color_ndx); fprintf(out, "true 0 %d %d %s %% %s\n", - row->left, offset, - XkbAtomGetString(dpy, shape->name), + row->left, offset, shape_name, XkbKeyNameText(key->name.name, XkbMessage)); } PSSetColor(out, state, state->black); } fprintf(out, "false 0 %d %d %s %% %s\n", row->left, offset, - XkbAtomGetString(dpy, shape->name), + shape_name, XkbKeyNameText(key->name.name, XkbMessage)); offset += shape->bounds.y2; } @@ -1957,16 +1990,17 @@ PSSection(FILE *out, PSState *state, XkbSectionPtr section) if (key->color_ndx != state->white) { PSSetColor(out, state, key->color_ndx); fprintf(out, "true 0 %d %d %s %% %s\n", offset, - row->top, XkbAtomGetString(dpy, shape->name), + row->top, shape_name, XkbKeyNameText(key->name.name, XkbMessage)); } PSSetColor(out, state, state->black); } fprintf(out, "false 0 %d %d %s %% %s\n", offset, row->top, - XkbAtomGetString(dpy, shape->name), + shape_name, XkbKeyNameText(key->name.name, XkbMessage)); offset += shape->bounds.x2; } + XFree(shape_name); } } for (r = 0, row = section->rows; r < section->num_rows; r++, row++) { @@ -2110,8 +2144,10 @@ GeometryToPostScript(FILE *out, XkbFileInfo *pResult, XKBPrintArgs *args) name = XkbAtomGetString(state.dpy, draw->u.doodad->any.name); if ((name != NULL) && (uStrCaseEqual(name, "edges"))) { dfltBorder = False; + XFree(name); break; } + XFree(name); } } for (i = 0; i < state.totalKB; i++) { |