git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-05-17 06:33:50 +00:00
Родитель 133ff3421a
Коммит 35e731649d
7 изменённых файлов: 62 добавлений и 23 удалений

Просмотреть файл

@ -1,3 +1,7 @@
Wed May 17 14:14:23 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* re.c (rb_reg_new_1): use /m instead of /p.
Wed May 17 02:22:03 2000 Yukihiro Matsumoto <matz@netlab.co.jp> Wed May 17 02:22:03 2000 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (rb_thread_polling): wait 0.06 second to let other * eval.c (rb_thread_polling): wait 0.06 second to let other

7
eval.c
Просмотреть файл

@ -6736,9 +6736,9 @@ rb_thread_schedule()
copy_fds(&readfds, &th->readfds, th->fd); copy_fds(&readfds, &th->readfds, th->fd);
copy_fds(&writefds, &th->writefds, th->fd); copy_fds(&writefds, &th->writefds, th->fd);
copy_fds(&exceptfds, &th->exceptfds, th->fd); copy_fds(&exceptfds, &th->exceptfds, th->fd);
th->fd = 0;
if (max < th->fd) max = th->fd; if (max < th->fd) max = th->fd;
need_select = 1; need_select = 1;
th->fd = 0;
} }
if (th->wait_for & WAIT_TIME) { if (th->wait_for & WAIT_TIME) {
if (th->delay <= now) { if (th->delay <= now) {
@ -6885,8 +6885,9 @@ rb_thread_fd_writable(fd)
curr_thread->status = THREAD_STOPPED; curr_thread->status = THREAD_STOPPED;
FD_ZERO(&curr_thread->readfds); FD_ZERO(&curr_thread->readfds);
FD_ZERO(&curr_thread->writefds); FD_ZERO(&curr_thread->writefds);
FD_ZERO(&curr_thread->exceptfds);
FD_SET(fd, &curr_thread->writefds); FD_SET(fd, &curr_thread->writefds);
FD_ZERO(&curr_thread->exceptfds);
curr_thread->fd = fd+1;
curr_thread->wait_for = WAIT_SELECT; curr_thread->wait_for = WAIT_SELECT;
rb_thread_schedule(); rb_thread_schedule();
} }
@ -7011,7 +7012,7 @@ rb_thread_select(max, read, write, except, timeout)
if (timeout) { if (timeout) {
curr_thread->delay = timeofday() + curr_thread->delay = timeofday() +
(double)timeout->tv_sec + (double)timeout->tv_usec*1e-6; (double)timeout->tv_sec + (double)timeout->tv_usec*1e-6;
curr_thread->wait_for = WAIT_TIME; curr_thread->wait_for |= WAIT_TIME;
} }
rb_thread_schedule(); rb_thread_schedule();
if (read) *read = curr_thread->readfds; if (read) *read = curr_thread->readfds;

Просмотреть файл

@ -621,17 +621,6 @@ ipaddr(sockaddr)
return ary; return ary;
} }
static void
thread_write_select(fd)
int fd;
{
fd_set fds;
FD_ZERO(&fds);
FD_SET(fd, &fds);
rb_thread_select(fd+1, 0, &fds, 0, 0);
}
static int static int
ruby_socket(domain, type, proto) ruby_socket(domain, type, proto)
int domain, type, proto; int domain, type, proto;
@ -692,7 +681,7 @@ ruby_connect(fd, sockaddr, len, socks)
#ifdef EINPROGRESS #ifdef EINPROGRESS
case EINPROGRESS: case EINPROGRESS:
#endif #endif
thread_write_select(fd); rb_thread_fd_writable(fd);
continue; continue;
#ifdef EISCONN #ifdef EISCONN

Просмотреть файл

@ -2256,8 +2256,9 @@ parse_regx(term, paren)
case 'x': case 'x':
options |= RE_OPTION_EXTENDED; options |= RE_OPTION_EXTENDED;
break; break;
case 'p': case 'p': /* /p is obsolete, works as /m */
options |= RE_OPTION_POSIXLINE; case 'm':
options |= RE_OPTION_MULTILINE;
break; break;
case 'o': case 'o':
once = 1; once = 1;

12
re.c
Просмотреть файл

