source: trunk/dll/strips.c@ 689

Last change on this file since 689 was 551, checked in by Gregg Young, 19 years ago

Indentation cleanup

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.5 KB
Line 
1
2/***********************************************************************
3
4 $Id: strips.c 551 2007-02-28 01:33:51Z gyoung $
5
6 String strippers
7
8 Copyright (c) 1993-98 M. Kimes
9 Copyright (c) 2004 Steven H.Levine
10
11 01 Aug 04 SHL Rework lstrip/rstrip usage
12 26 Jul 06 SHL Add chop_at_crnl
13
14***********************************************************************/
15
16#include <os2.h>
17#include <stdlib.h>
18#include <string.h>
19#include <ctype.h>
20
21#pragma alloc_text(MISC8,chop_at_crnl,convert_nl_to_nul,strip_trail_char,strip_lead_char)
22
23VOID chop_at_crnl(PSZ pszSrc)
24{
25 // Chop line at CR or NL
26 PSZ psz = strchr(pszSrc, '\r');
27
28 if (psz)
29 *psz = 0;
30 psz = strchr(pszSrc, '\n');
31 if (psz)
32 *psz = 0;
33}
34
35PSZ convert_nl_to_nul(PSZ pszSrc)
36{
37 // Convert newline to nul, return pointer to next or NULL
38 PSZ psz = strchr(pszSrc, '\n');
39
40 if (psz) {
41 *psz = 0;
42 psz++;
43 }
44 return psz;
45}
46
47void strip_trail_char(char *pszStripChars, char *pszSrc)
48{
49 char *psz;
50
51 if (pszSrc && *pszSrc && pszStripChars && *pszStripChars) {
52 psz = pszSrc + strlen(pszSrc) - 1;
53 // while not empty and tail char in strip list
54 while (*pszSrc && strchr(pszStripChars, *psz) != NULL) {
55 *psz = 0;
56 psz--;
57 }
58 }
59}
60
61void strip_lead_char(char *pszStripChars, char *pszSrc)
62{
63 char *psz = pszSrc;
64
65 if (pszSrc && *pszSrc && pszStripChars && *pszStripChars) {
66 // while lead char in strip list
67 while (*psz && strchr(pszStripChars, *psz) != NULL)
68 psz++;
69 if (psz != pszSrc)
70 memmove(pszSrc, psz, strlen(psz) + 1);
71 }
72}
Note: See TracBrowser for help on using the repository browser.