curl_escape 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9e245dcbc587665d607975ad25ca806804c28458
4
- data.tar.gz: 88e34847057a483229fef9a6887d2065ebc8ef69
3
+ metadata.gz: 1cc7b71d0852a4742c04075e57c59a9548afab18
4
+ data.tar.gz: 90d77f2ba82fb50bb2760750a425eccc05f9aaa8
5
5
  SHA512:
6
- metadata.gz: 414c3cca07d563b8bf429692080f4b5c2b89e3810e2a8bb47c44964400777ec7f64a73c42729f1ce777d364ac87442022d079a9f9b6a68fe5973f9a875e7585f
7
- data.tar.gz: 7b503b475257be37c14fe80daf5f0615f0f6bca774dfbb61d70f34ede40605f0dbbc95ad6eb52c5eef2c252f290d0dd828a4b2c7acf7b30ca647571362cc0c33
6
+ metadata.gz: 644f12380a3198872682c5d4bc0a42449a2e06066beb01909ce13adb749415090954142a9986e30fa2fcb0fe0bde37e3e6af7771ce4ac0a1f121ed2edeb682cc
7
+ data.tar.gz: 5892f35b9904110e2681994aa724b2248cd331dba4bce1feb3fb173ab484c0d40a60ebdb92d3ba4591c2075b4a9e1b8efb6a992fac4e09aebf7a89377ae2b9e4
@@ -3,7 +3,7 @@
3
3
  #include <ruby.h>
4
4
 
5
5
  VALUE ruby_curl_escape(VALUE self, VALUE str) {
6
- int rest, cnt;
6
+ int cnt;
7
7
  VALUE output;
8
8
 
9
9
  static CURL *curl;
@@ -14,23 +14,27 @@ VALUE ruby_curl_escape(VALUE self, VALUE str) {
14
14
  char *cStr = StringValueCStr(str);
15
15
  char *cOutput = curl_easy_escape(curl, cStr, strlen(cStr));
16
16
 
17
+ int pos = 0;
18
+ char buf[strlen(cOutput) * 3];
19
+
17
20
  if (cOutput) {
18
21
  for (cnt = 0; *(cOutput + cnt) != '\0'; cnt++) {
19
22
  if (strncmp(cOutput + cnt, "%20", 3) == 0) {
20
- *(cOutput + cnt) = '+';
21
- rest = strlen(cOutput + cnt + 3);
22
- memmove(cOutput + cnt + 1, cOutput + cnt + 3, rest);
23
- *(cOutput + cnt + 1 + rest) = '\0';
23
+ buf[pos] = '+';
24
+ cnt += 2;
24
25
  } else if (*(cOutput + cnt) == '~') {
25
- cOutput = realloc(cOutput, strlen(cOutput) + 2);
26
- rest = strlen(cOutput + cnt + 1);
27
- memmove(cOutput + cnt + 3, cOutput + cnt + 1, rest);
28
- *(cOutput + cnt + 3 + rest) = '\0';
29
- memcpy(cOutput + cnt, "%7E", 3);
26
+ buf[pos] = '%';
27
+ buf[pos+1] = '7';
28
+ buf[pos+2] = 'E';
29
+ pos += 2;
30
+ } else {
31
+ buf[pos] = *(cOutput + cnt);
30
32
  }
33
+ pos++;
31
34
  }
35
+ buf[pos++] = '\0';
32
36
 
33
- output = rb_str_new2(cOutput);
37
+ output = rb_str_new2(buf);
34
38
  curl_free(cOutput);
35
39
  return output;
36
40
  } else {
@@ -1,7 +1,5 @@
1
1
  require 'mkmf'
2
2
 
3
- $CFLAGS << ' -Wall'
4
-
5
3
  dir_config('curl').any? || pkg_config('libcurl')
6
4
 
7
5
  if have_header('curl/curl.h') && have_library('curl', 'curl_easy_init')
@@ -1,3 +1,3 @@
1
1
  module CurlEscape
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curl_escape
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - joker1007
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-28 00:00:00.000000000 Z
11
+ date: 2016-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler