mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 05:50:26 +02:00
(scm_peek_char): Safe the column of the port around the getc/ungetc
calls. Thanks to Dr. Peter Ivanyi!
This commit is contained in:
parent
ae0bdfe00d
commit
1a973c42e2
1 changed files with 3 additions and 1 deletions
|
@ -1198,15 +1198,17 @@ SCM_DEFINE (scm_peek_char, "peek-char", 0, 1, 0,
|
||||||
"to @code{read-char} would have hung.}")
|
"to @code{read-char} would have hung.}")
|
||||||
#define FUNC_NAME s_scm_peek_char
|
#define FUNC_NAME s_scm_peek_char
|
||||||
{
|
{
|
||||||
int c;
|
int c, column;
|
||||||
if (SCM_UNBNDP (port))
|
if (SCM_UNBNDP (port))
|
||||||
port = scm_cur_inp;
|
port = scm_cur_inp;
|
||||||
else
|
else
|
||||||
SCM_VALIDATE_OPINPORT (1, port);
|
SCM_VALIDATE_OPINPORT (1, port);
|
||||||
|
column = SCM_COL(port);
|
||||||
c = scm_getc (port);
|
c = scm_getc (port);
|
||||||
if (EOF == c)
|
if (EOF == c)
|
||||||
return SCM_EOF_VAL;
|
return SCM_EOF_VAL;
|
||||||
scm_ungetc (c, port);
|
scm_ungetc (c, port);
|
||||||
|
SCM_COL(port) = column;
|
||||||
return SCM_MAKE_CHAR (c);
|
return SCM_MAKE_CHAR (c);
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue