home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / XGRP_000.SZH / STRIPS.C < prev    next >
C/C++ Source or Header  |  1991-07-15  |  1KB  |  62 lines

  1. #include <string.h>
  2. #include <ctype.h>
  3. #include "nofast.h"
  4.  
  5.  
  6.  
  7.  
  8.  
  9. char * _fastcall rstrip (char *a) {   /* Remove trailing spaces and tabs */
  10.  
  11.   register int x;
  12.  
  13.   x=strlen(a);
  14.   while (x && a && (a[x-1]==' ' || a[x-1]=='\t')) a[--x]=0;
  15.   return a;
  16. }
  17.  
  18.  
  19.  
  20.  
  21. char * _fastcall lstrip (char *a) {   /* Remove leading spaces and tabs */
  22.  
  23.   register int x;
  24.  
  25.   x=strlen(a);
  26.   while (x && (*a==' ' || *a=='\t')) memmove (a,(a+1),x--);
  27.   return (a);
  28. }
  29.  
  30.  
  31.  
  32. char * _fastcall stripcr (char *a) {  /* Remove trailing crs and lfs */
  33.  
  34.   register int x;
  35.  
  36.   x=strlen(a);
  37.   while (x && (a[x-1]=='\n' || a[x-1]=='\r')) a[--x]=0;
  38.   return a;
  39. }
  40.  
  41.  
  42.  
  43. char * _fastcall strip_trail_bksl (char *a) {  /* Remove trailing slashes */
  44.  
  45.   register int x;
  46.   int y;
  47.  
  48.   /* note: this maintains the backslash instead of the slash so that
  49.      system calls (through CMD.EXE or COMMAND.COM) are 'guaranteed'
  50.      to work. */
  51.  
  52.  
  53.   x = strlen(a);
  54.   y = 0;
  55.   while(y < x) {
  56.       if(a[y] == '/') a[y] = '\\';
  57.       y++;
  58.   }
  59.   while(x && (a[x - 1] == '\\')) a[--x]=0;
  60.   return a;
  61. }
  62.