ときどきの雑記帖 RE* (新南口)
No One Noticed the Cat
ノイエ銀英伝
第三部第二章見てきた。
あそこで切るかー(笑)
東京都現代美術館
井上泰幸展 | 展覧会 | 東京都現代美術館|MUSEUM OF CONTEMPORARY ART TOKYO に行ってきた。
東京都現代美術館に行ったのは多分 館長 庵野秀明 特撮博物館 ミニチュアで見る昭和平成の技 | 展覧会 | 東京都現代美術館|MUSEUM OF CONTEMPORARY ART TOKYO 以来(まだリンク残してるの偉いな)。
って、もう10年になるのか😱>特撮博物館
制作のための図面類に書かれていた長さの単位が「尺」(と「分」、「厘」。見た感じ「寸」はなかったような) だったのにちょっと驚きつつも納得。 いつ頃までそうだったんだろう?
IIRC
【緩募】msys2/mingw64 の g++ で coroutine/generator を使う方法。 pic.twitter.com/whvOqduUgN
— mattn (@mattn_jp) April 9, 2022
このツイートに
IIRC, the generator class is not in the C++ standard, have to implement it. https://t.co/thvbTVnk3a
— Cocoa (@_uwu_cocoa) April 9, 2022
という反応があったのだけど、 頭の「IIRC」ってナニ? となったので調べた。
なるほど「わたしの記憶が確かならば」か(ちょっと違う)。
repeat until
X1のHu-BASIC、CZ-8FB01 V2.0はフリーエリアを広げるために使用頻度の低い命令を削ったとあるがREPEAT~UNTILを削るってどうよ?
— ほうめい マイコンで遊んでばっかりで (@houmei) April 3, 2022
残念ながら見つけ出すことはできなかったのだけど
何かの本でループ形式を前判定(while cond body
)と後判定(repeat body until cond
)
などに分類してそれぞれがどのくらい使われているかを調べた
というものがありました。
具体的な数値も覚えていないのですが かなり少数だったように思います。
であれば、
REPEAT
とUNTIL
という予約語だけでも10バイトかそこら削れるので
コード部分と合わせて(こっちはどのくらい削れるかちょっとわからんけど)
考えれば、まあ判断としてはありかなあ。
- Computing Preconditions and Postconditions of While Loops | SpringerLink
- Modula-2 tutorial: Loops and Control Structures
cut
gnu,bsdコマンドの差を吸収しよう を見ていたらGNU版を使うものに
- getopt
- sed
- awk
- xargs
- find
- date
- cut
- df
というのを挙げていて、 だいたい納得のいくものなんだけどcutについては わざわざGNU版使うような拡張(など)ってあったっけ? と思いマニュアルをみる。
‘–complement’
This option is a GNU extension. Select for printing the complement of the bytes, characters or fields selected with the -b, -c or -f options. In other words, do not print the bytes, characters or fields specified via those options. This option is useful when you have many fields and want to print all but a few of them.
これかな?
glob bash 2
前回 glob bash 1 から間が空きましたが。
グロブのルーチン(関数群)自体は
lib/glob/glob.c
にあることは
すでにわかっていることですが、
呼び出しフローの上から潜っていくことにします。
なお今回のコード読みではbash 5.1.8のものを使います。
さてmain
がどこにあるかというとshell.c
というファイル。
#if defined (NO_MAIN_ENV_ARG)
/* systems without third argument to main() */
int
main (argc, argv)
int argc;
char **argv;
#else /* !NO_MAIN_ENV_ARG */
int
main (argc, argv, env)
int argc;
char **argv, **env;
#endif /* !NO_MAIN_ENV_ARG */
{
のようなK&R形式な配慮した関数頭部から始まり、 オプションの処理やら初期設定やらを行って mainのほぼ最後の
shell_initialized = 1;
if (pretty_print_mode && interactive_shell)
{
internal_warning (_("pretty-printing mode ignored in interactive shells"));
pretty_print_mode = 0;
}
if (pretty_print_mode)
exit_shell (pretty_print_loop ());
/* Read commands until exit condition. */
reader_loop ();
exit_shell (last_command_exit_value);
}
reader_loop ()
でユーザーからの入力を読み込みと処理を行います。
そのreader_loop()
はeval.cにあって
/* Read and execute commands until EOF is reached. This assumes that
the input source has already been initialized. */
int
reader_loop ()
{
int our_indirection_level;
COMMAND * volatile current_command;
USE_VAR(current_command);
current_command = (COMMAND *)NULL;
our_indirection_level = ++indirection_level;
if (just_one_command)
reset_readahead_token ();
while (EOF_Reached == 0)
{
このwhileループの中で呼び出しているread_command ()
が
if (read_command () == 0)
{
省略
}
else
{
/* Parse error, maybe discard rest of stream if not interactive. */
if (interactive == 0)
EOF_Reached = EOF;
}
if (just_one_command)
EOF_Reached = EOF;
}
indirection_level--;
return (last_command_exit_value);
}
コメントにあるように
Read and parse a command, returning the status of the parse.
を行います。
read_command ()
の詳細はこう
(これは省略なしで)。
/* Read and parse a command, returning the status of the parse. The command
is left in the globval variable GLOBAL_COMMAND for use by reader_loop.
This is where the shell timeout code is executed. */
int
read_command ()
{
SHELL_VAR *tmout_var;
int tmout_len, result;
SigHandler *old_alrm;
set_current_prompt_level (1);
global_command = (COMMAND *)NULL;
/* Only do timeouts if interactive. */
tmout_var = (SHELL_VAR *)NULL;
tmout_len = 0;
old_alrm = (SigHandler *)NULL;
if (interactive)
{
tmout_var = find_variable ("TMOUT");
if (tmout_var && var_isset (tmout_var))
{
tmout_len = atoi (value_cell (tmout_var));
if (tmout_len > 0)
{
old_alrm = set_signal_handler (SIGALRM, alrm_catcher);
alarm (tmout_len);
}
}
}
QUIT;
current_command_line_count = 0;
result = parse_command ();
if (interactive && tmout_var && (tmout_len > 0))
{
alarm(0);
set_signal_handler (SIGALRM, old_alrm);
}
return (result);
}
あれ、QUITってラベル実際には使ってない?
まあそれはさておきここから呼び出している
parse_command ()
へと。
/* Call the YACC-generated parser and return the status of the parse.
Input is read from the current input stream (bash_input). yyparse
leaves the parsed command in the global variable GLOBAL_COMMAND.
This is where PROMPT_COMMAND is executed. */
int
parse_command ()
{
int r;
need_here_doc = 0;
run_pending_traps ();
/* Allow the execution of a random command just before the printing
of each primary prompt. If the shell variable PROMPT_COMMAND
is set then its value (array or string) is the command(s) to execute. */
/* The tests are a combination of SHOULD_PROMPT() and prompt_again()
from parse.y, which are the conditions under which the prompt is
actually printed. */
if (interactive && bash_input.type != st_string && parser_expanding_alias() == 0)
{
#if defined (READLINE)
if (no_line_editing || (bash_input.type == st_stdin && parser_will_prompt ()))
#endif
execute_prompt_command ();
if (running_under_emacs == 2)
send_pwd_to_eterm (); /* Yuck */
}
current_command_line_count = 0;
r = yyparse ();
if (need_here_doc)
gather_here_documents ();
return (r);
}
と、ここまできてようやく
インチキおじさん
構文解析の関数(yyparse())の呼び出しが登場。
つづく。