When we added input filtering in v4.2.21, we missed the execute
command. Because of that, funny characters can be treated differently
in batch files.
The main command loop uses getcommand(), which filters input.
execute() uses recvclient() directly, and doesn't filter input. Both
feed the command to parse(), which drops unwanted control and
non-ASCII characters.
Input filtering drops unwanted control characters and, for ASCII
sessions, replaces non-ASCII characters by '?'.
Because of that, execute in ASCII sessions drops non-ASCII command
characters in batch files rather than replacing them.
Except where parts of the command are used raw: execute's command
echo, flash and wall message argument. There, unwanted control
characters aren't dropped in UTF-8 sessions, and non-ASCII characters
are interpreted as UTF-8 in ASCII sessions. Output filtering replaces
any resulting non-ASCII characters.
players column "last command" also uses the command raw, but commands
executed from batch files are not visible there, so it isn't affected.
To get rid of the differences, move the prompting from getcommand() to
command(), then switch execute() over to getcommand().
Side effect: the batch file's commands are now recorded in
player_commands[]. That's desirable.
int
getcommand(char *combufp)
{
int
getcommand(char *combufp)
{
- struct natstr *natp = getnatp(player->cnum);
char buf[1024]; /* user text */
char buf[1024]; /* user text */
- prprompt(natp->nat_timeused / 60, natp->nat_btu);
if (recvclient(buf, sizeof(buf)) < 0)
return -1;
if (recvclient(buf, sizeof(buf)) < 0)
return -1;
static int
command(void)
{
static int
command(void)
{
+ struct natstr *natp = getnatp(player->cnum);
char *redir; /* UTF-8 */
char scanspace[1024];
time_t now;
char *redir; /* UTF-8 */
char scanspace[1024];
time_t now;
+ prprompt(natp->nat_timeused / 60, natp->nat_btu);
if (getcommand(player->combuf) < 0)
return player->aborted;
now = time(NULL);
update_timeused(now);
if (getcommand(player->combuf) < 0)
return player->aborted;
now = time(NULL);
update_timeused(now);
- if (!player->god && !may_play_now(getnatp(player->cnum), now))
+ if (!player->god && !may_play_now(natp, now))
return 0;
if (parse(player->combuf, scanspace, player->argp, player->comtail,
return 0;
if (parse(player->combuf, scanspace, player->argp, player->comtail,
while (!failed && status()) {
player->nstat &= ~EXEC;
while (!failed && status()) {
player->nstat &= ~EXEC;
- if (recvclient(buf, sizeof(buf)) < 0)
+ if (getcommand(buf) < 0)
break;
if (parse(buf, scanspace, player->argp, player->comtail,
&player->condarg, &redir) < 0) {
break;
if (parse(buf, scanspace, player->argp, player->comtail,
&player->condarg, &redir) < 0) {