またの名を作業記録かも? 今年も、あと「 」日くらい。 アナログは、あと「 」日使えます!
March 2009 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
勝ってよかったでーす。
arton さんから Ruby 会議について素敵な提案がありました。 人前で話すのが苦手な私はお断りしてしまうのでした。 人前で話すことができたらどんなにいいかな。
素敵な内容なので当日の arton さんの発表に注目です!
Ruby でも使える PDF を生成するためのライブラリ。 Ruby trunk 1.9.2dev で使うためには if/ruby/hpdf.c を修正する必要があります。
--- hpdf.c.org 2008-05-28 03:23:31.000000000 +0900
+++ hpdf.c 2009-03-18 00:38:37.000000000 +0900
@@ -16,7 +16,8 @@
*/
#include "ruby.h"
-#include "rubyio.h"
+#include "ruby/io.h"
+/* #include "rubyio.h" */
#include "hpdf.h"
#include "hpdf_conf.h"
@@ -144,7 +145,7 @@
HPDF_PTRACE(("hpdf_save_to_file pdf=%p\n", pdf));
- ret = HPDF_SaveToFile(pdf, STR2CSTR(file_name));
+ ret = HPDF_SaveToFile(pdf, RSTRING_PTR(file_name));
return INT2NUM(ret);
}
@@ -457,12 +458,12 @@
const char *s1;
const char *s2;
- s1 = STR2CSTR(font_name);
+ s1 = RSTRING_PTR(font_name);
if (encoding_name == Qnil)
s2 = NULL;
else {
- s2 = STR2CSTR(encoding_name);
+ s2 = RSTRING_PTR(encoding_name);
if (HPDF_StrLen(s2, -1) == 0)
s2 = NULL;
@@ -485,8 +486,8 @@
const char *s1;
const char *s2;
- s1 = STR2CSTR(afm);
- s2 = STR2CSTR(pfa);
+ s1 = RSTRING_PTR(afm);
+ s2 = RSTRING_PTR(pfa);
if (HPDF_StrLen(s2, -1) == 0)
s2 = NULL;
@@ -508,7 +509,7 @@
const char *s;
HPDF_INT i;
- s = STR2CSTR(file_name);
+ s = RSTRING_PTR(file_name);
i = NUM2INT(embedding);
Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
@@ -529,7 +530,7 @@
HPDF_INT i1;
HPDF_INT i2;
- s = STR2CSTR(file_name);
+ s = RSTRING_PTR(file_name);
i1 = NUM2INT(index);
i2 = NUM2INT(embedding);
@@ -555,7 +556,7 @@
i1 = NUM2INT(page_num);
i2 = NUM2INT(style);
i3 = NUM2INT(first_page);
- s = STR2CSTR(prefix);
+ s = RSTRING_PTR(prefix);
Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
@@ -642,7 +643,7 @@
if (HPDF_StrCmp(rb_obj_classname(encoder), "HPDFEncoder") == 0)
Data_Get_Struct(encoder, HPDF_Encoder_Rec, e);
- s = STR2CSTR(title);
+ s = RSTRING_PTR(title);
Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
@@ -857,7 +858,7 @@
HPDF_Doc pdf;
const char *s1;
- s1 = STR2CSTR(encoding_name);
+ s1 = RSTRING_PTR(encoding_name);
Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
HPDF_PTRACE(("hpdf_get_encoder pdf=%p\n", pdf));
@@ -889,7 +890,7 @@
HPDF_STATUS ret;
const char *s1;
- s1 = STR2CSTR(encoding_name);
+ s1 = RSTRING_PTR(encoding_name);
Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
HPDF_PTRACE(("hpdf_set_current_encoder pdf=%p\n", pdf));
@@ -922,7 +923,7 @@
HPDF_INT i;
HPDF_STATUS ret;
- s = STR2CSTR(text);
+ s = RSTRING_PTR(text);
i = NUM2INT(index);
Data_Get_Struct(obj, HPDF_Encoder_Rec, encoder);
@@ -1039,7 +1040,7 @@
if (HPDF_StrCmp(rb_obj_classname(encoder), "HPDFEncoder") == 0)
Data_Get_Struct(encoder, HPDF_Encoder_Rec, e);
- s = STR2CSTR(text);
+ s = RSTRING_PTR(text);
Data_Get_Struct(obj, HPDF_Dict_Rec, page);
rect.left = NUM2INT(left);
rect.bottom = NUM2INT(bottom);
@@ -1086,7 +1087,7 @@
const char *s;
HPDF_Annotation annot;
- s = STR2CSTR(uri);
+ s = RSTRING_PTR(uri);
Data_Get_Struct(obj, HPDF_Dict_Rec, page);
rect.left = NUM2INT(left);
rect.bottom = NUM2INT(bottom);
@@ -1179,7 +1180,7 @@
HPDF_Image image;
const char *s;
- s = STR2CSTR(file_name);
+ s = RSTRING_PTR(file_name);
Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
HPDF_PTRACE(("hpdf_load_png_image_from_file pdf=%p\n", pdf));
@@ -1197,7 +1198,7 @@
HPDF_Image image;
const char *s;
- s = STR2CSTR(file_name);
+ s = RSTRING_PTR(file_name);
Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
HPDF_PTRACE(("hpdf_load_png_image_from_file pdf=%p\n", pdf));
@@ -1350,7 +1351,7 @@
HPDF_STATUS ret;
i = NUM2INT(type);
- s = STR2CSTR(value);
+ s = RSTRING_PTR(value);
Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
HPDF_PTRACE(("hpdf_set_info_attr pdf=%p\n", pdf));
@@ -1387,8 +1388,8 @@
HPDF_STATUS ret;
Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
- s = STR2CSTR(ind);
- if (HPDF_StrLen(s, -1) != 1 || s[0] != '+' || s[0] != '-' || s[0] != 'Z')
+ s = RSTRING_PTR(ind);
+ if (HPDF_StrLen(s, -1) != 1 || (s[0] != '+' && s[0] != '-' && s[0] != 'Z' && s[0] != ' '))
rb_raise(rb_eHPDFError, "The eighth argument must be either of '+','-','Z',' '.");
tp = NUM2INT(type);
@@ -1418,8 +1419,8 @@
HPDF_STATUS ret;
Data_Get_Struct(obj, HPDF_Doc_Rec, pdf);
- s1 = STR2CSTR(owner_passwd);
- s2 = STR2CSTR(user_passwd);
+ s1 = RSTRING_PTR(owner_passwd);
+ s2 = RSTRING_PTR(user_passwd);
HPDF_PTRACE(("hpdf_set_password pdf=%p\n", pdf));
@@ -1490,7 +1491,7 @@
const char *s;
Data_Get_Struct(obj, HPDF_Dict_Rec, page);
- s = STR2CSTR(text);
+ s = RSTRING_PTR(text);
HPDF_PTRACE(("hpdf_page_text_width page=%p\n", page));
@@ -1509,7 +1510,7 @@
HPDF_INT ret;
Data_Get_Struct(obj, HPDF_Dict_Rec, page);
- s = STR2CSTR(text);
+ s = RSTRING_PTR(text);
i1 = NUM2INT(width);
i2 = NUM2INT(wordwrap);
@@ -2401,7 +2402,7 @@
HPDF_PTRACE(("hpdf_page_set_dash page=%p\n", page));
dash_phase = NUM2INT(phase);
- num_ptn = RARRAY(ptn)->len;
+ num_ptn = RARRAY_LEN(ptn);
if (!num_ptn) {
ret = HPDF_Page_SetDash(page, NULL, 0, 0);
return INT2NUM(ret);
@@ -2410,7 +2411,7 @@
for (i = 0; i < 8; i++)
dash_ptn[i] = 0;
- pptn = RARRAY(ptn)->ptr;
+ pptn = RARRAY_PTR(ptn);
for (i = 0; i < num_ptn; i++) {
dash_ptn[i] = NUM2INT(*pptn);
@@ -3072,7 +3073,7 @@
const char *s;
Data_Get_Struct(obj, HPDF_Dict_Rec, page);
- s = STR2CSTR(text);
+ s = RSTRING_PTR(text);
HPDF_PTRACE(("hpdf_page_show_text page=%p\n", page));
@@ -3089,7 +3090,7 @@
const char *s;
Data_Get_Struct(obj, HPDF_Dict_Rec, page);
- s = STR2CSTR(text);
+ s = RSTRING_PTR(text);
HPDF_PTRACE(("hpdf_page_show_text_next_line page=%p\n", page));
@@ -3108,7 +3109,7 @@
HPDF_REAL f2;
Data_Get_Struct(obj, HPDF_Dict_Rec, page);
- s = STR2CSTR(text);
+ s = RSTRING_PTR(text);
f1 = NUM2DBL(char_space);
f2 = NUM2DBL(word_space);
@@ -3369,7 +3370,7 @@
HPDF_REAL y;
Data_Get_Struct(obj, HPDF_Dict_Rec, page);
- s = STR2CSTR(text);
+ s = RSTRING_PTR(text);
x = NUM2DBL(xpos);
y = NUM2DBL(ypos);
@@ -3394,7 +3395,7 @@
HPDF_UINT i1;
Data_Get_Struct(obj, HPDF_Dict_Rec, page);
- s = STR2CSTR(text);
+ s = RSTRING_PTR(text);
f1 = NUM2DBL(left);
f2 = NUM2DBL(top);
f3 = NUM2DBL(right);
これと大きなフォントを使うために include/hpdf_consts.h を修正します。
--- hpdf_consts.h.org 2008-05-28 03:23:31.000000000 +0900 +++ hpdf_consts.h 2009-03-18 00:46:44.000000000 +0900 @@ -138,10 +138,10 @@ #define HPDF_MIN_HORIZONTALSCALING 10 #define HPDF_MAX_HORIZONTALSCALING 300 #define HPDF_MIN_WORDSPACE -30 -#define HPDF_MAX_WORDSPACE 300 +#define HPDF_MAX_WORDSPACE 600 #define HPDF_MIN_CHARSPACE -30 -#define HPDF_MAX_CHARSPACE 300 -#define HPDF_MAX_FONTSIZE 300 +#define HPDF_MAX_CHARSPACE 600 +#define HPDF_MAX_FONTSIZE 600 #define HPDF_MAX_ZOOMSIZE 10 #define HPDF_MAX_LEADING 300 #define HPDF_MAX_LINEWIDTH 100
これを使うと PDF のインタプリタというか、テキストに命令書いて PDF 生成できそうなんですよね。 マークアップ言語的な使い方とかできるようにしたいなと思いつつ、保留中。 これができるとテンプレート用のテキストと、はめ込み用テキストを用意して定型書式の PDF を作成したりできそう。
#605 test_thread.rb:219:in `<top (required)>':
open("zzz.rb", "w") do |f|
f.puts <<-END
begin
Thread.new { fork { GC.start } }.join
pid, status = Process.wait2
$result = status.success? ? :ok : :ng
rescue NotImplementedError
$result = :ok
end
END
end
require "zzz.rb"
$result
#=> "" (expected "ok")
#608 test_thread.rb:254:in `<top (required)>':
STDERR.reopen(STDOUT)
exec "/"
#=> killed by signal 32
FAIL 2/935 tests failed
core してますです。
./miniruby -I./lib -I.ext/common -I./- -r./ext/purelib.rb "./tool/transcode-tblgen.rb" -vo "enc/trans/big5.c" "enc/trans/big5.trans" /t1/src/ruby/1.9/trunk/lib/optparse.rb:1626: [BUG] Segmentation fault ruby 1.9.2dev (2009-03-14 trunk 22957) [i686-linux] -- control frame ---------- c:0020 p:---- s:0096 b:0096 l:000095 d:000095 CFUNC :=~ c:0019 p:---- s:0094 b:0094 l:001270 d:000093 IFUNC :lambda c:0018 p:---- s:0092 b:0092 l:000091 d:000091 CFUNC :delete_if c:0017 p:0055 s:0089 b:0089 l:000088 d:000088 METHOD /t1/src/ruby/1.9/trunk/lib/optparse.rb:1626 c:0016 p:0021 s:0085 b:0084 l:000083 d:000083 METHOD /t1/src/ruby/1.9/trunk/lib/optparse.rb:1632 c:0015 p:---- s:0080 b:0080 l:000079 d:000079 FINISH c:0014 p:0043 s:0078 b:0078 l:000374 d:00055c BLOCK /t1/src/ruby/1.9/trunk/lib/optparse.rb:1459 c:0013 p:---- s:0076 b:0076 l:000075 d:000075 FINISH c:0012 p:---- s:0074 b:0074 l:000073 d:000073 CFUNC :catch c:0011 p:0051 s:0070 b:0068 l:000374 d:000374 METHOD /t1/src/ruby/1.9/trunk/lib/optparse.rb:1457 c:0010 p:0263 s:0061 b:0061 l:000048 d:000060 BLOCK /t1/src/ruby/1.9/trunk/lib/optparse.rb:1290 c:0009 p:---- s:0055 b:0055 l:000054 d:000054 FINISH c:0008 p:---- s:0053 b:0053 l:000052 d:000052 CFUNC :catch c:0007 p:0062 s:0049 b:0049 l:000048 d:000048 METHOD /t1/src/ruby/1.9/trunk/lib/optparse.rb:1264 c:0006 p:0024 s:0039 b:0039 l:000038 d:000038 METHOD /t1/src/ruby/1.9/trunk/lib/optparse.rb:1258 c:0005 p:0038 s:0034 b:0034 l:000033 d:000033 METHOD /t1/src/ruby/1.9/trunk/lib/optparse.rb:1349 c:0004 p:0054 s:0029 b:0029 l:000028 d:000028 METHOD /t1/src/ruby/1.9/trunk/lib/optparse.rb:1370 c:0003 p:0723 s:0025 b:0025 l:000bbc d:001d90 EVAL ./tool/transcode-tblgen.rb:767 c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH c:0001 p:0000 s:0002 b:0002 l:000bbc d:000bbc TOP <main>:17 ---------------------------
#605 test_thread.rb:219:in `<top (required)>':
open("zzz.rb", "w") do |f|
f.puts <<-END
begin
Thread.new { fork { GC.start } }.join
pid, status = Process.wait2
$result = status.success? ? :ok : :ng
rescue NotImplementedError
$result = :ok
end
END
end
require "zzz.rb"
$result
#=> "" (expected "ok")
#608 test_thread.rb:254:in `<top (required)>':
STDERR.reopen(STDOUT)
exec "/"
#=> killed by signal 32
FAIL 2/935 tests failed
sample/test.rb:gc ....not ok bignum 26 -- ./sample/test.rb:1508:in `<main>' not ok bignum 27 -- ./sample/test.rb:1509:in `<main>' not ok/test: 900 failed 2 test failed
#605 test_thread.rb:219:in `<top (required)>':
open("zzz.rb", "w") do |f|
f.puts <<-END
begin
Thread.new { fork { GC.start } }.join
pid, status = Process.wait2
$result = status.success? ? :ok : :ng
rescue NotImplementedError
$result = :ok
end
END
end
require "zzz.rb"
$result
#=> "" (expected "ok")
#608 test_thread.rb:254:in `<top (required)>':
STDERR.reopen(STDOUT)
exec "/"
#=> killed by signal 32
FAIL 2/935 tests failed
#605 test_thread.rb:219:in `<top (required)>':
open("zzz.rb", "w") do |f|
f.puts <<-END
begin
Thread.new { fork { GC.start } }.join
pid, status = Process.wait2
$result = status.success? ? :ok : :ng
rescue NotImplementedError
$result = :ok
end
END
end
require "zzz.rb"
$result
#=> "" (expected "ok")
#608 test_thread.rb:254:in `<top (required)>':
STDERR.reopen(STDOUT)
exec "/"
#=> killed by signal 32
FAIL 2/935 tests failed
昨日の深夜コンパイルしたのですが、コンパイルエラーで止まります。 今朝もそのままみたいなのですが、エラーが起きるのは私のところだけなのかな? 最近差分ではなくて、全部最初からコンパイルしています。
いつもの二つになりました。
#605 test_thread.rb:219:in `<top (required)>':
open("zzz.rb", "w") do |f|
f.puts <<-END
begin
Thread.new { fork { GC.start } }.join
pid, status = Process.wait2
$result = status.success? ? :ok : :ng
rescue NotImplementedError
$result = :ok
end
END
end
require "zzz.rb"
$result
#=> "" (expected "ok")
#608 test_thread.rb:254:in `<top (required)>':
STDERR.reopen(STDOUT)
exec "/"
#=> killed by signal 32
FAIL 2/935 tests failed
すばらしいですねー
#605 test_thread.rb:219:in `<top (required)>':
open("zzz.rb", "w") do |f|
f.puts <<-END
begin
Thread.new { fork { GC.start } }.join
pid, status = Process.wait2
$result = status.success? ? :ok : :ng
rescue NotImplementedError
$result = :ok
end
END
end
require "zzz.rb"
$result
#=> "" (expected "ok")
#608 test_thread.rb:254:in `<top (required)>':
STDERR.reopen(STDOUT)
exec "/"
#=> killed by signal 32
FAIL 2/935 tests failed