MCPcopy Create free account
hub / github.com/boostorg/build / process_command

Function process_command

src/engine/debugger.cpp:2643–2698  ·  view source on GitHub ↗

Parses a single command into whitespace separated tokens, and runs it. */

Source from the content-addressed store, hash-verified

2641
2642/* Parses a single command into whitespace separated tokens, and runs it. */
2643static int process_command( char * line )
2644{
2645 int result;
2646 size_t capacity = 8;
2647 char * * buffer = (char **)malloc( capacity * sizeof( char * ) );
2648 char * * current = buffer;
2649 char * iter = line;
2650 char * saved = iter;
2651 *current = iter;
2652 for ( ; ; )
2653 {
2654 /* skip spaces */
2655 while ( *iter && isspace( *iter ) )
2656 {
2657 ++iter;
2658 }
2659 if ( ! *iter )
2660 {
2661 break;
2662 }
2663 /* Find the next token */
2664 saved = iter;
2665 if ( *iter == '\"' )
2666 {
2667 saved = ++iter;
2668 /* FIXME: handle escaping */
2669 while ( *iter && *iter != '\"' )
2670 {
2671 ++iter;
2672 }
2673 }
2674 else
2675 {
2676 while ( *iter && ! isspace( *iter ) )
2677 {
2678 ++iter;
2679 }
2680 }
2681 /* resize the buffer if necessary */
2682 if ( current == buffer + capacity )
2683 {
2684 buffer = (char**)realloc( (void *)buffer, capacity * 2 * sizeof( char * ) );
2685 current = buffer + capacity;
2686 }
2687 /* append the token to the buffer */
2688 *current++ = saved;
2689 /* null terminate the token */
2690 if ( *iter )
2691 {
2692 *iter++ = '\0';
2693 }
2694 }
2695 result = run_command( int(current - buffer), (const char **)buffer );
2696 free( (void *)buffer );
2697 return result;
2698}
2699
2700static int read_command( void )

Callers 2

read_commandFunction · 0.85

Calls 1

run_commandFunction · 0.85

Tested by

no test coverage detected