Ignore:
Timestamp:
Mar 29, 2018, 5:54:02 AM (7 years ago)
Author:
bird
Message:

kmk_time: Quote the arguments properly on windows.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/misc/kmk_time.c

    r2546 r3208  
    4040# include <process.h>
    4141# include <Windows.h>
     42# include "quote_argv.h"
    4243#else
    4344# include <unistd.h>
     
    194195    int                 cTimes = 1;
    195196#if defined(_MSC_VER)
     197    int                 fUnquoted = 0;
    196198    FILETIME ftStart,   ft;
    197199    unsigned _int64     usMin, usMax, usAvg, usTotal, usCur;
     
    233235            else if (!strcmp(psz, "-iterations"))
    234236                psz = "i";
     237#if defined(_MSC_VER)
     238            else if (!strcmp(psz, "-unquoted"))
     239            {
     240                fUnquoted = 1;
     241                continue;
     242            }
     243#endif
    235244        }
    236245
     
    243252            case 'V':
    244253                printf("kmk_time - kBuild version %d.%d.%d (r%u)\n"
    245                        "Copyright (C) 2007-2009 knut st. osmundsen\n",
     254                       "Copyright (C) 2007-2018 knut st. osmundsen\n",
    246255                       KBUILD_VERSION_MAJOR, KBUILD_VERSION_MINOR, KBUILD_VERSION_PATCH,
    247256                       KBUILD_SVN_REV);
     
    287296         * Execute the program (it's actually supposed to be a command I think, but wtf).
    288297         */
    289 
    290298#if defined(_MSC_VER)
    291         /** @todo
    292          * We'll have to find the '--' in the commandline and pass that
    293          * on to CreateProcess or spawn. Otherwise, the argument qouting
    294          * is gonna be messed up.
    295          */
     299        if (!fUnquoted)
     300        {
     301            if (quote_argv(argc - i, &argv[i], 0 /*fWatcomBrainDamage*/, 0 /*fFreeOrLeak*/) != 0)
     302            {
     303                fprintf(stderr, "%s: error: quote_argv failed\n");
     304                return 8;
     305            }
     306        }
     307
    296308        GetSystemTimeAsFileTime(&ftStart);
    297309        rc = _spawnvp(_P_WAIT, argv[i], &argv[i]);
Note: See TracChangeset for help on using the changeset viewer.