[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RFC: add a string-desc module
From: |
Bruno Haible |
Subject: |
Re: RFC: add a string-desc module |
Date: |
Wed, 29 Mar 2023 00:40:37 +0200 |
Paul Eggert wrote:
> > I'll add a comment regarding printf with the "%.*s" directive.
>
> That works only if the string lacks NULs
Ouch, indeed.
> and its length fits into int,
> and one must also convert the idx_t length to int (e.g., via a cast
> which I find tricky).
I've now documented that "%.*s" is NOT the solution.
> Although these limitations could be documented, it
> might also be good to have an API like quotearg to generate a quoted or
> quotable string that can be printed with plain %s.
Good point. I've added wrappers around the quotearg functions. Fortunately,
most of the quotearg functions already have a *_mem variant that was designed
precisely for this case.
Bruno