home *** CD-ROM | disk | FTP | other *** search
- /* ==( bench/cvts.c )== */
-
- /* ----------------------------------------------- */
- /* Pro-C Copyright (C) 1988 - 1990 Vestronix Inc. */
- /* Modification to this source is not supported */
- /* by Vestronix Inc. */
- /* All Rights Reserved */
- /* ----------------------------------------------- */
- /* Written Nig 1-Jan-87 */
- /* Modified Geo 4-Oct-89 See comments below */
- /* ----------------------------------------------- */
- /* %W% (%H% %T%) */
-
- /*
- * Modifications
- *
- * 4-Nov-89 Geo - V2 version
- * 25-Oct-89 Geo - 1.32 Merge
- */
-
- # include <bench.h>
-
- /* Function prototypes */
- # ifdef ANSI
- static void no_trailing(char *);
- static void no_leading(char *);
- # else
- static void no_trailing();
- static void no_leading();
- # endif
-
- /*
- *
- * 1 - remove leading spaces
- * 2 - remove trailing spaces
- * 4 - convert to UPPER case
- */
- char *cvt_str(str, fmode)
- char *str;
- int fmode;
- {
- register int i;
-
- for (i = 1; i < 16; i <<= 1)
- switch(fmode & i)
- {
- case 1 : no_leading(str); break;
- case 2 : no_trailing(str); break;
- case 4 : cvt_upper(str); break;
- }
- return str;
- }
-
- static void no_leading(str)
- char *str;
- {
- int slen;
- register int i;
- register int j;
-
- for (i = 0, slen = strlen(str); i < slen && str[i] == ' '; i++)
- ;
- for (j = i, i = 0; j < slen; j++, i++)
- str[i] = str[j];
- str[i] = '\0';
- }
-
- static void no_trailing(str)
- char *str;
- {
- register int i;
-
- for (i = strlen(str) - 1; i > -1 && str[i] == ' '; i--)
- ;
- str[i+1] = '\0';
- }
-
- char *cvt_upper(str)
- char *str;
- {
- char *ptr = str;
-
- for ( ; *str; str++)
- if (islower(*str))
- *str = toupper(*str);
-
- return ptr;
- }
-
- char *cvt_lower(str)
- char *str;
- {
- char *ptr = str;
-
- for ( ; *str; str++)
- if (isupper(*str))
- *str = tolower(*str);
-
- return ptr;
- }
-