Description of Sample Command Line Images

I created a set of images to help visualize how various command lines are parsed. This page explains these images.

You should first review and understand the two command line parser states that I defined: InterpretSpecialChars and IgnoreSpecialChars.

Consider the following command line:

[Test.exe “First Argument” Second]

This command line is parsed identically by parse_cmdline and CommandLineToArgvW to generate the following arguments:

argv[0] = [Test.exe]
argv[1] = [First Argument]
argv[2] = [Second]

Below is the sample image for this command line. Green regions show where the parser is actively looking for whitespace to split the command line (parser state is InterpretSpecialChars). Red regions show where the parser is ignoring whitespace (parser state is IgnoreSpecialChars).

Blue lines are drawn around the arguments that are produced.

Numbers along the top marked with Red Arrows indicate characters that the parser will remove (footnotes indicate the reason for removal).

Numbers along the bottom marked with Blue Arrows indicate where the parser changed state (footnotes indicate the reason for the state change). A state change only occurs at a double quote character, and the background color of the double quote character that caused the change indicates the state when the character was read by the parser, not the color of the new state.

Characters marked with a black dot ( • ) are literal spaces.

Hovering over the image removes any characters that the parser would remove.