[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] core: Fix unreadchar on string port when unreading EOF.
From: |
Jan Nieuwenhuizen |
Subject: |
Re: [PATCH] core: Fix unreadchar on string port when unreading EOF. |
Date: |
Mon, 15 Jun 2020 07:01:26 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) |
Danny Milosavljevic writes:
> * src/posix.c (unreadchar): Fix on string port when unreading EOF.
> ---
> src/posix.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/src/posix.c b/src/posix.c
> index fd753232..0ef1a599 100644
> --- a/src/posix.c
> +++ b/src/posix.c
> @@ -71,6 +71,8 @@ unreadchar (int c)
> {
> if (__stdin >= 0)
> return fdungetc (c, __stdin);
> + if (c == EOF) // can't unread EOF
> + return c;
> SCM port = current_input_port ();
> SCM string = STRING (port);
> size_t length = LENGTH (string);
Nice, LGTM!
Thanks, Janneke
PS: Ah ... and here's the EOF / -1 return -- missed that. "clever"
char *p = CSTRING (string);
p--;
--
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | AvatarĀ® http://AvatarAcademy.com