MCPcopy Create free account
hub / github.com/AppleWin/AppleWin / Colorize

Function Colorize

source/Debugger/Debugger_Help.cpp:292–399  ·  view source on GitHub ↗

TODO: Use nDstSz to prevent buffer overflow. Alternatively, Colorize() may simply return a std::string.

Source from the content-addressed store, hash-verified

290// TODO: Use nDstSz to prevent buffer overflow.
291// Alternatively, Colorize() may simply return a std::string.
292bool Colorize( char * pDst, size_t /*nDstSz*/, const char* pSrc)
293{
294 if (! pSrc)
295 return false;
296
297 if (! pDst)
298 return false;
299
300 const char sNote [] = "Note:";
301 const int nNote = sizeof( sNote ) - 1;
302
303 const char sSeeAlso[] = "See also:";
304 const char nSeeAlso = sizeof( sSeeAlso ) - 1;
305
306 const char sUsage[] = "Usage:";
307 const int nUsage = sizeof( sUsage ) - 1;
308
309 const char sTotal[] = "Total:";
310 const int nTotal = sizeof( sTotal ) - 1;
311
312 const char sExamples[] = "Examples:";
313 const int nExamples = sizeof( sExamples ) - 1;
314
315 while (*pSrc)
316 {
317 if (strncmp( sUsage, pSrc, nUsage) == 0)
318 {
319 _ColorizeHeader( pDst, pSrc, sUsage, nUsage );
320 }
321 else
322 if (strncmp( sSeeAlso, pSrc, nSeeAlso) == 0)
323 {
324 _ColorizeHeader( pDst, pSrc, sSeeAlso, nSeeAlso );
325 }
326 else
327 if (strncmp( sNote, pSrc, nNote) == 0)
328 {
329 _ColorizeHeader( pDst, pSrc, sNote, nNote );
330 }
331 else
332 if (strncmp( sTotal, pSrc, nNote) == 0)
333 {
334 _ColorizeHeader( pDst, pSrc, sTotal, nTotal );
335 }
336 else
337 if (strncmp( sExamples, pSrc, nExamples) == 0)
338 {
339 _ColorizeHeader( pDst, pSrc, sExamples, nExamples );
340 }
341 else
342 if (*pSrc == '[')
343 {
344 _ColorizeOperator( pDst, pSrc, CHC_ARG_OPT );
345 }
346 else
347 if (*pSrc == ']')
348 {
349 _ColorizeOperator( pDst, pSrc, CHC_ARG_OPT );

Callers 1

ConsoleColorizePrintFunction · 0.85

Calls 4

_ColorizeHeaderFunction · 0.85
_ColorizeOperatorFunction · 0.85
isHexDigitFunction · 0.85
_ColorizeStringFunction · 0.85

Tested by

no test coverage detected