SDDSlib
Loading...
Searching...
No Matches
delete_bnd.c File Reference

Implementation of string manipulation routine. More...

#include "mdb.h"
#include <ctype.h>

Go to the source code of this file.

Functions

char * delete_bounding (char *s, char *t)
 Deletes bounding characters from a string.
 

Detailed Description

Implementation of string manipulation routine.

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.

Function Documentation

◆ 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
sThe string to be modified.
tThe 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;
57 strcpy_ss(s, ptr0);
58 return (s);
59}
char * strcpy_ss(char *dest, const char *src)
Safely copies a string, handling memory overlap.
Definition str_copy.c:34