X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=src%2Frrd_tool.c;h=7464b3cd7f7789c97cea01976b31ccd555c5e59b;hp=8f233268f3fe46d5cb5b1387f5868d81cc6af829;hb=7412ab0c1230f2609313913793f9e6c0a93b28b1;hpb=cd6581d4edf9cd9c73f023eb9b1f5529959bf816 diff --git a/src/rrd_tool.c b/src/rrd_tool.c index 8f23326..7464b3c 100644 --- a/src/rrd_tool.c +++ b/src/rrd_tool.c @@ -29,7 +29,6 @@ int CountArgs( int CreateArgs( char *, char *, - int, char **); int HandleInputLine( int, @@ -139,7 +138,7 @@ void PrintUsage( "\t\t[-y|--y-grid y-axis grid and label]\n" "\t\t[-v|--vertical-label string] [-w|--width pixels]\n" "\t\t[--right-axis scale:shift] [--right-axis-label label]\n" - "\t\t[--right-axis-format format]\n" + "\t\t[--right-axis-format format]\n" "\t\t[-h|--height pixels] [-o|--logarithmic]\n" "\t\t[-u|--upper-limit value] [-z|--lazy]\n" "\t\t[-l|--lower-limit value] [-r|--rigid]\n" @@ -161,7 +160,9 @@ void PrintUsage( "\t\t[-S|--step seconds]\n" "\t\t[-f|--imginfo printfstr]\n" "\t\t[-a|--imgformat PNG]\n" - "\t\t[-c|--color COLORTAG#rrggbb[aa]] [-t|--title string]\n" + "\t\t[-c|--color COLORTAG#rrggbb[aa]]\n" + "\t\t[--border width\n" + "\t\t[-t|--title string]\n" "\t\t[-W|--watermark string]\n" "\t\t[DEF:vname=rrd:ds-name:CF]\n"); const char *help_graph3 = @@ -408,12 +409,13 @@ int main( fpsetmask(0); #endif #ifdef HAVE_LOCALE_H + /* initialize locale settings + according to localeconv(3) */ setlocale(LC_ALL, ""); #endif #if defined(HAVE_LIBINTL_H) && defined(BUILD_LIBINTL) bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR); - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); #endif if (argc == 1) { @@ -465,24 +467,21 @@ int main( } while (fgetslong(&aLine, stdin)) { + char *aLineOrig = aLine; if ((argc = CountArgs(aLine)) == 0) { free(aLine); printf("ERROR: not enough arguments\n"); + continue; } if ((myargv = (char **) malloc((argc + 1) * sizeof(char *))) == NULL) { perror("malloc"); exit(1); } - if ((argc = CreateArgs(argv[0], aLine, argc, myargv)) < 0) { - free(aLine); - free(myargv); + if ((argc = CreateArgs(argv[0], aLine, myargv)) < 0) { printf("ERROR: creating arguments\n"); } else { - int ret = HandleInputLine(argc, myargv, stdout); - - free(myargv); - if (ret == 0) { + if ( HandleInputLine(argc, myargv, stdout) == 0 ){ #if HAVE_GETRUSAGE getrusage(RUSAGE_SELF, &myusage); gettimeofday(¤ttime, NULL); @@ -501,7 +500,8 @@ int main( } } fflush(stdout); /* this is important for pipes to work */ - free(aLine); + free(myargv); + free(aLineOrig); } } else if (argc == 2) { PrintUsage(argv[1]); @@ -854,7 +854,6 @@ int CountArgs( int CreateArgs( char *pName, char *aLine, - int argc, char **argv) { char *getP, *putP; @@ -862,6 +861,7 @@ int CreateArgs( char Quote = 0; int inArg = 0; int len; + int argc = 1; len = strlen(aLine); /* remove trailing space and newlines */