@ -91,6 +91,7 @@ rb_str_cicmp(str1, str2)
#define REG_IGNORECASE FL_USER1 #define REG_IGNORECASE FL_USER1
#define REG_EXTENDED FL_USER2 #define REG_EXTENDED FL_USER2
#define REG_POSIXLINE FL_USER3 #define REG_POSIXLINE FL_USER3
#define REG_MULTILINE FL_USER3
#define KCODE_NONE 0 #define KCODE_NONE 0
#define KCODE_EUC FL_USER4 #define KCODE_EUC FL_USER4
@ -249,8 +250,8 @@ rb_reg_desc(s, len, re)
rb_str_cat2(str, "i"); rb_str_cat2(str, "i");
if (FL_TEST(re, REG_EXTENDED)) if (FL_TEST(re, REG_EXTENDED))
rb_str_cat2(str, "x"); rb_str_cat2(str, "x");
if (FL_TEST(re, REG_POSIXLINE)) if (FL_TEST(re, REG_MULTILINE))
rb_str_cat2(str, "p"); rb_str_cat2(str, "m");
if (FL_TEST(re, KCODE_FIXED)) { if (FL_TEST(re, KCODE_FIXED)) {
switch ((RBASIC(re)->flags & KCODE_MASK)) { switch ((RBASIC(re)->flags & KCODE_MASK)) {
case KCODE_NONE: case KCODE_NONE:
@ -757,7 +758,7 @@ rb_reg_new_1(klass, s, len, options)
int len; int len;
int options; /* CASEFOLD = 1 */ int options; /* CASEFOLD = 1 */
/* EXTENDED = 2 */ /* EXTENDED = 2 */
/* POSIXLINE = 4 */ /* MULTILINE = 4 */
/* CODE_NONE = 8 */ /* CODE_NONE = 8 */
/* CODE_EUC = 16 */ /* CODE_EUC = 16 */
/* CODE_SJIS = 24 */ /* CODE_SJIS = 24 */
@ -774,8 +775,8 @@ rb_reg_new_1(klass, s, len, options)
if (options & RE_OPTION_EXTENDED) { if (options & RE_OPTION_EXTENDED) {
FL_SET(re, REG_EXTENDED); FL_SET(re, REG_EXTENDED);
} }
if (options & RE_OPTION_POSIXLINE) { if (options & RE_OPTION_MULTILINE) {
FL_SET(re, REG_POSIXLINE); FL_SET(re, REG_MULTILINE);
} }
switch (options & ~0x7) { switch (options & ~0x7) {
case 0: case 0:
@ -1297,6 +1298,7 @@ Init_Regexp()
rb_define_const(rb_cRegexp, "IGNORECASE", INT2FIX(RE_OPTION_IGNORECASE)); rb_define_const(rb_cRegexp, "IGNORECASE", INT2FIX(RE_OPTION_IGNORECASE));
rb_define_const(rb_cRegexp, "EXTENDED", INT2FIX(RE_OPTION_EXTENDED)); rb_define_const(rb_cRegexp, "EXTENDED", INT2FIX(RE_OPTION_EXTENDED));
rb_define_const(rb_cRegexp, "POSIXLINE", INT2FIX(RE_OPTION_POSIXLINE)); rb_define_const(rb_cRegexp, "POSIXLINE", INT2FIX(RE_OPTION_POSIXLINE));
rb_define_const(rb_cRegexp, "MULTILINE", INT2FIX(RE_OPTION_MULTILINE));
rb_global_variable(&reg_cache); rb_global_variable(&reg_cache);

40
regex.c
Просмотреть файл

@ -352,6 +352,8 @@ enum regexpcode
casefold_off, /* Turn off casefold flag. */ casefold_off, /* Turn off casefold flag. */
posix_on, /* Turn on POSIXified line match (match with newlines). */ posix_on, /* Turn on POSIXified line match (match with newlines). */
posix_off, /* Turn off POSIXified line match. */ posix_off, /* Turn off POSIXified line match. */
mline_on, /* Turn on multi line match (match with newlines). */
mline_off, /* Turn off multi line match. */
start_nowidth, /* Save string point to the stack. */ start_nowidth, /* Save string point to the stack. */
stop_nowidth, /* Restore string place at the point start_nowidth. */ stop_nowidth, /* Restore string place at the point start_nowidth. */
pop_and_fail, /* Fail after popping nowidth entry from stack. */ pop_and_fail, /* Fail after popping nowidth entry from stack. */
@ -772,6 +774,14 @@ print_partial_compiled_pattern(start, end)
printf("/posix_off"); printf("/posix_off");
break; break;
case mline_on:
printf("/mline_on");
break;
case mline_off:
printf("/mline_off");
break;
case start_nowidth: case start_nowidth:
EXTRACT_NUMBER_AND_INCR (mcnt, p); EXTRACT_NUMBER_AND_INCR (mcnt, p);
printf("/start_nowidth//%d", mcnt); printf("/start_nowidth//%d", mcnt);
@ -1027,6 +1037,8 @@ calculate_must_string(start, end)
case stop_paren: case stop_paren:
case posix_on: case posix_on:
case posix_off: case posix_off:
case mline_on:
case mline_off:
break; break;
case charset: case charset:
@ -1689,6 +1701,18 @@ re_compile_pattern(pattern, size, bufp)
BUFPUSH(posix_on); BUFPUSH(posix_on);
} }
break; break;
case 'm':
if (negative) {
if (options&RE_OPTION_MULTILINE) {
options &= ~RE_OPTION_MULTILINE;
BUFPUSH(mline_off);
}
}
else if (!(options&RE_OPTION_MULTILINE)) {
options |= RE_OPTION_MULTILINE;
BUFPUSH(mline_on);
}
break;
case 'i': case 'i':
if (negative) { if (negative) {
if (options&RE_OPTION_IGNORECASE) { if (options&RE_OPTION_IGNORECASE) {
@ -1802,6 +1826,9 @@ re_compile_pattern(pattern, size, bufp)
if ((options ^ stackp[-1]) & RE_OPTION_POSIXLINE) { if ((options ^ stackp[-1]) & RE_OPTION_POSIXLINE) {
BUFPUSH((options&RE_OPTION_POSIXLINE)?posix_off:posix_on); BUFPUSH((options&RE_OPTION_POSIXLINE)?posix_off:posix_on);
} }
if ((options ^ stackp[-1]) & RE_OPTION_MULTILINE) {
BUFPUSH((options&RE_OPTION_POSIXLINE)?mline_off:mline_on);
}
pending_exact = 0; pending_exact = 0;
if (fixup_alt_jump) { if (fixup_alt_jump) {
/* Push a dummy failure point at the end of the /* Push a dummy failure point at the end of the
@ -2765,6 +2792,11 @@ re_compile_fastmap(bufp)
options ^= RE_OPTION_POSIXLINE; options ^= RE_OPTION_POSIXLINE;
continue; continue;
case mline_on:
case mline_off:
options ^= RE_OPTION_MULTILINE;
continue;
case endline: case endline:
if (TRANSLATE_P()) if (TRANSLATE_P())
fastmap[translate['\n']] = 1; fastmap[translate['\n']] = 1;
@ -4105,6 +4137,14 @@ re_match(bufp, string_arg, size, pos, regs)
options &= ~RE_OPTION_POSIXLINE; options &= ~RE_OPTION_POSIXLINE;
continue; continue;
case mline_on:
options |= RE_OPTION_MULTILINE;
continue;
case mline_off:
options &= ~RE_OPTION_MULTILINE;
continue;
case wordbound: case wordbound:
if (AT_STRINGS_BEG(d)) { if (AT_STRINGS_BEG(d)) {
if (IS_A_LETTER(d)) break; if (IS_A_LETTER(d)) break;

Просмотреть файл

@ -69,8 +69,10 @@
#define RE_OPTION_IGNORECASE (1L) #define RE_OPTION_IGNORECASE (1L)
/* perl-style extended pattern available */ /* perl-style extended pattern available */
#define RE_OPTION_EXTENDED (RE_OPTION_IGNORECASE<<1) #define RE_OPTION_EXTENDED (RE_OPTION_IGNORECASE<<1)
/* newline will be included for . and invert charclass matches */ /* newline will be included for ., ^, $ does not handle newline - obsolete */
#define RE_OPTION_POSIXLINE (RE_OPTION_EXTENDED<<1) #define RE_OPTION_POSIXLINE (RE_OPTION_EXTENDED<<1)
/* newline will be included for . */
#define RE_OPTION_MULTILINE (RE_OPTION_POSIXLINE<<1)
/* search for longest match, in accord with POSIX regexp */ /* search for longest match, in accord with POSIX regexp */
#define RE_OPTION_LONGEST (RE_OPTION_POSIXLINE<<1) #define RE_OPTION_LONGEST (RE_OPTION_POSIXLINE<<1)