A Possible Bug in Borland C/C++ Runtime Argument Parsing
2006年1月9日
I guess there is a bug in Borland C/C++ runtime argument parsing. In my program `rosh’, I often encounter strings like "C:/Program Files/Internet Explorer/. When this argument is passed to cmd, it will be interpreted as "C:Program FilesInternet Explorer\", and this form is passed on verbatim to the program called. If the program uses Borland C/C++ runtime argument parsing, for example, using argc and argv, it should parse it correctly as "C:\Program Files\Internet Explorer\" in C language. But I observed a strange result in my program cppath. It gets the string "C:\Program Files\Internet Explorer\"". I reviewed MSDN on the Microsoft C/C++ runtime argument parsing, and found that the result is not as specified in MSDN. So now I guess that this behaviour may be a bug. Note that this bug exists in Borland C++ Compiler 5.5, but it does not exist in Microsoft Visual C++ 6.0 SP5. I recompiled the cppath program using Microsoft Visual C++ 6.0 SP5, and it turned out to be all right.
This bug is worked-around in my librmosaic package (2011 version) in sourceforge.net/projects/winrosh, in the cmdtools_py3\librmosaic\msft\mscmd.c file. In addition, msft_decode_mscmdline and msft_destroy_mscmd_decode_rslt are the pair of functions that do the trick. For an example, please see mscmd_test.c, or you can find their use in tools (such as ntcp.tar or roshesc2.tar).