From 705c8b1988cda51a6d8d34215e3fbf3c12a9aa2a Mon Sep 17 00:00:00 2001 From: oetiker Date: Sun, 1 May 2005 10:23:11 +0000 Subject: [PATCH] reset optind opterr inside the function calls ... git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@460 a5681a0c-68f1-0310-ab6d-d61299d08faa --- bindings/perl-shared/RRDs.xs | 5 ----- src/rrd_cgi.c | 4 ++-- src/rrd_create.c | 1 + src/rrd_fetch.c | 1 + src/rrd_first.c | 2 ++ src/rrd_graph.c | 2 +- src/rrd_restore.c | 1 + src/rrd_tool.c | 2 -- src/rrd_tune.c | 1 + src/rrd_update.c | 2 ++ src/rrd_xport.c | 1 + 11 files changed, 12 insertions(+), 10 deletions(-) diff --git a/bindings/perl-shared/RRDs.xs b/bindings/perl-shared/RRDs.xs index 217482c..f7e5360 100644 --- a/bindings/perl-shared/RRDs.xs +++ b/bindings/perl-shared/RRDs.xs @@ -29,7 +29,6 @@ extern "C" { argv[i+1] = (char *) malloc((strlen(handle)+1)*sizeof(char)); \ strcpy(argv[i+1],handle); \ } \ - optind=0; opterr=0; \ rrd_clear_error();\ RETVAL=name(items+1,argv); \ for (i=0; i < items; i++) {\ @@ -53,7 +52,6 @@ extern "C" { argv[i+1] = (char *) malloc((strlen(handle)+1)*sizeof(char)); \ strcpy(argv[i+1],handle); \ } \ - optind=0; opterr=0; \ rrd_clear_error(); \ data=name(items+1, argv); \ for (i=0; i < items; i++) { \ @@ -203,7 +201,6 @@ rrd_graph(...) argv[i+1] = (char *) malloc((strlen(handle)+1)*sizeof(char)); strcpy(argv[i+1],handle); } - optind=0; opterr=0; rrd_clear_error(); rrd_graph(items+1,argv,&calcpr,&xsize,&ysize,NULL,&ymin,&ymax); for (i=0; i < items; i++) { @@ -251,7 +248,6 @@ rrd_fetch(...) argv[i+1] = (char *) malloc((strlen(handle)+1)*sizeof(char)); strcpy(argv[i+1],handle); } - optind=0; opterr=0; rrd_clear_error(); rrd_fetch(items+1,argv,&start,&end,&step,&ds_cnt,&ds_namv,&data); for (i=0; i < items; i++) { @@ -330,7 +326,6 @@ rrd_xport(...) argv[i+1] = (char *) malloc((strlen(handle)+1)*sizeof(char)); strcpy(argv[i+1],handle); } - optind=0; opterr=0; rrd_clear_error(); rrd_xport(items+1,argv,&xsize,&start,&end,&step,&col_cnt,&legend_v,&data); for (i=0; i < items; i++) { diff --git a/src/rrd_cgi.c b/src/rrd_cgi.c index 51e4c1c..ee46d5e 100644 --- a/src/rrd_cgi.c +++ b/src/rrd_cgi.c @@ -266,6 +266,8 @@ int main(int argc, char *argv[]) { #ifdef MUST_DISABLE_FPMASK fpsetmask(0); #endif + optind = 0; opterr = 0; /* initialize getopt */ + /* what do we get for cmdline arguments? for (i=0;i"; } - optind=0; /* reset gnu getopt */ - opterr=0; /* reset gnu getopt */ calfree(); if( rrd_graph(argc+1, args-1, &calcpr, &xsize, &ysize,NULL,&ymin,&ymax) != -1 ) { return stralloc(calcpr[0]); diff --git a/src/rrd_create.c b/src/rrd_create.c index bb32a3e..95dbc14 100644 --- a/src/rrd_create.c +++ b/src/rrd_create.c @@ -23,6 +23,7 @@ rrd_create(int argc, char **argv) char *parsetime_error = NULL; long long_tmp; int rc; + optind = 0; opterr = 0; /* initialize getopt */ while (1){ static struct option long_options[] = diff --git a/src/rrd_fetch.c b/src/rrd_fetch.c index c5a73a3..74ab730 100644 --- a/src/rrd_fetch.c +++ b/src/rrd_fetch.c @@ -75,6 +75,7 @@ rrd_fetch(int argc, struct rrd_time_value start_tv, end_tv; char *parsetime_error = NULL; + optind = 0; opterr = 0; /* initialize getopt */ /* init start and end time */ parsetime("end-24h", &start_tv); diff --git a/src/rrd_first.c b/src/rrd_first.c index ab3bd49..eee8140 100644 --- a/src/rrd_first.c +++ b/src/rrd_first.c @@ -14,6 +14,7 @@ rrd_first(int argc, char **argv) { int target_rraindex=0; char *endptr; + optind = 0; opterr = 0; /* initialize getopt */ while (1){ static struct option long_options[] = @@ -23,6 +24,7 @@ rrd_first(int argc, char **argv) }; int option_index = 0; int opt; + optind = 0; opterr = 0; /* initialize getopt */ opt = getopt_long(argc, argv, "", long_options, &option_index); if(opt == EOF) diff --git a/src/rrd_graph.c b/src/rrd_graph.c index dc21548..5efe827 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -2673,7 +2673,6 @@ int rrd_graph(int argc, char **argv, char ***prdata, int *xsize, int *ysize, FILE *stream, double *ymin, double *ymax) { image_desc_t im; - rrd_graph_init(&im); im.graphhandle = stream; @@ -2832,6 +2831,7 @@ rrd_graph_options(int argc, char *argv[],image_desc_t *im) long long_tmp; struct rrd_time_value start_tv, end_tv; gfx_color_t color; + optind = 0; opterr = 0; /* initialize getopt */ parsetime("end-24h", &start_tv); parsetime("now", &end_tv); diff --git a/src/rrd_restore.c b/src/rrd_restore.c index a3d09ad..4ca223a 100644 --- a/src/rrd_restore.c +++ b/src/rrd_restore.c @@ -488,6 +488,7 @@ rrd_restore(int argc, char **argv) char force_overwrite = 0; /* init rrd clean */ + optind = 0; opterr = 0; /* initialize getopt */ rrd_init(&rrd); if (argc<3) { rrd_set_error("usage rrdtool %s [--range-check/-r] [--force-overwrite/-f] file.xml file.rrd",argv[0]); diff --git a/src/rrd_tool.c b/src/rrd_tool.c index cc178fb..46a9e9c 100644 --- a/src/rrd_tool.c +++ b/src/rrd_tool.c @@ -416,8 +416,6 @@ int HandleInputLine(int argc, char **argv, FILE* out) #if defined(HAVE_SYS_STAT_H) struct stat st; #endif - optind=0; /* reset gnu getopt */ - opterr=0; /* no error messages */ if (RemoteMode){ if (argc>1 && strcmp("quit", argv[1]) == 0){ diff --git a/src/rrd_tune.c b/src/rrd_tune.c index 94d9293..7e2ac91 100644 --- a/src/rrd_tune.c +++ b/src/rrd_tune.c @@ -61,6 +61,7 @@ rrd_tune(int argc, char **argv) double min; double max; char dst[DST_SIZE]; + optind = 0; opterr = 0; /* initialize getopt */ if(rrd_open(argv[1],&rrd_file,&rrd, RRD_READWRITE)==-1){ diff --git a/src/rrd_update.c b/src/rrd_update.c index a67a93a..11d92bb 100644 --- a/src/rrd_update.c +++ b/src/rrd_update.c @@ -109,6 +109,7 @@ info_t *rrd_update_v(int argc, char **argv) char *template = NULL; info_t *result = NULL; infoval rc; + optind = 0; opterr = 0; /* initialize getopt */ while (1) { static struct option long_options[] = @@ -155,6 +156,7 @@ rrd_update(int argc, char **argv) { char *template = NULL; int rc; + optind = 0; opterr = 0; /* initialize getopt */ while (1) { static struct option long_options[] = diff --git a/src/rrd_xport.c b/src/rrd_xport.c index 2a0bf76..19c2067 100644 --- a/src/rrd_xport.c +++ b/src/rrd_xport.c @@ -46,6 +46,7 @@ rrd_xport(int argc, char **argv, int *xsize, time_t start_tmp=0,end_tmp=0; struct rrd_time_value start_tv, end_tv; char *parsetime_error = NULL; + optind = 0; opterr = 0; /* initialize getopt */ rrd_graph_init(&im); -- 2.11.0