| 
            Last change
 on this file since 344 was             123, checked in by root, 21 years ago           | 
        
        
          | 
             
Rework lstrip/rstrip usage 
 
           | 
        
        
          
            
              - 
Property                 svn:eol-style
 set to                 
native
               
              - 
Property                 svn:keywords
 set to                 
Author Date Id Revision
               
             
           | 
        
        
          | 
            File size:
            1.1 KB
           | 
        
      
      
| Line |   | 
|---|
| 1 | 
 | 
|---|
| 2 | /***********************************************************************
 | 
|---|
| 3 | 
 | 
|---|
| 4 |   $Id: strips.c 123 2004-12-05 00:20:19Z root $
 | 
|---|
| 5 | 
 | 
|---|
| 6 |   String strippers
 | 
|---|
| 7 | 
 | 
|---|
| 8 |   Copyright (c) 1993-98 M. Kimes
 | 
|---|
| 9 |   Copyright (c) 2004 Steven H.Levine
 | 
|---|
| 10 | 
 | 
|---|
| 11 |   Revisions     01 Aug 04 SHL - Rework lstrip/rstrip usage
 | 
|---|
| 12 | 
 | 
|---|
| 13 | ***********************************************************************/
 | 
|---|
| 14 | 
 | 
|---|
| 15 | #include <os2.h>
 | 
|---|
| 16 | #include <stdlib.h>
 | 
|---|
| 17 | #include <string.h>
 | 
|---|
| 18 | #include <ctype.h>
 | 
|---|
| 19 | 
 | 
|---|
| 20 | #pragma alloc_text(MISC8,strip_trail_char,strip_lead_char)
 | 
|---|
| 21 | 
 | 
|---|
| 22 | void strip_trail_char (char *pszStripChars,char *pszSrc) {
 | 
|---|
| 23 | 
 | 
|---|
| 24 |   char *psz;
 | 
|---|
| 25 | 
 | 
|---|
| 26 |   if(pszSrc && *pszSrc && pszStripChars && *pszStripChars) {
 | 
|---|
| 27 |     psz = pszSrc + strlen(pszSrc) - 1;
 | 
|---|
| 28 |     // while not empty and tail char in strip list
 | 
|---|
| 29 |     while (*pszSrc && strchr(pszStripChars,*psz) != NULL) {
 | 
|---|
| 30 |       *psz = 0;
 | 
|---|
| 31 |       psz--;
 | 
|---|
| 32 |     }
 | 
|---|
| 33 |   }
 | 
|---|
| 34 | }
 | 
|---|
| 35 | 
 | 
|---|
| 36 | void strip_lead_char (char *pszStripChars,char *pszSrc) {
 | 
|---|
| 37 | 
 | 
|---|
| 38 |   char *psz = pszSrc;
 | 
|---|
| 39 | 
 | 
|---|
| 40 |   if(pszSrc && *pszSrc && pszStripChars && *pszStripChars) {
 | 
|---|
| 41 |     // while lead char in strip list
 | 
|---|
| 42 |     while(*psz && strchr(pszStripChars,*psz) != NULL)
 | 
|---|
| 43 |       psz++;
 | 
|---|
| 44 |     if(psz != pszSrc)
 | 
|---|
| 45 |       memmove(pszSrc,psz,strlen(psz) + 1);
 | 
|---|
| 46 |   }
 | 
|---|
| 47 | }
 | 
|---|
| 48 | 
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.