home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c222 / 1.ddi / SOURCE / CLIB / ME_ALPH.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-10  |  1.3 KB  |  82 lines

  1. /*********************
  2.  *
  3.  *  me_alph.c - memory alphabetic functions.
  4.  *
  5.  *  Purpose: This file contains functions which operate on buffers
  6.  *           for alpha manipulation.
  7.  *
  8.  *  Blackstar C Function Library
  9.  *  (c) Copyright 1985,1989 Sterling Castle Software
  10.  *
  11.  *******/
  12.  
  13. #include <ctype.h>
  14. #include "blackstr.h"
  15.  
  16.  
  17. /********
  18.  *
  19.  *   me_upper(buf,n) - convert buffer to upper case
  20.  *
  21.  **/
  22.  
  23. void me_upper(char *buf, int n)
  24. {
  25.     while(n--) {
  26.     if(isalpha(*buf))
  27.         *buf =toupper(*buf);
  28.         ++buf;
  29.     }
  30. }
  31.  
  32.  
  33. /********
  34.  *
  35.  *   me_lower(buf,n) - convert buffer to lower case
  36.  *
  37.  **/
  38.  
  39. void me_lower(char *buf, int n)
  40. {
  41.     while(n--) {
  42.     if(isalpha(*buf))
  43.         *buf = tolower(*buf);
  44.     ++buf;
  45.     }
  46. }
  47.  
  48.  
  49. /********
  50.  *
  51.  *   me_cmpu(buf1,buf2,n) - compare two buffers in upper case
  52.  *
  53.  **/
  54.  
  55. int me_cmpu(char *buf1, char *buf2, int n)
  56. {
  57.     while(n--) {
  58.     if(toupper(*buf1)<toupper(*buf2))
  59.         return(-1);
  60.     else if(toupper(*buf1)>toupper(*buf2))
  61.         return(TRUE);
  62.     else ++buf1,++buf2;
  63.     }
  64.     return(FALSE);
  65. }
  66.  
  67.  
  68. /********
  69.  *
  70.  *   me_squ(buf,c,n) - squeeze c characters out of buff
  71.  *
  72.  **/
  73.  
  74. void me_squ(char *buf, char c, int n)
  75. {
  76.     int i,j;
  77.  
  78.     for(i=j=0; n-->0; i++)
  79.     if(buf[i] != c)
  80.         buf[j++] = buf[i];
  81. }
  82.