GNU sed on AIX (その2)

どこをどう調べていいかわからない。そもそもsedの中身よくわかってない。こんなことしてみた。

diff -ru sed-4.1.5.orig/lib/regex_internal.h sed-4.1.5/lib/regex_internal.h
--- sed-4.1.5.orig/lib/regex_internal.h 2005-12-06 17:50:56.000000000 +0900
+++ sed-4.1.5/lib/regex_internal.h      2007-12-07 22:22:42.000000000 +0900
@@ -425,8 +425,13 @@
 # endif
 #endif

+/* oioi
 #define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t)))
 #define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t)))
+*/
+#define re_malloc(t,n) ((t *) malloc ((n) * sizeof (t))) ; printf("re_malloc " #t ":%d\n",n)
+#define re_realloc(p,t,n) ((t *) realloc (p, (n) * sizeof (t))) ; printf("re_realloc " #t ":%d\n",n)
+
 #define re_free(p) free (p)

 struct bin_tree_t

結果↓

% echo nanika | sed -e 's/^//;'
re_realloc re_dfa_t:1
re_malloc re_token_t:2
re_realloc wint_t:2
re_malloc bin_tree_storage_t:1
re_malloc int:2
re_malloc int:2
re_malloc re_node_set:2
re_malloc re_node_set:2
re_malloc int:0
re_malloc int:1
re_malloc int:2
re_realloc re_token_t:4
re_realloc int:4
re_realloc int:4
re_realloc re_node_set:4
re_realloc re_node_set:4
re_malloc int:1
re_malloc int:1
re_malloc int:2
re_malloc int:2
re_malloc re_node_set:1
re_malloc int:2
re_malloc int:0
sed: -e expression #1, char 6: Memory exhausted

mallocをサイズ0で呼んでいる。でもエラーを起こすのは2回目。これはいったい。

同じのをLinuxでうごかしてみた

% echo nanika | sed/sed  's/^//'
re_realloc re_dfa_t:1
re_malloc re_token_t:2
re_realloc wint_t:2
re_malloc bin_tree_storage_t:1
re_malloc int:2
re_malloc int:2
re_malloc re_node_set:2
re_malloc re_node_set:2
re_malloc int:0
re_malloc int:1
re_malloc int:2
re_realloc re_token_t:4
re_realloc int:4
re_realloc int:4
re_realloc re_node_set:4
re_realloc re_node_set:4
re_malloc int:1
re_malloc int:1
re_malloc int:2
re_malloc int:2
re_malloc re_node_set:1
re_malloc int:2
re_malloc int:0
re_realloc re_dfastate_t *:2
re_malloc int:2
re_malloc re_node_set:1
re_malloc int:2
re_malloc int:0
re_realloc re_dfastate_t *:2
re_malloc int:2
re_malloc re_node_set:1
re_malloc int:2
re_malloc int:2
re_malloc int:2
re_malloc re_node_set:1
re_malloc int:2
re_malloc int:2
re_realloc re_dfastate_t *:6
re_malloc regmatch_t:1
re_malloc struct dests_alloc:1
re_realloc regoff_t:2
re_realloc regoff_t:2
nanika

エラーが出るまで同じだ。限りなくギブアップ。