Skip to content

Commit

Permalink
* math.c (log2): may be a macro.
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nobu committed Jun 9, 2006
1 parent 4b731d3 commit 3e5f70a
Show file tree
Hide file tree
Showing 11 changed files with 68 additions and 39 deletions.
23 changes: 23 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
Sat Jun %-2d 08:17:23 2006 U-HUDIE\nobu,S-1-5-21-3746871489-166115513-3294629105-1005 <[email protected]>

* 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 <[email protected]>

* eval.c (CALLARGS): remove last semicolon. C90 compiler doesn't
Expand Down
4 changes: 4 additions & 0 deletions ext/readline/readline.c
Original file line number Diff line number Diff line change
@@ -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 <errno.h>
#include <stdio.h>
#include <ctype.h>
Expand Down
4 changes: 0 additions & 4 deletions ext/ripper/eventids2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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 */
Expand Down
4 changes: 0 additions & 4 deletions ext/tk/tcltklib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion ext/tk/tkutil/tkutil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion ext/win32ole/win32ole.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions lib/mkmf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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']}" : ""
Expand Down
17 changes: 9 additions & 8 deletions lib/optparse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def parse_arg(arg)
def conv_arg(arg, val = [])
if block
if conv
val = conv.call(*val)
val = conv.yield(*val)
else
val = val[0]
end
Expand Down Expand Up @@ -849,7 +849,7 @@ def initialize(banner = nil, width = 32, indent = ' ' * 4)
def add_officious
list = base()
Officious.each do |opt, block|
list.long[opt] ||= block.call(self)
list.long[opt] ||= block.yield(self)
end
end

Expand Down Expand Up @@ -1319,7 +1319,7 @@ def order!(argv = default_argv, &nonopt)
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
Expand All @@ -1328,7 +1328,8 @@ def order!(argv = default_argv, &nonopt)
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.
Expand All @@ -1348,7 +1349,7 @@ def order!(argv = default_argv, &nonopt)
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
Expand All @@ -1357,17 +1358,17 @@ def order!(argv = default_argv, &nonopt)
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

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
Expand Down
5 changes: 4 additions & 1 deletion math.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

/*
Expand All @@ -340,7 +344,6 @@ log2(double x)
static VALUE
math_log2(VALUE obj, VALUE x)
{
extern double log2(double);
double d;

Need_Float(x);
Expand Down
36 changes: 18 additions & 18 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -3902,103 +3902,103 @@ 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
{
/*%%%*/
$$ = 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
{
/*%%%*/
$$ = 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
{
/*%%%*/
$$ = 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
{
/*%%%*/
$$ = 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
{
/*%%%*/
$$ = 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
{
/*%%%*/
$$ = 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
{
/*%%%*/
$$ = 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
{
/*%%%*/
$$ = 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
{
/*%%%*/
$$ = 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
{
/*%%%*/
$$ = 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
{
/*%%%*/
$$ = new_args(0, 0, 0, 0, $1);
/*%
$$ = dispatch4(params, Qnil, Qnil, Qnil, $1);
$$ = dispatch5(params, Qnil, Qnil, Qnil, Qnil, $1);
%*/
}
| /* none */
{
/*%%%*/
$$ = new_args(0, 0, 0, 0, 0);
/*%
$$ = dispatch4(params, Qnil, Qnil, Qnil, Qnil);
$$ = dispatch5(params, Qnil, Qnil, Qnil, Qnil, Qnil);
%*/
}
;
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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. */
Expand Down

0 comments on commit 3e5f70a

Please sign in to comment.