Description of Sample Command Line Images

I’m a visual thinker, not a language-based thinker. My brain is like Google 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.

Image of Example Command Line Parse

  1. 3) Switch to IgnoreSpecialChars
  2. 4) Switch to InterpretSpecialChars
  3. 8) Single double quote character- Enter IgnoreSpecialChars
  4. 9) Single double quote character- Return to InterpretSpecialChars

Post a Comment