ときどきの雑記帖 RE* (新南口)
機械じかけの明日
連休
終わり。
Firefox 100
Firefox もバージョン100に。 99.0.1からの更新後にいつもとちがう メッセージが出て少し驚いた。
んが、
「NHKプラス」、「Firefox」での視聴が不可能に 5月23日から - ITmedia NEWS
こういう話も。 そういえばとある動画配信サイトで新規にユーザー登録しようとしたら エラーメッセージはでないけど まともに動いてる気配がない(登録できなかった) というのがあったなあ…
string
これは興味深い質問だ(自分でもちょっと「起源」を調べたことがある)と 期待して読みに行ったのだけど(ry
プログラミングで文字列のことをstringって表記| OKWAVE
ndbm
これ、OS等を跨ってのファイルの互換性はないことによるエラーなんじゃ?
NDBM_Fileのデバッグ方法 -NDBM_Fileでデーターやりとりを- | OKWAVE
算額
八算や 福徳神社の算額 で触れた神社に行ってきた。 算額。というか算額の写し。といったものですかねえ (問題の脇に解答もあったし)。
アフィリエイト
なんか先々月のアフィリエイトの額が激増しててびっくりしたんだけど なにがあったんだろう(調べればなにが購入されてそうなったのかはわかるんだけど なんか見るのが怖い😓)
路線バスの座席
新型コロナウイルス感染対策ということで (なぜそうなるのかよくわからなかったけど) 使用禁止になっていた 運転手のすぐ後ろだとか その反対側(入口の直後)の席が 座れるようになっていた。
明倫館書店
連休中に行ってきたのだけど
本年6月より以下の通り定休日・営業時間を下記の通り変更いたします。
ご不便をお掛けしますが、ご理解のほどお願いいたします。定休日 : 木曜日・日曜日
営業時間
(平日)10:30~18:15
(祝日)11:30~17:45
というお知らせが出ていて
103
今年70歳になった著者による「あのころの自分が知っていたらと思う103のアドバイス」
— 新山祐介 (Yusuke Shinyama) (@mootastic) April 30, 2022
- ほとんどの場合、適切なタイミングは今である。
- 自分の所有物を立派だと思っているのは自分だけ。
- 決して自分がなりたくない人物のために働いてはならない。
...https://t.co/0b0BiyVEkI
複数のツイートにまたがっているのをまとめると
- ほとんどの場合、適切なタイミングは今である。
- 自分の所有物を立派だと思っているのは自分だけ。
- 決して自分がなりたくない人物のために働いてはならない。
- 2つの意見で論争が起きたときは、3つ目の意見をさがせ。
- リーダーの仕事とは、より多くのリーダーを作ることである。追随者を作ることではない。
- 生産性は誤解されている。効率よく仕事する方法を探すのではなく、やめたくなくなる仕事を探せ。
- 我々が自分につく最大のウソ:「こんなの書いておかなくても覚えておけるだろう」
- 人としての成長は、話したくないことをどれだけ話してきたかによって測られる。
- 人前で話すときは間を入れること: 新しいことを話すとき、重要なことを話すとき、そして話した事を人々に吸収させるとき。
- 悪い行為を罰するよりも、よい行為を伸ばしたほうが物事は10倍うまくいく。
- 電子メールの件名には本文と同じくらい時間をかけよ; ほとんどの人はそれしか読まないのだ。
- 教養というものの半分は、何を無視するかを学ぶということだ。
- 物事の真のコストは、値札には書かれていない。
- そんなに賢くはないが話がうまい人のほうが、超賢くて話下手な人より成功する。これはよいことだ: なぜならコミュニケーションを鍛えるほうが、知能を鍛えるよりも楽だから。
- たまに自分の街のガイドブックを買って旅行者のふりをしてみよ。
- 古いものと争うな。ただ新しいものを作れ。
- 自分は他人の2%しか見えないし、他人は自分の2%しか見ない。
- 目的地よりも針路に注力せよ。どのみち真の目的地なんぞわからないのだから。
- 借金を踏み倒された経験は、貸した金額と同じだけの価値がある。
- つねに驚きのある人生を求めよ。
ふむ。
ところで元記事を見ると
The Technium: 103 Bits of Advice I Wish I Had Known
Today is my birthday. I turn 70. I’ve learned a few things so far that might be helpful to others. For the past few years, I’ve jotted down bits of unsolicited advice each year and much to my surprise I have more to add this year. So here is my birthday gift to you all: 103 bits of wisdom I wish I had known when I was young.
(Previous years here and here.)
とあって、2年間で68→99→103と増えていってるのね😄
内容がどう変わったかまでは追いかけないけど。 ところで新山さんのあげたものの原文はというと (たぶん)これなんだけど
- About 99% of the time, the right time is right now.
- Dont ever work for someone you dont want to become.
- No one is as impressed with your possessions as you are.
- Whenever there is an argument between two sides, find the third side.
- When you lead, your real job is to create more leaders, not more followers.
- Productivity is often a distraction. Don’t aim for better ways to get through your tasks as quickly as possible, rather aim for better tasks that you never want to stop doing.
- The biggest lie we tell ourselves is “I dont need to write this down because I will remember it.”
- When public speaking, pause frequently. Pause before you say something in a new way, pause after you have said something you believe is important, and pause as a relief to let listeners absorb details.
- Your growth as a conscious being is measured by the number of uncomfortable conversations you are willing to have.
- You’ll get 10x better results by elevating good behavior rather than punishing bad behavior, especially in children and animals.
- Spend as much time crafting the subject line of an email as the message itself because the subject line is often the only thing people read.
- Half the skill of being educated is learning what you can ignore.
- What you actually pay for something is at least twice the listed price because of the energy, time, money needed to set it up, learn, maintain, repair, and dispose of at the end. Not all prices appear on labels. Actual costs are 2x listed prices.
- It’s possible that a not-so smart person, who can communicate well, can do much better than a super smart person who can’t communicate well. That is good news because it is much easier to improve your communication skills than your intelligence.
- Purchase the most recent tourist guidebook to your home town or region. You’ll learn a lot by playing the tourist once a year.
- Dont bother fighting the old; just build the new.
- You see only 2% of another person, and they see only 2% of you. Attune yourselves to the hidden 98%.
- Focus on directions rather than destinations. Who knows their destiny? But maintain the right direction and you’ll arrive at where you want to go.
- If you loan someone $20 and you never see them again because they are avoiding paying you back, that makes it worth $20.
- Rather than steering your life to avoid surprises, aim directly for them.
特に原文が長いものについてそう訳す(略す)のかあ と思ったり(批判的な意味ではない)。
せっかくなので(ry、自分が気になったのを挙げるとこのへん。
- Don’t wait for the storm to pass; dance in the rain.
- Take the stairs.
- Courtesy costs nothing. Lower the toilet seat after use. Let the people in the elevator exit before you enter. Return shopping carts to their designated areas. When you borrow something, return it better shape (filled up, cleaned) than when you got it.
- Three things you need: The ability to not give up something till it works, the ability to give up something that does not work, and the trust in other people to help you distinguish between the two.
- What you do on your bad days matters more than what you do on your good days.
- Buy used books. They have the same words as the new ones. Also libraries.
- Dont purchase extra insurance if you are renting a car with a credit card.
- Copying others is a good way to start. Copying yourself is a disappointing way to end.
- When you are stuck, explain your problem to others. Often simply laying out a problem will present a solution. Make “explaining the problem” part of your troubleshooting process.
- Making art is not selfish; it’s for the rest of us. If you don’t do your thing, you are cheating us.
- Art is whatever you can get away with.
glob bash 4
前回のglob bash 3 では構文解析で コマンド名を取り出すところまで 追いかけていったわけだけど、 その段階ではコマンドに対する引数は そのまま(interpolationとかglobをせずに) 線形リストにまとめられていた。
main
からの呼び出しを追いかけていくとこんな感じ(省略あり)。
構文解析はyyparse
で呼び出しているので
続きはreader_loop
に戻って
execute_command
に。
eval.c
/* Read and execute commands until EOF is reached. This assumes that
the input source has already been initialized. */
int
reader_loop ()
{
略
if (read_command () == 0)
{
略
current_command_number++;
executing = 1;
stdin_redir = 0;
execute_command (current_command);
ここね。
とはいうものの、例によって(?) 下請け関数を結構潜っていくのでありました。
main
reader_loop
read_command
parse_command
yyparse
execute_command
execute_command_internal
execute_simple_command
expand_words
expand_word_list_internal
shell_expand_word_list
expand_word_internal
glob_expand_word_list
shell_glob_filename (pathexp.c)
glob
execute_command
はというとこう。
短いと言えば短いのだけど、
準備をしてからさらにexecute_command_internal
を呼び出し。
bash/execute_cmd.c at master · bminor/bash
/* Execute the command passed in COMMAND. COMMAND is exactly what
read_command () places into GLOBAL_COMMAND. See "command.h" for the
details of the command structure.
EXECUTION_SUCCESS or EXECUTION_FAILURE are the only possible
return values. Executing a command with nothing in it returns
EXECUTION_SUCCESS. */
int
execute_command (command)
COMMAND *command;
{
struct fd_bitmap *bitmap;
int result;
current_fds_to_close = (struct fd_bitmap *)NULL;
bitmap = new_fd_bitmap (FD_BITMAP_DEFAULT_SIZE);
begin_unwind_frame ("execute-command");
add_unwind_protect (dispose_fd_bitmap, (char *)bitmap);
/* Just do the command, but not asynchronously. */
result = execute_command_internal (command, 0, NO_PIPE, NO_PIPE, bitmap);
dispose_fd_bitmap (bitmap);
discard_unwind_frame ("execute-command");
#if defined (PROCESS_SUBSTITUTION)
/* don't unlink fifos if we're in a shell function; wait until the function
returns. */
if (variable_context == 0 && executing_list == 0)
unlink_fifo_list ();
#endif /* PROCESS_SUBSTITUTION */
QUIT;
return (result);
}
そしてそのexecute_command_internal
。
こいつは関数直前のコメントと
関数頭部だけ貼り付け。
bash/execute_cmd.c at master · bminor/bash
/* Execute the command passed in COMMAND, perhaps doing it asynchronously.
COMMAND is exactly what read_command () places into GLOBAL_COMMAND.
ASYNCHRONOUS, if non-zero, says to do this command in the background.
PIPE_IN and PIPE_OUT are file descriptors saying where input comes
from and where it goes. They can have the value of NO_PIPE, which means
I/O is stdin/stdout.
FDS_TO_CLOSE is a list of file descriptors to close once the child has
been forked. This list often contains the unusable sides of pipes, etc.
EXECUTION_SUCCESS or EXECUTION_FAILURE are the only possible
return values. Executing a command with nothing in it returns
EXECUTION_SUCCESS. */
int
execute_command_internal (command, asynchronous, pipe_in, pipe_out,
fds_to_close)
COMMAND *command;
int asynchronous;
int pipe_in, pipe_out;
struct fd_bitmap *fds_to_close;
{
そこから
execute_simple_command
を呼び出し
(呼び出さないフローもあるけど今回はスルー)。
bash/execute_cmd.c at master · bminor/bash
/* The meaty part of all the executions. We have to start hacking the
real execution of commands here. Fork a process, set things up,
execute the command. */
static int
execute_simple_command (simple_command, pipe_in, pipe_out, async, fds_to_close)
SIMPLE_COM *simple_command;
int pipe_in, pipe_out, async;
struct fd_bitmap *fds_to_close;
{
略
/* If we are re-running this as the result of executing the `command'
builtin, do not expand the command words a second time. */
if ((cmdflags & CMD_INHIBIT_EXPANSION) == 0)
{
current_fds_to_close = fds_to_close;
fix_assignment_words (simple_command->words);
/* Pass the ignore return flag down to command substitutions */
if (cmdflags & CMD_IGNORE_RETURN) /* XXX */
comsub_ignore_return++;
words = expand_words (simple_command->words);
if (cmdflags & CMD_IGNORE_RETURN)
comsub_ignore_return--;
current_fds_to_close = (struct fd_bitmap *)NULL;
}
else
words = copy_word_list (simple_command->words);
そのexpand_words
はというとまたまた下請け関数を呼び出していたり。
WORD_LIST *
expand_words (list)
WORD_LIST *list;
{
return (expand_word_list_internal (list, WEXP_ALL));
}
/* Same as expand_words (), but doesn't hack variable or environment
variables. */
WORD_LIST *
expand_words_no_vars (list)
WORD_LIST *list;
{
return (expand_word_list_internal (list, WEXP_NOVARS));
}
WORD_LIST *
expand_words_shellexp (list)
WORD_LIST *list;
{
return (expand_word_list_internal (list, WEXP_SHELLEXP));
}
expand_word_list_internal
で
glob_expand_word_list
を呼び出し。
ここまできてようやくglobの文字が。
static WORD_LIST *
glob_expand_word_list (tlist, eflags)
WORD_LIST *tlist;
int eflags;
{
char **glob_array, *temp_string;
register int glob_index;
WORD_LIST *glob_list, *output_list, *disposables, *next;
WORD_DESC *tword;
int x;
output_list = disposables = (WORD_LIST *)NULL;
glob_array = (char **)NULL;
while (tlist)
{
/* For each word, either globbing is attempted or the word is
added to orig_list. If globbing succeeds, the results are
added to orig_list and the word (tlist) is added to the list
of disposable words. If globbing fails and failed glob
expansions are left unchanged (the shell default), the
original word is added to orig_list. If globbing fails and
failed glob expansions are removed, the original word is
added to the list of disposable words. orig_list ends up
in reverse order and requires a call to REVERSE_LIST to
be set right. After all words are examined, the disposable
words are freed. */
next = tlist->next;
/* If the word isn't an assignment and contains an unquoted
pattern matching character, then glob it. */
if ((tlist->word->flags & W_NOGLOB) == 0 &&
unquoted_glob_pattern_p (tlist->word->word))
{
glob_array = shell_glob_filename (tlist->word->word, QGLOB_CTLESC); /* XXX */
さらにshell_glob_filename
を呼び出し。
この関数は
#if defined (USE_POSIX_GLOB_LIBRARY)
で大きく二つに分かれているのだけど
/* Call the glob library to do globbing on PATHNAME. */
char **
shell_glob_filename (pathname, qflags)
const char *pathname;
int qflags;
{
#if defined (USE_POSIX_GLOB_LIBRARY)
register int i;
char *temp, **results;
glob_t filenames;
int glob_flags;
temp = quote_string_for_globbing (pathname, QGLOB_FILENAME|qflags);
filenames.gl_offs = 0;
# if defined (GLOB_PERIOD)
glob_flags = glob_dot_filenames ? GLOB_PERIOD : 0;
# else
glob_flags = 0;
# endif /* !GLOB_PERIOD */
glob_flags |= (GLOB_ERR | GLOB_DOOFFS);
i = glob (temp, glob_flags, (posix_glob_errfunc_t *)NULL, &filenames);
free (temp);
if (i == GLOB_NOSPACE || i == GLOB_ABORTED)
return ((char **)NULL);
else if (i == GLOB_NOMATCH)
filenames.gl_pathv = (char **)NULL;
else if (i != 0) /* other error codes not in POSIX.2 */
filenames.gl_pathv = (char **)NULL;
results = filenames.gl_pathv;
if (results && ((GLOB_FAILED (results)) == 0))
{
if (should_ignore_glob_matches ())
ignore_glob_matches (results);
if (results && results[0])
strvec_sort (results, 1); /* posix sort */
else
{
FREE (results);
results = (char **)NULL;
}
}
return (results);
#else /* !USE_POSIX_GLOB_LIBRARY */
char *temp, **results;
int gflags, quoted_pattern;
noglob_dot_filenames = glob_dot_filenames == 0;
temp = quote_string_for_globbing (pathname, QGLOB_FILENAME|qflags);
gflags = glob_star ? GX_GLOBSTAR : 0;
results = glob_filename (temp, gflags);
free (temp);
if (results && ((GLOB_FAILED (results)) == 0))
{
if (should_ignore_glob_matches ())
ignore_glob_matches (results);
if (results && results[0])
strvec_sort (results, 1); /* posix sort */
else
{
FREE (results);
results = (char **)&glob_error_return;
}
}
return (results);
#endif /* !USE_POSIX_GLOB_LIBRARY */
}
これはelse部分を追いかければいいかな。
glob_filename
を呼び出した後でなにやらやっているけど
そこで呼び出している「怪しい名前」の関数の
実体を見ると以下の通り。
int
should_ignore_glob_matches ()
{
return globignore.num_ignores;
}
void
ignore_glob_matches (names)
char **names;
{
if (globignore.num_ignores == 0)
return;
ignore_globbed_names (names, glob_name_is_acceptable);
}
globignore.num_ignores
という構造体変数を参照しているけどこれは次のようなもの。
static struct ignorevar globignore =
{
"GLOBIGNORE",
(struct ign *)0,
0,
(char *)0,
(sh_iv_item_func_t *)0,
};
といったところでつづく。
GCC
Graydon HoareのCompiler講義資料が面白かった話
一番気になったのはGCCに含まれているという60万行のAdaコードだ・・・。何に使われているのだろうか。
https://t.co/ZdbFLKvoQK
— とみながたけひろ (@takehiro_t) May 4, 2022
「ですよねー」というかんじ。やっぱりそうなっちゃうよねー、というか。
gccにadaのコードが60万行がある、というのはgccの一機能であるadaコンパイラが60万行ということじゃないかな。adaで書かれたコードではなくて。
というのが気になったので(ry
確かに自分の第一印象もとみながさんの云う通りじゃないか? というものだったのだけど、スライドの原文をあたると
http://venge.net/graydon/talks/CompilerTalk-2019.pdf
p.12
~2.2m lines of mostly C, C++. 600k lines Ada. Self-hosting, bootstrapped from other C compilers.
なので、Adaで書かれたコードが600k lines(60万行)
という見方でよいのでは?
となったので、さらにGCCのリポジトリ
gcc-mirror/gcc
をみると
gcc/gcc/ada at master · gcc-mirror/gcc
というディレクトリに.adb
だとか.ads
という拡張子のファイルがたくさんある
(数は数えてない)。末尾のb
やs
の意味がよくわからないけど
.ada
ぽいよねといったところで中身を見ると
gcc/adabkend.adb at master · gcc-mirror/gcc
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- A D A B K E N D --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2022, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
------------------------------------------------------------------------------
-- This is the version of the Back_End package for back ends written in Ada
with Atree; use Atree;
with Backend_Utils; use Backend_Utils;
with Debug;
with Lib;
with Opt; use Opt;
with Output; use Output;
with Osint; use Osint;
with Osint.C; use Osint.C;
with Switch.C; use Switch.C;
with Types; use Types;
with System.OS_Lib; use System.OS_Lib;
package body Adabkend is
use Switch;
-------------------
-- Call_Back_End --
-------------------
procedure Call_Back_End is
begin
if (Opt.Verbose_Mode or Opt.Full_List)
and then not Debug.Debug_Flag_7
then
Write_Eol;
Write_Str (Product_Name);
Write_Str (", Copyright ");
Write_Str (Copyright_Years);
Write_Str (" Ada Core Technologies, Inc.");
Write_Str (" (http://www.adacore.com)");
Write_Eol;
Write_Eol;
end if;
-- The front end leaves the Current_Error_Node at a location that is
-- meaningless and confusing when emitting bug boxes from the back end.
-- Reset the global variable in order to emit "No source file position
-- information available" messages on back end crashes.
Current_Error_Node := Empty;
Driver (Lib.Cunit (Types.Main_Unit));
end Call_Back_End;
以下略
gcc/adabkend.ads at master · gcc-mirror/gcc
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- A D A B K E N D --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Generic package implementing the common parts of back_end.adb for back ends
-- written in Ada, thereby reducing code duplication.
with Types;
generic
Product_Name : String;
Copyright_Years : String;
with procedure Driver (Root : Types.Node_Id);
-- Main driver procedure for back end
with function Is_Back_End_Switch (Switch : String) return Boolean;
-- Back-end specific function to determine validity of switches
package Adabkend is
procedure Call_Back_End;
-- Call back end, i.e. make call to the Driver passing the root
-- node for this compilation unit.
procedure Scan_Compiler_Arguments;
-- Acquires command-line parameters passed to the compiler and processes
-- them. Calls Scan_Front_End_Switches for any front-end switches
-- encountered. See spec of Back_End for more details.
end Adabkend;
Adaのコードっすね
(.adb
と.ads
は上記のコードのコメントを見ればわかる通りそれぞれ body と spec)。
60万行あるかどうか確かめる元気はないので省略するけど
GCCにはAdaで書かれたコードも含まれていました。
ということで。
WM-20
売れのこったブラウン管のおはなし。(379)
— 都築和彦 (@KazuhikoTsuduki) April 30, 2022
カセットテープケースサイズの
カセットテーププレーヤー
WM-20 pic.twitter.com/P7W5Tkcjis
このウォークマン欲しかったんだよなあ(持っている友達が羨ましかった)。 んで、後年バイトして買ったのは別メーカーの薄くもないタイプのものだったり😓
FSFEが運営する「税金で開発されたソフトウェアは、すべてフリー/オープンソースにすべき」という請願の署名簿。
— 新山祐介 (Yusuke Shinyama) (@mootastic) April 28, 2022
こんな当たり前のことをなぜ今まで誰も言い出さなかったんだ?https://t.co/FokznqhyAf
ヨーロッパではどうだったかわからないけど rms(とEでないFSF)は初めのころから そういった主張していなかったかなあ という記憶があったのだけど
GNUプロジェクトの理念 - GNUプロジェクト - フリーソフトウェアファウンデーション
ここには見当たらない? ということで記憶違いかもしれない (が気が向いたらもうちょっと探してみよう)。