jsminc 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/ext/jsminc/extconf.rb +0 -4
- data/ext/jsminc/jsminc.c +42 -38
- data/lib/jsminc/version.rb +1 -1
- metadata +15 -14
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6be255c5b142e78b904ef8ab6948630ab86c67e9
|
4
|
+
data.tar.gz: 4482f12697501691d2d021a4ec4ddfc0af3cbbc3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1941945c97d9bdd864bab7e3f526d3dd0b84a95715c1a7c40fcd5a5ae058393d92fc2ce15702bd28bca58a81ff9b65f3dc52c46a6fd32ce0fba80d08fb7aa394
|
7
|
+
data.tar.gz: ce759234d390c32c96b1333947993a6c1039e769babfdc7699b2d6bf7bf9960929b0e65fee4bb7ac7eb10f49c1fc82283a49015f165a0b9a4b4ba89077ce9f8e
|
data/ext/jsminc/extconf.rb
CHANGED
data/ext/jsminc/jsminc.c
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
typedef struct jsmin_struct {
|
4
4
|
char theA;
|
5
5
|
char theB;
|
6
|
+
char theX;
|
7
|
+
char theY;
|
6
8
|
char theLookahead;
|
7
9
|
char *in;
|
8
10
|
char *out;
|
@@ -47,7 +49,7 @@ static void
|
|
47
49
|
write_char(jsmin_struct *s, const char c)
|
48
50
|
{
|
49
51
|
*(s->out) = c;
|
50
|
-
|
52
|
+
*(s->out)++;
|
51
53
|
}
|
52
54
|
|
53
55
|
/* peek -- get the next character without getting it.
|
@@ -75,27 +77,29 @@ next(jsmin_struct *s)
|
|
75
77
|
for (;;) {
|
76
78
|
c = get(s);
|
77
79
|
if (c <= '\n') {
|
78
|
-
|
80
|
+
break;
|
79
81
|
}
|
80
82
|
}
|
83
|
+
break;
|
81
84
|
case '*':
|
82
85
|
get(s);
|
83
|
-
|
86
|
+
while (c != ' ') {
|
84
87
|
switch (get(s)) {
|
85
88
|
case '*':
|
86
89
|
if (peek(s) == '/') {
|
87
90
|
get(s);
|
88
|
-
|
91
|
+
c = ' ';
|
89
92
|
}
|
90
93
|
break;
|
91
94
|
case '\0':
|
92
95
|
rb_raise(rb_eStandardError, "unterminated comment");
|
93
96
|
}
|
94
97
|
}
|
95
|
-
|
96
|
-
return c;
|
98
|
+
break;
|
97
99
|
}
|
98
100
|
}
|
101
|
+
s->theY = s->theX;
|
102
|
+
s->theX = c;
|
99
103
|
return c;
|
100
104
|
}
|
101
105
|
|
@@ -114,6 +118,11 @@ action(jsmin_struct *s, int d)
|
|
114
118
|
switch (d) {
|
115
119
|
case 1:
|
116
120
|
write_char(s, s->theA);
|
121
|
+
if ((s->theY == '\n' || s->theY == ' ') &&
|
122
|
+
(s->theA == '+' || s->theA == '-' || s->theA == '*' || s->theA == '/') &&
|
123
|
+
(s->theB == '+' || s->theB == '-' || s->theB == '*' || s->theB == '/')) {
|
124
|
+
write_char(s, s->theY);
|
125
|
+
}
|
117
126
|
case 2:
|
118
127
|
s->theA = s->theB;
|
119
128
|
if (s->theA == '\'' || s->theA == '"' || s->theA == '`') {
|
@@ -134,12 +143,15 @@ action(jsmin_struct *s, int d)
|
|
134
143
|
}
|
135
144
|
case 3:
|
136
145
|
s->theB = next(s);
|
137
|
-
if (s->theB == '/' && (
|
138
|
-
s->theA == '
|
139
|
-
s->theA == '
|
140
|
-
s->theA == '
|
141
|
-
s->theA == '\n')) {
|
146
|
+
if (s->theB == '/' && (
|
147
|
+
s->theA == '(' || s->theA == ',' || s->theA == '=' || s->theA == ':' ||
|
148
|
+
s->theA == '[' || s->theA == '!' || s->theA == '&' || s->theA == '|' ||
|
149
|
+
s->theA == '?' || s->theA == '+' || s->theA == '-' || s->theA == '~' ||
|
150
|
+
s->theA == '*' || s->theA == '/' || s->theA == '{' || s->theA == '\n')) {
|
142
151
|
write_char(s, s->theA);
|
152
|
+
if (s->theA == '/' || s->theA == '*') {
|
153
|
+
write_char(s, ' ');
|
154
|
+
}
|
143
155
|
write_char(s, s->theB);
|
144
156
|
for (;;) {
|
145
157
|
s->theA = get(s);
|
@@ -159,6 +171,11 @@ action(jsmin_struct *s, int d)
|
|
159
171
|
}
|
160
172
|
}
|
161
173
|
} else if (s->theA == '/') {
|
174
|
+
switch (peek(s)) {
|
175
|
+
case '/':
|
176
|
+
case '*':
|
177
|
+
rb_raise(rb_eStandardError, "unterminated set in regex literal");
|
178
|
+
}
|
162
179
|
break;
|
163
180
|
} else if (s->theA =='\\') {
|
164
181
|
write_char(s, s->theA);
|
@@ -184,18 +201,18 @@ action(jsmin_struct *s, int d)
|
|
184
201
|
static void
|
185
202
|
jsmin(jsmin_struct *s)
|
186
203
|
{
|
204
|
+
if (peek(s) == 0xEF) {
|
205
|
+
get(s);
|
206
|
+
get(s);
|
207
|
+
get(s);
|
208
|
+
}
|
187
209
|
s->theA = '\n';
|
188
|
-
s->theLookahead = '\0';
|
189
210
|
|
190
211
|
action(s, 3);
|
191
212
|
while (s->theA != '\0') {
|
192
213
|
switch (s->theA) {
|
193
214
|
case ' ':
|
194
|
-
|
195
|
-
action(s, 1);
|
196
|
-
} else {
|
197
|
-
action(s, 2);
|
198
|
-
}
|
215
|
+
action(s, isAlphanum(s->theB) ? 1 : 2);
|
199
216
|
break;
|
200
217
|
case '\n':
|
201
218
|
switch (s->theB) {
|
@@ -204,27 +221,21 @@ jsmin(jsmin_struct *s)
|
|
204
221
|
case '(':
|
205
222
|
case '+':
|
206
223
|
case '-':
|
224
|
+
case '!':
|
225
|
+
case '~':
|
207
226
|
action(s, 1);
|
208
227
|
break;
|
209
228
|
case ' ':
|
210
229
|
action(s, 3);
|
211
230
|
break;
|
212
231
|
default:
|
213
|
-
|
214
|
-
action(s, 1);
|
215
|
-
} else {
|
216
|
-
action(s, 2);
|
217
|
-
}
|
232
|
+
action(s, isAlphanum(s->theB) ? 1 : 2);
|
218
233
|
}
|
219
234
|
break;
|
220
235
|
default:
|
221
236
|
switch (s->theB) {
|
222
237
|
case ' ':
|
223
|
-
|
224
|
-
action(s, 1);
|
225
|
-
break;
|
226
|
-
}
|
227
|
-
action(s, 3);
|
238
|
+
action(s, isAlphanum(s->theA) ? 1 : 3);
|
228
239
|
break;
|
229
240
|
case '\n':
|
230
241
|
switch (s->theA) {
|
@@ -239,11 +250,7 @@ jsmin(jsmin_struct *s)
|
|
239
250
|
action(s, 1);
|
240
251
|
break;
|
241
252
|
default:
|
242
|
-
|
243
|
-
action(s, 1);
|
244
|
-
} else {
|
245
|
-
action(s, 3);
|
246
|
-
}
|
253
|
+
action(s, isAlphanum(s->theA) ? 1 : 3);
|
247
254
|
}
|
248
255
|
break;
|
249
256
|
default:
|
@@ -263,19 +270,16 @@ static VALUE minify(VALUE self, VALUE _in_s) {
|
|
263
270
|
long in_length = strlen(in_s);
|
264
271
|
char out_s[in_length + 1];
|
265
272
|
|
266
|
-
#ifdef RUBY_19
|
267
273
|
VALUE prev_encoding = rb_funcall(_in_s, rb_intern("encoding"), 0);
|
268
|
-
#endif
|
269
274
|
|
275
|
+
s.theLookahead = '\0';
|
276
|
+
s.theX = '\0';
|
277
|
+
s.theY = '\0';
|
270
278
|
s.in = in_s;
|
271
279
|
s.out = out_s;
|
272
280
|
jsmin(&s);
|
273
281
|
|
274
|
-
#ifdef RUBY_19
|
275
282
|
return rb_funcall(rb_str_new2(out_s + 1), rb_intern("force_encoding"), 1, prev_encoding);
|
276
|
-
#else
|
277
|
-
return rb_str_new2(out_s + 1);
|
278
|
-
#endif
|
279
283
|
}
|
280
284
|
|
281
285
|
|
data/lib/jsminc/version.rb
CHANGED
metadata
CHANGED
@@ -1,27 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsminc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Ryan Fitzgerald
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-12-17 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake-compiler
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
25
27
|
description: JSMinC is the original C version of JSMin, embedded in Ruby.
|
26
28
|
email:
|
27
29
|
- rwfitzge@gmail.com
|
@@ -30,7 +32,7 @@ extensions:
|
|
30
32
|
- ext/jsminc/extconf.rb
|
31
33
|
extra_rdoc_files: []
|
32
34
|
files:
|
33
|
-
- .gitignore
|
35
|
+
- ".gitignore"
|
34
36
|
- Gemfile
|
35
37
|
- LICENSE
|
36
38
|
- Rakefile
|
@@ -41,26 +43,25 @@ files:
|
|
41
43
|
- lib/jsminc/version.rb
|
42
44
|
homepage: http://rynftz.gr/
|
43
45
|
licenses: []
|
46
|
+
metadata: {}
|
44
47
|
post_install_message:
|
45
48
|
rdoc_options: []
|
46
49
|
require_paths:
|
47
50
|
- lib
|
48
51
|
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
52
|
requirements:
|
51
|
-
- -
|
53
|
+
- - ">="
|
52
54
|
- !ruby/object:Gem::Version
|
53
55
|
version: '0'
|
54
56
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
57
|
requirements:
|
57
|
-
- -
|
58
|
+
- - ">="
|
58
59
|
- !ruby/object:Gem::Version
|
59
60
|
version: '0'
|
60
61
|
requirements: []
|
61
62
|
rubyforge_project: jsminc
|
62
|
-
rubygems_version:
|
63
|
+
rubygems_version: 2.5.2
|
63
64
|
signing_key:
|
64
|
-
specification_version:
|
65
|
+
specification_version: 4
|
65
66
|
summary: A fast JavaScript minifier written in C (by Douglas Crockford)
|
66
67
|
test_files: []
|