Source

blake / blake_strfunc.c

/*
Copyright (C) 2001-2006 Daybo Logic.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
   may be used to endorse or promote products derived from this software
   without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
/*
  Blake - String functions.  Note: Check blake_ansi too.  These functions
  are my own or those of other and not things which are part of the non
  standard C language.

  Maintainer is David Duncan Ross Palmer
                <daybologic.co.uk/mailddrp>
*/

#define BLAKE_SOURCE

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif /*HAVE_CONFIG_H*/

#include <time.h>
#include <stdio.h>

#ifdef HAVE_STRING_H
# include <string.h>
#endif /*HAVE_STRING_H*/

#ifdef HAVE_LIMITS_H
# include <limits.h>
#endif /*HAVE_LIMITS_H*/

#ifdef BLAKE_HDRSTOP
# pragma hdrstop
#endif /*BLAKE_HDRSTOP*/

#ifdef HAVE_DLSTDINC_H
# include "dlstdinc.h"
#endif /*HAVE_DLSTDINC_H*/

#include "blake_threads.h"
#include "blake.h"
#include "blake_main.h"
#include "blake_strfunc.h"
/*-------------------------------------------------------------------------*/
static const char *const rcsid =
  "$Id: blake_strfunc.c,v 0.7 2006/03/17 21:08:00 ddrp Exp $";
/*-------------------------------------------------------------------------*/
void blake_int_strfunc_NCI()
{
  blake_Unused(rcsid);
}
/*-------------------------------------------------------------------------*/
BLAKEAPI(void) blake_LTrim(char* Str)
{
  if ( Str ) {
    size_t len = strlen(Str);
    while ( Str[0] != '\0' && Str[0] == ' ' )
      memmove(Str, Str+1, len);
  }
}
/*-------------------------------------------------------------------------*/
BLAKEAPI(void) blake_RTrim(char* Str)
{
  if ( Str ) {
    size_t i = strlen(Str);
    while ( i-- ) {
      if ( Str[i] == ' ' )
        Str[i] = '\0';
      else
        break;
    }
  }
}
/*-------------------------------------------------------------------------*/
BLAKEAPI(void) blake_Trim(char* Str)
{
  blake_RTrim(Str);
  blake_LTrim(Str);
}
/*-------------------------------------------------------------------------*/