This commit is contained in:
Branimir Karadžić
2018-07-01 21:51:34 -07:00
parent af62b2c717
commit 7f4f5a282b
2 changed files with 6 additions and 5 deletions

View File

@@ -6,13 +6,13 @@
#ifndef BX_COMMANDLINE_H_HEADER_GUARD
#define BX_COMMANDLINE_H_HEADER_GUARD
#include "bx.h"
#include "string.h"
namespace bx
{
/// Reference:
/// http://msdn.microsoft.com/en-us/library/a1y7w461.aspx
const char* tokenizeCommandLine(const char* _commandLine, char* _buffer, uint32_t& _bufferSize, int32_t& _argc, char* _argv[], int32_t _maxArgvs, char _term = '\0');
const char* tokenizeCommandLine(const StringView& _commandLine, char* _buffer, uint32_t& _bufferSize, int32_t& _argc, char* _argv[], int32_t _maxArgvs, char _term = '\0');
///
class CommandLine

View File

@@ -12,10 +12,11 @@ namespace bx
// Reference:
// - https://web.archive.org/web/20180629044234/https://msdn.microsoft.com/en-us/library/a1y7w461.aspx
//
const char* tokenizeCommandLine(const char* _commandLine, char* _buffer, uint32_t& _bufferSize, int32_t& _argc, char* _argv[], int32_t _maxArgvs, char _term)
const char* tokenizeCommandLine(const StringView& _commandLine, char* _buffer, uint32_t& _bufferSize, int32_t& _argc, char* _argv[], int32_t _maxArgvs, char _term)
{
int32_t argc = 0;
const char* curr = _commandLine;
const char* curr = _commandLine.getPtr();
const char* end = _commandLine.getTerm();
char* currOut = _buffer;
char term = ' ';
bool sub = false;
@@ -31,7 +32,7 @@ namespace bx
ParserState state = SkipWhitespace;
while ('\0' != *curr
while (end != curr
&& _term != *curr
&& argc < _maxArgvs)
{