From 3e5f70a8153f8ec955af1c6bc721f2e3ea1814a5 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 9 Jun 2006 23:18:04 +0000 Subject: * math.c (log2): may be a macro. * parse.y (args, block_param, f_args): pass f_post_arg to #params. * util.c (powersOf10): constified. * ext/readline/readline.c: include extconf.h first. * ext/ripper/eventids2.c: removed tLAMBDA_ARG. * ext/tk/tcltklib.c (lib_fromUTF8_core): removed conflict. * ext/tk/tkutil/tkutil.c (cbsubst_get_subst_arg): rb_id2name() is defined as const now. * ext/win32ole/win32ole.c (fole_missing): ditto. * lib/mkmf.rb (create_makefile): force to create extconf header. * lib/optparse.rb (order!): use Proc#yield. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 23 +++++++++++++++++++++++ ext/readline/readline.c | 4 ++++ ext/ripper/eventids2.c | 4 ---- ext/tk/tcltklib.c | 4 ---- ext/tk/tkutil/tkutil.c | 3 ++- ext/win32ole/win32ole.c | 2 +- lib/mkmf.rb | 4 ++++ lib/optparse.rb | 17 +++++++++-------- math.c | 5 ++++- parse.y | 36 ++++++++++++++++++------------------ util.c | 5 +++-- 11 files changed, 68 insertions(+), 39 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7beebff4ed..9cab9b391d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,26 @@ +Sat Jun %-2d 08:17:23 2006 U-HUDIE\nobu,S-1-5-21-3746871489-166115513-3294629105-1005 + + * math.c (log2): may be a macro. + + * parse.y (args, block_param, f_args): pass f_post_arg to #params. + + * util.c (powersOf10): constified. + + * ext/readline/readline.c: include extconf.h first. + + * ext/ripper/eventids2.c: removed tLAMBDA_ARG. + + * ext/tk/tcltklib.c (lib_fromUTF8_core): removed conflict. + + * ext/tk/tkutil/tkutil.c (cbsubst_get_subst_arg): rb_id2name() is + defined as const now. + + * ext/win32ole/win32ole.c (fole_missing): ditto. + + * lib/mkmf.rb (create_makefile): force to create extconf header. + + * lib/optparse.rb (order!): use Proc#yield. + Sat Jun 10 06:53:22 2006 NAKAMURA Usaku * eval.c (CALLARGS): remove last semicolon. C90 compiler doesn't diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 4a28b6e11c..626c0e0dc7 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -1,6 +1,10 @@ /* readline.c -- GNU Readline module Copyright (C) 1997-2001 Shugo Maeda */ +#ifdef RUBY_EXTCONF_H +#include RUBY_EXTCONF_H +#endif + #include #include #include diff --git a/ext/ripper/eventids2.c b/ext/ripper/eventids2.c index 18d803873c..ba9c90269a 100644 --- a/ext/ripper/eventids2.c +++ b/ext/ripper/eventids2.c @@ -7,7 +7,6 @@ #define tHEREDOC_BEG (tLAST_TOKEN + 7) #define tHEREDOC_END (tLAST_TOKEN + 8) #define k__END__ (tLAST_TOKEN + 9) -#define tCHAR (tLAST_TOKEN + 10) static ID ripper_id_backref; static ID ripper_id_backtick; @@ -44,7 +43,6 @@ static ID ripper_id_regexp_beg; static ID ripper_id_regexp_end; static ID ripper_id_label; static ID ripper_id_tlambda; -static ID ripper_id_tlambda_arg; static ID ripper_id_tlambeg; static ID ripper_id_ignored_nl; @@ -98,7 +96,6 @@ ripper_init_eventids2(VALUE self) ripper_id_regexp_end = rb_intern("on_regexp_end"); ripper_id_label = rb_intern("on_label"); ripper_id_tlambda = rb_intern("on_tlambda"); - ripper_id_tlambda_arg = rb_intern("on_tlambda_arg"); ripper_id_tlambeg = rb_intern("on_tlambeg"); ripper_id_ignored_nl = rb_intern("on_ignored_nl"); @@ -248,7 +245,6 @@ static struct token_assoc { {tXSTRING_BEG, &ripper_id_backtick}, {tLABEL, &ripper_id_label}, {tLAMBDA, &ripper_id_tlambda}, - {tLAMBDA_ARG, &ripper_id_tlambda_arg}, {tLAMBEG, &ripper_id_tlambeg}, /* ripper specific tokens */ diff --git a/ext/tk/tcltklib.c b/ext/tk/tcltklib.c index 9a64c27870..e43b98e2c1 100644 --- a/ext/tk/tcltklib.c +++ b/ext/tk/tcltklib.c @@ -6217,11 +6217,7 @@ lib_fromUTF8_core(ip_obj, src, encodename) char *s; int len; -<<<<<<< tcltklib.c - StringValue(str); -======= StringValue(str); ->>>>>>> 1.45 s = Tcl_GetByteArrayFromObj(Tcl_NewStringObj(RSTRING(str)->ptr, RSTRING(str)->len), &len); diff --git a/ext/tk/tkutil/tkutil.c b/ext/tk/tkutil/tkutil.c index f4271a724c..7789d4071d 100644 --- a/ext/tk/tkutil/tkutil.c +++ b/ext/tk/tkutil/tkutil.c @@ -1234,7 +1234,8 @@ cbsubst_get_subst_arg(argc, argv, self) VALUE self; { struct cbsubst_info *inf; - char *str, *buf, *ptr; + const char *str; + char *buf, *ptr; int i, j, len; ID id; volatile VALUE arg_sym, ret; diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index ba4fc4b921..202b54f93e 100644 --- a/ext/win32ole/win32ole.c +++ b/ext/win32ole/win32ole.c @@ -2984,7 +2984,7 @@ static VALUE fole_missing(int argc, VALUE *argv, VALUE self) { ID id; - char* mname; + const char* mname; int n; id = rb_to_id(argv[0]); mname = rb_id2name(id); diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 1d495e8205..77ccd94546 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -1083,6 +1083,10 @@ def create_makefile(target, srcprefix = nil) end end + if $extmk and not $extconf_h + create_header + end + libpath = libpathflag(libpath) dllib = target ? "$(TARGET).#{CONFIG['DLEXT']}" : "" diff --git a/lib/optparse.rb b/lib/optparse.rb index 9c7676f4be..13528f98dc 100644 --- a/lib/optparse.rb +++ b/lib/optparse.rb @@ -355,7 +355,7 @@ class OptionParser def conv_arg(arg, val = []) if block if conv - val = conv.call(*val) + val = conv.yield(*val) else val = val[0] end @@ -849,7 +849,7 @@ class OptionParser def add_officious list = base() Officious.each do |opt, block| - list.long[opt] ||= block.call(self) + list.long[opt] ||= block.yield(self) end end @@ -1319,7 +1319,7 @@ class OptionParser end begin opt, sw, val = sw.parse(rest, argv) {|*exc| raise(*exc)} - sw.call(*val) if sw + sw.yield(*val) if sw rescue ParseError raise $!.set_option(arg, rest) end @@ -1328,7 +1328,8 @@ class OptionParser when /\A-(.)((=).*|.+)?/nm opt, has_arg, eq, val, rest = $1, $3, $3, $2, $2 begin - unless sw = search(:short, opt) + sw, = search(:short, opt) + unless sw begin sw, = complete(:short, opt) # short option matched. @@ -1348,7 +1349,7 @@ class OptionParser opt, sw, val = sw.parse(val, argv) {|*exc| raise(*exc) if eq} raise InvalidOption, arg if has_arg and !eq and arg == "-#{opt}" argv.unshift(opt) if opt and (opt = opt.sub(/\A-*/, '-')) != '-' - sw.call(val) if sw + sw.yield(val) if sw rescue ParseError raise $!.set_option(arg, arg.length > 2) end @@ -1357,9 +1358,9 @@ class OptionParser else catch(:prune) do visit(:each_option) do |sw| - sw.block.call(arg) if Switch === sw and sw.match_nonswitch?(arg) + sw.block.yield(arg) if Switch === sw and sw.match_nonswitch?(arg) end - nonopt.call(arg) + nonopt.yield(arg) end end end @@ -1367,7 +1368,7 @@ class OptionParser nil } - visit(:search, :short, nil) {|sw| sw.block.call(argv) if !sw.pattern} + visit(:search, :short, nil) {|sw| sw.block.yield(argv) if !sw.pattern} argv end diff --git a/math.c b/math.c index d7b264cccc..4cdcbc7471 100644 --- a/math.c +++ b/math.c @@ -322,12 +322,16 @@ math_log(int argc, VALUE *argv) return rb_float_new(d); } +#ifndef log2 #ifndef HAVE_LOG2 double log2(double x) { return log10(x)/log10(2.0); } +#else +extern double log2(double); +#endif #endif /* @@ -340,7 +344,6 @@ log2(double x) static VALUE math_log2(VALUE obj, VALUE x) { - extern double log2(double); double d; Need_Float(x); diff --git a/parse.y b/parse.y index 0c984f6f7a..a5bb44da6c 100644 --- a/parse.y +++ b/parse.y @@ -2314,7 +2314,7 @@ args : arg_value /*%%%*/ $$ = NEW_SPLAT($2); /*% - $$ = arg_add_star(arg_new(), $1); + $$ = arg_add_star(arg_new(), $2); %*/ } | args ',' arg_value @@ -2938,7 +2938,7 @@ block_param : block_param0 $$ = NEW_BLOCK_PARAM($9, NEW_MASGN($1, NEW_POSTARG($4,$6))); /*% $$ = blockvar_add_star(blockvar_new($1), $4); - $$ = blockvar_add_block($$, $7); + $$ = blockvar_add_block($$, $6); %*/ } | block_param0 ',' tSTAR ',' tAMPER lhs @@ -2956,7 +2956,7 @@ block_param : block_param0 $$ = NEW_BLOCK_PARAM($8, NEW_MASGN($1, NEW_POSTARG(-1,$5))); /*% $$ = blockvar_add_star(blockvar_new($1), Qnil); - $$ = blockvar_add_block($$, $6); + $$ = blockvar_add_block($$, $5); %*/ } | block_param0 ',' tSTAR lhs @@ -3902,7 +3902,7 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg /*%%%*/ $$ = new_args($1, $3, $5, 0, $6); /*% - $$ = dispatch4(params, $1, $3, $5, escape_Qundef($6)); + $$ = dispatch5(params, $1, $3, $5, Qnil, escape_Qundef($6)); %*/ } | f_arg ',' f_optarg ',' f_rest_arg ',' f_post_arg opt_f_block_arg @@ -3910,7 +3910,7 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg /*%%%*/ $$ = new_args($1, $3, $5, $7, $8); /*% - $$ = dispatch4(params, $1, $3, $5, escape_Qundef($6)); + $$ = dispatch5(params, $1, $3, $5, $7, escape_Qundef($8)); %*/ } | f_arg ',' f_optarg opt_f_block_arg @@ -3918,7 +3918,7 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg /*%%%*/ $$ = new_args($1, $3, 0, 0, $4); /*% - $$ = dispatch4(params, $1, $3, Qnil, escape_Qundef($4)); + $$ = dispatch5(params, $1, $3, Qnil, Qnil, escape_Qundef($4)); %*/ } | f_arg ',' f_rest_arg opt_f_block_arg @@ -3926,7 +3926,7 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg /*%%%*/ $$ = new_args($1, 0, $3, 0, $4); /*% - $$ = dispatch4(params, $1, Qnil, $3, escape_Qundef($4)); + $$ = dispatch5(params, $1, Qnil, $3, Qnil, escape_Qundef($4)); %*/ } | f_arg ',' f_rest_arg ',' f_post_arg opt_f_block_arg @@ -3934,7 +3934,7 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg /*%%%*/ $$ = new_args($1, 0, $3, $5, $6); /*% - $$ = dispatch4(params, $1, Qnil, $3, escape_Qundef($4)); + $$ = dispatch5(params, $1, Qnil, $3, $5, escape_Qundef($6)); %*/ } | f_arg opt_f_block_arg @@ -3942,7 +3942,7 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg /*%%%*/ $$ = new_args($1, 0, 0, 0, $2); /*% - $$ = dispatch4(params, $1, Qnil, Qnil, escape_Qundef($2)); + $$ = dispatch5(params, $1, Qnil, Qnil, Qnil, escape_Qundef($2)); %*/ } | f_optarg ',' f_rest_arg opt_f_block_arg @@ -3950,7 +3950,7 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg /*%%%*/ $$ = new_args(0, $1, $3, 0, $4); /*% - $$ = dispatch4(params, Qnil, $1, $3, escape_Qundef($4)); + $$ = dispatch5(params, Qnil, $1, $3, Qnil, escape_Qundef($4)); %*/ } | f_optarg ',' f_rest_arg ',' f_post_arg opt_f_block_arg @@ -3958,7 +3958,7 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg /*%%%*/ $$ = new_args(0, $1, $3, $5, $6); /*% - $$ = dispatch4(params, Qnil, $1, $3, escape_Qundef($4)); + $$ = dispatch5(params, Qnil, $1, $3, $5, escape_Qundef($6)); %*/ } | f_optarg opt_f_block_arg @@ -3966,7 +3966,7 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg /*%%%*/ $$ = new_args(0, $1, 0, 0, $2); /*% - $$ = dispatch4(params, Qnil, $1, Qnil, escape_Qundef($2)); + $$ = dispatch5(params, Qnil, $1, Qnil, Qnil, escape_Qundef($2)); %*/ } | f_rest_arg opt_f_block_arg @@ -3974,7 +3974,7 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg /*%%%*/ $$ = new_args(0, 0, $1, 0, $2); /*% - $$ = dispatch4(params, Qnil, Qnil, $1, escape_Qundef($2)); + $$ = dispatch5(params, Qnil, Qnil, $1, Qnil, escape_Qundef($2)); %*/ } | f_rest_arg ',' f_post_arg opt_f_block_arg @@ -3982,7 +3982,7 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg /*%%%*/ $$ = new_args(0, 0, $1, $3, $4); /*% - $$ = dispatch4(params, Qnil, Qnil, $1, escape_Qundef($2)); + $$ = dispatch5(params, Qnil, Qnil, $1, $3, escape_Qundef($4)); %*/ } | f_block_arg @@ -3990,7 +3990,7 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg /*%%%*/ $$ = new_args(0, 0, 0, 0, $1); /*% - $$ = dispatch4(params, Qnil, Qnil, Qnil, $1); + $$ = dispatch5(params, Qnil, Qnil, Qnil, Qnil, $1); %*/ } | /* none */ @@ -3998,7 +3998,7 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg /*%%%*/ $$ = new_args(0, 0, 0, 0, 0); /*% - $$ = dispatch4(params, Qnil, Qnil, Qnil, Qnil); + $$ = dispatch5(params, Qnil, Qnil, Qnil, Qnil, Qnil); %*/ } ; @@ -4744,9 +4744,9 @@ parser_newtok(struct parser_params *parser) } static void -parser_tokadd(struct parser_params *parser, char c) +parser_tokadd(struct parser_params *parser, int c) { - tokenbuf[tokidx++] = c; + tokenbuf[tokidx++] = (char)c; if (tokidx >= toksiz) { toksiz *= 2; REALLOC_N(tokenbuf, char, toksiz); diff --git a/util.c b/util.c index fbc08de1e7..81d3799dc7 100644 --- a/util.c +++ b/util.c @@ -669,7 +669,7 @@ ruby_getcwd(void) #define MDMINEXPT DBL_MIN_EXP #define MDMAXEXPT DBL_MAX_EXP -static double powersOf10[] = { /* Table giving binary powers of 10. Entry */ +static const double powersOf10[] = { /* Table giving binary powers of 10. Entry */ 10.0, /* is 10^2^i. Used to convert decimal */ 100.0, /* exponents into floating-point numbers. */ 1.0e4, @@ -721,7 +721,8 @@ ruby_strtod( * address here. */ { int sign, expSign = Qfalse; - double fraction = 0.0, dblExp, *d; + double fraction = 0.0, dblExp; + const double *d; register const char *p; register int c; int exp = 0; /* Exponent read from "EX" field. */ -- cgit v1.2.3