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
wta for range errors (ASSERT still needs work).
*
* Return the new port.
*/
-
+SCM_PROC(s_open_file, "open-file", 2, 0, 0, scm_open_file);
#ifdef __STDC__
SCM
-scm_mkfile (char * name, char * modes)
+scm_open_file (SCM filename, SCM modes)
#else
SCM
-scm_mkfile (name, modes)
- char * name;
- char * modes;
+scm_open_file (filename, modes)
+ SCM filename;
+ SCM modes;
#endif
{
- register 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 (modes) && SCM_ROSTRINGP (modes), modes, SCM_ARG2, s_open_file);
+ if (SCM_SUBSTRP (filename))
+ filename = scm_makfromstr (SCM_ROCHARS (filename), SCM_ROLENGTH (filename), 0);
+ if (SCM_SUBSTRP (modes))
+ modes = scm_makfromstr (SCM_ROCHARS (modes), SCM_ROLENGTH (modes), 0);
+
+ file = SCM_ROCHARS (filename);
+ mode = SCM_ROCHARS (modes);
+
SCM_NEWCELL (port);
SCM_DEFER_INTS;
- SCM_SYSCALL (f = fopen (name, modes));
+ SCM_SYSCALL (f = fopen (file, mode));
if (!f)
{
- SCM_ALLOW_INTS;
- port = SCM_BOOL_F;
+ scm_syserror_msg (s_open_file, "%S: %S",
+ scm_listify (scm_makfrom0str (strerror (errno)),
+ filename,
+ SCM_UNDEFINED));
}
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)))
+ 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 (name);
- SCM_ALLOW_INTS;
+ /* SCM_PTAB_ENTRY (port)->file_name = scm_makfrom0str (filename); */
}
- return port;
-}
-
-SCM_PROC(s_open_file, "open-file", 2, 0, 0, scm_open_file);
-#ifdef __STDC__
-SCM
-scm_open_file (SCM filename, SCM modes)
-#else
-SCM
-scm_open_file (filename, modes)
- SCM filename;
- SCM modes;
-#endif
-{
- SCM port;
- 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);
- if (SCM_SUBSTRP (filename))
- filename = scm_makfromstr (SCM_ROCHARS (filename), SCM_ROLENGTH (filename), 0);
- if (SCM_SUBSTRP (modes))
- modes = scm_makfromstr (SCM_ROCHARS (modes), SCM_ROLENGTH (modes), 0);
- port = scm_mkfile (SCM_ROCHARS (filename), SCM_ROCHARS (modes));
-
- if (port == SCM_BOOL_F) {
- scm_syserror_msg (s_open_file, "%S: %S",
- scm_listify (scm_makfrom0str (strerror (errno)),
- filename,
- SCM_UNDEFINED));
- /* Force the compiler to keep filename and modes alive. */
- scm_cons (filename, modes);
- }
+ SCM_ALLOW_INTS;
return port;
}
int writing;
#endif
{
+ /*
SCM name;
char * c;
if (SCM_CLOSEDP (exp))
else
c = "file";
}
-
+
scm_prinport (exp, port, c);
+ */
+ scm_prinport (exp, port, "file");
return !0;
}
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]->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]->column_number = 0;
scm_port_table[scm_port_table_size]->representation = scm_regular_port;
}
/* !!! dubious feature */
+#if 0
SCM_PROC (s_port_file_name, "port-file-name", 0, 1, 0, scm_port_file_name);
#ifdef __STDC__
SCM
else
return SCM_PTAB_ENTRY (p)->file_name;
}
+#endif
#ifndef ttyname
extern char * ttyname();
*/
SCM stream;
- SCM file_name;
+ /* SCM file_name; */
int unchr; /* pushed back character, if any */
int line_number;
extern SCM scm_unread_char (SCM cobj, SCM port);
extern SCM scm_line_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_ports_prehistory (void);
extern SCM scm_void_port (char * mode_str);
extern SCM scm_unread_char ();
extern SCM scm_line_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_ports_prehistory ();
extern SCM scm_void_port ();