Inform on unexpected control characters in batch files

This commit informs the user when an illegal character is
encounter in a batch file.  It does not change the actual
parsing or handling of the illegal character, which is to
skip the character.

Because some control characters are invisible when TYPE'd
on the command line or viewed in an editor, this messaging
will alert users that something is (very likely) amiss in
their batch file and could be the cause for unexpected
behavior or parsing.

patch by kcgen ported from dosbox-staging
be07ddb031
This commit is contained in:
rderooy 2020-06-15 14:11:49 +02:00
parent b59c73d2a1
commit 0aad6c3ddf
2 changed files with 10 additions and 2 deletions

View File

@ -878,6 +878,8 @@ void SHELL_Init() {
MSG_Add("SHELL_CMD_HELP","If you want a list of all supported commands type \033[33;1mHELP /ALL\033[0m.\nA short list of the most often used commands:\n");
MSG_Add("SHELL_CMD_ECHO_ON","ECHO is on.\n");
MSG_Add("SHELL_CMD_ECHO_OFF","ECHO is off.\n");
MSG_Add("SHELL_ILLEGAL_CONTROL_CHARACTER",
"Unexpected control character: Dec %03u and Hex %#04x.\n");
MSG_Add("SHELL_ILLEGAL_SWITCH","Illegal switch: %s.\n");
MSG_Add("SHELL_MISSING_PARAMETER","Required parameter missing.\n");
MSG_Add("SHELL_CMD_CHDIR_ERROR","Unable to change to: %s.\n");

View File

@ -73,7 +73,10 @@ emptyline:
//So we continue reading till EOL/EOF
if (((cmd_write - temp) + 1) < (CMD_MAXLINE - 1))
*cmd_write++ = (char)c;
}
} else {
if (c != '\n' && c != '\r')
shell->WriteOut(MSG_Get("SHELL_ILLEGAL_CONTROL_CHARACTER"), c, c);
}
}
} while (c!='\n' && n);
*cmd_write=0;
@ -176,7 +179,10 @@ again:
if (c>31) {
if (((cmd_write - cmd_buffer) + 1) < (CMD_MAXLINE - 1))
*cmd_write++ = (char)c;
}
} else {
if (c != '\n' && c != '\r')
shell->WriteOut(MSG_Get("SHELL_ILLEGAL_CONTROL_CHARACTER"), c, c);
}
}
} while (c!='\n' && n);
*cmd_write++ = 0;