-/* Copyright (C) 1995,1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
SCM port;
{
scm_sizet i = SCM_PTOBNUM (port);
- SCM_SYSCALL ((scm_ptobs[i].fputc) (c, SCM_STREAM (port)));
+ SCM_SYSCALL ((scm_ptobs[i].fputc) (c, port));
}
void
SCM port;
{
scm_sizet i = SCM_PTOBNUM (port);
- SCM_SYSCALL ((scm_ptobs[i].fputs) (s, SCM_STREAM (port)));
-#ifdef TRANSCRIPT_SUPPORT
- if (scm_trans && (port == def_outp || port == cur_errp))
- SCM_SYSCALL (fputs (s, scm_trans));
-#endif
+ SCM_SYSCALL ((scm_ptobs[i].fputs) (s, port));
}
void
SCM port;
{
scm_sizet i = SCM_PTOBNUM (port);
- SCM_SYSCALL (scm_ptobs[i].fwrite(ptr, size, 1, SCM_STREAM (port)));
-#ifdef TRANSCRIPT_SUPPORT
- if (scm_trans && (port == def_outp || port == cur_errp))
- SCM_SYSCALL (fwrite (ptr, size, 1, scm_trans));
-#endif
+ SCM_SYSCALL (scm_ptobs[i].fwrite (ptr, size, 1, port));
}
+void
+scm_fflush (port)
+ SCM port;
+{
+ scm_sizet i = SCM_PTOBNUM (port);
+ (scm_ptobs[i].fflush) (port);
+}
+
\f
int
int c;
scm_sizet i;
- /* One char may be stored in the high bits of (car port) orre@nada.kth.se. */
if (SCM_CRDYP (port))
{
c = SCM_CGETUN (port);
- SCM_CLRDY (port); /* Clear ungetted char */
+ SCM_TRY_CLRDY (port); /* Clear ungetted char */
}
else
{
while (n == -1 && errno == EINTR);
}
#endif
- SCM_SYSCALL (c = (scm_ptobs[i].fgetc) (f));
+ SCM_SYSCALL (c = (scm_ptobs[i].fgetc) (port));
}
if (c == '\n')
int c;
SCM port;
{
-/* SCM_ASSERT(!SCM_CRDYP(port), port, SCM_ARG2, "too many scm_ungetc");*/
SCM_CUNGET (c, port);
+
if (c == '\n')
{
/* What should col be in this case?
}
+void
+scm_ungets (s, n, port)
+ char *s;
+ int n;
+ SCM port;
+{
+ /* This is simple minded and inefficient, but unreading strings is
+ * probably not a common operation, and remember that line and
+ * column numbers have to be handled...
+ *
+ * Please feel freee to write an optimized version!
+ */
+ while (n--)
+ scm_ungetc (s[n], port);
+}
+
+
char *
scm_do_read_line (port, len)
SCM port;
i = SCM_PTOBNUM (port);
SCM_SYSCALL (s = (scm_ptobs[i].fgets) (port, len));
+
+ /* We should never get an empty string. Every line has a newline at
+ the end, except for the last one. If the last line has no
+ newline and is empty, then that's just an ordinary EOF, and we
+ should have s == NULL. But this seems obscure to me, so we check
+ this here, to protect ourselves from odd port implementations. */
+ if (s && *len <= 0)
+ abort ();
+
+ /* If we're not at EOF, and there was a newline at the end of the
+ string, increment the line counter. */
+ if (s && s[*len - 1] == '\n')
+ SCM_INCLINE(port);
+
return s;
}
-