From 38e085a8c062092c9e66b8cf591bad1825ef41ba Mon Sep 17 00:00:00 2001 From: vladislavbelov Date: Tue, 25 May 2021 18:42:27 +0000 Subject: [PATCH] Removes unused wutil command line arguments parsing added in 5383eff15c. We already have a single place to access arguments, so we don't need a platform dependent place for that. Refs 3f58951808, 8c1bd05ab9. This was SVN commit r25567. --- source/lib/sysdep/os/win/wutil.cpp | 90 ------------------------------ source/lib/sysdep/os/win/wutil.h | 11 +--- 2 files changed, 1 insertion(+), 100 deletions(-) diff --git a/source/lib/sysdep/os/win/wutil.cpp b/source/lib/sysdep/os/win/wutil.cpp index d109510185..10c8ad3c74 100644 --- a/source/lib/sysdep/os/win/wutil.cpp +++ b/source/lib/sysdep/os/win/wutil.cpp @@ -162,92 +162,6 @@ Status StatusFromWin() } } - -//----------------------------------------------------------------------------- -// command line - -// copy of GetCommandLine string. will be tokenized and then referenced by -// the argv pointers. -static wchar_t* argvContents; - -int s_argc = 0; -wchar_t** s_argv = 0; - -static void ReadCommandLine() -{ - const wchar_t* commandLine = GetCommandLineW(); - // (this changes as quotation marks are removed) - size_t numChars = wcslen(commandLine); - argvContents = (wchar_t*)HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, (numChars+1)*sizeof(wchar_t)); - wcscpy_s(argvContents, numChars+1, commandLine); - - // first pass: tokenize string and count number of arguments - bool ignoreSpace = false; - for(size_t i = 0; i < numChars; i++) - { - switch(argvContents[i]) - { - case '"': - ignoreSpace = !ignoreSpace; - // strip the " character - memmove(argvContents+i, argvContents+i+1, (numChars-i)*sizeof(wchar_t)); - numChars--; - i--; - break; - - case ' ': - if(!ignoreSpace) - { - argvContents[i] = '\0'; - s_argc++; - } - break; - } - } - s_argc++; - - // have argv entries point into the tokenized string - s_argv = (wchar_t**)HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, s_argc*sizeof(wchar_t*)); - wchar_t* nextArg = argvContents; - for(int i = 0; i < s_argc; i++) - { - s_argv[i] = nextArg; - nextArg += wcslen(nextArg)+1; - } -} - - -int wutil_argc() -{ - return s_argc; -} - -wchar_t** wutil_argv() -{ - ENSURE(s_argv); - return s_argv; -} - - -static void FreeCommandLine() -{ - HeapFree(GetProcessHeap(), 0, s_argv); - HeapFree(GetProcessHeap(), 0, argvContents); -} - - -bool wutil_HasCommandLineArgument(const wchar_t* arg) -{ - for(int i = 0; i < s_argc; i++) - { - if(!wcscmp(s_argv[i], arg)) - return true; - } - - return false; -} - - //----------------------------------------------------------------------------- // directories @@ -530,8 +444,6 @@ static Status wutil_Init() EnableLowFragmentationHeap(); - ReadCommandLine(); - GetDirectories(); ImportWow64Functions(); @@ -543,8 +455,6 @@ static Status wutil_Init() static Status wutil_Shutdown() { - FreeCommandLine(); - ShutdownLocks(); FreeDirectories(); diff --git a/source/lib/sysdep/os/win/wutil.h b/source/lib/sysdep/os/win/wutil.h index b45c2b4796..3642150b1b 100644 --- a/source/lib/sysdep/os/win/wutil.h +++ b/source/lib/sysdep/os/win/wutil.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 Wildfire Games. +/* Copyright (C) 2021 Wildfire Games. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the @@ -153,15 +153,6 @@ private: extern Status StatusFromWin(); -//----------------------------------------------------------------------------- -// command line - -extern int wutil_argc(); -extern wchar_t** wutil_argv(); - -extern bool wutil_HasCommandLineArgument(const wchar_t* arg); - - //----------------------------------------------------------------------------- // directories