mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 11:32:48 -05:00
Switch CONF_remote_cmd to being STR_AMBI.
The immediate usefulness of this is in pterm.exe: when the user uses -e to specify a command to run in the pterm, we retrieve the command in Unicode, store it in CONF_remote_cmd as UTF-8, and then in conpty.c we can extract it in the same form and convert it back to Unicode to pass losslessly to CreateProcessW. So now non-ACP Unicode works in that part of the pterm command line.
This commit is contained in:
@ -176,7 +176,7 @@ static char *conpty_init(const BackendVtable *vt, Seat *seat,
|
||||
HPCON pcon;
|
||||
bool pcon_needs_cleanup = false;
|
||||
|
||||
STARTUPINFOEX si;
|
||||
STARTUPINFOEXW si;
|
||||
memset(&si, 0, sizeof(si));
|
||||
|
||||
if (!init_conpty_api()) {
|
||||
@ -238,16 +238,21 @@ static char *conpty_init(const BackendVtable *vt, Seat *seat,
|
||||
PROCESS_INFORMATION pi;
|
||||
memset(&pi, 0, sizeof(pi));
|
||||
|
||||
char *command;
|
||||
const char *conf_cmd = conf_get_str(conf, CONF_remote_cmd);
|
||||
if (*conf_cmd) {
|
||||
command = dupstr(conf_cmd);
|
||||
} else {
|
||||
command = dupcat(get_system_dir(), "\\cmd.exe");
|
||||
wchar_t *command;
|
||||
{
|
||||
bool utf8;
|
||||
const char *conf_cmd = conf_get_str_ambi(conf, CONF_remote_cmd, &utf8);
|
||||
if (*conf_cmd) {
|
||||
command = dup_mb_to_wc(utf8 ? CP_UTF8 : CP_ACP, conf_cmd);
|
||||
} else {
|
||||
char *cmd = dupcat(get_system_dir(), "\\cmd.exe");
|
||||
command = dup_mb_to_wc(CP_ACP, cmd);
|
||||
sfree(cmd);
|
||||
}
|
||||
}
|
||||
bool created_ok = CreateProcess(NULL, command, NULL, NULL,
|
||||
false, EXTENDED_STARTUPINFO_PRESENT,
|
||||
NULL, NULL, &si.StartupInfo, &pi);
|
||||
bool created_ok = CreateProcessW(NULL, command, NULL, NULL,
|
||||
false, EXTENDED_STARTUPINFO_PRESENT,
|
||||
NULL, NULL, &si.StartupInfo, &pi);
|
||||
sfree(command);
|
||||
if (!created_ok) {
|
||||
err = dupprintf("CreateProcess: %s",
|
||||
|
@ -82,8 +82,8 @@ static SeatPromptResult plink_get_userpass_input(Seat *seat, prompts_t *p)
|
||||
|
||||
static bool plink_seat_interactive(Seat *seat)
|
||||
{
|
||||
return (!*conf_get_str(conf, CONF_remote_cmd) &&
|
||||
!*conf_get_str(conf, CONF_remote_cmd2) &&
|
||||
return (!*conf_get_str_ambi(conf, CONF_remote_cmd, NULL) &&
|
||||
!*conf_get_str_ambi(conf, CONF_remote_cmd2, NULL) &&
|
||||
!*conf_get_str(conf, CONF_ssh_nc_host));
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,8 @@ void gui_term_process_cmdline(Conf *conf, char *cmdline)
|
||||
if (nextarg) {
|
||||
/* The command to execute is taken to be the unparsed
|
||||
* version of the whole remainder of the command line. */
|
||||
char *cmd = cmdline_arg_remainder_acp(nextarg);
|
||||
conf_set_str(conf, CONF_remote_cmd, cmd);
|
||||
char *cmd = cmdline_arg_remainder_utf8(nextarg);
|
||||
conf_set_utf8(conf, CONF_remote_cmd, cmd);
|
||||
sfree(cmd);
|
||||
return;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user