home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name EDREDUCE - Reduce all consecutive whitespace to a
- * single blank.
- *
- * Synopsis edreduce(pedit_buffer);
- *
- * ED_BUFFER *pedit_buffer Pointer to edit buffer to
- * reduce.
- *
- * Description EDREDUCE will scan the pbuffer member of
- * *pedit_buffer, reducing all runs of consecutive
- * whitespace to a single blank. The data_end and
- * cursor_pos fields are adjusted accordingly.
- *
- * Returns nothing.
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1989
- *
- **/
- #include <bedit.h>
-
- void edreduce(pedit_buffer)
- ED_BUFFER *pedit_buffer;
- {
- int current_char;
- int in_white = 0;
- int data_end = pedit_buffer->data_end;
- int cursor_pos = pedit_buffer->cursor_pos;
- char *pdest;
-
- pdest = pedit_buffer->pbuffer;
-
- for (current_char = 0; current_char < pedit_buffer->data_end;
- current_char++)
- {
- if (isspace(pedit_buffer->pbuffer[current_char]))
- {
- if (!in_white)
- {
- in_white = 1;
- *pdest++ = ' ';
- }
- else
- {
- if (pedit_buffer->data_end >= current_char)
- data_end--;
- if (pedit_buffer->cursor_pos >= current_char)
- cursor_pos--;
- }
- }
- else
- {
- in_white = 0;
- *pdest++ = pedit_buffer->pbuffer[current_char];
- }
- }
-
- while (pdest < (pedit_buffer->pbuffer + pedit_buffer->buffer_size))
- {
- *pdest++ = ' ';
- }
-
- pedit_buffer->data_end = data_end;
- pedit_buffer->cursor_pos = cursor_pos;
- }