chipper 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/ext/src/chipper.cc +12 -6
- data/ext/src/version.h +1 -1
- metadata +3 -3
data/ext/src/chipper.cc
CHANGED
@@ -55,15 +55,21 @@ void replace(char *string, const char *pattern, int c) {
|
|
55
55
|
}
|
56
56
|
}
|
57
57
|
|
58
|
+
// TODO: inplace version that doesn't barf on pointer math.
|
58
59
|
void remove(char *string, const char *pattern) {
|
59
|
-
int
|
60
|
-
char *
|
60
|
+
int width = strlen(pattern);
|
61
|
+
char *sanitized = (char *)malloc(strlen(string) + 1), *src = string, *dst = sanitized;
|
61
62
|
|
62
|
-
while (
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
while (*src) {
|
64
|
+
if (memcmp(src, pattern, width) == 0)
|
65
|
+
src += width;
|
66
|
+
else
|
67
|
+
*dst++ = *src++;
|
66
68
|
}
|
69
|
+
|
70
|
+
*dst = 0;
|
71
|
+
strcpy(string, sanitized);
|
72
|
+
free(sanitized);
|
67
73
|
}
|
68
74
|
|
69
75
|
typedef struct List {
|
data/ext/src/version.h
CHANGED
@@ -1 +1 @@
|
|
1
|
-
#define CHIPPER_VERSION "0.4.
|
1
|
+
#define CHIPPER_VERSION "0.4.3"
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 3
|
9
|
+
version: 0.4.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Bharanee Rathna
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-01-
|
18
|
+
date: 2012-01-19 00:00:00 +11:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|