Revision | 599 (tree) |
---|---|
Time | 2016-05-10 00:30:30 |
Author | toshinagata1964 |
Encoding exception was caused while reading a file created on another platform. Hopefully fixed...
@@ -1041,6 +1041,13 @@ | ||
1041 | 1041 | |
1042 | 1042 | #pragma mark ====== IO extension ====== |
1043 | 1043 | |
1044 | +static VALUE | |
1045 | +s_Ruby_str_encode_protected(VALUE val) | |
1046 | +{ | |
1047 | + return rb_str_encode(val, rb_enc_from_encoding(rb_default_external_encoding()), | |
1048 | + ECONV_INVALID_REPLACE | ECONV_UNDEF_REPLACE, Qnil); | |
1049 | +} | |
1050 | + | |
1044 | 1051 | /* |
1045 | 1052 | * call-seq: |
1046 | 1053 | * gets_any_eol |
@@ -1050,9 +1057,9 @@ | ||
1050 | 1057 | static VALUE |
1051 | 1058 | s_IO_gets_any_eol(VALUE self) |
1052 | 1059 | { |
1053 | - VALUE val, cval; | |
1060 | + VALUE val, val2, cval; | |
1054 | 1061 | char buf[1024]; |
1055 | - int i, c; | |
1062 | + int i, c, status; | |
1056 | 1063 | static ID id_getbyte = 0, id_ungetbyte; |
1057 | 1064 | if (id_getbyte == 0) { |
1058 | 1065 | id_getbyte = rb_intern("getbyte"); |
@@ -1089,7 +1096,9 @@ | ||
1089 | 1096 | val = rb_str_new(buf, i); |
1090 | 1097 | else if (i > 0) |
1091 | 1098 | rb_str_append(val, rb_str_new(buf, i)); |
1092 | - val = rb_str_encode(val, rb_enc_from_encoding(rb_default_external_encoding()), 0, Qnil); | |
1099 | + val2 = rb_protect(s_Ruby_str_encode_protected, val, &status); /* Ignore exception */ | |
1100 | + if (status == 0) | |
1101 | + val = val2; | |
1093 | 1102 | if (cval != Qnil) { |
1094 | 1103 | /* Needs a end-of-line mark */ |
1095 | 1104 | cval = rb_gv_get("$/"); |
@@ -1340,9 +1340,9 @@ | ||
1340 | 1340 | int nn = 0; |
1341 | 1341 | { |
1342 | 1342 | char *dochome = MyAppCallback_getDocumentHomeDir(); |
1343 | - snprintf(buf, sizeof buf, "%s/%s.log", dochome, (procname ? procname : "subprocess")); | |
1343 | + snprintf(buf, sizeof buf, "%s/molby_subprocess.log", dochome); | |
1344 | 1344 | free(dochome); |
1345 | - fplog = fopen(buf, "w"); | |
1345 | + fplog = fopen(buf, "a"); | |
1346 | 1346 | if (fplog == NULL) |
1347 | 1347 | return -1; |
1348 | 1348 | } |