updated on Thu Jan 19 00:16:31 UTC 2012
[aur-mirror.git] / eruby / patch01.patch
bloba6e164eba6e83e3685ceaff2574acea453732bf9
1 diff -rupN eruby-1.0.5/ChangeLog eruby/ChangeLog
2 --- eruby-1.0.5/ChangeLog 2003-12-23 11:11:54.000000000 -0400
3 +++ eruby/ChangeLog 2009-03-04 20:41:28.000000000 -0430
4 @@ -1,3 +1,23 @@
5 +Tue Jul 19 19:07:12 2005 Jb Evain <jbevain@gmail.com>
7 + * eruby_lib.c: clean warnings, little refactoring
9 +Tue Mar 9 14:16:06 2004 Shugo Maeda <shugo@modruby.net>
11 + * Makefile.in: use $(RUBY) to execute bin2c.
13 +Tue Mar 9 14:08:19 2004 MOROHOSHI Akihiko <moro@remus.dti.ne.jp>
15 + * eruby_main.c (proc_args): pass ARGV to scripts.
17 +Wed Feb 25 13:37:07 2004 U.Nakamura <usa@garbagecollect.jp>
19 + * autoconf.rb: should use RUBY_PLATFORM instead of PLATFORM.
21 +Wed Dec 24 00:45:29 2003 Shugo Maeda <shugo@modruby.net>
23 + * eruby_main.c (run): call rb_exec_end_proc().
25 Wed Dec 24 00:11:19 2003 Shugo Maeda <shugo@modruby.net>
27 * version 1.0.5 released.
28 diff -rupN eruby-1.0.5/Makefile.in eruby/Makefile.in
29 --- eruby-1.0.5/Makefile.in 2003-07-26 06:21:33.000000000 -0400
30 +++ eruby/Makefile.in 2009-03-04 20:41:28.000000000 -0430
31 @@ -160,7 +160,7 @@ $(MANPAGE): @VPATH@eruby.rd
32 $(RM) $@~
34 eruby_logo.c: @VPATH@eruby_logo.png
35 - $(srcdir)/bin2c $(srcdir)/eruby_logo.png
36 + $(RUBY) $(srcdir)/bin2c $(srcdir)/eruby_logo.png
37 eruby_lib.@OBJEXT@: @VPATH@eruby_lib.c @VPATH@eruby.h config.h
38 eruby_logo.@OBJEXT@: @VPATH@eruby_logo.c @VPATH@eruby_logo.h
39 eruby_main.@OBJEXT@: @VPATH@eruby_main.c @VPATH@eruby.h @VPATH@eruby_logo.h
40 diff -rupN eruby-1.0.5/README.ja eruby/README.ja
41 --- eruby-1.0.5/README.ja 2001-05-16 05:27:08.000000000 -0400
42 +++ eruby/README.ja 2009-03-04 20:41:28.000000000 -0430
43 @@ -5,8 +5,7 @@
44 == eRuby¤È¤Ï?
46 eRuby¤ÏRuby¤Î¥³¡¼¥É¤¬Ëä¤á¤³¤Þ¤ì¤¿¥Æ¥­¥¹¥È¥Õ¥¡¥¤¥ë¤ò²ò¼á¼Â¹Ô¤·¤Þ¤¹¡£
47 -¤¿¤È¤¨¤Ð¡¢eRuby¤ò»È¤¨¤Ð¡¢HTML¤ËRuby¤Î¥³¡¼¥É¤òHTML¥Õ¥¡¥¤¥ë¤ËËä¤á¤³¤à
48 -¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
49 +¤¿¤È¤¨¤Ð¡¢eRuby¤ò»È¤¨¤Ð¡¢HTML¤ËRuby¤Î¥³¡¼¥É¤òËä¤á¤³¤à¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£
51 == Í׵ᤵ¤ì¤ë´Ä¶­
53 diff -rupN eruby-1.0.5/configure.rb eruby/configure.rb
54 --- eruby-1.0.5/configure.rb 2003-02-09 23:18:10.000000000 -0400
55 +++ eruby/configure.rb 2009-03-04 20:41:28.000000000 -0430
56 @@ -59,21 +59,24 @@ def AC_WITH(package, action = Proc.new)
57 end
58 end
60 -require 'ftools'
61 +require 'fileutils'
63 def AC_OUTPUT(*files)
64 + $DEFS ||= ""
65 if $AC_LIST_HEADER
66 - $DEFS = "-DHAVE_CONFIG_H"
67 + $DEFS << " -DHAVE_CONFIG_H"
68 AC_OUTPUT_HEADER($AC_LIST_HEADER)
69 else
70 - $DEFS = $ac_confdefs.collect {|k, v| "-D#{k}=#{v}" }.join(" ")
71 + $DEFS << " " + $ac_confdefs.collect {|k, v| "-D#{k}=#{v}" }.join(" ")
72 end
73 for file in files
74 print "creating ", file, "\n"
75 open(File.join($srcdir, file + ".in")) do |fin|
76 - File.makedirs(File.dirname(file))
77 + FileUtils.mkdir_p(File.dirname(file))
78 open(file, "w") do |fout|
79 + depend = false
80 while line = fin.gets
81 + depend = true if /^\#\#\# depend/ =~ line
82 line.gsub!(/@([A-Za-z_]+)@/) do |s|
83 name = $1
84 if $ac_sed.key?(name)
85 @@ -82,6 +85,7 @@ def AC_OUTPUT(*files)
87 end
88 end
89 + line.gsub!(/(\s)([^\s\/]+\.[ch])/, '\1{$(srcdir)}\2') if depend && $nmake
90 fout.print(line)
91 end
92 end
93 @@ -153,13 +157,18 @@ def AC_CONFIG_AUX_DIRS(*dirs)
94 file = File.join(dir, prog)
95 if File.file?(file); then
96 $ac_aux_dir = dir
97 - $ac_install_rb = "#{file} -c"
98 + $ac_install_rb = "$(RUBY) #{file} -c"
99 return
105 +begin
106 + require "continuation"
107 +rescue LoadError
108 +end
110 def AC_PROG_INSTALL
111 AC_MSG_CHECKING("for a BSD compatible install")
112 $ac_cv_path_install = callcc { |c|
113 @@ -291,6 +300,13 @@ $CC = CONFIG["CC"]
114 $AR = CONFIG["AR"]
115 $LD = "$(CC)"
116 $RANLIB = CONFIG["RANLIB"]
117 +$ruby = arg_config("--ruby", File.join(Config::CONFIG["bindir"], CONFIG["ruby_install_name"]))
118 +$RUBY = ($nmake && !$configure_args.has_key?('--ruby')) ? $ruby.gsub(%r'/', '\\') : $ruby
119 +if RUBY_VERSION < "1.8.0"
120 + $RM = 'rm -f'
121 +else
122 + $RM = CONFIG["RM"] || '$(RUBY) -run -e rm -- -f'
123 +end
125 if not defined? CFLAGS
126 CFLAGS = CONFIG["CFLAGS"]
127 @@ -306,7 +322,7 @@ if $LDFLAGS.to_s.empty? && /mswin32/ =~
128 $LDFLAGS = "-link -incremental:no -pdb:none"
130 $LIBS = CONFIG["LIBS"]
131 -$XLDFLAGS = CONFIG["XLDFLAGS"]
132 +$XLDFLAGS = CONFIG["XLDFLAGS"].to_s
133 $XLDFLAGS.gsub!(/-L\./, "")
134 if /mswin32/ !~ RUBY_PLATFORM
135 $XLDFLAGS += " -L$(libdir)"
136 @@ -333,7 +349,7 @@ $LIBRUBY = CONFIG["LIBRUBY"]
137 $LIBRUBY_A = CONFIG["LIBRUBY_A"]
138 $RUBY_SO_NAME = CONFIG["RUBY_SO_NAME"]
140 -case PLATFORM
141 +case RUBY_PLATFORM
142 when /-aix/
143 if $RUBY_SHARED
144 $LIBRUBYARG = "-Wl,$(libdir)/" + CONFIG["LIBRUBY_SO"]
145 @@ -349,6 +365,14 @@ when /-aix/
149 +$COMPILE_RULES = ''
150 +if defined?(COMPILE_RULES)
151 + COMPILE_RULES.each do |rule|
152 + $COMPILE_RULES << sprintf(rule, 'c', $OBJEXT)
153 + $COMPILE_RULES << sprintf("\n\t%s\n\n", COMPILE_C)
154 + end
155 +end
157 AC_SUBST("srcdir")
158 AC_SUBST("topdir")
159 AC_SUBST("hdrdir")
160 @@ -375,6 +399,8 @@ AC_SUBST("CC")
161 AC_SUBST("AR")
162 AC_SUBST("LD")
163 AC_SUBST("RANLIB")
164 +AC_SUBST("RUBY")
165 +AC_SUBST("RM")
167 AC_SUBST("CFLAGS")
168 AC_SUBST("DEFS")
169 @@ -388,6 +414,8 @@ AC_SUBST("OBJEXT")
170 AC_SUBST("EXEEXT")
171 AC_SUBST("DLEXT")
173 +AC_SUBST("COMPILE_RULES")
175 AC_SUBST("RUBY_INSTALL_NAME")
176 AC_SUBST("LIBRUBYARG")
177 AC_SUBST("LIBRUBYARG_SHARED")
178 @@ -431,7 +459,7 @@ AC_MSG_CHECKING("whether enable shared")
179 $ENABLE_SHARED = false
180 AC_ENABLE("shared") { |enableval|
181 if enableval == "yes"
182 - if PLATFORM =~ /-mswin32/
183 + if /-mswin32/ =~ RUBY_PLATFORM
184 AC_MSG_ERROR("can't enable shared on mswin32")
186 $ENABLE_SHARED = true
187 @@ -449,7 +477,7 @@ $LIBERUBY_ALIASES = "liberuby.#{CONFIG['
188 if $ENABLE_SHARED
189 $LIBERUBY = "${LIBERUBY_SO}"
190 $LIBERUBYARG = "-L. -leruby"
191 - case PLATFORM
192 + case RUBY_PLATFORM
193 when /-sunos4/
194 $LIBERUBY_ALIASES = "liberuby.so.$(MAJOR).$(MINOR) liberuby.so"
195 when /-linux/
196 @@ -457,7 +485,7 @@ if $ENABLE_SHARED
197 $LIBERUBY_ALIASES = "liberuby.so.$(MAJOR).$(MINOR) liberuby.so"
198 when /-(freebsd|netbsd)/
199 $LIBERUBY_SO = "liberuby.so.$(MAJOR).$(MINOR)"
200 - if PLATFORM =~ /elf/ || PLATFORM =~ /-freebsd[3-9]/
201 + if /elf/ =~ RUBY_PLATFORM || /-freebsd[3-9]/ =~ RUBY_PLATFORM
202 $LIBERUBY_SO = "liberuby.so.$(MAJOR_MINOR)"
203 $LIBERUBY_ALIASES = "liberuby.so"
204 else
205 @@ -493,7 +521,7 @@ EOIF
209 -if PLATFORM =~ /-mswin32/
210 +if /-mswin32/ =~ RUBY_PLATFORM
211 $AR = "lib"
212 $AROPT = "/out:$@"
213 $LIBERUBY_A = "liberuby.lib"
214 @@ -519,7 +547,7 @@ AC_SUBST("LIBERUBY_ALIASES")
215 AC_SUBST("AROPT")
217 $EXT_DLDFLAGS = CONFIG["DLDFLAGS"]
218 -if $RUBY_SHARED || RUBY_PLATFORM =~ /mswin32/
219 +if $RUBY_SHARED || /mswin32/ =~ RUBY_PLATFORM
220 $EXT_LIBRUBYARG = "$(LIBRUBYARG)"
221 else
222 $EXT_LIBRUBYARG = ""
223 diff -rupN eruby-1.0.5/configure.rb.in eruby/configure.rb.in
224 --- eruby-1.0.5/configure.rb.in 2003-01-20 03:22:41.000000000 -0400
225 +++ eruby/configure.rb.in 2009-03-04 20:41:28.000000000 -0430
226 @@ -35,7 +35,7 @@ $ENABLE_SHARED = false
227 AC_ARG_ENABLE("shared",
228 " --enable-shared build a shared library for eruby") { |enableval|
229 if enableval == "yes"
230 - if PLATFORM =~ /-mswin32/
231 + if /-mswin32/ =~ RUBY_PLATFORM
232 AC_MSG_ERROR("can't enable shared on mswin32")
234 $ENABLE_SHARED = true
235 @@ -53,7 +53,7 @@ $LIBERUBY_ALIASES = "liberuby.#{CONFIG['
236 if $ENABLE_SHARED
237 $LIBERUBY = "${LIBERUBY_SO}"
238 $LIBERUBYARG = "-L. -leruby"
239 - case PLATFORM
240 + case RUBY_PLATFORM
241 when /-sunos4/
242 $LIBERUBY_ALIASES = "liberuby.so.$(MAJOR).$(MINOR) liberuby.so"
243 when /-linux/
244 @@ -61,7 +61,7 @@ if $ENABLE_SHARED
245 $LIBERUBY_ALIASES = "liberuby.so.$(MAJOR).$(MINOR) liberuby.so"
246 when /-(freebsd|netbsd)/
247 $LIBERUBY_SO = "liberuby.so.$(MAJOR).$(MINOR)"
248 - if PLATFORM =~ /elf/ || PLATFORM =~ /-freebsd[3-9]/
249 + if /elf/ =~ RUBY_PLATFORM || /-freebsd[3-9]/ =~ RUBY_PLATFORM
250 $LIBERUBY_SO = "liberuby.so.$(MAJOR_MINOR)"
251 $LIBERUBY_ALIASES = "liberuby.so"
252 else
253 @@ -97,7 +97,7 @@ EOIF
257 -if PLATFORM =~ /-mswin32/
258 +if /-mswin32/ =~ RUBY_PLATFORM
259 $AR = "lib"
260 $AROPT = "/out:$@"
261 $LIBERUBY_A = "liberuby.lib"
262 @@ -123,7 +123,7 @@ AC_SUBST("LIBERUBY_ALIASES")
263 AC_SUBST("AROPT")
265 $EXT_DLDFLAGS = CONFIG["DLDFLAGS"]
266 -if $RUBY_SHARED || RUBY_PLATFORM =~ /mswin32/
267 +if $RUBY_SHARED || /mswin32/ =~ RUBY_PLATFORM
268 $EXT_LIBRUBYARG = "$(LIBRUBYARG)"
269 else
270 $EXT_LIBRUBYARG = ""
271 diff -rupN eruby-1.0.5/eruby.1 eruby/eruby.1
272 --- eruby-1.0.5/eruby.1 2000-09-13 03:35:51.000000000 -0400
273 +++ eruby/eruby.1 2009-03-04 20:41:28.000000000 -0430
274 @@ -1,5 +1,5 @@
275 .\" DO NOT MODIFY THIS FILE! it was generated by rd2
276 -.TH eruby 1 "September 2000"
277 +.TH eruby 1 "January 2007"
278 .SH NAME
280 eruby \- Embedded Ruby Language
281 @@ -10,13 +10,15 @@ eruby [options] [inputfile]
283 eruby interprets a Ruby code embedded text file. For example, eruby
284 enables you to embed a Ruby code to a HTML file.
285 +.PP
286 A Ruby block starts with `<%' and ends with `%>'. eRuby replaces
287 the block with its output.
288 +.PP
289 If `<%' is followed by `=', eRuby replaces the block with a value
290 of the block.
291 +.PP
292 If `<%' is followed by `#', the block is ignored as a comment.
293 .SH OPTIONS
294 -.PP
298 @@ -36,8 +38,7 @@ specifies runtime mode
299 \& f: filter mode
300 \& c: CGI mode
301 \& n: NPH\-CGI mode
302 -.fi
303 -.TP
304 +.fi.TP
307 \-C charset
308 @@ -55,7 +56,7 @@ enables verbose mode
312 -\-\-version
313 +\-\-version
314 print version information and exit
315 .SH AUTHOR
317 diff -rupN eruby-1.0.5/eruby.h eruby/eruby.h
318 --- eruby-1.0.5/eruby.h 2003-12-23 11:11:54.000000000 -0400
319 +++ eruby/eruby.h 2009-03-04 20:41:28.000000000 -0430
320 @@ -1,5 +1,5 @@
322 - * $Id: eruby.h,v 1.31 2003/12/23 15:11:54 shugo Exp $
323 + * $Id: eruby.h 129 2007-01-23 07:53:20Z shugo $
324 * Copyright (C) 2000 ZetaBITS, Inc.
325 * Copyright (C) 2000 Information-technology Promotion Agency, Japan
327 @@ -7,7 +7,7 @@
328 #ifndef ERUBY_H
329 #define ERUBY_H
331 -#define ERUBY_VERSION "1.0.5"
332 +#define ERUBY_VERSION "1.0.6"
334 #define ERUBY_MIME_TYPE "application/x-httpd-eruby"
336 @@ -28,18 +28,34 @@ enum eruby_mode {
337 extern char *eruby_filename;
338 extern int eruby_mode;
339 extern int eruby_noheader;
340 +extern int eruby_sync;
341 extern VALUE eruby_charset;
342 extern VALUE eruby_default_charset;
343 -#define ERUBY_CHARSET RSTRING(eruby_charset)->ptr
344 +#define ERUBY_CHARSET RSTRING_PTR(eruby_charset)
346 const char *eruby_version();
347 int eruby_parse_options(int argc, char **argv, int *optind);
348 VALUE eruby_compiler_new();
349 +VALUE eruby_compiler_set_sourcefile(VALUE self, VALUE filename);
350 VALUE eruby_compiler_compile_file(VALUE self, VALUE file);
351 VALUE eruby_compiler_compile_string(VALUE self, VALUE s);
352 VALUE eruby_load(char *filename, int wrap, int *state);
353 void eruby_init();
355 +/* for compatibility with ruby 1.9 */
356 +#ifndef RARRAY_LEN
357 +# define RARRAY_LEN(ary) (RARRAY(ary)->len)
358 +#endif
359 +#ifndef RARRAY_PTR
360 +# define RARRAY_PTR(ary) (RARRAY(ary)->ptr)
361 +#endif
362 +#ifndef RSTRING_LEN
363 +# define RSTRING_LEN(str) (RSTRING(str)->len)
364 +#endif
365 +#ifndef RSTRING_PTR
366 +# define RSTRING_PTR(str) (RSTRING(str)->ptr)
367 +#endif
369 #endif /* ERUBY_H */
372 diff -rupN eruby-1.0.5/eruby_ext.c eruby/eruby_ext.c
373 --- eruby-1.0.5/eruby_ext.c 2001-06-04 01:20:18.000000000 -0400
374 +++ eruby/eruby_ext.c 2009-03-04 20:41:28.000000000 -0430
375 @@ -1,5 +1,5 @@
377 - * $Id: eruby_ext.c,v 1.2 2001/06/04 05:20:18 shugo Exp $
378 + * $Id: eruby_ext.c 10 2004-07-01 04:48:04Z shugo $
379 * Copyright (C) 2000 ZetaBITS, Inc.
380 * Copyright (C) 2000 Information-technology Promotion Agency, Japan
381 * Copyright (C) 2000 Shugo Maeda <shugo@modruby.net>
382 diff -rupN eruby-1.0.5/eruby_lib.c eruby/eruby_lib.c
383 --- eruby-1.0.5/eruby_lib.c 2003-07-28 23:42:56.000000000 -0400
384 +++ eruby/eruby_lib.c 2009-03-04 20:41:28.000000000 -0430
385 @@ -1,5 +1,5 @@
387 - * $Id: eruby_lib.c,v 1.19 2003/07/29 03:42:56 shugo Exp $
388 + * $Id: eruby_lib.c 129 2007-01-23 07:53:20Z shugo $
389 * Copyright (C) 2000 ZetaBITS, Inc.
390 * Copyright (C) 2000 Information-technology Promotion Agency, Japan
391 * Copyright (C) 2000 Shugo Maeda <shugo@modruby.net>
392 @@ -48,6 +48,7 @@ static VALUE eERubyCompileError;
393 char *eruby_filename = NULL;
394 int eruby_mode = MODE_UNKNOWN;
395 int eruby_noheader = 0;
396 +int eruby_sync = 0;
397 VALUE eruby_charset;
398 VALUE eruby_default_charset;
400 @@ -82,6 +83,7 @@ usage: %s [switches] [inputfile]\n\n\
401 n: NPH-CGI mode\n\
402 -C [charset] specifies charset parameter for Content-Type\n\
403 -n, --noheader disables CGI header output\n\
404 + -s, --sync sync output\n\
405 -v, --verbose enables verbose mode\n\
406 --version print version information and exit\n\
407 \n", progname);
408 @@ -112,10 +114,19 @@ static int set_mode(char *mode)
409 return 0;
412 +static int is_option (const char *s, const char *opt)
414 + int len = strlen (opt);
415 + if (strncmp(s , opt, len) == 0
416 + && (s[len] == '\0' || isspace(s[len])))
417 + return len;
418 + return 0;
421 int eruby_parse_options(int argc, char **argv, int *optind)
423 - int i, result = 0;
424 - unsigned char *s;
425 + int i, next, result = 0;
426 + char *s;
428 for (i = 1; i < argc; i++) {
429 if (argv[i][0] != '-' || argv[i][1] == '\0') {
430 @@ -123,7 +134,7 @@ int eruby_parse_options(int argc, char *
432 s = argv[i];
433 again:
434 - while (isspace(*s))
435 + while (isspace(*(unsigned char *) s))
436 s++;
437 if (*s == '-') s++;
438 switch (*s) {
439 @@ -155,8 +166,8 @@ int eruby_parse_options(int argc, char *
440 break;
442 else {
443 - unsigned char *p = s;
444 - while (*p && !isspace(*p)) p++;
445 + char *p = s;
446 + while (*p && !isspace(*(unsigned char *) p)) p++;
447 eruby_charset = rb_str_new(s, p - s);
448 s = p;
449 goto again;
450 @@ -173,6 +184,10 @@ int eruby_parse_options(int argc, char *
451 eruby_noheader = 1;
452 s++;
453 goto again;
454 + case 's':
455 + eruby_sync = 1;
456 + s++;
457 + goto again;
458 case '\0':
459 break;
460 case 'h':
461 @@ -180,31 +195,31 @@ int eruby_parse_options(int argc, char *
462 result = 1; break;
463 case '-':
464 s++;
465 - if (strncmp(s , "debug", 5) == 0
466 - && (s[5] == '\0' || isspace(s[5]))) {
467 + if ((next = is_option (s, "debug"))) {
468 ruby_debug = Qtrue;
469 - s += 5;
470 + s += next;
471 goto again;
473 - else if (strncmp(s, "noheader", 8) == 0
474 - && (s[8] == '\0' || isspace(s[8]))) {
475 + else if ((next = is_option (s, "noheader"))) {
476 eruby_noheader = 1;
477 - s += 8;
478 + s += next;
479 goto again;
481 - else if (strncmp(s, "version", 7) == 0
482 - && (s[7] == '\0' || isspace(s[7]))) {
483 + else if ((next = is_option (s, "sync"))) {
484 + eruby_sync = 1;
485 + s += next;
486 + goto again;
488 + else if (is_option (s, "version")) {
489 show_version();
490 result = 1; break;
492 - else if (strncmp(s, "verbose", 7) == 0
493 - && (s[7] == '\0' || isspace(s[7]))) {
494 + else if ((next = is_option (s, "verbose"))) {
495 ruby_verbose = Qtrue;
496 - s += 7;
497 + s += next;
498 goto again;
500 - else if (strncmp(s, "help", 4) == 0
501 - && (s[4] == '\0' || isspace(s[4]))) {
502 + else if (is_option (s, "help")) {
503 usage(argv[0]);
504 result = 1; break;
506 @@ -296,18 +311,18 @@ static VALUE lex_str_gets(eruby_compiler
507 VALUE s = compiler->lex_input;
508 char *beg, *end, *pend;
510 - if (RSTRING(s)->len == compiler->lex_gets_ptr)
511 + if (RSTRING_LEN(s) == compiler->lex_gets_ptr)
512 return Qnil;
513 - beg = RSTRING(s)->ptr;
514 + beg = RSTRING_PTR(s);
515 if (compiler->lex_gets_ptr > 0) {
516 beg += compiler->lex_gets_ptr;
518 - pend = RSTRING(s)->ptr + RSTRING(s)->len;
519 + pend = RSTRING_PTR(s) + RSTRING_LEN(s);
520 end = beg;
521 while (end < pend) {
522 if (*end++ == '\n') break;
524 - compiler->lex_gets_ptr = end - RSTRING(s)->ptr;
525 + compiler->lex_gets_ptr = end - RSTRING_PTR(s);
526 return rb_str_new(beg, end - beg);
529 @@ -326,8 +341,8 @@ static inline int nextc(eruby_compiler_t
531 if (NIL_P(v)) return EOF;
532 compiler->sourceline++;
533 - compiler->lex_pbeg = compiler->lex_p = RSTRING(v)->ptr;
534 - compiler->lex_pend = compiler->lex_p + RSTRING(v)->len;
535 + compiler->lex_pbeg = compiler->lex_p = RSTRING_PTR(v);
536 + compiler->lex_pend = compiler->lex_p + RSTRING_LEN(v);
537 compiler->lex_lastline = v;
539 else {
540 @@ -469,9 +484,9 @@ static VALUE eruby_compile(eruby_compile
541 if (c == '#') {
542 c = nextc(compiler);
543 if (c == '!') {
544 - unsigned char *p;
545 + char *p;
546 char *argv[2];
547 - char *line = RSTRING(compiler->lex_lastline)->ptr;
548 + char *line = RSTRING_PTR(compiler->lex_lastline);
550 if (line[strlen(line) - 1] == '\n') {
551 line[strlen(line) - 1] = '\0';
552 @@ -479,9 +494,9 @@ static VALUE eruby_compile(eruby_compile
554 argv[0] = "eruby";
555 p = line;
556 - while (isspace(*p)) p++;
557 - while (*p && !isspace(*p)) p++;
558 - while (isspace(*p)) p++;
559 + while (isspace(*(unsigned char *) p)) p++;
560 + while (*p && !isspace(*(unsigned char *) p)) p++;
561 + while (isspace(*(unsigned char *) p)) p++;
562 argv[1] = p;
563 if (eruby_parse_options(2, argv, NULL) != 0) {
564 rb_raise(eERubyCompileError, "invalid #! line");
565 @@ -632,78 +647,6 @@ VALUE eruby_compiler_compile_file(VALUE
566 return eruby_compile(compiler);
569 -static VALUE file_open(VALUE filename)
571 - return rb_file_open((char *) filename, "r");
574 -typedef struct compile_arg {
575 - VALUE compiler;
576 - VALUE input;
577 -} compile_arg_t;
579 -static VALUE eruby_compile_file(VALUE arg)
581 - return eruby_compiler_compile_file(((compile_arg_t *) arg)->compiler,
582 - ((compile_arg_t *) arg)->input);
585 -typedef struct eval_arg {
586 - VALUE src;
587 - VALUE filename;
588 -} eval_arg_t;
590 -static VALUE eval_string(VALUE arg)
592 - return rb_funcall(ruby_top_self, rb_intern("eval"), 3,
593 - ((eval_arg_t *) arg)->src,
594 - Qnil,
595 - ((eval_arg_t *) arg)->filename);
598 -VALUE eruby_load(char *filename, int wrap, int *state)
600 - VALUE compiler;
601 - VALUE code;
602 - VALUE f;
603 - VALUE vfilename = rb_str_new2(filename);
604 - compile_arg_t carg;
605 - eval_arg_t earg;
606 - int status;
608 - if (strcmp(filename, "-") == 0) {
609 - f = rb_stdin;
611 - else {
612 - f = rb_protect(file_open, (VALUE) filename, &status);
613 - if (status) {
614 - if (state) *state = status;
615 - return Qnil;
618 - compiler = eruby_compiler_new();
619 - eruby_compiler_set_sourcefile(compiler, vfilename);
620 - carg.compiler = compiler;
621 - carg.input = f;
622 - code = rb_protect(eruby_compile_file, (VALUE) &carg, &status);
623 - if (status) {
624 - if (state) *state = status;
625 - return Qnil;
627 - if (wrap) {
628 - rb_eval_string_wrap(STR2CSTR(code), &status);
630 - else {
631 - earg.src = code;
632 - earg.filename = vfilename;
633 - rb_protect(eval_string, (VALUE) &earg, &status);
635 - if (state) *state = status;
636 - if (f != rb_stdin)
637 - rb_io_close(f);
638 - return code;
641 static VALUE noheader_getter()
643 return eruby_noheader ? Qtrue : Qfalse;
644 @@ -765,6 +708,7 @@ void eruby_init()
645 rb_define_virtual_variable("$NOHEADER", noheader_getter, noheader_setter);
647 mERuby = rb_define_module("ERuby");
648 + rb_define_const(mERuby, "VERSION", rb_str_new2(ERUBY_VERSION));
649 rb_define_singleton_method(mERuby, "noheader", eruby_get_noheader, 0);
650 rb_define_singleton_method(mERuby, "noheader=", eruby_set_noheader, 1);
651 rb_define_singleton_method(mERuby, "charset", eruby_get_charset, 0);
652 diff -rupN eruby-1.0.5/eruby_logo.h eruby/eruby_logo.h
653 --- eruby-1.0.5/eruby_logo.h 2000-12-06 01:52:29.000000000 -0400
654 +++ eruby/eruby_logo.h 2009-03-04 20:41:28.000000000 -0430
655 @@ -1,5 +1,5 @@
657 - * $Id: eruby_logo.h,v 1.2 2000/12/06 05:52:29 shugo Exp $
658 + * $Id: eruby_logo.h 10 2004-07-01 04:48:04Z shugo $
659 * Copyright (C) 2000 ZetaBITS, Inc.
660 * Copyright (C) 2000 Information-technology Promotion Agency, Japan
662 diff -rupN eruby-1.0.5/eruby_main.c eruby/eruby_main.c
663 --- eruby-1.0.5/eruby_main.c 2003-12-23 11:10:54.000000000 -0400
664 +++ eruby/eruby_main.c 2009-03-04 20:41:28.000000000 -0430
665 @@ -1,5 +1,5 @@
667 - * $Id: eruby_main.c,v 1.37 2003/12/23 15:10:54 shugo Exp $
668 + * $Id: eruby_main.c 130 2007-01-23 07:54:39Z shugo $
669 * Copyright (C) 2000 ZetaBITS, Inc.
670 * Copyright (C) 2000 Information-technology Promotion Agency, Japan
671 * Copyright (C) 2000 Shugo Maeda <shugo@modruby.net>
672 @@ -42,6 +42,7 @@ EXTERN VALUE rb_stdout;
673 EXTERN VALUE rb_defout;
674 #endif
675 EXTERN VALUE rb_load_path;
676 +EXTERN VALUE ruby_top_self;
678 /* copied from eval.c */
679 #define TAG_RETURN 0x1
680 @@ -92,7 +93,11 @@ static void write_escaping_html(FILE *ou
681 static void error_pos(FILE *out, int cgi)
683 char buff[BUFSIZ];
684 +#if RUBY_VERSION_CODE >= 190
685 + ID last_func = rb_frame_this_func();
686 +#else
687 ID last_func = rb_frame_last_func();
688 +#endif
690 if (ruby_sourcefile) {
691 if (last_func) {
692 @@ -119,34 +124,34 @@ static void exception_print(FILE *out, i
694 errat = rb_funcall(ruby_errinfo, rb_intern("backtrace"), 0);
695 if (!NIL_P(errat)) {
696 - VALUE mesg = RARRAY(errat)->ptr[0];
697 + VALUE mesg = RARRAY_PTR(errat)[0];
699 if (NIL_P(mesg)) {
700 error_pos(out, cgi);
702 else {
703 if (cgi)
704 - write_escaping_html(out, RSTRING(mesg)->ptr, RSTRING(mesg)->len);
705 + write_escaping_html(out, RSTRING_PTR(mesg), RSTRING_LEN(mesg));
706 else
707 - fwrite(RSTRING(mesg)->ptr, 1, RSTRING(mesg)->len, out);
708 + fwrite(RSTRING_PTR(mesg), 1, RSTRING_LEN(mesg), out);
712 eclass = CLASS_OF(ruby_errinfo);
713 einfo = rb_obj_as_string(ruby_errinfo);
714 - if (eclass == rb_eRuntimeError && RSTRING(einfo)->len == 0) {
715 + if (eclass == rb_eRuntimeError && RSTRING_LEN(einfo) == 0) {
716 fprintf(out, ": unhandled exception\n");
718 else {
719 VALUE epath;
721 epath = rb_class_path(eclass);
722 - if (RSTRING(einfo)->len == 0) {
723 + if (RSTRING_LEN(einfo) == 0) {
724 fprintf(out, ": ");
725 if (cgi)
726 - write_escaping_html(out, RSTRING(epath)->ptr, RSTRING(epath)->len);
727 + write_escaping_html(out, RSTRING_PTR(epath), RSTRING_LEN(epath));
728 else
729 - fwrite(RSTRING(epath)->ptr, 1, RSTRING(epath)->len, out);
730 + fwrite(RSTRING_PTR(epath), 1, RSTRING_LEN(epath), out);
731 if (cgi)
732 fprintf(out, "<br>\n");
733 else
734 @@ -154,24 +159,24 @@ static void exception_print(FILE *out, i
736 else {
737 char *tail = 0;
738 - int len = RSTRING(einfo)->len;
739 + int len = RSTRING_LEN(einfo);
741 - if (RSTRING(epath)->ptr[0] == '#') epath = 0;
742 - if ((tail = strchr(RSTRING(einfo)->ptr, '\n')) != NULL) {
743 - len = tail - RSTRING(einfo)->ptr;
744 + if (RSTRING_PTR(epath)[0] == '#') epath = 0;
745 + if ((tail = strchr(RSTRING_PTR(einfo), '\n')) != NULL) {
746 + len = tail - RSTRING_PTR(einfo);
747 tail++; /* skip newline */
749 fprintf(out, ": ");
750 if (cgi)
751 - write_escaping_html(out, RSTRING(einfo)->ptr, len);
752 + write_escaping_html(out, RSTRING_PTR(einfo), len);
753 else
754 - fwrite(RSTRING(einfo)->ptr, 1, len, out);
755 + fwrite(RSTRING_PTR(einfo), 1, len, out);
756 if (epath) {
757 fprintf(out, " (");
758 if (cgi)
759 - write_escaping_html(out, RSTRING(epath)->ptr, RSTRING(epath)->len);
760 + write_escaping_html(out, RSTRING_PTR(epath), RSTRING_LEN(epath));
761 else
762 - fwrite(RSTRING(epath)->ptr, 1, RSTRING(epath)->len, out);
763 + fwrite(RSTRING_PTR(epath), 1, RSTRING_LEN(epath), out);
764 if (cgi)
765 fprintf(out, ")<br>\n");
766 else
767 @@ -179,9 +184,9 @@ static void exception_print(FILE *out, i
769 if (tail) {
770 if (cgi)
771 - write_escaping_html(out, tail, RSTRING(einfo)->len - len - 1);
772 + write_escaping_html(out, tail, RSTRING_LEN(einfo) - len - 1);
773 else
774 - fwrite(tail, 1, RSTRING(einfo)->len - len - 1, out);
775 + fwrite(tail, 1, RSTRING_LEN(einfo) - len - 1, out);
776 if (cgi)
777 fprintf(out, "<br>\n");
778 else
779 @@ -200,38 +205,38 @@ static void exception_print(FILE *out, i
781 rb_ary_pop(errat);
782 ep = RARRAY(errat);
783 - for (i=1; i<ep->len; i++) {
784 - if (TYPE(ep->ptr[i]) == T_STRING) {
785 + for (i=1; i<RARRAY_LEN(ep); i++) {
786 + if (TYPE(RARRAY_PTR(ep)[i]) == T_STRING) {
787 if (cgi) {
788 fprintf(out, "<div class=\"backtrace\">from ");
789 write_escaping_html(out,
790 - RSTRING(ep->ptr[i])->ptr,
791 - RSTRING(ep->ptr[i])->len);
792 + RSTRING_PTR(RARRAY_PTR(ep)[i]),
793 + RSTRING_LEN(RARRAY_PTR(ep)[i]));
795 else {
796 fprintf(out, " from ");
797 - fwrite(RSTRING(ep->ptr[i])->ptr, 1,
798 - RSTRING(ep->ptr[i])->len, out);
799 + fwrite(RSTRING_PTR(RARRAY_PTR(ep)[i]), 1,
800 + RSTRING_LEN(RARRAY_PTR(ep)[i]), out);
802 if (cgi)
803 fprintf(out, "<br></div>\n");
804 else
805 fprintf(out, "\n");
807 - if (i == TRACE_HEAD && ep->len > TRACE_MAX) {
808 + if (i == TRACE_HEAD && RARRAY_LEN(ep) > TRACE_MAX) {
809 char buff[BUFSIZ];
810 if (cgi)
811 snprintf(buff, BUFSIZ,
812 "<div class=\"backtrace\">... %ld levels...\n",
813 - ep->len - TRACE_HEAD - TRACE_TAIL);
814 + RARRAY_LEN(ep) - TRACE_HEAD - TRACE_TAIL);
815 else
816 snprintf(buff, BUFSIZ, " ... %ld levels...<br></div>\n",
817 - ep->len - TRACE_HEAD - TRACE_TAIL);
818 + RARRAY_LEN(ep) - TRACE_HEAD - TRACE_TAIL);
819 if (cgi)
820 write_escaping_html(out, buff, strlen(buff));
821 else
822 fputs(buff, out);
823 - i = ep->len - TRACE_TAIL;
824 + i = RARRAY_LEN(ep) - TRACE_TAIL;
828 @@ -251,10 +256,10 @@ static void print_generated_code(FILE *o
831 if (cgi) {
832 - write_escaping_html(out, RSTRING(code)->ptr, RSTRING(code)->len);
833 + write_escaping_html(out, RSTRING_PTR(code), RSTRING_LEN(code));
835 else {
836 - fwrite(RSTRING(code)->ptr, 1, RSTRING(code)->len, out);
837 + fwrite(RSTRING_PTR(code), 1, RSTRING_LEN(code), out);
839 if (cgi) {
840 fprintf(out, "</code></pre>\n");
841 @@ -394,15 +399,14 @@ static void error_print(FILE *out, int s
842 static VALUE defout_write(VALUE self, VALUE str)
844 str = rb_obj_as_string(str);
845 - rb_str_cat(self, RSTRING(str)->ptr, RSTRING(str)->len);
846 + rb_str_cat(self, RSTRING_PTR(str), RSTRING_LEN(str));
847 return Qnil;
850 static VALUE defout_cancel(VALUE self)
852 - if (RSTRING(self)->len == 0) return Qnil;
853 - RSTRING(self)->len = 0;
854 - RSTRING(self)->ptr[0] = '\0';
855 + if (RSTRING_LEN(self) == 0) return Qnil;
856 + rb_str_resize(self, 0);
857 return Qnil;
860 @@ -453,18 +457,6 @@ static void init()
861 #endif
862 if (eruby_mode == MODE_CGI || eruby_mode == MODE_NPHCGI)
863 rb_set_safe_level(1);
865 -#if RUBY_VERSION_CODE >= 180
866 - rb_io_binmode(rb_stdout); /* for mswin32 */
867 - rb_stdout = rb_str_new("", 0);
868 - rb_define_singleton_method(rb_stdout, "write", defout_write, 1);
869 - rb_define_singleton_method(rb_stdout, "cancel", defout_cancel, 0);
870 -#else
871 - rb_defout = rb_str_new("", 0);
872 - rb_io_binmode(rb_stdout); /* for mswin32 */
873 - rb_define_singleton_method(rb_defout, "write", defout_write, 1);
874 - rb_define_singleton_method(rb_defout, "cancel", defout_cancel, 0);
875 -#endif
876 eruby_init();
879 @@ -540,22 +532,14 @@ static void proc_args(int argc, char **a
880 eruby_filename = "-";
882 else {
883 - eruby_filename = argv[option_index];
884 + eruby_filename = argv[option_index++];
885 + ruby_set_argv(argc - option_index, argv + option_index);
890 -static void run()
891 +static void error(int state, VALUE code)
893 - VALUE stack_start;
894 - VALUE code;
895 - int state;
896 - char *out;
897 - int nout;
898 - void Init_stack _((VALUE*));
900 - Init_stack(&stack_start);
901 - code = eruby_load(eruby_filename, 0, &state);
902 if (state && !rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
903 if (RTEST(ruby_debug) &&
904 (eruby_mode == MODE_CGI || eruby_mode == MODE_NPHCGI)) {
905 @@ -567,32 +551,160 @@ static void run()
906 eruby_exit(1);
909 - if (eruby_mode == MODE_FILTER && (RTEST(ruby_debug) || RTEST(ruby_verbose))) {
910 - print_generated_code(stderr, code, 0);
912 -#if RUBY_VERSION_CODE >= 180
913 - out = RSTRING(rb_stdout)->ptr;
914 - nout = RSTRING(rb_stdout)->len;
915 -#else
916 - out = RSTRING(rb_defout)->ptr;
917 - nout = RSTRING(rb_defout)->len;
918 -#endif
921 +static void print_headers(int length)
923 if (!eruby_noheader &&
924 (eruby_mode == MODE_CGI || eruby_mode == MODE_NPHCGI)) {
925 if (eruby_mode == MODE_NPHCGI)
926 print_http_headers();
928 printf("Content-Type: text/html; charset=%s\r\n", ERUBY_CHARSET);
929 - printf("Content-Length: %d\r\n", nout);
930 + if (length >= 0) {
931 + printf("Content-Length: %d\r\n", length);
933 printf("\r\n");
937 +static void replace_stdout()
939 +#if RUBY_VERSION_CODE >= 180
940 + rb_io_binmode(rb_stdout); /* for mswin32 */
941 + rb_stdout = rb_str_new("", 0);
942 + rb_define_singleton_method(rb_stdout, "write", defout_write, 1);
943 + rb_define_singleton_method(rb_stdout, "cancel", defout_cancel, 0);
944 +#else
945 + rb_defout = rb_str_new("", 0);
946 + rb_io_binmode(rb_stdout); /* for mswin32 */
947 + rb_define_singleton_method(rb_defout, "write", defout_write, 1);
948 + rb_define_singleton_method(rb_defout, "cancel", defout_cancel, 0);
949 +#endif
952 +static void flush_buffer()
954 + char *out;
955 + int nout;
957 +#if RUBY_VERSION_CODE >= 180
958 + out = RSTRING_PTR(rb_stdout);
959 + nout = RSTRING_LEN(rb_stdout);
960 +#else
961 + out = RSTRING(rb_defout)->ptr;
962 + nout = RSTRING(rb_defout)->len;
963 +#endif
964 + print_headers(nout);
965 fwrite(out, nout, 1, stdout);
966 fflush(stdout);
969 +static VALUE file_open(VALUE filename)
971 + return rb_file_open((char *) filename, "r");
974 +typedef struct compile_arg {
975 + VALUE compiler;
976 + VALUE input;
977 +} compile_arg_t;
979 +static VALUE eruby_compile_file(VALUE arg)
981 + return eruby_compiler_compile_file(((compile_arg_t *) arg)->compiler,
982 + ((compile_arg_t *) arg)->input);
985 +static VALUE compile(char *filename)
987 + VALUE compiler;
988 + VALUE code;
989 + VALUE f;
990 + VALUE vfilename = rb_str_new2(filename);
991 + compile_arg_t carg;
992 + int status;
994 + if (strcmp(filename, "-") == 0) {
995 + f = rb_stdin;
997 + else {
998 + f = rb_protect(file_open, (VALUE) filename, &status);
999 + if (status) {
1000 + error(status, Qnil);
1003 + compiler = eruby_compiler_new();
1004 + eruby_compiler_set_sourcefile(compiler, vfilename);
1005 + carg.compiler = compiler;
1006 + carg.input = f;
1007 + code = rb_protect(eruby_compile_file, (VALUE) &carg, &status);
1008 + if (status) {
1009 + error(status, Qnil);
1011 + if (f != rb_stdin)
1012 + rb_io_close(f);
1013 + return code;
1016 +typedef struct eval_arg {
1017 + VALUE src;
1018 + VALUE filename;
1019 +} eval_arg_t;
1021 +static VALUE eval_string(VALUE arg)
1023 + return rb_funcall(ruby_top_self, rb_intern("eval"), 3,
1024 + ((eval_arg_t *) arg)->src,
1025 + Qnil,
1026 + ((eval_arg_t *) arg)->filename);
1029 +static VALUE eval(VALUE code, char *filename)
1031 + int status;
1032 + eval_arg_t earg;
1034 + earg.src = code;
1035 + earg.filename = rb_str_new2(filename);
1036 + rb_protect(eval_string, (VALUE) &earg, &status);
1037 + if (status) {
1038 + error(status, code);
1040 + return code;
1043 +static void run()
1045 + VALUE stack_start;
1046 + VALUE code;
1047 + void Init_stack _((VALUE*));
1049 + Init_stack(&stack_start);
1050 + code = compile(eruby_filename);
1051 + if (eruby_sync) {
1052 + print_headers(-1);
1054 + else {
1055 + replace_stdout();
1057 + code = eval(code, eruby_filename);
1058 + if (eruby_mode == MODE_FILTER &&
1059 + (RTEST(ruby_debug) || RTEST(ruby_verbose))) {
1060 + print_generated_code(stderr, code, 0);
1062 + rb_exec_end_proc();
1063 + if (!eruby_sync) {
1064 + flush_buffer();
1066 ruby_finalize();
1069 int main(int argc, char **argv)
1071 +#ifdef _WIN32
1072 + NtInitialize(&argc, &argv);
1073 +#endif
1074 init();
1075 proc_args(argc, argv);
1076 run();