summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6f3a47b)
raw | patch | inline | side by side (parent: 6f3a47b)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Mon, 29 Apr 2002 17:11:03 +0000 (17:11 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Mon, 29 Apr 2002 17:11:03 +0000 (17:11 +0000) |
src/rrd_graph.c | patch | blob | history |
diff --git a/src/rrd_graph.c b/src/rrd_graph.c
index 89a67c087c58a67a4fd227e8cb0f983ae8eb0c49..17ec03a72df02f538dd578d36e2f16c3e75bec3b 100644 (file)
--- a/src/rrd_graph.c
+++ b/src/rrd_graph.c
int bad_format(char *fmt) {
- char *ptr;
- int n=0;
-
- ptr = fmt;
- while (*ptr != '\0') {
- if (*ptr == '%') {ptr++;
- if (*ptr == '\0') return 1;
- while ((*ptr >= '0' && *ptr <= '9') || *ptr == '.') {
- ptr++;
- }
- if (*ptr == '\0') return 1;
- else if (*ptr == ' ') ptr++;
- else if (*ptr == '-') ptr++;
- else if (*ptr == '+') ptr++;
- if (*ptr == 'l') {
- ptr++;
- n++;
- if (*ptr == '\0') return 1;
- if (*ptr == 'e' || *ptr == 'f') {
- ptr++;
- } else { return 1; }
- }
- else if (*ptr == 's' || *ptr == 'S' || *ptr == '%') { ++ptr; }
- else { return 1; }
- } else {
- ++ptr;
- }
- }
- return (n!=1);
+ char *ptr;
+ int n=0;
+ ptr = fmt;
+ while (*ptr != '\0')
+ if (*ptr++ == '%') {
+
+ /* line cannot end with percent char */
+ if (*ptr == '\0') return 1;
+
+ /* '%s', '%S' and '%%' are allowed */
+ if (*ptr == 's' || *ptr == 'S' || *ptr == '%') ptr++;
+
+ /* or else '% 6.2lf' and such are allowed */
+ else {
+
+ /* optional padding character */
+ if (*ptr == ' ' || *ptr == '+' || *ptr == '-') ptr++;
+
+ /* This should take care of 'm.n' with all three optional */
+ while (*ptr >= '0' && *ptr <= '9') ptr++;
+ if (*ptr == '.') ptr++;
+ while (*ptr >= '0' && *ptr <= '9') ptr++;
+
+ /* Either 'le' or 'lf' must follow here */
+ if (*ptr++ != 'l') return 1;
+ if (*ptr == 'e' || *ptr == 'f') ptr++;
+ else return 1;
+ n++;
+ }
+ }
+
+ return (n!=1);
}
+
+
int
vdef_parse(gdes,str)
struct graph_desc_t *gdes;
};
return 0;
}
+
+
int
vdef_calc(im,gdi)
image_desc_t *im;