There is a bug in stata, that the end-of-line (EOL) symbol does not separate the comment symbol and combinations such as “/*” or “\*” end a comment and run the next executable line in comment unexpectedly. For example, code with comment:
* comment here
* also see D:\folder1\subfolder2\
* some executable code in stata[unexpected execution]
* some executable code in stata[will not be executed since with a new asterisks]
This would cause line 3 of the code to run without any awareness. The reason is that * and \ constitutes the end of comment symbol “\*”, which stops the comment even there is no “\*” to begin the comment in the upper section.
The issue is not solved up to now till Stata 17. Users must pay attention to any executable code in comment usage. I found a way to avoid comment execution, just add the snippet “[Avoid_execution]” at the end of possible executed code in the comment section. For example, here is our comment section:
/*
* This file is located in D:\project1\folder2\subfolder3\
* code executable #1
* code executable #2
*/
Here, code executable #1 gets executed though it is in the comment section. It is because the previous line backslash “\” and the code #1 line * forms the end of a comment “\*“. To avoid that case, we add the snippet “[Avoid_execution]” at the end of executable lines, which becomes:
/*
* This file is located in D:\project1\folder2\subfolder3\
* code executable #1 [Avoid_execution]
* code executable #2 [Avoid_execution]
*/
Then nothing gets executed. If it does, at least the user will be notified with an error in the terminal.
Maybe the issue exists for various EOL(end of line) symbols across OSs. The MS-DOS and MS windows systems marks CR(Carriage Return) LF(Line feed) “\r\n”( 0x0D (13 decimal) and 0x0A (10 decimal) ) as a end line, while Linux (and c programming language) only accepts LF(Line feed) “\n” and Mac OS only accepts CR(Carriage Return) “\r”. Stata supports all these 3 platforms and the designers of Stata decide to settle the difference via ignoring the entire EOL symbol. That’s where the bug comes from.