X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_tool.c;h=302669d6641ff428a317e2e1474219dbfdc75d7d;hb=b4fd5d71cb3e4bdb9e12cc22f3d1373123c7e050;hp=853f0db4c308fd21a828efc4d7c1cf25cae15cf8;hpb=829d0547396813c62e606d95fd42612f15ab9cb3;p=rrdtool.git diff --git a/src/rrd_tool.c b/src/rrd_tool.c index 853f0db..302669d 100644 --- a/src/rrd_tool.c +++ b/src/rrd_tool.c @@ -18,9 +18,8 @@ #include "rrd_xport.h" #include "rrd_i18n.h" -#ifdef HAVE_LOCALE_H #include -#endif + void PrintUsage( char *cmd); @@ -29,7 +28,6 @@ int CountArgs( int CreateArgs( char *, char *, - int, char **); int HandleInputLine( int, @@ -409,13 +407,13 @@ int main( #ifdef MUST_DISABLE_FPMASK 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) { @@ -467,24 +465,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); @@ -503,7 +498,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]); @@ -856,7 +852,6 @@ int CountArgs( int CreateArgs( char *pName, char *aLine, - int argc, char **argv) { char *getP, *putP; @@ -864,6 +859,7 @@ int CreateArgs( char Quote = 0; int inArg = 0; int len; + int argc = 1; len = strlen(aLine); /* remove trailing space and newlines */