X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_graph.c;h=d6568f359cf522ebc056ff83f0dab97a7bdfa0af;hb=a39d10a2244a55d5af2d1c4b10f318fed3397cd4;hp=7fbe8651146c94b54e48ed47e33c7c44002969f9;hpb=7d0d6b07c9f5bd5dfd99aa7fe9826eebf2181f1f;p=rrdtool.git diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 7fbe865..d6568f3 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -308,7 +308,7 @@ int im_free( image_desc_t *im) { unsigned long i, ii; - cairo_status_t status; + cairo_status_t status = 0; if (im == NULL) return 0; @@ -329,10 +329,10 @@ int im_free( if (im->font_options) cairo_font_options_destroy(im->font_options); - status = cairo_status(im->cr); - - if (im->cr) + if (im->cr) { + status = cairo_status(im->cr); cairo_destroy(im->cr); + } if (im->surface) cairo_surface_destroy(im->surface); if (status) @@ -3721,53 +3721,55 @@ void rrd_graph_options( long long_tmp; struct rrd_time_value start_tv, end_tv; long unsigned int color; + char *old_locale = ""; + /* defines for long options without a short equivalent. should be bytes, and may not collide with (the ASCII value of) short options */ #define LONGOPT_UNITS_SI 255 - struct option long_options[] = { - {"start", required_argument, 0, 's'}, - {"end", required_argument, 0, 'e'}, - {"x-grid", required_argument, 0, 'x'}, - {"y-grid", required_argument, 0, 'y'}, - {"vertical-label", required_argument, 0, 'v'}, - {"width", required_argument, 0, 'w'}, - {"height", required_argument, 0, 'h'}, - {"full-size-mode", no_argument, 0, 'D'}, - {"interlaced", no_argument, 0, 'i'}, - {"upper-limit", required_argument, 0, 'u'}, - {"lower-limit", required_argument, 0, 'l'}, - {"rigid", no_argument, 0, 'r'}, - {"base", required_argument, 0, 'b'}, - {"logarithmic", no_argument, 0, 'o'}, - {"color", required_argument, 0, 'c'}, - {"font", required_argument, 0, 'n'}, - {"title", required_argument, 0, 't'}, - {"imginfo", required_argument, 0, 'f'}, - {"imgformat", required_argument, 0, 'a'}, - {"lazy", no_argument, 0, 'z'}, - {"zoom", required_argument, 0, 'm'}, - {"no-legend", no_argument, 0, 'g'}, - {"force-rules-legend", no_argument, 0, 'F'}, - {"only-graph", no_argument, 0, 'j'}, - {"alt-y-grid", no_argument, 0, 'Y'}, - {"no-minor", no_argument, 0, 'I'}, - {"slope-mode", no_argument, 0, 'E'}, - {"alt-autoscale", no_argument, 0, 'A'}, - {"alt-autoscale-min", no_argument, 0, 'J'}, - {"alt-autoscale-max", no_argument, 0, 'M'}, - {"no-gridfit", no_argument, 0, 'N'}, - {"units-exponent", required_argument, 0, 'X'}, - {"units-length", required_argument, 0, 'L'}, - {"units", required_argument, 0, LONGOPT_UNITS_SI}, - {"step", required_argument, 0, 'S'}, - {"tabwidth", required_argument, 0, 'T'}, - {"font-render-mode", required_argument, 0, 'R'}, - {"graph-render-mode", required_argument, 0, 'G'}, - {"font-smoothing-threshold", required_argument, 0, 'B'}, - {"watermark", required_argument, 0, 'W'}, - {"alt-y-mrtg", no_argument, 0, 1000}, /* this has no effect it is just here to save old apps from crashing when they use it */ - {0, 0, 0, 0} - }; + struct option long_options[] = { + {"start", required_argument, 0, 's'}, + {"end", required_argument, 0, 'e'}, + {"x-grid", required_argument, 0, 'x'}, + {"y-grid", required_argument, 0, 'y'}, + {"vertical-label", required_argument, 0, 'v'}, + {"width", required_argument, 0, 'w'}, + {"height", required_argument, 0, 'h'}, + {"full-size-mode", no_argument, 0, 'D'}, + {"interlaced", no_argument, 0, 'i'}, + {"upper-limit", required_argument, 0, 'u'}, + {"lower-limit", required_argument, 0, 'l'}, + {"rigid", no_argument, 0, 'r'}, + {"base", required_argument, 0, 'b'}, + {"logarithmic", no_argument, 0, 'o'}, + {"color", required_argument, 0, 'c'}, + {"font", required_argument, 0, 'n'}, + {"title", required_argument, 0, 't'}, + {"imginfo", required_argument, 0, 'f'}, + {"imgformat", required_argument, 0, 'a'}, + {"lazy", no_argument, 0, 'z'}, + {"zoom", required_argument, 0, 'm'}, + {"no-legend", no_argument, 0, 'g'}, + {"force-rules-legend", no_argument, 0, 'F'}, + {"only-graph", no_argument, 0, 'j'}, + {"alt-y-grid", no_argument, 0, 'Y'}, + {"no-minor", no_argument, 0, 'I'}, + {"slope-mode", no_argument, 0, 'E'}, + {"alt-autoscale", no_argument, 0, 'A'}, + {"alt-autoscale-min", no_argument, 0, 'J'}, + {"alt-autoscale-max", no_argument, 0, 'M'}, + {"no-gridfit", no_argument, 0, 'N'}, + {"units-exponent", required_argument, 0, 'X'}, + {"units-length", required_argument, 0, 'L'}, + {"units", required_argument, 0, LONGOPT_UNITS_SI}, + {"step", required_argument, 0, 'S'}, + {"tabwidth", required_argument, 0, 'T'}, + {"font-render-mode", required_argument, 0, 'R'}, + {"graph-render-mode", required_argument, 0, 'G'}, + {"font-smoothing-threshold", required_argument, 0, 'B'}, + {"watermark", required_argument, 0, 'W'}, + {"alt-y-mrtg", no_argument, 0, 1000}, /* this has no effect it is just here to save old apps from crashing when they use it */ + {0, 0, 0, 0} + }; optind = 0; opterr = 0; /* initialize getopt */ @@ -3815,6 +3817,7 @@ void rrd_graph_options( case LONGOPT_UNITS_SI: if (im->extra_flags & FORCE_UNITS) { rrd_set_error("--units can only be used once!"); + setlocale(LC_NUMERIC, old_locale); return; } if (strcmp(optarg, "si") == 0) @@ -3832,10 +3835,14 @@ void rrd_graph_options( im->forceleftspace = 1; break; case 'T': + old_locale = setlocale(LC_NUMERIC, "C"); im->tabwidth = atof(optarg); + setlocale(LC_NUMERIC, old_locale); break; case 'S': + old_locale = setlocale(LC_NUMERIC, "C"); im->step = atoi(optarg); + setlocale(LC_NUMERIC, old_locale); break; case 'N': im->gridfit = 0; @@ -3895,8 +3902,9 @@ void rrd_graph_options( im->draw_y_grid = 0; break; }; - + old_locale = setlocale(LC_NUMERIC, "C"); if (sscanf(optarg, "%lf:%d", &im->ygridstep, &im->ylabfact) == 2) { + setlocale(LC_NUMERIC, old_locale); if (im->ygridstep <= 0) { rrd_set_error("grid step must be > 0"); return; @@ -3905,6 +3913,7 @@ void rrd_graph_options( return; } } else { + setlocale(LC_NUMERIC, old_locale); rrd_set_error("invalid y-grid format"); return; } @@ -3914,10 +3923,14 @@ void rrd_graph_options( im->ylegend[150] = '\0'; break; case 'u': + old_locale = setlocale(LC_NUMERIC, "C"); im->maxval = atof(optarg); + setlocale(LC_NUMERIC, old_locale); break; case 'l': + old_locale = setlocale(LC_NUMERIC, "C"); im->minval = atof(optarg); + setlocale(LC_NUMERIC, old_locale); break; case 'b': im->base = atol(optarg); @@ -4016,9 +4029,11 @@ void rrd_graph_options( double size = 1; char font[1024] = ""; + old_locale = setlocale(LC_NUMERIC, "C"); if (sscanf(optarg, "%10[A-Z]:%lf:%1000s", prop, &size, font) >= 2) { int sindex, propidx; + setlocale(LC_NUMERIC, old_locale); if ((sindex = text_prop_conv(prop)) != -1) { for (propidx = sindex; propidx < TEXT_PROP_LAST; propidx++) { @@ -4036,13 +4051,16 @@ void rrd_graph_options( return; } } else { + setlocale(LC_NUMERIC, old_locale); rrd_set_error("invalid text property format"); return; } break; } case 'm': + old_locale = setlocale(LC_NUMERIC, "C"); im->zoom = atof(optarg); + setlocale(LC_NUMERIC, old_locale); if (im->zoom <= 0.0) { rrd_set_error("zoom factor must be > 0"); return; @@ -4242,9 +4260,12 @@ int vdef_parse( double param; char func[30]; int n; + char *old_locale; n = 0; + old_locale = setlocale(LC_NUMERIC, "C"); sscanf(str, "%le,%29[A-Z]%n", ¶m, func, &n); + setlocale(LC_NUMERIC, old_locale); if (n == (int) strlen(str)) { /* matched */ ; } else { @@ -4527,7 +4548,8 @@ int vdef_calc( /* NaN < -INF < finite_values < INF */ int vdef_percent_compar( - const void *a, const void *b) + const void *a, + const void *b) { /* Equality is not returned; this doesn't hurt except * (maybe) for a little performance.