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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b6839e528155e45a2816c36a41415dee39106d12dbe409d75274a97d42b1877
4
- data.tar.gz: 5c06f9d9fd44692d1a5047226bf5de33775760a021d5194be3b205d539d08747
3
+ metadata.gz: 86f425b567e457397df034bf61c511f8a4b783f4c16d0ff71947fcd752f9ecee
4
+ data.tar.gz: 4155a8c79c3992726445fe4c94401c4070328fd89aa6622a45c5bd575fff62c9
5
5
  SHA512:
6
- metadata.gz: 72c4ca9bcd78e412e49fbba2368bc04abcdc63907925988338c155bf096928ec37ed2d17e51a69970057b604b21002efe413e7b50288fdc69bbfd704fcfe2947
7
- data.tar.gz: f0507106a61b5d03fc713d0f54d3bd3c4c7f24a5510a27b50db796417281099793b8e131c79e863c291d26e635834654f0683f10903a06b0bebe7db833c87388
6
+ metadata.gz: '08d87b1bf5134634ab9738b8c5e03ca4faa2a45786c82416e8bcd3397b6eee2da3d8674a2f24a884da74a17b317e93bbcd13ea68917d56646d52dc1cf811f9ed'
7
+ data.tar.gz: 745e1d8033be4534f915f7402bf0847e20d6a471b5a9361790e109d1340f5cd6d94abd7ddc70df2ae82ef93d6e2373f1fdc5913a4bcf5145ed38c1739908696b
@@ -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
- int written = 0;
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
- if (TYPE(input) != T_STRING) {
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(size_t i = 1; i <= srclen; i++) {
76
+ for(i = 1; i < srclen; i++) {
71
77
  if (written >= 3) {
72
78
  break;
73
79
  }
74
80
 
75
- if ('\0' == src[i]) {
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
- unsigned char current = tolower(src[i]);
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
- VALUE rbString = rb_str_new_cstr(dest);
118
+ rbDestString = rb_str_new_cstr(dest);
116
119
 
117
- return rbString;
120
+ return rbDestString;
118
121
  }
119
122
  void
120
123
  Init_soundx() {
@@ -1,3 +1,3 @@
1
1
  module SoundX
2
- VERSION = '1.0.4'
2
+ VERSION = '1.0.5'
3
3
  end
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
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-10 00:00:00.000000000 Z
11
+ date: 2019-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler