prepare for the release of rrdtool-1.2.8
[rrdtool.git] / src / rrd_gfx.c
index 2b32831..56f4a98 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * RRDtool 1.2.4  Copyright by Tobi Oetiker, 1997-2005
+ * RRDtool 1.2.8  Copyright by Tobi Oetiker, 1997-2005
  ****************************************************************************
  * rrd_gfx.c  graphics wrapper for rrdtool
   **************************************************************************/
@@ -1399,7 +1399,7 @@ int       gfx_render_svg (gfx_canvas_t *canvas,
 "   \"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd\">\n"
 "<!--\n"
 "   SVG file created by\n"
-"        RRDtool 1.2.4 Tobias Oetiker, http://tobi.oetiker.ch\n"
+"        RRDtool 1.2.8 Tobias Oetiker, http://tobi.oetiker.ch\n"
 "\n"
 "   The width/height attributes in the outhermost svg node\n"
 "   are just default sizes for the browser which is used\n"
@@ -1567,7 +1567,7 @@ static int eps_prologue(eps_state *state)
   gfx_node_t *node;
   fputs(
     "%!PS-Adobe-3.0 EPSF-3.0\n"
-    "%%Creator: RRDtool 1.2.4 Tobias Oetiker, http://tobi.oetiker.ch\n"
+    "%%Creator: RRDtool 1.2.8 Tobias Oetiker, http://tobi.oetiker.ch\n"
     /* can't like weird chars here */
     "%%Title: (RRDtool output)\n"
     "%%DocumentData: Clean7Bit\n"
@@ -1696,7 +1696,7 @@ static void eps_write_linearea(eps_state *state, gfx_node_t *node)
 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;
@@ -1712,28 +1712,41 @@ static void eps_write_text(eps_state *state, gfx_node_t *node)
          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
@@ -1927,17 +1940,23 @@ static void pdf_put_string_contents(pdf_buffer *buf, const char *text)
 {
     const char *p = text;
     while (1) {
-       char ch = *p;
+       unsigned char ch = *(unsigned char*)p;
        switch (ch) {
            case 0: return;
            case '(':
            case ')':
            case '\\':
+               pdf_puts(buf, "\\");
+               pdf_put(buf, p, 1);
+               break;
            case '\n':
+               pdf_puts(buf, "\\n");
+               break;
            case '\r':
+               pdf_puts(buf, "\\r");
+               break;
            case '\t':
-               pdf_puts(buf, "\\");
-               pdf_put(buf, (char)ch, 1);
+               pdf_puts(buf, "\\t");
                break;
            default:
                if (ch >= 126 || ch < 32) {
@@ -2235,7 +2254,7 @@ static void pdf_init_document(pdf_state *state)
 
 static void pdf_setup_document(pdf_state *state)
 {
-  const char *creator = "RRDtool 1.2.4 Tobias Oetiker, http://tobi.oetiker.ch";
+  const char *creator = "RRDtool 1.2.8 Tobias Oetiker, http://tobi.oetiker.ch";
   /* all objects created by now, so init code can reference them */
   /* HEADER */
   pdf_puts(&state->pdf_header, "%PDF-1.3\n");