soundx 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/soundx/soundx.c +10 -21
- data/lib/soundx/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70da174fdeb5829dc7ad150b4d3f55ffdc10234e2f3b766fbe0a5b958855fa9f
|
4
|
+
data.tar.gz: 69fd9ec26626d65efd54ef0ced2112bf1818ea8ce9557c68253e1299abc5b5da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4045704be2c535c5cf56324e156300217a820e9aa52518c96ff8865906d2c9bb191bb7cb98044842382d96752d871b2acd46cea9c4a91d8b207222d423e3bf78
|
7
|
+
data.tar.gz: 616866e481e640814594105e59407d200e782ffeabfbde84fd4895189cac7dd3c270f691914bd436d6adf5828674c7747ba2b491dd13c960f52df387ddf35331
|
data/ext/soundx/soundx.c
CHANGED
@@ -20,7 +20,7 @@ r => 6
|
|
20
20
|
Pre-computed mapping of a-z to the above
|
21
21
|
table.
|
22
22
|
*/
|
23
|
-
static const char mapping[128] = {
|
23
|
+
static const unsigned char mapping[128] = {
|
24
24
|
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
25
25
|
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
26
26
|
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
@@ -46,14 +46,15 @@ static VALUE
|
|
46
46
|
rb_soundx(int argc, VALUE* argv, VALUE self)
|
47
47
|
{
|
48
48
|
VALUE input;
|
49
|
-
|
49
|
+
unsigned char* src;
|
50
50
|
int written = 0;
|
51
51
|
size_t srclen;
|
52
|
-
char *dest = malloc(5);
|
53
52
|
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
/*
|
54
|
+
Destination is padded with up to 3 trailing zeros
|
55
|
+
for short names.
|
56
|
+
*/
|
57
|
+
char dest[5] = {'0', '0', '0', '0', '\0'};
|
57
58
|
|
58
59
|
rb_scan_args(argc, argv, "1", &input);
|
59
60
|
|
@@ -62,7 +63,7 @@ rb_soundx(int argc, VALUE* argv, VALUE self)
|
|
62
63
|
}
|
63
64
|
|
64
65
|
srclen = RSTRING_LEN(input);
|
65
|
-
src = (
|
66
|
+
src = (unsigned char *) StringValueCStr(input);
|
66
67
|
|
67
68
|
dest[0] = toupper(src[0]);
|
68
69
|
|
@@ -76,15 +77,14 @@ rb_soundx(int argc, VALUE* argv, VALUE self)
|
|
76
77
|
}
|
77
78
|
|
78
79
|
if (src[i] > 128) {
|
79
|
-
free(dest);
|
80
80
|
rb_raise(rb_eArgError, "non-ASCII character found");
|
81
81
|
break;
|
82
82
|
}
|
83
83
|
|
84
84
|
unsigned char current = tolower(src[i]);
|
85
85
|
|
86
|
-
char match = mapping[ current ];
|
87
|
-
if (0xFE ==
|
86
|
+
unsigned char match = mapping[ current ];
|
87
|
+
if (0xFE == match) {
|
88
88
|
continue;
|
89
89
|
}
|
90
90
|
|
@@ -104,18 +104,7 @@ rb_soundx(int argc, VALUE* argv, VALUE self)
|
|
104
104
|
written++;
|
105
105
|
}
|
106
106
|
|
107
|
-
// Pad at most three '0' characters
|
108
|
-
// to handle really short names
|
109
|
-
if (written < 3) {
|
110
|
-
for( int i = (3-written); i > 0; i--) {
|
111
|
-
dest[written+i] = '0';
|
112
|
-
}
|
113
|
-
}
|
114
|
-
|
115
|
-
dest[4] = '\0';
|
116
|
-
|
117
107
|
VALUE rbString = rb_str_new_cstr(dest);
|
118
|
-
free(dest);
|
119
108
|
|
120
109
|
return rbString;
|
121
110
|
}
|
data/lib/soundx/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soundx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Cook
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|