[patch] scp + UTF-8

Darren Tucker
Tue, 19 Jan 2016 22:39:33 -0000

On Wed, Jan 20, 2016 at 8:48 AM, Ingo Schwarze <schwarze at usta.de>
wrote:
> Hi,
>
> Martijn sent the following patch to me in private and agreed that i post
> it here.
>
> In any other program in OpenBSD base, i'd probably agree with the
> basic approach.  Regarding OpenSSH, however, i worry whether wcwidth(3)
> can be used.  While wcwidth(3) is POSIX, it is not ISO C.  Does
> OpenSSH target platforms that don't provide wcwidth(3)?

OpenSSH nominally targets POSIX, but it builds on a wide enough range
of platforms that it's likely at least some don't have it.

Our general approach is to target POSIX then implement any needed
missing bits either by stealing the implementation from OpenBSD, some
other BSD licensed source or writing from scratch.  If we have to
we'll ifdef stuff but prefer not to.

> If so,
> do you think the problem can be solved by simply providing US-ASCII
> support only on such platforms, but no UTF-8 support at all?

Yes.  That's what I did with mblen when we picked up a need for that
via libedit for platforms with no wide character support.

$ grep -i mblen openbsd-compat/*.h
openbsd-compat/openbsd-compat.h:#ifndef HAVE_MBLEN
openbsd-compat/openbsd-compat.h:# define mblen(x, y)  (1)

Is there any reason the same approach would not work with wcwidth?

[...]
> P.S.
> This patch also uses mbtowc(3), but i assume that's no problem
> because that's ANSI C.

I would not assume that its existence in the standard is equal to its
existence in all deployments :-)  That said it looks like we can
implement it in libcompat if needed.

--
Darren Tucker (dtucker at zip.com.au)
GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4  37C9 C982 80C7 8FF4 FA69
    Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.