diff options
| author | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:31:46 -0800 |
|---|---|---|
| committer | Jørgen P. Tjernø <[email protected]> | 2013-12-02 19:46:31 -0800 |
| commit | f56bb35301836e56582a575a75864392a0177875 (patch) | |
| tree | de61ddd39de3e7df52759711950b4c288592f0dc /mp/src/public/filesystem_helpers.cpp | |
| parent | Mark some more files as text. (diff) | |
| download | source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip | |
Fix line endings. WHAMMY.
Diffstat (limited to 'mp/src/public/filesystem_helpers.cpp')
| -rw-r--r-- | mp/src/public/filesystem_helpers.cpp | 258 |
1 files changed, 129 insertions, 129 deletions
diff --git a/mp/src/public/filesystem_helpers.cpp b/mp/src/public/filesystem_helpers.cpp index 4e1ea169..5e4ac997 100644 --- a/mp/src/public/filesystem_helpers.cpp +++ b/mp/src/public/filesystem_helpers.cpp @@ -1,129 +1,129 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-//=====================================================================================//
-
-#include "filesystem.h"
-#include "filesystem_helpers.h"
-#include "characterset.h"
-
-// memdbgon must be the last include file in a .cpp file!!!
-#include "tier0/memdbgon.h"
-
-// wordbreak parsing set
-static characterset_t g_BreakSet, g_BreakSetIncludingColons;
-
-static void InitializeCharacterSets()
-{
- static bool s_CharacterSetInitialized = false;
- if (!s_CharacterSetInitialized)
- {
- CharacterSetBuild( &g_BreakSet, "{}()'" );
- CharacterSetBuild( &g_BreakSetIncludingColons, "{}()':" );
- s_CharacterSetInitialized = true;
- }
-}
-
-
-const char* ParseFileInternal( const char* pFileBytes, char* pTokenOut, bool* pWasQuoted, characterset_t *pCharSet, size_t nMaxTokenLen )
-{
- pTokenOut[0] = 0;
-
- if (pWasQuoted)
- *pWasQuoted = false;
-
- if (!pFileBytes)
- return 0;
-
- InitializeCharacterSets();
-
- // YWB: Ignore colons as token separators in COM_Parse
- static bool com_ignorecolons = false;
- characterset_t& breaks = pCharSet ? *pCharSet : (com_ignorecolons ? g_BreakSet : g_BreakSetIncludingColons);
-
- int c;
- unsigned int len = 0;
-
-// skip whitespace
-skipwhite:
-
- while ( (c = *pFileBytes) <= ' ')
- {
- if (c == 0)
- return 0; // end of file;
- pFileBytes++;
- }
-
-// skip // comments
- if (c=='/' && pFileBytes[1] == '/')
- {
- while (*pFileBytes && *pFileBytes != '\n')
- pFileBytes++;
- goto skipwhite;
- }
-
-// skip c-style comments
- if (c=='/' && pFileBytes[1] == '*' )
- {
- // Skip "/*"
- pFileBytes += 2;
-
- while ( *pFileBytes )
- {
- if ( *pFileBytes == '*' &&
- pFileBytes[1] == '/' )
- {
- pFileBytes += 2;
- break;
- }
-
- pFileBytes++;
- }
-
- goto skipwhite;
- }
-
-// handle quoted strings specially
- if (c == '\"')
- {
- if (pWasQuoted)
- *pWasQuoted = true;
-
- pFileBytes++;
- while (1)
- {
- c = *pFileBytes++;
- if (c=='\"' || !c)
- {
- pTokenOut[len] = 0;
- return pFileBytes;
- }
- pTokenOut[len] = c;
- len += ( len < nMaxTokenLen-1 ) ? 1 : 0;
- }
- }
-
-// parse single characters
- if ( IN_CHARACTERSET( breaks, c ) )
- {
- pTokenOut[len] = c;
- len += ( len < nMaxTokenLen-1 ) ? 1 : 0;
- pTokenOut[len] = 0;
- return pFileBytes+1;
- }
-
-// parse a regular word
- do
- {
- pTokenOut[len] = c;
- pFileBytes++;
- len += ( len < nMaxTokenLen-1 ) ? 1 : 0;
- c = *pFileBytes;
- if ( IN_CHARACTERSET( breaks, c ) )
- break;
- } while (c>32);
-
- pTokenOut[len] = 0;
- return pFileBytes;
-}
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=====================================================================================// + +#include "filesystem.h" +#include "filesystem_helpers.h" +#include "characterset.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +// wordbreak parsing set +static characterset_t g_BreakSet, g_BreakSetIncludingColons; + +static void InitializeCharacterSets() +{ + static bool s_CharacterSetInitialized = false; + if (!s_CharacterSetInitialized) + { + CharacterSetBuild( &g_BreakSet, "{}()'" ); + CharacterSetBuild( &g_BreakSetIncludingColons, "{}()':" ); + s_CharacterSetInitialized = true; + } +} + + +const char* ParseFileInternal( const char* pFileBytes, char* pTokenOut, bool* pWasQuoted, characterset_t *pCharSet, size_t nMaxTokenLen ) +{ + pTokenOut[0] = 0; + + if (pWasQuoted) + *pWasQuoted = false; + + if (!pFileBytes) + return 0; + + InitializeCharacterSets(); + + // YWB: Ignore colons as token separators in COM_Parse + static bool com_ignorecolons = false; + characterset_t& breaks = pCharSet ? *pCharSet : (com_ignorecolons ? g_BreakSet : g_BreakSetIncludingColons); + + int c; + unsigned int len = 0; + +// skip whitespace +skipwhite: + + while ( (c = *pFileBytes) <= ' ') + { + if (c == 0) + return 0; // end of file; + pFileBytes++; + } + +// skip // comments + if (c=='/' && pFileBytes[1] == '/') + { + while (*pFileBytes && *pFileBytes != '\n') + pFileBytes++; + goto skipwhite; + } + +// skip c-style comments + if (c=='/' && pFileBytes[1] == '*' ) + { + // Skip "/*" + pFileBytes += 2; + + while ( *pFileBytes ) + { + if ( *pFileBytes == '*' && + pFileBytes[1] == '/' ) + { + pFileBytes += 2; + break; + } + + pFileBytes++; + } + + goto skipwhite; + } + +// handle quoted strings specially + if (c == '\"') + { + if (pWasQuoted) + *pWasQuoted = true; + + pFileBytes++; + while (1) + { + c = *pFileBytes++; + if (c=='\"' || !c) + { + pTokenOut[len] = 0; + return pFileBytes; + } + pTokenOut[len] = c; + len += ( len < nMaxTokenLen-1 ) ? 1 : 0; + } + } + +// parse single characters + if ( IN_CHARACTERSET( breaks, c ) ) + { + pTokenOut[len] = c; + len += ( len < nMaxTokenLen-1 ) ? 1 : 0; + pTokenOut[len] = 0; + return pFileBytes+1; + } + +// parse a regular word + do + { + pTokenOut[len] = c; + pFileBytes++; + len += ( len < nMaxTokenLen-1 ) ? 1 : 0; + c = *pFileBytes; + if ( IN_CHARACTERSET( breaks, c ) ) + break; + } while (c>32); + + pTokenOut[len] = 0; + return pFileBytes; +} |