git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] config: do not ungetc EOF

From
Heiko Voigt <hvoigt@hvoigt.net>
Date
Feb 8, 2015, 21:22 UTC
Message-ID
<20150208212220.GB3796@book.hvoigt.net>
In-Reply-To
<20150205212847.GA2360@peff.net>
On Thu, Feb 05, 2015 at 04:28:47PM -0500, Jeff King wrote:
Show 28 quoted lines
> On Thu, Feb 05, 2015 at 01:16:36PM -0800, Junio C Hamano wrote:
> 
> > Jeff King <peff@peff.net> writes:
> > 
> > > On Thu, Feb 05, 2015 at 01:53:27AM -0500, Jeff King wrote:
> > >
> > >> I also notice that config_buf_ungetc does not actually ungetc the
> > >> character we give it; it just rewinds one character in the stream. This
> > >> is fine, because we always feed the last-retrieved character. I dunno if
> > >> it is worth fixing (it also would have fixed this infinite loop, but for
> > >> the wrong reason; we would have stuck "-1" back into the stream, and
> > >> retrieved it on the next fgetc rather than the same '\r' over and over).
> > >
> > > Here's a patch to deal with that. I'm not sure if it's worth doing or
> > > not.
> > 
> > I am not sure, either.  If this were to become stdio emulator over
> > random in-core data used throughout the system, perhaps.
> > 
> > But in its current form it is tied to the implementation of config.c
> > very strongly, so...
> 
> Yeah, that was my thinking, and why I have doubts. Maybe a comment would
> make more sense, like the patch below. I am also OK with just leaving
> it as-is.
> 
> -- >8 --
> Subject: [PATCH] config_buf_ungetc: document quirks in a comment

I think a comment would be fine as well. Both helps to quickly find the cause why our ungetc() might not behave as the caller expects. But I think one of both would be good so we document that this behavior is in fact intentional.

Cheers Heiko
Previous: Jeff KingNext: Heiko Voigt
Message 5 of 6 in “config: do not ungetc EOF”
  1. config: do not ungetc EOFJeff King, Feb 5, 2015
  2. Jeff KingFeb 5, 2015
  3. Junio C HamanoFeb 5, 2015
  4. Jeff KingFeb 5, 2015
  5. Heiko VoigtFeb 8, 2015
  6. Heiko VoigtFeb 8, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.