1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
/******************************************************************************
** $Id: type.c,v 2.17 1997/12/06 22:56:00 gerd Exp gerd $
**=============================================================================
**
** This file is part of BibTool.
** It is distributed under the GNU General Public License.
** See the file COPYING for details.
**
** (c) 1996-1997 Gerd Neugebauer
**
** Net: gerd@informatik.uni-koblenz.de
**
**-----------------------------------------------------------------------------
**
** Description:
** This file contains functions to support a separate treatment of
** character types. The normal functions and macros in |ctype.h| are
** replaced by those in |type.h|. This file contains an initialization
** function which is required for the macros in |type.h| to work
** properly.
**
** See also the documentation of the header file |type.h| for
** further information.
**
******************************************************************************/
/*****************************************************************************/
/* Internal Programs */
/*===========================================================================*/
#define INIT_TYPE
#include <bibtool/type.h>
/*****************************************************************************/
/* External Programs */
/*===========================================================================*/
/*---------------------------------------------------------------------------*/
#define to_lower(C) ((C) + 'a'-'A')
#define to_upper(C) ((C) + 'A'-'a')
/*-----------------------------------------------------------------------------
** Function: init_type()
** Purpose: This is the initialization routine for this file. This
** has to be called before some of the macros in |type.h|
** will work as described. It does no harm to call this
** initialization more than once. It just takes some time.
**
** Note that this function is for internal purposes
** only. The normal user should call |init_bibtool()|
** instead.
** Arguments: none
** Returns: nothing
**___________________________________________________ */
void init_type() /* */
{ register int i; /* */
/* */
for ( i=0; i<256; ++i ) /* */
{ trans_lower[i] = is_upper(i)?to_lower(i):i; /* */
trans_upper[i] = is_lower(i)?to_upper(i):i; /* */
trans_id[i] = i; /* */
} /* */
} /*------------------------*/
/*-----------------------------------------------------------------------------
** Function: case_cmp()
** Purpose: Compare two strings ignoring cases. If the strings are
** identical up to differences in case then this function
** returns |TRUE|.
** Arguments:
** s First string to consider.
** t Second string to consider.
** Returns: |FALSE| iff the strings differ.
**___________________________________________________ */
int case_cmp(s,t) /* */
register char * s; /* */
register char * t; /* */
{ /* */
while ( *s ) /* */
{ if ( ToLower(*(s++)) != ToLower(*(t++)) ) /* */
return 0; /* */
} /* */
return(*t=='\0'?1:0); /* */
} /*------------------------*/
/*-----------------------------------------------------------------------------
** Function: lower()
** Purpose: Function to translate all letters in a string to lower case.
** Arguments:
** s string to convert
** Returns: The converted string
**___________________________________________________ */
char * lower(s) /* */
register char * s; /* */
{ char *t = s; /* */
while ( *s ) { *s = ToLower(*s); ++s; } /* */
return t; /* */
} /*------------------------*/
|