- dprintf("- in '%s'\n",&line[*eaten]);
- /* the legend for a graph item must start with "m " the first
- m will then be over drawn with a color box. Since there
- is ample space I overwrite the first few characters of the line
- with the material that I want to see in the legend */
- if (line[*eaten] != '\0' && line[*eaten] != ':'){
- *eaten = *eaten - 2;
- line[*eaten] = 'm';
- line[*eaten+1] = ' ';
- }
- if (rrd_parse_legend(line, eaten, gdp)) return 1;
- }
-
- /* PART, HRULE, VRULE and TICK cannot be stacked. We're finished */
+
+ dprintf("- examining '%s'\n",&line[*eaten]);
+ if (linecp[*eaten] != '\0' && linecp[*eaten] != ':') {
+ int spi;
+ /* If the legend is not empty, it has to be prefixed with spacecnt ' ' characters. This then gets
+ * replaced by the color box later on. */
+ for (spi=0;spi<spacecnt && (*eaten) > 1;spi++){
+ linecp[--(*eaten)]=' ';
+ }
+ }
+
+ if (rrd_parse_legend(linecp, eaten, gdp)) err=1;
+ free(linecp);
+ if (err) return 1;
+
+ dprintf("- found legend '%s'\n", &gdp->legend[2]);
+ } else {
+ dprintf("- skipping empty legend\n");
+ if (line[*eaten] != '\0' && line[*eaten] != ':') {
+ rrd_set_error("Legend set but no color: %s",&line[*eaten]);
+ return 1;
+ }
+ }
+ if (line[*eaten]=='\0') {
+ dprintf("- done parsing line\n");
+ return 0;
+ }
+ (*eaten)++; /* after colon */
+
+ /* PART, HRULE, VRULE and TICK cannot be stacked. */