utility
|
cmd_head.c,
count_tokens.c,
cp_file.c,
errmsg.c,
file_opened.c,
find_line.c,
find_string.c,
fn_base.c,
fn_dir.c,
fn_ext.c,
fn_root.c,
gchoice.c,
gdata_line.c,
gdouble.c,
gfield.c,
gint.c,
gntoken.c,
graphics_ok.c,
gstring.c,
lock.c,
lower.c,
mat_multiply.c,
mat_transform.c,
mat_transpose.c,
mv_file.c,
new_extension.c,
nolead.c,
notrail.c,
ordinal.c,
pfield.c,
squish_blanks.c,
test.c,
unlock.c,
upper.c,
utility.h,
utility.make,
valchars.c,
vec_angle.c,
vec_crossprod.c,
vec_diff.c,
vec_dotprod.c,
vec_length.c,
vec_norm.c,
|
|
|
#include "utility.h"
char *squish_blanks(string)
/*============================================================================*/
/* PURPOSE: SQUISH MULTIPLE CONSECUTIVE BLANKS TO A SINGLE BLANK, AND REMOVE
/* ALL LEADING AND TRAILING BLANKS FROM THE SPECIFIED STRING.
/* INPUTS:
/* STRING STRING WITH EXCESSIVE BLANKS.
/* OUTPUTS:
/* STRING MODIFIED STRING, BLANKS COMPRESSED OUT.
/* RETURN VALUE POINTER TO MODIFIED STRING.
/* WRITTEN: M.V.GRIESHABER
/* LAST MODIFICATION: 11 JUNE 1991 MVG
*/
char string[]; /* ORIGINAL STRING (MODIFIED). */
{
char *work_string; /* WORKING COPY OF STRING. */
char *strtok_ptr; /* POINTER FOR STRTOK. */
char *new_string; /* NEW VERSION OF STRING. */
char *word; /* WORD IN STRING. */
strtok_ptr=string;
new_string=strdup(string);
*new_string='\0';
/* EXTRACT EACH WORD FROM THE STRING AND ADD TO NEW STRING. */
while ((word=strtok(strtok_ptr," "))!=NULL)
{
strcat(new_string,word);
strcat(new_string," ");
strtok_ptr=NULL;
}
/* ZAP LAST TRAILING BLANK PUT ON IN LOOP. */
new_string[strlen(new_string)-1]='\0';
strcpy(string,new_string);
free(new_string);
return(string);
}
|