mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-22 04:30:19 +02:00
* ports.h (scm_port_table): remove file_name member for now, it seems
undesirable. * fports.c (scm_open_file): don't set file_name in PTAB. (prinfport): don't use file_name in PTAB. * ioext.c (scm_sys_duplicate_port): don't set file_name in PTAB. * ports.c (scm_add_to_port_table): don't intialize file_name. (scm_port_file_name): remove for now. * gc.c (scm_gc_mark): don't mark PTAB file_name. * fports.h (scm_mkfile): prototype deleted. * fports.c (scm_mkfile): merged into scm_open_file to simplify.
This commit is contained in:
parent
52859adfb9
commit
19639113d1
7 changed files with 56 additions and 53 deletions
|
@ -1,5 +1,17 @@
|
||||||
Sun Sep 15 03:58:29 1996 Gary Houston <ghouston@actrix.gen.nz>
|
Sun Sep 15 03:58:29 1996 Gary Houston <ghouston@actrix.gen.nz>
|
||||||
|
|
||||||
|
* ports.h (scm_port_table): remove file_name member for now, it seems
|
||||||
|
undesirable.
|
||||||
|
* fports.c (scm_open_file): don't set file_name in PTAB.
|
||||||
|
(prinfport): don't use file_name in PTAB.
|
||||||
|
* ioext.c (scm_sys_duplicate_port): don't set file_name in PTAB.
|
||||||
|
* ports.c (scm_add_to_port_table): don't intialize file_name.
|
||||||
|
(scm_port_file_name): remove for now.
|
||||||
|
* gc.c (scm_gc_mark): don't mark PTAB file_name.
|
||||||
|
|
||||||
|
* fports.h (scm_mkfile): prototype deleted.
|
||||||
|
* fports.c (scm_mkfile): merged into scm_open_file to simplify.
|
||||||
|
|
||||||
* debug.c, unif.c: use scm_out_of_range instead of
|
* debug.c, unif.c: use scm_out_of_range instead of
|
||||||
wta for range errors (ASSERT still needs work).
|
wta for range errors (ASSERT still needs work).
|
||||||
|
|
||||||
|
|
|
@ -140,41 +140,6 @@ scm_mode_bits (modes)
|
||||||
*
|
*
|
||||||
* Return the new port.
|
* Return the new port.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __STDC__
|
|
||||||
SCM
|
|
||||||
scm_mkfile (char * name, char * modes)
|
|
||||||
#else
|
|
||||||
SCM
|
|
||||||
scm_mkfile (name, modes)
|
|
||||||
char * name;
|
|
||||||
char * modes;
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
register SCM port;
|
|
||||||
FILE *f;
|
|
||||||
SCM_NEWCELL (port);
|
|
||||||
SCM_DEFER_INTS;
|
|
||||||
SCM_SYSCALL (f = fopen (name, modes));
|
|
||||||
if (!f)
|
|
||||||
{
|
|
||||||
SCM_ALLOW_INTS;
|
|
||||||
port = SCM_BOOL_F;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
struct scm_port_table * pt;
|
|
||||||
pt = scm_add_to_port_table (port);
|
|
||||||
SCM_SETPTAB_ENTRY (port, pt);
|
|
||||||
if (SCM_BUF0 & (SCM_CAR (port) = scm_tc16_fport | scm_mode_bits (modes)))
|
|
||||||
scm_setbuf0 (port);
|
|
||||||
SCM_SETSTREAM (port, (SCM)f);
|
|
||||||
SCM_PTAB_ENTRY (port)->file_name = scm_makfrom0str (name);
|
|
||||||
SCM_ALLOW_INTS;
|
|
||||||
}
|
|
||||||
return port;
|
|
||||||
}
|
|
||||||
|
|
||||||
SCM_PROC(s_open_file, "open-file", 2, 0, 0, scm_open_file);
|
SCM_PROC(s_open_file, "open-file", 2, 0, 0, scm_open_file);
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
SCM
|
SCM
|
||||||
|
@ -187,22 +152,42 @@ scm_open_file (filename, modes)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
SCM port;
|
SCM port;
|
||||||
|
FILE *f;
|
||||||
|
char *file;
|
||||||
|
char *mode;
|
||||||
|
|
||||||
SCM_ASSERT (SCM_NIMP (filename) && SCM_ROSTRINGP (filename), filename, SCM_ARG1, s_open_file);
|
SCM_ASSERT (SCM_NIMP (filename) && SCM_ROSTRINGP (filename), filename, SCM_ARG1, s_open_file);
|
||||||
SCM_ASSERT (SCM_NIMP (modes) && SCM_ROSTRINGP (modes), modes, SCM_ARG2, s_open_file);
|
SCM_ASSERT (SCM_NIMP (modes) && SCM_ROSTRINGP (modes), modes, SCM_ARG2, s_open_file);
|
||||||
if (SCM_SUBSTRP (filename))
|
if (SCM_SUBSTRP (filename))
|
||||||
filename = scm_makfromstr (SCM_ROCHARS (filename), SCM_ROLENGTH (filename), 0);
|
filename = scm_makfromstr (SCM_ROCHARS (filename), SCM_ROLENGTH (filename), 0);
|
||||||
if (SCM_SUBSTRP (modes))
|
if (SCM_SUBSTRP (modes))
|
||||||
modes = scm_makfromstr (SCM_ROCHARS (modes), SCM_ROLENGTH (modes), 0);
|
modes = scm_makfromstr (SCM_ROCHARS (modes), SCM_ROLENGTH (modes), 0);
|
||||||
port = scm_mkfile (SCM_ROCHARS (filename), SCM_ROCHARS (modes));
|
|
||||||
|
|
||||||
if (port == SCM_BOOL_F) {
|
file = SCM_ROCHARS (filename);
|
||||||
|
mode = SCM_ROCHARS (modes);
|
||||||
|
|
||||||
|
SCM_NEWCELL (port);
|
||||||
|
SCM_DEFER_INTS;
|
||||||
|
SCM_SYSCALL (f = fopen (file, mode));
|
||||||
|
if (!f)
|
||||||
|
{
|
||||||
scm_syserror_msg (s_open_file, "%S: %S",
|
scm_syserror_msg (s_open_file, "%S: %S",
|
||||||
scm_listify (scm_makfrom0str (strerror (errno)),
|
scm_listify (scm_makfrom0str (strerror (errno)),
|
||||||
filename,
|
filename,
|
||||||
SCM_UNDEFINED));
|
SCM_UNDEFINED));
|
||||||
/* Force the compiler to keep filename and modes alive. */
|
|
||||||
scm_cons (filename, modes);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
struct scm_port_table * pt;
|
||||||
|
|
||||||
|
pt = scm_add_to_port_table (port);
|
||||||
|
SCM_SETPTAB_ENTRY (port, pt);
|
||||||
|
if (SCM_BUF0 & (SCM_CAR (port) = scm_tc16_fport | scm_mode_bits (mode)))
|
||||||
|
scm_setbuf0 (port);
|
||||||
|
SCM_SETSTREAM (port, (SCM)f);
|
||||||
|
/* SCM_PTAB_ENTRY (port)->file_name = scm_makfrom0str (filename); */
|
||||||
|
}
|
||||||
|
SCM_ALLOW_INTS;
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,6 +234,7 @@ prinfport (exp, port, writing)
|
||||||
int writing;
|
int writing;
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
SCM name;
|
SCM name;
|
||||||
char * c;
|
char * c;
|
||||||
if (SCM_CLOSEDP (exp))
|
if (SCM_CLOSEDP (exp))
|
||||||
|
@ -265,6 +251,8 @@ prinfport (exp, port, writing)
|
||||||
}
|
}
|
||||||
|
|
||||||
scm_prinport (exp, port, c);
|
scm_prinport (exp, port, c);
|
||||||
|
*/
|
||||||
|
scm_prinport (exp, port, "file");
|
||||||
return !0;
|
return !0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,6 @@ extern scm_ptobfuns scm_pipob;
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
extern SCM scm_setbuf0 (SCM port);
|
extern SCM scm_setbuf0 (SCM port);
|
||||||
extern long scm_mode_bits (char *modes);
|
extern long scm_mode_bits (char *modes);
|
||||||
extern SCM scm_mkfile (char * name, char * modes);
|
|
||||||
extern SCM scm_open_file (SCM filename, SCM modes);
|
extern SCM scm_open_file (SCM filename, SCM modes);
|
||||||
extern SCM scm_port_mode (SCM port);
|
extern SCM scm_port_mode (SCM port);
|
||||||
extern void scm_init_fports (void);
|
extern void scm_init_fports (void);
|
||||||
|
|
|
@ -677,8 +677,10 @@ gc_mark_nimp:
|
||||||
goto def;
|
goto def;
|
||||||
if (SCM_GC8MARKP (ptr))
|
if (SCM_GC8MARKP (ptr))
|
||||||
break;
|
break;
|
||||||
|
/*
|
||||||
if (SCM_PTAB_ENTRY(ptr))
|
if (SCM_PTAB_ENTRY(ptr))
|
||||||
scm_gc_mark (SCM_PTAB_ENTRY(ptr)->file_name);
|
scm_gc_mark (SCM_PTAB_ENTRY(ptr)->file_name);
|
||||||
|
*/
|
||||||
ptr = (scm_ptobs[i].mark) (ptr);
|
ptr = (scm_ptobs[i].mark) (ptr);
|
||||||
goto gc_mark_loop;
|
goto gc_mark_loop;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -182,7 +182,7 @@ scm_sys_duplicate_port (oldpt, modes)
|
||||||
if (SCM_BUF0 & (SCM_CAR (newpt) = scm_tc16_fport | scm_mode_bits (SCM_CHARS (modes))))
|
if (SCM_BUF0 & (SCM_CAR (newpt) = scm_tc16_fport | scm_mode_bits (SCM_CHARS (modes))))
|
||||||
scm_setbuf0 (newpt);
|
scm_setbuf0 (newpt);
|
||||||
SCM_SETSTREAM (newpt, (SCM)f);
|
SCM_SETSTREAM (newpt, (SCM)f);
|
||||||
SCM_PTAB_ENTRY (newpt)->file_name = SCM_PTAB_ENTRY (oldpt)->file_name;
|
/* SCM_PTAB_ENTRY (newpt)->file_name = SCM_PTAB_ENTRY (oldpt)->file_name;*/
|
||||||
}
|
}
|
||||||
SCM_ALLOW_INTS;
|
SCM_ALLOW_INTS;
|
||||||
return newpt;
|
return newpt;
|
||||||
|
|
|
@ -380,7 +380,7 @@ scm_add_to_port_table (port)
|
||||||
scm_port_table[scm_port_table_size]->port = port;
|
scm_port_table[scm_port_table_size]->port = port;
|
||||||
scm_port_table[scm_port_table_size]->revealed = 0;
|
scm_port_table[scm_port_table_size]->revealed = 0;
|
||||||
scm_port_table[scm_port_table_size]->stream = 0;
|
scm_port_table[scm_port_table_size]->stream = 0;
|
||||||
scm_port_table[scm_port_table_size]->file_name = SCM_BOOL_F;
|
/* scm_port_table[scm_port_table_size]->file_name = SCM_BOOL_F;*/
|
||||||
scm_port_table[scm_port_table_size]->line_number = 1;
|
scm_port_table[scm_port_table_size]->line_number = 1;
|
||||||
scm_port_table[scm_port_table_size]->column_number = 0;
|
scm_port_table[scm_port_table_size]->column_number = 0;
|
||||||
scm_port_table[scm_port_table_size]->representation = scm_regular_port;
|
scm_port_table[scm_port_table_size]->representation = scm_regular_port;
|
||||||
|
@ -747,6 +747,7 @@ scm_column_number (port)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* !!! dubious feature */
|
/* !!! dubious feature */
|
||||||
|
#if 0
|
||||||
SCM_PROC (s_port_file_name, "port-file-name", 0, 1, 0, scm_port_file_name);
|
SCM_PROC (s_port_file_name, "port-file-name", 0, 1, 0, scm_port_file_name);
|
||||||
#ifdef __STDC__
|
#ifdef __STDC__
|
||||||
SCM
|
SCM
|
||||||
|
@ -766,6 +767,7 @@ scm_port_file_name (port)
|
||||||
else
|
else
|
||||||
return SCM_PTAB_ENTRY (p)->file_name;
|
return SCM_PTAB_ENTRY (p)->file_name;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef ttyname
|
#ifndef ttyname
|
||||||
extern char * ttyname();
|
extern char * ttyname();
|
||||||
|
|
|
@ -71,7 +71,7 @@ struct scm_port_table
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SCM stream;
|
SCM stream;
|
||||||
SCM file_name;
|
/* SCM file_name; */
|
||||||
int unchr; /* pushed back character, if any */
|
int unchr; /* pushed back character, if any */
|
||||||
|
|
||||||
int line_number;
|
int line_number;
|
||||||
|
@ -188,7 +188,7 @@ extern SCM scm_peek_char (SCM port);
|
||||||
extern SCM scm_unread_char (SCM cobj, SCM port);
|
extern SCM scm_unread_char (SCM cobj, SCM port);
|
||||||
extern SCM scm_line_number (SCM port);
|
extern SCM scm_line_number (SCM port);
|
||||||
extern SCM scm_column_number (SCM port);
|
extern SCM scm_column_number (SCM port);
|
||||||
extern SCM scm_port_file_name (SCM port);
|
/* extern SCM scm_port_file_name (SCM port); */
|
||||||
extern void scm_prinport (SCM exp, SCM port, char *type);
|
extern void scm_prinport (SCM exp, SCM port, char *type);
|
||||||
extern void scm_ports_prehistory (void);
|
extern void scm_ports_prehistory (void);
|
||||||
extern SCM scm_void_port (char * mode_str);
|
extern SCM scm_void_port (char * mode_str);
|
||||||
|
@ -225,7 +225,7 @@ extern SCM scm_peek_char ();
|
||||||
extern SCM scm_unread_char ();
|
extern SCM scm_unread_char ();
|
||||||
extern SCM scm_line_number ();
|
extern SCM scm_line_number ();
|
||||||
extern SCM scm_column_number ();
|
extern SCM scm_column_number ();
|
||||||
extern SCM scm_port_file_name ();
|
/* extern SCM scm_port_file_name ();*/
|
||||||
extern void scm_prinport ();
|
extern void scm_prinport ();
|
||||||
extern void scm_ports_prehistory ();
|
extern void scm_ports_prehistory ();
|
||||||
extern SCM scm_void_port ();
|
extern SCM scm_void_port ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue