Sun Jun 2 22:28:43 1996 Miles Bader <miles@gnu.ai.mit.edu>

* linewrap.c (lwupdate): Update D->point_offs when done.
	Use memmove instead of memcpy where overlap is possible (not
 	necessary using current implementation of memcpy, but...).
	(__line_wrap_update): Don't update D->point_offs (lwupdate does it).

Fri May 31 11:48:46 1996  Miles Bader  <miles@gnu.ai.mit.edu>

	* linewrap.c (lwupdate): New function, mostly was __line_wrap_update.
	Use POINT_COL field instead of POINT.
	(__line_wrap_output): Use lwupdate.
	(__line_wrap_update): New function.
	(ensure_unwrapped, ensure_wrapped): New functions.
	(line_wrap_set_lmargin, line_wrap_set_rmargin,
	line_wrap_set_wmargin, line_wrap_point): Use __line_wrap_update.

	* linewrap.h (struct line_wrap_data): Rename POINT field to POINT_COL.
	Add POINT_OFFS field.
	(__line_wrap_update): New decl.
	(line_wrap_set_lmargin, line_wrap_set_rmargin,
	line_wrap_set_wmargin, line_wrap_point): Use __line_wrap_update.
This commit is contained in:
Miles Bader 1996-07-07 16:54:03 +00:00
parent dd411cc7bc
commit 99ed3e3909
2 changed files with 51 additions and 17 deletions

View File

@ -1,3 +1,26 @@
Sun Jun 2 22:28:43 1996 Miles Bader <miles@gnu.ai.mit.edu>
* linewrap.c (lwupdate): Update D->point_offs when done.
Use memmove instead of memcpy where overlap is possible (not
necessary using current implementation of memcpy, but...).
(__line_wrap_update): Don't update D->point_offs (lwupdate does it).
Fri May 31 11:48:46 1996 Miles Bader <miles@gnu.ai.mit.edu>
* linewrap.c (lwupdate): New function, mostly was __line_wrap_update.
Use POINT_COL field instead of POINT.
(__line_wrap_output): Use lwupdate.
(__line_wrap_update): New function.
(ensure_unwrapped, ensure_wrapped): New functions.
(line_wrap_set_lmargin, line_wrap_set_rmargin,
line_wrap_set_wmargin, line_wrap_point): Use __line_wrap_update.
* linewrap.h (struct line_wrap_data): Rename POINT field to POINT_COL.
Add POINT_OFFS field.
(__line_wrap_update): New decl.
(line_wrap_set_lmargin, line_wrap_set_rmargin,
line_wrap_set_wmargin, line_wrap_point): Use __line_wrap_update.
Fri Jul 5 17:34:47 1996 Miles Bader <miles@gnu.ai.mit.edu> Fri Jul 5 17:34:47 1996 Miles Bader <miles@gnu.ai.mit.edu>
* login/logout.c (logout): Do nothing if getutline_r returns ESRCH. * login/logout.c (logout): Do nothing if getutline_r returns ESRCH.

View File

@ -35,7 +35,12 @@ struct line_wrap_data
{ {
size_t lmargin, rmargin; /* Left and right margins. */ size_t lmargin, rmargin; /* Left and right margins. */
size_t wmargin; /* Margin to wrap to, or -1 to truncate. */ size_t wmargin; /* Margin to wrap to, or -1 to truncate. */
size_t point; /* Current column of last chars flushed. */
/* Point in stdio buffer to which we've processed for wrapping, but
not output. */
size_t point_offs;
/* Output column at POINT_OFFS. */
size_t point_col;
/* Original cookie and hooks from the stream. */ /* Original cookie and hooks from the stream. */
void *cookie; void *cookie;
@ -85,11 +90,18 @@ extern size_t line_wrap_set_wmargin (FILE *stream, size_t wmargin);
the current output point. */ the current output point. */
extern size_t line_wrap_point (FILE *stream); extern size_t line_wrap_point (FILE *stream);
#ifdef __OPTIMIZE__ #ifdef __OPTIMIZE__
extern void __line_wrap_output (FILE *, int); /* private */ extern void __line_wrap_output (FILE *, int); /* private */
/* If STREAM is not line-wrapped, return 0. Otherwise all pending text
buffered text in STREAM so that the POINT_OFFS field refers to the last
position in the stdio buffer, and return the line wrap state object for
STREAM. Since all text has been processed, this means that (1) the
POINT_COL field refers to the column at which any new text would be added,
and (2) any changes to the margin parameters will only affect new text. */
extern struct line_wrap_data *__line_wrap_update (FILE *stream); /* private */
/* Returns true if STREAM is line wrapped. */ /* Returns true if STREAM is line wrapped. */
extern inline int extern inline int
line_wrapped (FILE *stream) line_wrapped (FILE *stream)
@ -111,15 +123,15 @@ line_wrap_lmargin (FILE *stream)
extern inline size_t extern inline size_t
line_wrap_set_lmargin (FILE *stream, size_t lmargin) line_wrap_set_lmargin (FILE *stream, size_t lmargin)
{ {
if (! line_wrapped (stream)) struct line_wrap_data *d = __line_wrap_update (stream);
return -1; if (d)
else
{ {
struct line_wrap_data *d = stream->__cookie;
size_t old = d->lmargin; size_t old = d->lmargin;
d->lmargin = lmargin; d->lmargin = lmargin;
return old; return old;
} }
else
return -1;
} }
/* If STREAM is not line-wrapped return -1, else return its left margin. */ /* If STREAM is not line-wrapped return -1, else return its left margin. */
@ -136,15 +148,15 @@ line_wrap_rmargin (FILE *stream)
extern inline size_t extern inline size_t
line_wrap_set_rmargin (FILE *stream, size_t rmargin) line_wrap_set_rmargin (FILE *stream, size_t rmargin)
{ {
if (! line_wrapped (stream)) struct line_wrap_data *d = __line_wrap_update (stream);
return -1; if (d)
else
{ {
struct line_wrap_data *d = stream->__cookie;
size_t old = d->rmargin; size_t old = d->rmargin;
d->rmargin = rmargin; d->rmargin = rmargin;
return old; return old;
} }
else
return -1;
} }
/* If STREAM is not line-wrapped return -1, else return its wrap margin. */ /* If STREAM is not line-wrapped return -1, else return its wrap margin. */
@ -161,15 +173,15 @@ line_wrap_wmargin (FILE *stream)
extern inline size_t extern inline size_t
line_wrap_set_wmargin (FILE *stream, size_t wmargin) line_wrap_set_wmargin (FILE *stream, size_t wmargin)
{ {
if (! line_wrapped (stream)) struct line_wrap_data *d = __line_wrap_update (stream);
return -1; if (d)
else
{ {
struct line_wrap_data *d = stream->__cookie;
size_t old = d->wmargin; size_t old = d->wmargin;
d->wmargin = wmargin; d->wmargin = wmargin;
return old; return old;
} }
else
return -1;
} }
/* If STREAM is not line-wrapped return -1, else return the column number of /* If STREAM is not line-wrapped return -1, else return the column number of
@ -177,9 +189,8 @@ line_wrap_set_wmargin (FILE *stream, size_t wmargin)
extern inline size_t extern inline size_t
line_wrap_point (FILE *stream) line_wrap_point (FILE *stream)
{ {
if (! line_wrapped (stream)) struct line_wrap_data *d = __line_wrap_update (stream);
return -1; return d ? d->point_col : -1;
return ((struct line_wrap_data *)stream->__cookie)->point;
} }
#endif /* Optimizing. */ #endif /* Optimizing. */