MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / stripRepeatSlashes

Function stripRepeatSlashes

Engine/source/console/console.cpp:2390–2430  ·  view source on GitHub ↗

-----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

2388
2389//-----------------------------------------------------------------------------
2390bool stripRepeatSlashes(char* pDstPath, const char* pSrcPath, S32 dstSize)
2391{
2392 // Note original destination.
2393 char* pOriginalDst = pDstPath;
2394
2395 // Reset last source character.
2396 char lastSrcChar = 0;
2397
2398 // Search source...
2399 while (dstSize > 0)
2400 {
2401 // Fetch characters.
2402 const char srcChar = *pSrcPath++;
2403
2404 // Do we have a repeat slash?
2405 if (srcChar == '/' && lastSrcChar == '/')
2406 {
2407 // Yes, so skip it.
2408 continue;
2409 }
2410
2411 // No, so copy character.
2412 *pDstPath++ = srcChar;
2413
2414 // Finish if end of source.
2415 if (srcChar == 0)
2416 return true;
2417
2418 // Reduce room left in destination.
2419 dstSize--;
2420
2421 // Set last character.
2422 lastSrcChar = srcChar;
2423 }
2424
2425 // Terminate the destination string as we ran out of room.
2426 *pOriginalDst = 0;
2427
2428 // Fail!
2429 return false;
2430}
2431
2432} // end of Console namespace
2433

Callers 3

addPathExpandoFunction · 0.85
expandPathFunction · 0.85
collapsePathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected