ときどきの雑記帖 RE* (新南口)
What Good is a Glass Dagger?
tuple
「tuple」をどう読むかという話。
Do you say “too-ple” or “tuh-ple”? : programming
日本語で書かれた書籍(書名は伏せる)で
“tuh-ple” “too-ple”のカタカナ表記が使われたときは
びっくりした覚えが。
本の著者が著者だったので「まーたこの人適当書いて」 と思ったのだけど、 念のため英和辞典で調べたら 二つの読み(発音記号)が書かれていて ここでもう一度びっくり。
True/False
とあるTrueが-1、Falseが0となるプログラミング言語で
pos = hairly_func() + bool_value
という感じのコード
(bool_value
が真偽のいずれかの値をとる)
を書いて
「計算結果が合わねえ」
としばらく悩んでしまった😄
30th
「Ruby」が来年30歳に ~記念イベント開催に向けて特設サイトを公開 - 窓の杜
メモ。
海栗雲丹海胆
今週のナワバリクイズから (ただし実際の問題文とは違う)
以下の三つ、どれも「ウニ」と読むけど一つ仲間はずれがある。それはどれ?
- 海栗
- 雲丹
- 海胆
Misreading Chat
#107: Simple Ideas That Changed Printing and Publishing – Misreading Chat
23分あたりで「リノタイプ」と言ってるけど 「ライノタイプ」の間違いじゃないかなあ。
ライノタイプ (Linotype GmbH) は、ドイツのフォントベンダー。モノタイプ・イメージングの傘下にある。
Mergenthaler Linotype Company - Wikipedia
The Mergenthaler Linotype Company is a corporation founded in the United States in 1886 to market the Linotype machine (/ˈlaɪnəˌtaɪp, -noʊ-/),
修復クラウドファンディング
すぐに目標額に達したらしい。
🚨明日開始🚨
— 機動警察パトレイバー公式 (@patlabor0810) December 25, 2022
実物⼤AV-98 イングラム 修復クラウドファンディングの実施が決定!!
来年2⽉に開催する第⼀回幕張国際レイバーショウinワンフェス会場でのデッキアップイベントを⽬標にファンの皆さまに⽀援を頂き、修復作業を実施致します。
▼12/26〜プロジェクトスタートhttps://t.co/uT4Ut7Ryyb pic.twitter.com/32GsyQTWeV
三回くらい(それぞれ別の場所で)見たかな>デッキアップ
休刊
イブニング休刊のお知らせ|イブニング公式サイト - 講談社の青年漫画誌
あら。 イブニングも一時期買っていたのだけど、いつごろ止めたんだっけか。 と言いつつモーニングも あまり好きではない作品が(不定期連載ではあるけど)続いている一方で 楽しみに読んでた作品が打ち切りだったり Dモーニング行きになってたりで どうしたものかと思っていたりする。
typedef
GNU grep
ふと気が向いてGNU grepのメーリングリストを覗いてみたら いくつか興味深いものに遭遇した。
その1
- bug#36148: Debian Bug#930247: grep: does not handle backreferences corre
- bug#36148: Debian Bug#930247: grep: does not handle backreferences corre
- patch
パターンを複数与えていて、かつ後方参照を使っていると… というバグらしい。
修正差分
From b061d24916fb9a14da37a3f2a05cb80dc65cfd38 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Mon, 5 Dec 2022 14:16:45 -0800
Subject: [PATCH] grep: bug: backref in last of multiple patterns
* NEWS: Mention this.
* src/dfasearch.c (GEAcompile): Trim trailing newline from
the last pattern, even if it has back-references and follows
a pattern that lacks back-references.
* tests/backref: Add test for this bug.
---
NEWS | 6 ++++++
src/dfasearch.c | 25 ++++++++++++-------------
tests/backref | 8 ++++++++
3 files changed, 26 insertions(+), 13 deletions(-)
diff --git a/NEWS b/NEWS
index da293a3..6c00b2b 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,12 @@ GNU grep NEWS -*- outline -*-
* Noteworthy changes in release ?.? (????-??-??) [?]
+** Bug fixes
+
+ When given multiple patterns the last of which has a back-reference,
+ grep no longer sometimes mistakenly matches lines in some cases.
+ [Bug#36148#13 introduced in grep 3.4]
+
* Noteworthy changes in release 3.8 (2022-09-02) [stable]
diff --git a/src/dfasearch.c b/src/dfasearch.c
index a71902a..a5b0d90 100644
--- a/src/dfasearch.c
+++ b/src/dfasearch.c
@@ -281,20 +281,19 @@ GEAcompile (char *pattern, idx_t size, reg_syntax_t syntax_bits,
if (compilation_failed)
exit (EXIT_TROUBLE);
- if (prev <= patlim)
+ if (patlim < prev)
+ buflen--;
+ else if (pattern < prev)
{
- if (pattern < prev)
- {
- idx_t prevlen = patlim - prev;
- buf = xirealloc (buf, buflen + prevlen);
- memcpy (buf + buflen, prev, prevlen);
- buflen += prevlen;
- }
- else
- {
- buf = pattern;
- buflen = size;
- }
+ idx_t prevlen = patlim - prev;
+ buf = xirealloc (buf, buflen + prevlen);
+ memcpy (buf + buflen, prev, prevlen);
+ buflen += prevlen;
+ }
+ else
+ {
+ buf = pattern;
+ buflen = size;
}
/* In the match_words and match_lines cases, we use a different pattern
diff --git a/tests/backref b/tests/backref
index 510e130..97cb157 100755
--- a/tests/backref
+++ b/tests/backref
@@ -43,4 +43,12 @@ if test $? -ne 2 ; then
failures=1
fi
+# https://bugs.gnu.org/36148#13
+echo 'Total failed: 2 (1 ignored)' |
+ grep -e '^Total failed: 0$' -e '^Total failed: \([0-9]*\) (\1 ignored)$'
+if test $? -ne 1 ; then
+ echo "Backref: Multiple -e test, test #5 failed"
+ failures=1
+fi
+
Exit $failures
--
2.38.1
その2
bug#60038: grep 2.20 - invalid option with search pattern “-/”
Hello,
When searching for a pattern that includes “-/”, the pattern is interpreted as option:
[dsg@db01]# grep "-" example.txt --/-- [dsg@db01]# grep "/" example.txt --/-- [dsg@db01]# grep "-/" example.txt grep: invalid option -- '/' Usage: grep [OPTION]... PATTERN [FILE]... Try 'grep --help' for more information.
これは-
で始まるパターンで検索しようとして
それがオプション指定と解釈されてしまった
というありがち(?)なケース。
バックスラッシュでエスケープというパターンもあれば完ぺきだったのに(謎)。
ということで-e
オプションを使いましょう。
shift operators
「右シフト」じゃなくて「左シフト」? と思ったが、そうか整数の内部表現が2の補数とは限らないからか。 とすると、2の補数であることが求められるようになった最新のC++では? それとJavaとか。
WG14/N1256 Septermber 7, 2007 ISO/IEC 9899:TC3 のSemanticsを見ると
3 The integer promotions are performed on each of the operands. The type of the result is that of the promoted left operand. If the value of the right operand is negative or is greater than or equal to the width of the promoted left operand, the behavior is undefined.
4 The result of E1 « E2 is E1 left-shifted E2 bit positions; vacated bits are filled with zeros. If E1 has an unsigned type, the value of the result is E1 x 2E2 , reduced modulo one more than the maximum value representable in the result type. If E1 has a signed type and nonnegative value, and E1 x 2E2 is representable in the result type, then that is the resulting value; otherwise, the behavior is undefined.
5 The result of E1 » E2 is E1 right-shifted E2 bit positions. If E1 has an unsigned type or if E1 has a signed type and a nonnegative value, the value of the result is the integral part of the quotient of E1 / 2E2 . If E1 has a signed type and a negative value, the resulting value is implementation-defined.
左シフトが
If E1 has a signed type (略) the behavior is undefined.
なのに対して、
右シフトは
If E1 has a signed type (略) the resulting value is implementation-defined.
なんですな。
なるほど。
Java
ということでJavaも見ておく。
The value of n « s is n left-shifted s bit positions; this is equivalent (even if overflow occurs) to multiplication by two to the power s.
The value of n » s is n right-shifted s bit positions with sign-extension. The resulting value is floor(n / 2s). For non-negative values of n, this is equivalent to truncating integer division, as computed by the integer division operator /, by two to the power s.
The value of n »> s is n right-shifted s bit positions with zero-extension, where:
- If n is positive, then the result is the same as that of n » s.
- If n is negative and the type of the left-hand operand is int, then the result is equal to that of the expression (n » s) + (2 « ~s).
- If n is negative and the type of the left-hand operand is long, then the result is equal to that of the expression (n » s) + (2L « ~s).
ふむ。 そういやJavaには三つ目のシフト演算子があったのだっけ。
Y2K
Excelに「23/1/1」と入力すると「2023/1/1」に変換してくれます。
— 筒井.xls@Excel関数擬人化マンガを描く経理 (@Tsutsui0524) December 26, 2022
「97/1/1」だと「1997/1/1」に…これは便利。
では、20世紀と21世紀の境目はどこなのか??
「29」は「2029」に、「30」は「1930」に変換されます。
つまり2030年の日付を入力する際は省略せず「2030」と入力しないといけない。
これって2000年問題対応で入った奴じゃね? と2000年問題 - Wikipedia を見ると
2000年問題への対応として、年の内部表現が十進2桁のまま、ある数値までは20XX年とすることで1900年以降のある年から 100年間を表せるようにするdate windowがあるが、UNIXエポックの1970年1月1日±50年である1920 - 2019年をwindowとしたシステムが多く、 2020年の到来により誤動作を起こしている[6][7]。
KDDI/auのフィーチャーフォンのうちKCPを採用しているモデルにて、2020年になると同時に表示が"0/0(SUN)0:00"となり時計が機能しなくなる。 発売当時から2019年までという仕様だったことが指摘されている[8]。
ああ、なんか聞き覚えが>フィーチャーフォンの不具合
それはさておき、さらに英語版うぃきぺの Year 2000 problem - Wikipedia から
Date windowing - Wikipedia を見るとExcelの事例があった。
Examples
Unix and Windows systems have environment variables that set the fixed pivot year for the system. Any year after the pivot year will belong to this century (the 21st century), and any year before or equal to the pivot year will belong to last century (the 20th century).[6]
Some products, such as Microsoft Excel 95 used a window of years 1920–2019 which had the potential to encounter a windowing bug reoccurring only 20 years after the year 2000 problem had been addressed.[7]
The IBM i operating system uses a window of 1940-2039 for date formats with a two-digit year.[8] In the 7.5 release of the operating system, an option was added to use a window of 1970-2069 instead.[9]
上記の引用部分ではウィンドウが1920年から2019年となっているけれども、 他を調べるとそれはExcel 95だけでExcel 97以降で変わっているらしい。
http://innovision.sushilfinance.com/Modules/Files/Watch%20Out/PDF/30Mar2013144423_y2kexcel.pdf
Understanding Dates in Excel 97, 98, 2000
Did You Know…
- If you type 00 through 29 for the year, it is entered as 2000 through 2029 .
- If you type 30 through 99 for the year, it is entered as 1930 through 1999.
Dates in Excel 95 and Earlier
Did You Know…
- If you type 00 through 19 for the year, it is entered as 2000 through 2019
- If you type 20 through 99 for the year, it is entered as 1920 through 1999. It is important to note that the cutoff year is 19 in Excel 95 and earlier, and not 29 as it is in Excel 97, 98 and 2000.
Microsoftのサイトからも
Excel works with two-digit year numbers - Office | Microsoft Learn
The 2029 Rule
By default, Excel determines the century by using a cutoff year of 2029, which results in the following behavior:
Dates in the inclusive range from January 1, 1900 (1/1/1900) to December 31, 9999 (12/31/9999) are valid.
When you type a date that uses a two-digit year, Excel uses the following centuries:
Two-digit year typed Century used 00-29 21st (year 2000) 30-99 20th (year 1900)
ところで今の若い人に「2000年問題対応」と言って 話がどのくらい通じるんだろうか?🤔
E2BIG
[Q&A] xargsコマンドの引数分割のおかしな挙動についての質問 - Qiita
すでに解決してるけどChangeLogからE2BIGを探すとこんなのがある。
* ChangeLog, NEWS, lib/buildcmd.c,
xargs/testsuite/inputs/16383-ys.xi,
xargs/testsuite/inputs/32767-ys.xi,
xargs/testsuite/xargs.posix/arg_max_32bit_linux_bug.exp,
xargs/testsuite/xargs.posix/arg_max_32bit_linux_bug.xo,
xargs/testsuite/xargs.posix/arg_max_64bit_linux_bug.exp,
xargs/testsuite/xargs.posix/arg_max_64bit_linux_bug.xo: Applied
bugfix from Jim Meyering (tiny change), where many short arguments
would cause xargs (and probably find -exec .. {} +) to fail
because execve() returns E2BIG, which we should avoid
まさにそのままですな>where many short arguments
さらに調べると該当の修正はこれだろうか
- [PATCH] Fix Savannah bug#27328, segfault if the initial exec for “find -
- findutils - Bugs: bug #27328, find-4.5.5 -exec + segfaults in… [Savannah]
E2BIGではこんなのも見つかった
FORTRAN Compiler on IBM 704
一回休み。
2022 → 2023
ということで2022年分もたぶんこれで終わり。 予定では28日に一つ上げて31日にもう一つ。 とも考えていたのだけど、 よんどころない理由により 28日に上げそこなったので以下略。
良いお年を。