| 
            Last change
 on this file since 283 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
           | 
        
      
      
| Rev | Line |   | 
|---|
| [123] | 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 | 
 | 
|---|
| [2] | 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 | 
 | 
|---|
| [123] | 22 | void strip_trail_char (char *pszStripChars,char *pszSrc) {
 | 
|---|
| [2] | 23 | 
 | 
|---|
| [123] | 24 |   char *psz;
 | 
|---|
| [2] | 25 | 
 | 
|---|
| [123] | 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--;
 | 
|---|
| [2] | 32 |     }
 | 
|---|
 | 33 |   }
 | 
|---|
 | 34 | }
 | 
|---|
 | 35 | 
 | 
|---|
| [123] | 36 | void strip_lead_char (char *pszStripChars,char *pszSrc) {
 | 
|---|
| [2] | 37 | 
 | 
|---|
| [123] | 38 |   char *psz = pszSrc;
 | 
|---|
| [2] | 39 | 
 | 
|---|
| [123] | 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);
 | 
|---|
| [2] | 46 |   }
 | 
|---|
 | 47 | }
 | 
|---|
 | 48 | 
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.