public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "steffen at sdaoden dot eu" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug libc/29913] iconv(3) is not POSIX compliant, and does not conform to linux man-pages manual
Date: Sun, 19 Feb 2023 01:58:39 +0000	[thread overview]
Message-ID: <bug-29913-131-6Xyq5H21mm@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-29913-131@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=29913

--- Comment #6 from Steffen Nurpmeso <steffen at sdaoden dot eu> ---
Do not know how to relate (unless you did by noting).

Linux man says

  The conversion can stop for four reasons

then the only thing that may match is

  An invalid multibyte sequence is encountered in the input

and that is not what is going on.
It is not an invalid input.

And no, iconv users surely always have to be prepared for a loop i would say,
just in case the input has a problem and needs to be replaced with a
replacement character.

That gnulib snippet is terrible.  I have such a thing also in order to be able
to perform an iconv test (we pass through what the lib does).
For example, this snippet was in the program i took maintainership over before
2004:


/*
 * Fault-tolerant iconv() function.
 */
static size_t
iconv_ft(iconv_t cd, char **inb, size_t *inbleft, char **outb, size_t
*outbleft)
{
        size_t sz = 0;

        while ((sz = iconv(cd, inb, inbleft, outb, outbleft)) == (size_t)-1
                        && (errno == EILSEQ || errno == EINVAL)) {
                if (*inbleft > 0) {
                        (*inb)++;
                        (*inbleft)--;
                } else {
                        **outb = '\0';
                        break;
                }
                if (*outbleft > 0) {
                        *(*outb)++ = '?';
                        (*outbleft)--;
                } else {
                        **outb = '\0';
                        break;
                }
        }
        return sz;
}

Instead GNU should have reused the EINVAL error for this case.  Or IO, NODATA,
NOENT, NOMSG, NOTSUP, NOSYS, NOTOBACCO.

Anyhow, that gnulib snippet was a shock.  What a mess.

The problem with the GNU approach is that portable software that glues to the
POSIX standard and/or reads the Linux manual has to perform a lot of checks in
order to find out whether the native iconv supports / wants //TRANSLIT to get
the behaviour that the standard describes.

At least in my opinion.
And, as you say, all others but GNU follow this.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2023-02-19  1:58 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-16 23:03 [Bug libc/29913] New: " steffen at sdaoden dot eu
2023-02-18 20:48 ` [Bug libc/29913] " rrt at sc3d dot org
2023-02-18 21:20 ` rrt at sc3d dot org
2023-02-18 22:43 ` steffen at sdaoden dot eu
2023-02-19  0:40 ` bruno at clisp dot org
2023-02-19  0:51 ` bruno at clisp dot org
2023-02-19  1:58 ` steffen at sdaoden dot eu [this message]
2023-02-19 10:06 ` rrt at sc3d dot org
2023-02-19 10:15 ` rrt at sc3d dot org
2023-02-19 10:22 ` rrt at sc3d dot org
2023-02-19 22:57 ` steffen at sdaoden dot eu
2023-02-19 23:02 ` steffen at sdaoden dot eu
2023-02-20 20:09 ` steffen at sdaoden dot eu
2023-02-20 20:54 ` steffen at sdaoden dot eu
2023-02-20 21:52 ` steffen at sdaoden dot eu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-29913-131-6Xyq5H21mm@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).