jsmin_c 1.0.1 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/jsmin_c.c +6 -4
  2. data/jsmin_c.gemspec +2 -2
  3. data/test_jsmin.rb +10 -0
  4. metadata +3 -3
data/jsmin_c.c CHANGED
@@ -133,10 +133,12 @@ next()
133
133
  static inline void put_to_dest(int c)
134
134
  {
135
135
  /* this should be impossible? */
136
- if (desti < src_len+1)
136
+ if (desti <= src_len)
137
137
  dest[desti++] = c;
138
- else
138
+ else {
139
+ printf("desti: %d < src_len: %d\n", desti, src_len);
139
140
  rb_raise(rb_eIndexError, "JSMIN target file is larger than source.");
141
+ }
140
142
  }
141
143
 
142
144
  /* action -- do something! What you do is determined by the argument:
@@ -209,7 +211,7 @@ action(int d)
209
211
  static void
210
212
  jsmin()
211
213
  {
212
- theA = '\n';
214
+ theA = ' ';
213
215
  action(3);
214
216
  while (theA != EOF) {
215
217
  switch (theA) {
@@ -291,7 +293,7 @@ static VALUE jsmin_convert(VALUE self, VALUE str)
291
293
  src_len = RSTRING_LEN(str);
292
294
 
293
295
  srci = desti = 0;
294
- dest = malloc(src_len);
296
+ dest = malloc(src_len+1);
295
297
  if (!dest)
296
298
  rb_raise(rb_eNoMemError, "malloc failed in %s", __func__);
297
299
 
data/jsmin_c.gemspec CHANGED
@@ -2,8 +2,8 @@ Gem::Specification.new do |s|
2
2
  s.name = 'jsmin_c'
3
3
  s.author = 'Domen Puncer'
4
4
  s.email = 'domen@cba.si'
5
- s.version = '1.0.1'
6
- s.date = '2010-03-03'
5
+ s.version = '1.0.4'
6
+ s.date = '2010-03-23'
7
7
  s.homepage = 'http://www.riassence.org/'
8
8
  s.summary = 'Riassence JSMin Wrapper'
9
9
  s.has_rdoc = true
data/test_jsmin.rb CHANGED
@@ -44,5 +44,15 @@ class TestJSMin < Test::Unit::TestCase
44
44
  assert_equal( @@test_output, jsmin.minimize( @@test_input ) )
45
45
  end
46
46
 
47
+ def test_mem
48
+ jsmin = JSMin.new
49
+ a = Thread.new { 500.times {|n| assert_equal( jsmin.minimize( @@test_input ), @@test_output) } }; Thread.pass
50
+ b = Thread.new { 500.times {|n| assert_equal( jsmin.minimize( @@test_output ), @@test_output) } }; Thread.pass
51
+ c = Thread.new { 500.times {|n| assert_equal( jsmin.minimize( @@test_input ), @@test_output) } }; Thread.pass
52
+ a.join
53
+ b.join
54
+ c.join
55
+ end
56
+
47
57
  end
48
58
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 1
9
- version: 1.0.1
8
+ - 4
9
+ version: 1.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Domen Puncer
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-03 00:00:00 +02:00
17
+ date: 2010-03-23 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies: []
20
20