SDDS ToolKit Programs and Libraries for C and Python
Toggle main menu visibility
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
d
g
l
p
s
Functions
_
d
g
l
p
s
Files
File List
•
All
Classes
Files
Functions
Variables
Macros
Pages
Loading...
Searching...
No Matches
SDDS
mdblib
compress.c
Go to the documentation of this file.
1
/**
2
* @file compress.c
3
* @brief Provides a string manipulation function.
4
*
5
* This file contains functions to create, manage, and manipulate buffers that store
6
* lines of text strings. Buffers can be dynamically created, added to, cleared, and
7
* printed to files.
8
*
9
* @copyright
10
* - (c) 2002 The University of Chicago, as Operator of Argonne National Laboratory.
11
* - (c) 2002 The Regents of the University of California, as Operator of Los Alamos National Laboratory.
12
*
13
* @license
14
* This file is distributed under the terms of the Software License Agreement
15
* found in the file LICENSE included with this distribution.
16
*
17
* @author C. Saunders, R. Soliday
18
*/
19
20
#include "mdb.h"
21
#include <ctype.h>
22
23
/**
24
* @brief Eliminates repeated occurrences of characters in string t from string s.
25
*
26
* This function removes consecutive duplicate characters in string `s` that are present in string `t`.
27
*
28
* @param s Pointer to the string to be compressed. The string is modified in place.
29
* @param t Pointer to the string containing characters to remove from `s`.
30
* @return Pointer to the compressed string `s`.
31
*/
32
char
*
compressString
(
char
*s,
char
*t) {
33
register
char
*ptr, *ptr0, *tptr;
34
35
ptr = ptr0 = s;
36
while
(*ptr0) {
37
tptr = t;
38
while
(*tptr) {
39
if
(*tptr != *ptr0) {
40
tptr++;
41
continue
;
42
}
43
while
(*++ptr0 == *tptr)
44
;
45
tptr++;
46
ptr0--;
47
}
48
*ptr++ = *ptr0++;
49
}
50
*ptr = 0;
51
return
(s);
52
}
32
char
*
compressString
(
char
*s,
char
*t) {
…
}
compressString
char * compressString(char *s, char *t)
Eliminates repeated occurrences of characters in string t from string s.
Definition
compress.c:32
Generated by
1.12.0