[#19261] lstripped here-document (Re: comments and continuing strings on the next line) — nobu.nakada@...
なかだです。
29 messages
2003/01/01
[#19360] Re: lstripped here-document (Re: comments and continuing strings on the next line)
— "K.Kosako" <kosako@...>
2003/01/15
nobu.nakada@nifty.ne.jpさんの
[#19361] Re: lstripped here-document (Re: comments and continuing strings on the next line)
— "NAKAMURA, Hiroshi" <nakahiro@...>
2003/01/15
なひです。
[#19364] Re: lstripped here-document (Re: comments and continuing strings on the next line)
— nobu.nakada@...
2003/01/17
なかだです。
[#19366] Re: lstripped here-document (Re: comments and continuing strings on the next line)
— "NAKAMURA, Hiroshi" <nakahiro@...>
2003/01/17
なひです。
[#19387] standard ruby lib coding convension (was Re: lstripped here-document)
— "NAKAMURA, Hiroshi" <nakahiro@...>
2003/01/20
なひです。
[#19395] Re: standard ruby lib coding convension (was Re: lstripped here-document)
— "NAKAMURA, Hiroshi" <nakahiro@...>
2003/01/20
camelCaseなひです。
[#19398] Re: standard ruby lib coding convension (was Re: lstripped here-document)
— matz@... (Yukihiro Matsumoto)
2003/01/20
まつもと ゆきひろです
[#19287] Re: Class.inherited — matz@... (Yukihiro Matsumoto)
まつもと ゆきひろです
4 messages
2003/01/02
[#19299] [BUG] errno == 0 — Kazuhiro Yoshida <moriq@...>
もりきゅうです。win32だけかもしれません。
22 messages
2003/01/04
[#19301] Re: [BUG] errno == 0
— "U.Nakamura" <usa@...>
2003/01/04
こんにちは、なかむら(う)です。
[#19302] Re: [BUG] errno == 0
— "U.Nakamura" <usa@...>
2003/01/04
こんにちは、なかむら(う)です。
[#19303] Re: [BUG] errno == 0
— "U.Nakamura" <usa@...>
2003/01/04
こんにちは、なかむら(う)です。
[#19304] Re: [BUG] errno == 0
— "U.Nakamura" <usa@...>
2003/01/04
こんにちは、なかむら(う)です。
[#19306] Re: [BUG] errno == 0
— nobu.nakada@...
2003/01/05
なかだです。
[#19307] Re: [BUG] errno == 0
— "U.Nakamura" <usa@...>
2003/01/05
こんにちは、なかむら(う)です。
[#19308] Re: [BUG] errno == 0
— nobu.nakada@...
2003/01/05
なかだです。
[#19324] Re: [BUG] errno == 0
— "U.Nakamura" <usa@...>
2003/01/09
こんにちは、なかむら(う)です。
[#19325] Re: [BUG] errno == 0
— nobu.nakada@...
2003/01/09
なかだです。
[#19327] Re: [BUG] errno == 0
— "U.Nakamura" <usa@...>
2003/01/09
こんにちは、なかむら(う)です。
[#19333] Re: [BUG] errno == 0
— "U.Nakamura" <usa@...>
2003/01/09
こんにちは、なかむら(う)です。
[#19336] Re: [BUG] errno == 0
— nobu.nakada@...
2003/01/09
なかだです。
[#19338] Re: [BUG] errno == 0
— "U.Nakamura" <usa@...>
2003/01/09
こんにちは、なかむら(う)です。
[#19309] Re: [ruby-cvs] ruby, ruby/ext: * ext/extmk.rb (extmake): set $0 temporarily while loading — WATANABE Hirofumi <eban@...>
わたなべです。
6 messages
2003/01/05
[#19310] Re: [ruby-cvs] ruby, ruby/ext: * ext/extmk.rb (extmake): set $0 temporarily while loading
— nobu.nakada@...
2003/01/05
なかだです。
[#19317] [patch] cast for st_*. — "U.Nakamura" <usa@...>
こんにちは、なかむら(う)です。
6 messages
2003/01/09
[#19328] [Ruby/DL] 'S', 's' — WATANABE Hirofumi <eban@...>
わたなべです。
5 messages
2003/01/09
[#19329] [Ruby/DL] Bignum to ... — WATANABE Hirofumi <eban@...>
わたなべです。
6 messages
2003/01/09
[#19332] Re: [Ruby/DL] Bignum to ...
— Takaaki Tateishi <ttate@...>
2003/01/09
At Thu, 9 Jan 2003 16:30:59 +0900,
[#19370] shebang line of bin/* — "U.Nakamura" <usa@...>
こんにちは、なかむら(う)です。
7 messages
2003/01/17
[#19371] dbm.so + Berkeley DB[234] — akira yamada / やまだあきら <akira@...>
5 messages
2003/01/17
[#19405] Re: cannot find -lruby-static (PR#384) — WATANABE Hirofumi <eban@...>
わたなべです。
9 messages
2003/01/21
[#19407] Re: cannot find -lruby-static (PR#384)
— nobu.nakada@...
2003/01/21
なかだです。
[#19408] Re: cannot find -lruby-static (PR#384)
— nobu.nakada@...
2003/01/21
なかだです。
[#19410] [] 内での \001 のマッチ — WATANABE Tetsuya <tetsu@...>
渡辺哲也です。
10 messages
2003/01/22
[#19411] Re: [] 内での \001 のマッチ
— matz@... (Yukihiro Matsumoto)
2003/01/22
まつもと ゆきひろです
[#19423] Numeric#quo — matz@... (Yukihiro Matsumoto)
まつもと ゆきひろです
6 messages
2003/01/23
[#19430] HAVE_* macros — "Akinori MUSHA" <knu@...>
拡張ライブラリで 1.6/1.8 に両対応する際、以下のようなマクロが
10 messages
2003/01/24
[#19431] Re: HAVE_* macros
— matz@... (Yukihiro Matsumoto)
2003/01/24
まつもと ゆきひろです
[#19433] Re: HAVE_* macros
— "Akinori MUSHA" <knu@...>
2003/01/24
At Fri, 24 Jan 2003 22:08:48 +0900,
[#19437] recursive dryrun (Re: [ruby-cvs] ruby, ruby/ext, ruby/win32, ruby/bcc32: * instruby.rb, ext/extmk.rb, Makefile.in, win32/Makefile.sub,) — nobu.nakada@...
なかだです。
6 messages
2003/01/25
[#19441] Integer#gcd — masaki <GEC01122@...>
11 messages
2003/01/26
[#20244] Re: Integer#gcd
— matz@... (Yukihiro Matsumoto)
2003/05/20
まつもと ゆきひろです
[#20246] Re: Integer#gcd
— Shin-ichiro HARA <sinara@...>
2003/05/20
原です。
[ruby-dev:19261] lstripped here-document (Re: comments and continuing strings on the next line)
From:
nobu.nakada@...
Date:
2003-01-01 00:55:17 UTC
List:
ruby-dev #19261
なかだです。
At Tue, 17 Sep 2002 22:52:00 +0900,
Paul Brannan wrote:
> I do recall one of the apocalypses mentioning a perl rfc that proposed a
> <<< operator for 'here documents', which would remove whitespace from
> the 'here document' (at compile-time) that matched the whitespace in
> front of the terminator. Doesn't seem like a bad idea for either perl
> or ruby.
しばらく前のruby-coreの話ですが、こういうのはどうでしょうか。
p <<-|EOS
| foo
| bar
EOS
# => " foo\n bar\n"
つまり、<<-とterminatorの間にクォーテーション以外の記号があった場合、
行頭の空白とその記号までを削除します。その記号がなければエラーです。
Index: parse.y
===================================================================
RCS file: /cvs/ruby/src/ruby/parse.y,v
retrieving revision 1.239
diff -u -2 -p -r1.239 parse.y
--- parse.y 30 Dec 2002 22:56:21 -0000 1.239
+++ parse.y 1 Jan 2003 00:49:46 -0000
@@ -2859,4 +2859,5 @@ regx_options()
#define STR_FUNC_SYMBOL 0x10
#define STR_FUNC_INDENT 0x20
+#define STR_FUNC_LSTRIP 0x40
enum string_type {
@@ -3020,4 +3021,5 @@ heredoc_identifier()
{
int c = nextc(), term, func = 0, len;
+ unsigned char margin = 0;
if (c == '-') {
@@ -3025,4 +3027,5 @@ heredoc_identifier()
func = STR_FUNC_INDENT;
}
+ again:
switch (c) {
case '\'':
@@ -3048,4 +3051,10 @@ heredoc_identifier()
default:
if (!is_identchar(c)) {
+ if (!margin && (func & STR_FUNC_INDENT) && ISPRINT(c) && !isspace(c)) {
+ func |= STR_FUNC_LSTRIP;
+ margin = (unsigned char)c;
+ c = nextc();
+ goto again;
+ }
pushback(c);
if (func & STR_FUNC_INDENT) {
@@ -3065,4 +3074,5 @@ heredoc_identifier()
}
+ if (margin) tokadd(margin);
tokfix();
len = lex_p - lex_pbeg;
@@ -3101,5 +3111,5 @@ whole_match_p(eos, len, indent)
while (*p && ISSPACE(*p)) p++;
}
- n= lex_pend - (p + len);
+ n = lex_pend - (p + len);
if (n < 0 || n > 0 && p[len] != '\n' && p[len] != '\r') return Qfalse;
if (strncmp(eos, p, len) == 0) return Qtrue;
@@ -3112,5 +3122,5 @@ here_document(here)
{
int c, func, indent = 0;
- char *eos, *p, *pend;
+ char *eos, *p, *pend, margin = 0;
long len;
VALUE str = 0;
@@ -3119,4 +3129,5 @@ here_document(here)
len = RSTRING(here->nd_lit)->len - 1;
indent = (func = *eos++) & STR_FUNC_INDENT;
+ if (func & STR_FUNC_LSTRIP) margin = eos[--len];
if ((c = nextc()) == -1) {
@@ -3136,4 +3147,11 @@ here_document(here)
p = RSTRING(lex_lastline)->ptr;
pend = lex_pend;
+ if (margin) {
+ while ((c = *p) == ' ' || c == '\t') p++;
+ if (margin && *p++ != margin) {
+ lex_p = p;
+ goto no_margin;
+ }
+ }
if (pend > p) {
switch (pend[-1]) {
@@ -3173,5 +3191,11 @@ here_document(here)
}
do {
- pushback(c);
+ if (margin && was_bol()) {
+ while (c == ' ' || c == '\t') c = nextc();
+ if (margin && c != margin) goto no_margin;
+ }
+ else {
+ pushback(c);
+ }
if ((c = tokadd_string(func, '\n', 0)) == -1) goto error;
if (c != '\n') {
@@ -3188,4 +3212,15 @@ here_document(here)
yylval.node = NEW_STR(str);
return tSTRING_CONTENT;
+
+ no_margin:
+ {
+ char buf[40];
+ sprintf(buf, "can't find left margin character \"%c\"", margin);
+ --lex_p;
+ yyerror(buf);
+ heredoc_restore(lex_strterm);
+ lex_strterm = 0;
+ return 0;
+ }
}
--
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
中田 伸悦