Discovering a Bug in Windows System Programming Edition 4

I’ve discovered a bug in the book Windows System Programming. The bugged code is stated below:

/* SkipArg.c
Skip one command line argument – skip tabs and spaces. */

#include “Everything.h”

LPTSTR SkipArg (LPCTSTR targv)
{
LPTSTR p;

p = (LPTSTR)targv;
/* Skip up to the next tab or space. */
while (*p != _T(”) && *p != _T(‘ ‘) && *p != _T(‘\t’)) p++;
/* Skip over tabs and spaces to the next arg. */
while (*p != _T(”) && (*p == _T(‘ ‘) || *p == _T(‘\t’))) p++;
return p;
}

This message was last reply from John (author of the book):

My apologies. I see what you’re talking about now. The correct solution, I think, is to fix SkipArg so that it accounts for quotes in the command line. I’ll take a look at it and send you the solution. SkipArg is used in other projects, so it’s worth fixing.
Thanks for pointing this out. Interestingly, in 17 years since Edition 1, no one seems to have noticed this problem, or, at least, no one has reported it.
John

Further you can check more details by searching for the word “‘Ogail” in the book’s web page.