/**---------------------------------------------------------------------------
 ** 
 ** string.c -- Miscellaneous sring functions
 ** 
 ** Author          : Pierre Jaccard
 ** Created On      : 1999/07/15 12:07:20
 ** Last Modified By: Pierre Jaccard
 ** Last Modified On: 1999/07/16 21:19:47
 ** Update Count    : 3
 ** Directory       : /home/pego/pcd1/codas3c/gfi/src/libs/misc/
 ** Version         : 0.0
 ** Status          : Unknown
 ** ---------------------------------------------------------------------- ** 
 ** DESCRIPTION: 
 ** 
 **    Miscellaneous string functions.
 ** 
 ** ---------------------------------------------------------------------- ** 
 ** REVISIONS: 
 ** ---------------------------------------------------------------------- ** 
 ** CHANGES: 
 **------------------------------------------------------------------------**/

#include "string.h"

/* ------------------------------------------------------------------
	 Remove leading spaces from a string. 

   RETURNS: the new string.
	 ------------------------------------------------------------------ */
#if PROTOTYPE_ALLOWED
char *strtrim_l(/* String to process */
                char *s)
#else
     char *strtrim_l(s)
     char *s;
#endif
{

	int j=0, i=0;

	while((s[i] != '\0') && isspace(s[i])) i++;
	while(s[i] != '\0') s[j++] = s[i++];
	s[j] = '\0';
	
	return(s);

}

/* ------------------------------------------------------------------
	 Remove trailing spaces. 

   RETURNS: the new string.
	 ------------------------------------------------------------------ */
#if PROTOTYPE_ALLOWED
char *strtrim_t(/* String to process */
                char *s)
#else
     char *strtrim_t(s)
     char *s;
#endif
{

	int i=0;

	while(s[i++] != '\0');
	i--;
	while(isspace(s[--i]));
	s[++i] = '\0';
	
	return(s);
	
}

/* ------------------------------------------------------------------
	 Remove leading and trailing spaces. 

   RETURNS: the new string.
	 ------------------------------------------------------------------ */
#if PROTOTYPE_ALLOWED
char *strtrim_lt(/* Sting to process */
                 char *s)
#else
     char *strtrim_lt(s)
     char *s;
#endif
{

	s = strtrim_l(s);
	s = strtrim_t(s);

	return(s);

}

