2 * COMPONENT_NAME: austext
4 * FUNCTIONS: delete_whitespace
9 * (C) COPYRIGHT International Business Machines Corp. 1990,1995
11 * Licensed Materials - Property of IBM
12 * US Government Users Restricted Rights - Use, duplication or
13 * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
15 /***************************** DELSPACE.C *****************************
16 * $XConsortium: delspace.c /main/5 1996/05/07 13:28:17 drk $
17 * Removes trailing whitespace from a character buffer
18 * (such as a line read in with fgets).
19 * If the last char in the original buffer was \n,
20 * then the last char in the resulting string will be \n.
21 * Replaces all internal control and extended graphics
22 * characters (except the last \n) with a blank.
23 * Does nothing to empty strings ("\0") and strings
24 * beginning with a form feed ("\f....").
25 * All Conversions are done inplace, i.e. within
26 * the same buffer passed to the function.
29 * Revision 2.3 1995/12/01 16:05:37 miker
30 * No longer overlays tabs with a space char.
32 * Revision 2.2 1995/10/25 22:06:36 miker
35 * Revision 2.1 1995/09/22 19:46:16 miker
36 * Freeze DtSearch 0.1, AusText 2.1.8
38 * Revision 1.2 1995/08/31 22:27:03 miker
39 * Minor changes for DtSearch.
44 void delete_whitespace (char *linebuf)
46 static char *ptr, *endptr;
47 static int has_linefeed;
49 /* do nothing if empty or ff string */
50 if (*linebuf == '\0' || *linebuf == '\f')
53 ptr = linebuf + strlen (linebuf) - 1;
54 has_linefeed = (*ptr == '\n');
55 while (!isgraph (*ptr) && ptr >= linebuf)
58 endptr = ptr + 1; /* endptr = just past last char */
59 for (ptr = linebuf; ptr < endptr; ptr++)
60 if (!isprint(*ptr) && *ptr != '\t')
69 /***************************** DELSPACE.C *****************************/