Date:2010-04-29 23:34:29 (9 years 1 month ago)
Author:werner
Commit:24011c74d6e7d3461b435cb89f1099d19dbaae3f
Message:Removed an old bug: parentheses and backslash are meta-characters in Postscript strings but weren't escaped until now.

- postscript.c: output all Postscript strings with ps_string, which correctly
escapes parentheses and backslashes
- TODO: removed the bug entry



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5952 99fdad57-331a-0410-800a-d7fa5415bdb3
Files: TODO (1 diff)
postscript.c (7 diffs)

Change Details

TODO
3232- focus should return to canvas if nobody else wants it
3333- whenever we call parse_* for input parsing, we may leak lots of expressions
3434- can't edit measurement labels through the GUI
35- unbalanced parentheses in text throw off Postscript syntax
3635
3736Code cleanup:
3837- merge edit_unique with edit_name
postscript.c
166166}
167167
168168
169/* ----- Helper functions -------------------------------------------------- */
170
171
172static void ps_string(FILE *file, const char *s)
173{
174    fputc('(', file);
175    while (*s) {
176        if (*s == '(' || *s == ')' || *s == '\\')
177            fputc('\\', file);
178        fputc(*s, file);
179        s++;
180    }
181    fputc(')', file);
182}
183
184
169185/* ----- Items ------------------------------------------------------------- */
170186
171187
...... 
184200    if (w < 0)
185201        w = -w;
186202    fprintf(file, "0 setgray /Helvetica-Bold findfont dup\n");
187    fprintf(file, " (%s) %d %d\n", inst->u.pad.name, w/2, h/2);
203    fprintf(file, " ");
204    ps_string(file, inst->u.pad.name);
205    fprintf(file, " %d %d\n", w/2, h/2);
188206    fprintf(file, " boxfont\n");
189207    fprintf(file, " %d %d moveto\n", (a.x+b.x)/2, (a.y+b.y)/2);
190    fprintf(file, " (%s) center %d showoutlined newpath\n",
191        inst->u.pad.name, PS_FONT_OUTLINE);
208    fprintf(file, " ");
209    ps_string(file, inst->u.pad.name);
210    fprintf(file, " center %d showoutlined newpath\n", PS_FONT_OUTLINE);
192211}
193212
194213
...... 
372391    d = sub_vec(b, a);
373392    fprintf(file, "gsave %d %d moveto\n", c.x/2, c.y/2);
374393    fprintf(file, " /Helvetica-Bold findfont dup\n");
375    fprintf(file, " (%s) %d %d realsize\n", s,
394    fprintf(file, " ");
395    ps_string(file, s);
396    fprintf(file, " %d %d realsize\n",
376397        (int) (dist_point(a, b)-2*PS_VEC_ARROW_LEN),
377398        PS_VEC_TEXT_HEIGHT);
378399    fprintf(file, " boxfont\n");
379400    fprintf(file, " %f rotate\n", atan2(d.y, d.x)/M_PI*180);
380    fprintf(file, " (%s) %d realsize pop 0 hcenter\n",
381        s, PS_VEC_BASE_OFFSET);
401    fprintf(file, " ");
402    ps_string(file, s);
403    fprintf(file, " %d realsize pop 0 hcenter\n", PS_VEC_BASE_OFFSET);
382404    fprintf(file, " show grestore\n");
383405    free(s);
384406}
...... 
450472    if (height) {
451473        fprintf(file, "gsave %d %d moveto\n", c.x/2, c.y/2);
452474        fprintf(file, " /Helvetica-Bold findfont dup\n");
453        fprintf(file, " (%s) %d realsize %d realsize\n",
454            s, width, height);
475        fprintf(file, " ");
476        ps_string(file, s);
477        fprintf(file, " %d realsize %d realsize\n", width, height);
455478        fprintf(file, " boxfont\n");
456479        fprintf(file, " %f rotate\n", atan2(d.y, d.x)/M_PI*180);
457        fprintf(file, " (%s) %d realsize hcenter\n", s, offset);
480        fprintf(file, " ");
481        ps_string(file, s);
482        fprintf(file, " %d realsize hcenter\n", offset);
458483        fprintf(file, " show grestore\n");
459484    } else {
460485        fprintf(file, "gsave %d %d moveto\n", c.x/2, c.y/2);
461486        fprintf(file, " /Helvetica-Bold findfont dup\n");
462        fprintf(file, " (%s) %d %d realsize\n", s, width,
463            PS_MEAS_TEXT_HEIGHT);
487        fprintf(file, " ");
488        ps_string(file, s);
489        fprintf(file, " %d %d realsize\n", width, PS_MEAS_TEXT_HEIGHT);
464490        fprintf(file, " boxfont\n");
465491        fprintf(file, " %f rotate\n", atan2(d.y, d.x)/M_PI*180);
466        fprintf(file, " (%s) %d realsize hcenter\n", s, offset);
492        fprintf(file, " ");
493        ps_string(file, s);
494        fprintf(file, " %d realsize hcenter\n", offset);
467495        fprintf(file, " show grestore\n");
468496    }
469497    free(s);
...... 
694722    fprintf(file, "gsave %d %d moveto\n",
695723        -PAGE_HALF_WIDTH, PAGE_HALF_HEIGHT-PS_HEADER_HEIGHT);
696724    fprintf(file, " /Helvetica-Bold findfont dup\n");
697    fprintf(file, " (%s) %d %d\n",
698        pkg->name, PAGE_HALF_WIDTH, PS_HEADER_HEIGHT);
725    fprintf(file, " ");
726    ps_string(file, pkg->name);
727    fprintf(file, " %d %d\n", PAGE_HALF_WIDTH, PS_HEADER_HEIGHT);
699728    fprintf(file, " boxfont\n");
700    fprintf(file, " (%s) show grestore\n", pkg->name);
729    fprintf(file, " ");
730    ps_string(file, pkg->name);
731    fprintf(file, " show grestore\n");
701732
702733    ps_hline(file, PAGE_HALF_HEIGHT-PS_HEADER_HEIGHT-PS_DIVIDER_BORDER);
703734}
...... 
716747" 72 %d div 1000 div dup scale\n",
717748    (int) MIL_UNITS);
718749    fprintf(file, "%%%%EndPageSetup\n");
719    fprintf(file, "[ /Title (%s) /OUT pdfmark\n", pkg->name);
750    fprintf(file, "[ /Title ");
751    ps_string(file, pkg->name);
752    fprintf(file, " /OUT pdfmark\n");
720753}
721754
722755
...... 
740773
741774    fprintf(file, "gsave %d %d moveto\n", x, y);
742775    fprintf(file, " /Helvetica findfont dup\n");
743    fprintf(file, " (%s) %d %d\n", s, w, h);
776    fprintf(file, " ");
777    ps_string(file, s);
778    fprintf(file, " %d %d\n", w, h);
744779    fprintf(file, " boxfont\n");
745    fprintf(file, " (%s) show grestore\n", s);
780    fprintf(file, " ");
781    ps_string(file, s);
782    fprintf(file, " show grestore\n");
746783}
747784
748785

Archive Download the corresponding diff file

Branches:
master



interactive