1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-18 11:31:00 -05:00

Change type of CONF_username to the new CONF_TYPE_STR_AMBI.

This is the pathfinding change that proves it's possible for _one_
Conf setting to become Unicode-capable.

That seems like quite a small reward for all the refactoring in the
previous patches this week! But changing over one configuration
setting is enough to get started with: once all the bugs are out of
this one, we can try switching over some more.

Changing the type to CONF_TYPE_STR_AMBI is enough by itself to make
the configuration dialog box write it into Conf as UTF-8, because
conf_editbox_handler automatically checks whether that possibility is
available. However, setting the same Conf entry from the command line
isn't automatic: I had to add code in the handler for the -l
command-line option in cmdline.c.

This commit also doesn't yet handle the _other_ way to specify a
username on the command line: including it as part of the hostname
argument via "putty user@host" or similar. That's more difficult,
because it also requires deciding what to do about UTF-8 in the actual
hostname.

(That looks as if it ought to be possible: Windows should be able to
handle looking up Unicode hostnames if you use GetAddrInfoW() in place
of getaddrinfo(). But plumbing it through everything in between
cmdline.c and windows/network.c is a bigger job than I'm prepared to
do in this proof-of-concept commit.)
This commit is contained in:
Simon Tatham
2024-09-23 16:59:11 +01:00
parent 841bf321d4
commit b57fb48b27
6 changed files with 12 additions and 6 deletions

View File

@ -195,6 +195,7 @@ int cmdline_process_param(CmdlineArg *arg, CmdlineArg *nextarg,
{
int ret = 0;
const char *p = cmdline_arg_to_str(arg);
const char *value_utf8 = cmdline_arg_to_utf8(nextarg);
const char *value = cmdline_arg_to_str(nextarg);
if (p[0] != '-') {
@ -459,7 +460,10 @@ int cmdline_process_param(CmdlineArg *arg, CmdlineArg *nextarg,
RETURN(2);
UNAVAILABLE_IN(TOOLTYPE_NONNETWORK);
SAVEABLE(0);
conf_set_str(conf, CONF_username, value);
if (value_utf8)
conf_set_utf8(conf, CONF_username, value_utf8);
else
conf_set_str(conf, CONF_username, value);
}
if (!strcmp(p, "-loghost")) {
RETURN(2);