[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 05/18: Move line-buffing machinery to ports.c
From: |
Andy Wingo |
Subject: |
[Guile-commits] 05/18: Move line-buffing machinery to ports.c |
Date: |
Wed, 06 Apr 2016 17:27:07 +0000 |
wingo pushed a commit to branch wip-port-refactor
in repository guile.
commit 4eb9fd47c47fcd3d9da8aaced8b729a9cd303ab4
Author: Andy Wingo <address@hidden>
Date: Sun Apr 3 10:51:58 2016 +0200
Move line-buffing machinery to ports.c
* libguile/ports.c (scm_lfwrite_unlocked):
* libguile/fports.c (fport_write): Move line-buffering from fport_write
to scm_lfwrite_unlocked.
---
libguile/fports.c | 4 ----
libguile/ports.c | 16 +++++++---------
2 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/libguile/fports.c b/libguile/fports.c
index ff6d49d..8ad8ba0 100644
--- a/libguile/fports.c
+++ b/libguile/fports.c
@@ -784,10 +784,6 @@ fport_write (SCM port, const void *data, size_t size)
}
}
}
-
- /* handle line buffering. */
- if ((SCM_CELL_WORD_0 (port) & SCM_BUFLINE) && memchr (data, '\n', size))
- fport_flush (port);
}
}
#undef FUNC_NAME
diff --git a/libguile/ports.c b/libguile/ports.c
index d394193..da8b4d2 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -2753,23 +2753,21 @@ scm_c_write (SCM port, const void *ptr, size_t size)
/* scm_lfwrite
*
* This function differs from scm_c_write; it updates port line and
- * column. */
+ * column, flushing line-buffered ports when appropriate. */
void
scm_lfwrite_unlocked (const char *ptr, size_t size, SCM port)
{
- scm_t_port *pt = SCM_PTAB_ENTRY (port);
- scm_t_ptob_descriptor *ptob = SCM_PORT_DESCRIPTOR (port);
+ int saved_line;
- if (pt->rw_active == SCM_PORT_READ)
- scm_end_input_unlocked (port);
-
- ptob->write (port, ptr, size);
+ scm_c_write_unlocked (port, ptr, size);
+ saved_line = SCM_LINUM (port);
for (; size; ptr++, size--)
update_port_lf ((scm_t_wchar) (unsigned char) *ptr, port);
- if (pt->rw_random)
- pt->rw_active = SCM_PORT_WRITE;
+ /* Handle line buffering. */
+ if ((SCM_CELL_WORD_0 (port) & SCM_BUFLINE) && saved_line != SCM_LINUM (port))
+ scm_flush_unlocked (port);
}
void
- [Guile-commits] 08/18: Remove port equal functions, (continued)
- [Guile-commits] 08/18: Remove port equal functions, Andy Wingo, 2016/04/06
- [Guile-commits] 06/18: Remove port mark functions, Andy Wingo, 2016/04/06
- [Guile-commits] 14/18: Fix POLLOUT assignment from port buffers, Andy Wingo, 2016/04/06
- [Guile-commits] 02/18: display-{application, -backtrace} delegate to Scheme, Andy Wingo, 2016/04/06
- [Guile-commits] 13/18: Flush buffered reads / writes before seeking, Andy Wingo, 2016/04/06
- [Guile-commits] 15/18: Cosmetic changes to vports.c, Andy Wingo, 2016/04/06
- [Guile-commits] 01/18: Fix frame->stack-vector when no stack is active, Andy Wingo, 2016/04/06
- [Guile-commits] 07/18: Remove port free functions; just close instead, Andy Wingo, 2016/04/06
- [Guile-commits] 16/18: When making soft port, parse handlers into struct, Andy Wingo, 2016/04/06
- [Guile-commits] 12/18: Whitespace fixes, Andy Wingo, 2016/04/06
- [Guile-commits] 05/18: Move line-buffing machinery to ports.c,
Andy Wingo <=
- [Guile-commits] 10/18: Custom binary port internals refactor, Andy Wingo, 2016/04/06
- [Guile-commits] 04/18: Use symbols instead of _IONBF values as args to setvbuf, Andy Wingo, 2016/04/06
- [Guile-commits] 03/18: Move setvbuf impl to ports.[ch], Andy Wingo, 2016/04/06
- [Guile-commits] 09/18: Cosmetic changes to r6rs-ports.c, Andy Wingo, 2016/04/06
- [Guile-commits] 17/18: Port close functions return void, Andy Wingo, 2016/04/06
- [Guile-commits] 11/18: Refactor to rw_random / rw_active port flags, Andy Wingo, 2016/04/06
- [Guile-commits] 18/18: Generic port facility provides buffering uniformly, Andy Wingo, 2016/04/06