Implementation of string manipulation routine.
More...
#include "mdb.h"
#include <ctype.h>
Go to the source code of this file.
|
char * | delete_bounding (char *s, char *t) |
| Deletes bounding characters from a string.
|
|
Implementation of string manipulation routine.
- Copyright
- (c) 2002 The University of Chicago, as Operator of Argonne National Laboratory.
- (c) 2002 The Regents of the University of California, as Operator of Los Alamos National Laboratory.
- License
- This file is distributed under the terms of the Software License Agreement found in the file LICENSE included with this distribution.
- Author
- M. Borland, C. Saunders, R. Soliday
Definition in file delete_bnd.c.
◆ delete_bounding()
char * delete_bounding |
( |
char * | s, |
|
|
char * | t ) |
Deletes bounding characters from a string.
Removes all leading and trailing characters from the string s
that are present in the string t
.
- Parameters
-
s | The string to be modified. |
t | The string containing bounding characters to remove from s . |
- Returns
- The modified string
s
.
Definition at line 28 of file delete_bnd.c.
29{
30 register char *ptr1, *ptr0, *ptrt;
31
32 if (!s)
33 return (s);
34 ptr0 = s;
35 while (*ptr0) {
36 ptrt = t;
37 while (*ptrt && *ptrt != *ptr0)
38 ptrt++;
39 if (*ptrt == *ptr0)
40 ptr0++;
41 else
42 break;
43 }
44
45 ptr1 = ptr0 + strlen(ptr0) - 1;
46 while (ptr1 != ptr0) {
47 ptrt = t;
48 while (*ptrt && *ptrt != *ptr1)
49 ptrt++;
50 if (*ptrt == *ptr1)
51 ptr1--;
52 else
53 break;
54 }
55
56 *++ptr1 = 0;
58 return (s);
59}
char * strcpy_ss(char *dest, const char *src)
Safely copies a string, handling memory overlap.