summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 37329a5)
raw | patch | inline | side by side (parent: 37329a5)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Tue, 10 May 2005 18:35:55 +0000 (18:35 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Tue, 10 May 2005 18:35:55 +0000 (18:35 +0000) |
git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@538 a5681a0c-68f1-0310-ab6d-d61299d08faa
src/rrd_gfx.c | patch | blob | history |
diff --git a/src/rrd_gfx.c b/src/rrd_gfx.c
index 9322e9eb7d62b0a9c32f91d09c3a8a4e05af63e8..b38f5ad42dbf3b22fd7897e88537a237290e1dba 100644 (file)
--- a/src/rrd_gfx.c
+++ b/src/rrd_gfx.c
static void eps_write_text(eps_state *state, gfx_node_t *node)
{
FILE *fp = state->fp;
- const unsigned char *p;
+ const char *p;
const char *ps_font = afm_get_font_postscript_name(node->filename);
int lineLen = 0;
pdf_coords g;
fputs("T1 ", fp);
fputs("(", fp);
lineLen = 20;
- for (p = (const unsigned char*)node->text; *p; p++) {
- if (lineLen > 70) {
+ p = node->text;
+ while (1) {
+ unsigned char ch = *(unsigned char*)p;
+ if (!ch)
+ break;
+ if (++lineLen > 70) {
fputs("\\\n", fp); /* backslash and \n */
lineLen = 0;
}
- switch (*p) {
+ switch (ch) {
+ case '%':
case '(':
case ')':
case '\\':
+ fputc('\\', fp);
+ fputc(ch, fp);
+ break;
case '\n':
+ fputs("\\n", fp);
+ break;
case '\r':
+ fputs("\\r", fp);
+ break;
case '\t':
- fputc('\\', fp);
- lineLen++;
- /* fall-through */
+ fputs("\\t", fp);
+ break;
default:
- if (*p >= 126)
- fprintf(fp, "\\%03o", *p);
- else
- fputc(*p, fp);
- lineLen++;
- }
+ if (ch >= 126 || ch < 32) {
+ fprintf(fp, "\\%03o", ch);
+ lineLen += 3;
+ } else {
+ fputc(ch, fp);
+ }
+ }
+ p++;
}
if (node->angle) {
/* can't use svg_write_number as 2 decimals is far from enough to avoid
{
const char *p = text;
while (1) {
- char ch = *p;
+ unsigned char ch = *(unsigned char*)p;
switch (ch) {
case 0: return;
case '(':