summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-03-09 09:04:36 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-03-09 09:04:36 +0000
commit13adec97c9c4ad2aa8ea3edfd9c65710b703f51f (patch)
tree75c2ef9bbab2d191b42567bd580c2a6f04415db1
parent33f7442e0f1056548f3b972ee1c2d32556939d57 (diff)
2000-03-09
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_4@637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--lib/getoptlong.rb87
-rw-r--r--missing/flock.c48
-rw-r--r--regex.c3
-rw-r--r--version.h4
5 files changed, 104 insertions, 46 deletions
diff --git a/ChangeLog b/ChangeLog
index 77168b5081..4a22888023 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Thu Mar 9 11:13:32 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * regex.c (re_compile_fastmap): fixed embarrassing brace bug.
+
+Thu Mar 9 01:36:32 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
+
+ * missing/flock.c: emulate missing flock() with fcntl().
+
Wed Mar 8 02:08:43 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* parse.y: escape expansion too early.
diff --git a/lib/getoptlong.rb b/lib/getoptlong.rb
index 82cccf43b9..5dd444adcd 100644
--- a/lib/getoptlong.rb
+++ b/lib/getoptlong.rb
@@ -1,5 +1,5 @@
# -*- Ruby -*-
-# Copyright (C) 1998 Motoyuki Kasahara
+# Copyright (C) 1998, 1999, 2000 Motoyuki Kasahara
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -232,7 +232,7 @@ class GetoptLong
# Termintate option processing.
#
def terminate
- return if @status == STATUS_TERMINATED
+ return nil if @status == STATUS_TERMINATED
raise RuntimeError, "an error has occured" if @error != nil
@status = STATUS_TERMINATED
@@ -293,12 +293,12 @@ class GetoptLong
# Get next option name and its argument as an array.
#
def get
- name, argument = nil, ''
+ option_name, option_argument = nil, ''
#
# Check status.
#
- return if @error != nil
+ return nil if @error != nil
case @status
when STATUS_YET
@status = STATUS_STARTED
@@ -310,7 +310,7 @@ class GetoptLong
# Get next option argument.
#
if 0 < @rest_singles.length
- $_ = '-' + @rest_singles
+ argument = '-' + @rest_singles
elsif (ARGV.length == 0)
terminate
return nil
@@ -322,22 +322,22 @@ class GetoptLong
terminate
return nil
end
- $_ = ARGV.shift
+ argument = ARGV.shift
elsif @ordering == REQUIRE_ORDER
if (ARGV[0] !~ /^-./)
terminate
return nil
end
- $_ = ARGV.shift
+ argument = ARGV.shift
else
- $_ = ARGV.shift
+ argument = ARGV.shift
end
#
# Check the special argument `--'.
# `--' indicates the end of the option list.
#
- if $_ == '--' && @rest_singles.length == 0
+ if argument == '--' && @rest_singles.length == 0
terminate
return nil
end
@@ -345,87 +345,88 @@ class GetoptLong
#
# Check for long and short options.
#
- if /^(--[^=]+)/ && @rest_singles.length == 0
+ if argument =~ /^(--[^=]+)/ && @rest_singles.length == 0
#
# This is a long style option, which start with `--'.
#
pattern = $1
if @canonical_names.include?(pattern)
- name = pattern
+ option_name = pattern
else
#
- # The option `name' is not registered in `@canonical_names'.
+ # The option `option_name' is not registered in `@canonical_names'.
# It may be an abbreviated.
#
match_count = 0
@canonical_names.each_key do |key|
if key.index(pattern) == 0
- name = key
+ option_name = key
match_count += 1
end
end
if 2 <= match_count
- set_error(AmbigousOption, "option `#{$_}' is ambiguous")
+ set_error(AmbigousOption, "option `#{argument}' is ambiguous")
elsif match_count == 0
- set_error(InvalidOption, "unrecognized option `#{$_}'")
+ set_error(InvalidOption, "unrecognized option `#{argument}'")
end
end
#
# Check an argument to the option.
#
- if @argument_flags[name] == REQUIRED_ARGUMENT
- if /=(.*)$/
- argument = $1
+ if @argument_flags[option_name] == REQUIRED_ARGUMENT
+ if argument =~ /=(.*)$/
+ option_argument = $1
elsif 0 < ARGV.length
- argument = ARGV.shift
+ option_argument = ARGV.shift
else
- set_error(MissingArgument, "option `#{$_}' requires an argument")
+ set_error(MissingArgument,
+ "option `#{argument}' requires an argument")
end
- elsif @argument_flags[name] == OPTIONAL_ARGUMENT
- if /=(.*)$/
- argument = $1
+ elsif @argument_flags[option_name] == OPTIONAL_ARGUMENT
+ if argument =~ /=(.*)$/
+ option_argument = $1
elsif 0 < ARGV.length && ARGV[0] !~ /^-./
- argument = ARGV.shift
+ option_argument = ARGV.shift
else
- argument = ''
+ option_argument = ''
end
- elsif /=(.*)$/
+ elsif argument =~ /=(.*)$/
set_error(NeedlessArgument,
- "option `#{name}' doesn't allow an argument")
+ "option `#{option_name}' doesn't allow an argument")
end
- elsif /^(-(.))(.*)/
+ elsif argument =~ /^(-(.))(.*)/
#
# This is a short style option, which start with `-' (not `--').
# Short options may be catinated (e.g. `-l -g' is equivalent to
# `-lg').
#
- name, ch, @rest_singles = $1, $2, $3
+ option_name, ch, @rest_singles = $1, $2, $3
- if @canonical_names.include?(name)
+ if @canonical_names.include?(option_name)
#
- # The option `name' is found in `@canonical_names'.
+ # The option `option_name' is found in `@canonical_names'.
# Check its argument.
#
- if @argument_flags[name] == REQUIRED_ARGUMENT
+ if @argument_flags[option_name] == REQUIRED_ARGUMENT
if 0 < @rest_singles.length
- argument = @rest_singles
+ option_argument = @rest_singles
@rest_singles = ''
elsif 0 < ARGV.length
- argument = ARGV.shift
+ option_argument = ARGV.shift
else
# 1003.2 specifies the format of this message.
set_error(MissingArgument, "option requires an argument -- #{ch}")
end
- elsif @argument_flags[name] == OPTIONAL_ARGUMENT
+ elsif @argument_flags[option_name] == OPTIONAL_ARGUMENT
if 0 < @rest_singles.length
- argument = @rest_singles
+ option_argument = @rest_singles
@rest_singles = ''
elsif 0 < ARGV.length && ARGV[0] !~ /^-./
- argument = ARGV.shift
+ option_argument = ARGV.shift
else
- argument = ''
+ option_argument = ''
end
end
else
@@ -444,10 +445,10 @@ class GetoptLong
# This is a non-option argument.
# Only RETURN_IN_ORDER falled into here.
#
- return '', $_
+ return '', argument
end
- return @canonical_names[name], argument
+ return @canonical_names[option_name], option_argument
end
#
@@ -460,9 +461,9 @@ class GetoptLong
#
def each
loop do
- name, argument = get_option
- break if name == nil
- yield name, argument
+ option_name, option_argument = get_option
+ break if option_name == nil
+ yield option_name, option_argument
end
end
diff --git a/missing/flock.c b/missing/flock.c
index a4a9544b56..0eaa8d8fdb 100644
--- a/missing/flock.c
+++ b/missing/flock.c
@@ -78,6 +78,54 @@ flock(fd, operation)
}
return i;
}
+#elif defined HAVE_FCNTL && defined HAVE_FCNTL_H
+
+/* These are the flock() constants. Since this sytems doesn't have
+ flock(), the values of the constants are probably not available.
+*/
+# ifndef LOCK_SH
+# define LOCK_SH 1
+# endif
+# ifndef LOCK_EX
+# define LOCK_EX 2
+# endif
+# ifndef LOCK_NB
+# define LOCK_NB 4
+# endif
+# ifndef LOCK_UN
+# define LOCK_UN 8
+# endif
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+
+int
+flock(fd, operation)
+ int fd;
+ int operation;
+{
+ struct flock lock;
+
+ switch (operation & ~LOCK_NB) {
+ case LOCK_SH:
+ lock.l_type = F_RDLCK;
+ break;
+ case LOCK_EX:
+ lock.l_type = F_WRLCK;
+ break;
+ case LOCK_UN:
+ lock.l_type = F_UNLCK;
+ break;
+ default:
+ errno = EINVAL;
+ return -1;
+ }
+ lock.l_whence = SEEK_SET;
+ lock.l_start = lock.l_len = 0L;
+
+ return fcntl(fd, (operation & LOCK_NB) ? F_SETLK : F_SETLKW, &lock);
+}
#else
int
flock(fd, operation)
diff --git a/regex.c b/regex.c
index c5e5b38d78..0ecd457b52 100644
--- a/regex.c
+++ b/regex.c
@@ -2956,11 +2956,12 @@ re_compile_fastmap(bufp)
c = beg + 1;
}
- for (j = c; j < (1 << BYTEWIDTH); j++)
+ for (j = c; j < (1 << BYTEWIDTH); j++) {
if (num_literal)
fastmap[j] = 1;
if (ismbchar(j))
fastmap[j] = 1;
+ }
}
break;
diff --git a/version.h b/version.h
index ef834eefeb..0e5e039a80 100644
--- a/version.h
+++ b/version.h
@@ -1,4 +1,4 @@
#define RUBY_VERSION "1.4.4"
-#define RUBY_RELEASE_DATE "2000-03-08"
+#define RUBY_RELEASE_DATE "2000-03-09"
#define RUBY_VERSION_CODE 144
-#define RUBY_RELEASE_CODE 20000308
+#define RUBY_RELEASE_CODE 20000309