ときどきの雑記帖 RE* (新南口)
オーソゴナルダイアゴナライザー
プリンストン大学教授が教える “数字"に強くなるレッスン14
住んでいる地域の図書館に新しく入った本をチェックしていたら 「プリンストン大学教授が教える “数字"に強くなるレッスン14」 というタイトルが目に入ってきた。 分類は数学だったのだけど、「プリンストン大学教授」というのが気になったので タイトルでググると…
大先生(Brian Kernighan)の本じゃねーすか。 いつの間にこんなの出てたんだ。
出版社のページ プリンストン大学教授が教える “数字”に強くなるレッスン14|白揚社 -Hakuyosha- にも原著タイトルがないけど、翻訳本の目次にある Lesson 2 ミリオン(100 万)、ビリオン(10 億)、ジリオン(何兆億……) から考えて
これかな。
2018年11月かあ。 表紙やタイトルはなんとなく見覚えがあるような気もするんだけど、紙、Kindleその他でも購入記録にないな。
zip code
郵便番号のことをしばしばZIP Codeと呼ぶことがありますが、ZIP Codeは米国の郵政公社USPSが採用している郵便番号の呼称で、郵便番号全般を意味する言葉ではないことに留意する必要があります。モデルの項目名に郵便番号を持つ場面に遭遇したら、どうかzipではなくpostal_codeなどを選んでください
— Moriyoshi Koizumi (@moriyoshit) July 2, 2021
そういやそうか。と思い調べてみると
言語 | 表記 |
---|---|
フランス語 | codes postaux |
スペイン語 | Código Postal |
ドイツ語 | Postleitzahl |
こんな感じ?
なるほどと思いつつも、今度は逆になんでメリケンでZIP Code
って呼んでるのさ?
という疑問が。
The term ZIP is an acronym for Zone Improvement Plan;[1] it was chosen to suggest that the mail travels more efficiently and quickly[2] (zipping along) when senders use the code in the postal address. The term ZIP Code was originally registered as a servicemark by the USPS; its registration expired in 1997.[3]
なるほど。
郵便番号
郵便番号(ゆうびんばんごう、英語圏共通: postal code . アメリカ英語: ZIP code)とは、郵便物の分類に役立てるために、 宛先に加えて記された、数字や文字である[1]。
OpenID
住所とかそのへんの呼び名とかはOpenIDのAddress Claimsに合わせておけば安心。https://t.co/qgKlFBhaw7 https://t.co/KiEeB6LkWb
— かえる (@Flog_kt) July 2, 2021
セミ
まー西日本限定ネタということで。
— @karasugai (@karasugai2001) July 9, 2021
(ネタじゃない)
クマゼミの生息範囲ってじわじわ東進してるんじゃなかったっけ? と調べてみるとなかなか複雑(?)な状況らしい。
断線被害
近年の光回線の普及で、光ファイバーケーブルを枯れ枝と間違えて産卵し断線させるケースが、西日本で数多く報告されている。 NTT西日本の事業エリアでは2005年、2006年共に1,000件近いクマゼミ被害が報告されたという。主に家庭への引き込み線が被害に遭うケースが多く、 2006年からはケーブルの形状を改良しているという。
分布
(略)
近年、関東地方では、生息数を増やしている。京都大学教授・沼田英治の2019年時点の見解によると、 関東での北限は50年前(昭和期に相当)の神奈川県から、東京都内や茨城県へ北上している。その原因として、 気候の温暖化や植樹に伴う卵・幼虫の移動の可能性を推定している[1]。
env
env -
することで既存の環境変数をクリアします。env -
については どさにっき - デーモンさんの起こしかた も参照するとよいでしょう。
というのをみかけ、envってそういう使い方あったのか と追いかけてみた。
使い方は確かに書いてあるけど、envのその機能に対する説明に物足りなさを感じたので さらに検索。まずはopengroup(POSIX)でどう規定しているのかを確認する。
OPTIONS
The env utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
The following options shall be supported:
-i Invoke utility with exactly the environment specified by the arguments; the inherited environment shall be ignored completely.
EXAMPLES
The following command:
env -i PATH=/mybin mygrep xyz myfile
invokes the command mygrep with a new PATH value as the only entry in its environment. In this case, PATH is used to locate mygrep, which then must reside in /mybin.
-i
オプション指定時の動作が今回のそれに近い(同じ)もののように思えるけど
-
のみはなし(当然と言えば当然)。
さらに読み進めるとこんな記述にあたった。
RATIONALE
As with all other utilities that invoke other utilities, this volume of IEEE Std 1003.1-2001 only specifies what env does with standard input, standard output, standard error, input files, and output files. If a utility is executed, it is not constrained by the specification of input and output by env.
The -i option was added to allow the functionality of the withdrawn - option in a manner compatible with the Utility Syntax Guidelines.
なるほどね。
ちなみに SunOS リファレンスマニュアル 1 : ユーザーコマンド env(1) ではこんな感じだった。
形式
/usr/bin/env [-i | -] [name=value]… [utility [arg ..]]
/usr/xpg4/bin/env [-i | -] [name=value]… [utility [arg ..]]
オプション
以下のオプションを指定できます。
-i | –
現在のシェルから引き継いだ環境はすべて無視し、 引数で指定された環境だけを用いて utility を実行します。
さらにenv - Wikipediaから色々手繰る。
外部リンク 公式GNU envマニュアル(英語)
Manpage of ENV
env(1) man page(SunOSリファレンスマニュアル)
env(1) man page(HP-UXリファレンス)
- だけを指定した場合は -i を指定したことになります。 COMMAND が指定されなければ最終的な環境変数を表示します。
‘-’
‘-i’
‘–ignore-environment’Start with an empty environment, ignoring the inherited environment.
WARNING
The - option is obsolete. Use -i instead.
英語版Wikipedia
英語版Wikipedia env - Wikipedia をみると
The version of env bundled in GNU coreutils was written by Richard Mlynarik, David MacKenzie, and Assaf Gordon.[1] It first appeared in 4.4BSD, and is a part of POSIX.1 (with the -i option only).[2]
GNU’s env has been extended to handle signals and the current directory.[1] FreeBSD’s env supports a custom search path. Extensions found in both versions include -u, for unsetting variables, and -S, for splitting arguments (mainly in shebang).[2]
External links をみると、この三つがそろい踏みしていた (それぞれ違いでもあるんだろうか?)。
4.4BSD-Lite2
せっかくなので、オリジナル(に近いところ)の実装はどうだったのかと 4.4BSD-Lite2/env.c at master · sergev/4.4BSD-Lite2 をみると意外に短かった。
extern char **environ;
int
main(argc, argv)
int argc;
char **argv;
{
char **ep, *p;
char *cleanenv[1];
int ch;
while ((ch = getopt(argc, argv, "-")) != EOF)
switch(ch) {
case '-':
environ = cleanenv;
cleanenv[0] = NULL;
break;
case '?':
default:
(void)fprintf(stderr,
"usage: env [-] [name=value ...] [command]\n");
exit(1);
}
for (argv += optind; *argv && (p = strchr(*argv, '=')); ++argv)
(void)setenv(*argv, ++p, 1);
if (*argv) {
execvp(*argv, argv);
err(1, "%s", *argv);
}
for (ep = environ; *ep; ep++)
(void)printf("%s\n", *ep);
exit(0);
}
あれ、getoptってこんな使い方できたっけ? (コードの出自からしてできたのは間違いないのだけど)
getoptの第三引数にはオプション文字を並べるから
(単独の)-
をオプションにするのなら理屈には合うけど
そもそもオプションだと認識するのに-
が必要
(そこはハードコーディングされていた(つまりオプションの開始記号を差し替えたりはできないと思う))
なのでは…?
GNU getopt
ということでGNU getoptのソースコードに当たると コメントにこんな記述。
OPTSTRING is a string containing the legitimate option characters.
If an option character is seen that is not listed in OPTSTRING,
return '?' after printing an error message. If you set `opterr' to
zero, the error message is suppressed but we still return '?'.
If a char in OPTSTRING is followed by a colon, that means it wants an arg,
so the following text in the same ARGV-element, or the text of the following
ARGV-element, is returned in `optarg'. Two colons mean an option that
wants an optional arg; if there is text in the current ARGV-element,
it is returned in `optarg', otherwise `optarg' is set to zero.
If OPTSTRING starts with `-' or `+', it requests different methods of
handling the non-option ARGV-elements.
See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
ふむ。
これはまあGNUでの話なので、BSDではどうだったのよという話でもあり。
getopt.c
- 4.4BSD-Lite2/getopt.3 at 50587b00e922225c62f1706266587f435898126d · sergev/4.4BSD-Lite2
- 4.4BSD-Lite2/getopt.c at master · sergev/4.4BSD-Lite2
- 4.4BSD-Lite2/getopt.c at 50587b00e922225c62f1706266587f435898126d · sergev/4.4BSD-Lite2
- 4.4BSD-Lite2/getopt.c at 50587b00e922225c62f1706266587f435898126d · sergev/4.4BSD-Lite2
つづく(かもしれない)。
glob zsh 3
glob.cのコードを見ていると、関数の定義部分の直前に/**/
というものがついていることに気がついた(ついていない関数もあった)。
また、関数だけではなくファイルスコープやグローバルスコープの変数でも
ついているものがあった。
/**/
int badcshglob;
/**/
int pathpos; /* position in pathbuf (needed by pattern code) */
/*
* pathname buffer (needed by pattern code).
* It is currently believed the string in here is stored metafied and is
* unmetafied temporarily as needed by system calls.
*/
/**/
char *pathbuf;
最初はコメントに書くことがないので開始記号と終了記号だけあるのかと思ったが ひょっとしてなにかのマーカー?
/* Add a component to pathbuf: This keeps track of how *
* far we are into a file name, since each path component *
* must be matched separately. */
/**/
static void
addpath(char *s, int l)
{
この statfullpath は /**/
がついていない。
/* stat the filename s appended to pathbuf. l should be true for lstat, *
* false for stat. If st is NULL, the file is only checked for existence. *
* s == "" is treated as s == ".". This is necessary since on most systems *
* foo/ can be used to reference a non-directory foo. Returns nonzero if *
* the file does not exists. */
static int
statfullpath(const char *s, struct stat *st, int l)
{
そしてこんなものにもついていた。
/**/
#ifdef MULTIBYTE_SUPPORT
/**/
#else
目的(と役割)は一体なんなのだろうか?