soundx 1.0.4 → 1.0.5
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 +17 -14
- 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: 86f425b567e457397df034bf61c511f8a4b783f4c16d0ff71947fcd752f9ecee
|
4
|
+
data.tar.gz: 4155a8c79c3992726445fe4c94401c4070328fd89aa6622a45c5bd575fff62c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08d87b1bf5134634ab9738b8c5e03ca4faa2a45786c82416e8bcd3397b6eee2da3d8674a2f24a884da74a17b317e93bbcd13ea68917d56646d52dc1cf811f9ed'
|
7
|
+
data.tar.gz: 745e1d8033be4534f915f7402bf0847e20d6a471b5a9361790e109d1340f5cd6d94abd7ddc70df2ae82ef93d6e2373f1fdc5913a4bcf5145ed38c1739908696b
|
data/ext/soundx/soundx.c
CHANGED
@@ -46,9 +46,13 @@ static VALUE
|
|
46
46
|
rb_soundx(int argc, VALUE* argv, VALUE self)
|
47
47
|
{
|
48
48
|
VALUE input;
|
49
|
+
VALUE rbDestString;
|
49
50
|
unsigned char* src;
|
50
|
-
|
51
|
+
unsigned char written = 0; // Should not exceed 3, so 8 bits is plenty.
|
51
52
|
size_t srclen;
|
53
|
+
size_t i; // for looping the src
|
54
|
+
unsigned char current;
|
55
|
+
unsigned char match;
|
52
56
|
|
53
57
|
/*
|
54
58
|
Destination is padded with up to 3 trailing zeros
|
@@ -58,32 +62,31 @@ rb_soundx(int argc, VALUE* argv, VALUE self)
|
|
58
62
|
|
59
63
|
rb_scan_args(argc, argv, "1", &input);
|
60
64
|
|
61
|
-
|
62
|
-
rb_raise(rb_eTypeError, "expected a String");
|
63
|
-
}
|
65
|
+
Check_Type(input, T_STRING);
|
64
66
|
|
65
67
|
srclen = RSTRING_LEN(input);
|
66
68
|
src = (unsigned char *) StringValueCStr(input);
|
67
69
|
|
70
|
+
if (src[0] > 127) {
|
71
|
+
rb_raise(rb_eArgError, "non-ASCII character found");
|
72
|
+
}
|
73
|
+
|
68
74
|
dest[0] = toupper(src[0]);
|
69
75
|
|
70
|
-
for(
|
76
|
+
for(i = 1; i < srclen; i++) {
|
71
77
|
if (written >= 3) {
|
72
78
|
break;
|
73
79
|
}
|
74
80
|
|
75
|
-
if (
|
76
|
-
break;
|
77
|
-
}
|
78
|
-
|
79
|
-
if (src[i] > 128) {
|
81
|
+
if (src[i] > 127) {
|
80
82
|
rb_raise(rb_eArgError, "non-ASCII character found");
|
81
83
|
break;
|
82
84
|
}
|
83
85
|
|
84
|
-
|
86
|
+
current = tolower(src[i]);
|
87
|
+
|
88
|
+
match = mapping[ current ];
|
85
89
|
|
86
|
-
unsigned char match = mapping[ current ];
|
87
90
|
if (0xFE == match) {
|
88
91
|
continue;
|
89
92
|
}
|
@@ -112,9 +115,9 @@ rb_soundx(int argc, VALUE* argv, VALUE self)
|
|
112
115
|
written++;
|
113
116
|
}
|
114
117
|
|
115
|
-
|
118
|
+
rbDestString = rb_str_new_cstr(dest);
|
116
119
|
|
117
|
-
return
|
120
|
+
return rbDestString;
|
118
121
|
}
|
119
122
|
void
|
120
123
|
Init_soundx() {
|
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.5
|
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-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|