mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-11 16:20:19 +02:00
* ports.c (scm_port_line, scm_set_port_line_x, scm_port_column,
scm_set_port_column_x, scm_port_filename, scm_set_port_filename_x): Removed optional arguments. Added proper argument checking.
This commit is contained in:
parent
a74145b809
commit
360fc44c98
1 changed files with 39 additions and 75 deletions
114
libguile/ports.c
114
libguile/ports.c
|
@ -667,129 +667,93 @@ scm_unread_char (cobj, port)
|
||||||
return cobj;
|
return cobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCM_PROC (s_port_line, "port-line", 0, 1, 0, scm_port_line);
|
SCM_PROC (s_port_line, "port-line", 1, 0, 0, scm_port_line);
|
||||||
|
|
||||||
SCM
|
SCM
|
||||||
scm_port_line (port)
|
scm_port_line (port)
|
||||||
SCM port;
|
SCM port;
|
||||||
{
|
{
|
||||||
SCM p;
|
|
||||||
|
|
||||||
port = SCM_COERCE_OUTPORT (port);
|
port = SCM_COERCE_OUTPORT (port);
|
||||||
|
SCM_ASSERT (SCM_NIMP (port) && SCM_PORTP (port) && SCM_OPENP (port),
|
||||||
p = ((port == SCM_UNDEFINED)
|
port,
|
||||||
? scm_cur_inp
|
SCM_ARG1,
|
||||||
: port);
|
s_port_line);
|
||||||
if (!(SCM_NIMP (p) && SCM_PORTP (p)))
|
return SCM_MAKINUM (SCM_LINUM (port));
|
||||||
return SCM_BOOL_F;
|
|
||||||
else
|
|
||||||
return SCM_MAKINUM (SCM_LINUM (p));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SCM_PROC (s_set_port_line_x, "set-port-line!", 1, 1, 0, scm_set_port_line_x);
|
SCM_PROC (s_set_port_line_x, "set-port-line!", 2, 0, 0, scm_set_port_line_x);
|
||||||
|
|
||||||
SCM
|
SCM
|
||||||
scm_set_port_line_x (port, line)
|
scm_set_port_line_x (port, line)
|
||||||
SCM port;
|
SCM port;
|
||||||
SCM line;
|
SCM line;
|
||||||
{
|
{
|
||||||
if (line == SCM_UNDEFINED)
|
port = SCM_COERCE_OUTPORT (port);
|
||||||
{
|
SCM_ASSERT (SCM_NIMP (port) && SCM_PORTP (port) && SCM_OPENP (port),
|
||||||
line = port;
|
port,
|
||||||
port = scm_cur_inp;
|
SCM_ARG1,
|
||||||
}
|
s_set_port_line_x);
|
||||||
else
|
SCM_ASSERT (SCM_INUMP (line), line, SCM_ARG2, s_set_port_line_x);
|
||||||
{
|
|
||||||
port = SCM_COERCE_OUTPORT (port);
|
|
||||||
SCM_ASSERT (SCM_NIMP (port) && SCM_PORTP (port) && SCM_OPENP (port),
|
|
||||||
port,
|
|
||||||
SCM_ARG1,
|
|
||||||
s_set_port_line_x);
|
|
||||||
}
|
|
||||||
return SCM_PTAB_ENTRY (port)->line_number = SCM_INUM (line);
|
return SCM_PTAB_ENTRY (port)->line_number = SCM_INUM (line);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCM_PROC (s_port_column, "port-column", 0, 1, 0, scm_port_column);
|
SCM_PROC (s_port_column, "port-column", 1, 0, 0, scm_port_column);
|
||||||
|
|
||||||
SCM
|
SCM
|
||||||
scm_port_column (port)
|
scm_port_column (port)
|
||||||
SCM port;
|
SCM port;
|
||||||
{
|
{
|
||||||
SCM p;
|
|
||||||
|
|
||||||
port = SCM_COERCE_OUTPORT (port);
|
port = SCM_COERCE_OUTPORT (port);
|
||||||
|
SCM_ASSERT (SCM_NIMP (port) && SCM_PORTP (port) && SCM_OPENP (port),
|
||||||
p = ((port == SCM_UNDEFINED)
|
port,
|
||||||
? scm_cur_inp
|
SCM_ARG1,
|
||||||
: port);
|
s_port_column);
|
||||||
if (!(SCM_NIMP (p) && SCM_PORTP (p)))
|
return SCM_MAKINUM (SCM_COL (port));
|
||||||
return SCM_BOOL_F;
|
|
||||||
else
|
|
||||||
return SCM_MAKINUM (SCM_COL (p));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SCM_PROC (s_set_port_column_x, "set-port-column!", 1, 1, 0, scm_set_port_column_x);
|
SCM_PROC (s_set_port_column_x, "set-port-column!", 2, 0, 0, scm_set_port_column_x);
|
||||||
|
|
||||||
SCM
|
SCM
|
||||||
scm_set_port_column_x (port, column)
|
scm_set_port_column_x (port, column)
|
||||||
SCM port;
|
SCM port;
|
||||||
SCM column;
|
SCM column;
|
||||||
{
|
{
|
||||||
if (column == SCM_UNDEFINED)
|
port = SCM_COERCE_OUTPORT (port);
|
||||||
{
|
SCM_ASSERT (SCM_NIMP (port) && SCM_PORTP (port) && SCM_OPENP (port),
|
||||||
column = port;
|
port,
|
||||||
port = scm_cur_inp;
|
SCM_ARG1,
|
||||||
}
|
s_set_port_column_x);
|
||||||
else
|
SCM_ASSERT (SCM_INUMP (column), column, SCM_ARG2, s_set_port_column_x);
|
||||||
{
|
|
||||||
port = SCM_COERCE_OUTPORT (port);
|
|
||||||
SCM_ASSERT (SCM_NIMP (port) && SCM_PORTP (port) && SCM_OPENP (port),
|
|
||||||
port,
|
|
||||||
SCM_ARG1,
|
|
||||||
s_set_port_column_x);
|
|
||||||
}
|
|
||||||
return SCM_PTAB_ENTRY (port)->column_number = SCM_INUM (column);
|
return SCM_PTAB_ENTRY (port)->column_number = SCM_INUM (column);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCM_PROC (s_port_filename, "port-filename", 0, 1, 0, scm_port_filename);
|
SCM_PROC (s_port_filename, "port-filename", 1, 0, 0, scm_port_filename);
|
||||||
|
|
||||||
SCM
|
SCM
|
||||||
scm_port_filename (port)
|
scm_port_filename (port)
|
||||||
SCM port;
|
SCM port;
|
||||||
{
|
{
|
||||||
SCM p;
|
|
||||||
|
|
||||||
port = SCM_COERCE_OUTPORT (port);
|
port = SCM_COERCE_OUTPORT (port);
|
||||||
|
SCM_ASSERT (SCM_NIMP (port) && SCM_PORTP (port) && SCM_OPENP (port),
|
||||||
p = ((port == SCM_UNDEFINED)
|
port,
|
||||||
? scm_cur_inp
|
SCM_ARG1,
|
||||||
: port);
|
s_port_filename);
|
||||||
if (!(SCM_NIMP (p) && SCM_PORTP (p)))
|
return SCM_PTAB_ENTRY (port)->file_name;
|
||||||
return SCM_BOOL_F;
|
|
||||||
else
|
|
||||||
return SCM_PTAB_ENTRY (p)->file_name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SCM_PROC (s_set_port_filename_x, "set-port-filename!", 1, 1, 0, scm_set_port_filename_x);
|
SCM_PROC (s_set_port_filename_x, "set-port-filename!", 2, 0, 0, scm_set_port_filename_x);
|
||||||
|
|
||||||
SCM
|
SCM
|
||||||
scm_set_port_filename_x (port, filename)
|
scm_set_port_filename_x (port, filename)
|
||||||
SCM port;
|
SCM port;
|
||||||
SCM filename;
|
SCM filename;
|
||||||
{
|
{
|
||||||
if (filename == SCM_UNDEFINED)
|
port = SCM_COERCE_OUTPORT (port);
|
||||||
{
|
SCM_ASSERT (SCM_NIMP (port) && SCM_PORTP (port) && SCM_OPENP (port),
|
||||||
filename = port;
|
port,
|
||||||
port = scm_cur_inp;
|
SCM_ARG1,
|
||||||
}
|
s_set_port_filename_x);
|
||||||
else
|
/* We allow the user to set the filename to whatever he likes. */
|
||||||
{
|
|
||||||
port = SCM_COERCE_OUTPORT (port);
|
|
||||||
SCM_ASSERT (SCM_NIMP (port) && SCM_PORTP (port) && SCM_OPENP (port),
|
|
||||||
port,
|
|
||||||
SCM_ARG1,
|
|
||||||
s_set_port_filename_x);
|
|
||||||
}
|
|
||||||
return SCM_PTAB_ENTRY (port)->file_name = filename;
|
return SCM_PTAB_ENTRY (port)->file_name = filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue