Re: bug report: symbolic-ref --short command echos the wrong text while use Chinese language
- From
Jeff King <peff@peff.net>
- Date
- Feb 14, 2023, 17:40 UTC
- Message-ID
- <Y+vHebrL6Uuv+HR/@coredump.intra.peff.net>
- In-Reply-To
- <xmqqk00k6w08.fsf@gitster.g>
On Tue, Feb 14, 2023 at 08:40:23AM -0800, Junio C Hamano wrote:
Show 14 quoted lines
> Jeff King <peff@peff.net> writes: > > > Oof. So it is some weird locale thing that scanf is doing. I don't even > > want to think about what the details could be. ;) > > > > Since scanf is such a bad and error-prone interface in the first place > > (and I'd actually like to put it on the banned list), what about just > > parsing manually here? > > Me likee. > > This will eradicate the only use of sscanf() from the tree; > unfortunately there is a topic that adds a new one or two back in > flight X-<.
Sadly, not quite. There's one in test-date.c, though it would be pretty easy to convert to strtol() or similar. But there's also an fscanf() in builtin/gc.c. To my mind, fscanf() is even worse, as you cannot know the size of the "%s" you're about to receive (the case here works around it with a max-size specifier, so I don't think it's buggy, but the contortions one must go through seem...not worth it).
-Peff