• R/O
  • SSH
  • HTTPS

molby: Commit


Commit MetaInfo

Revision599 (tree)
Time2016-05-10 00:30:30
Authortoshinagata1964

Log Message

Encoding exception was caused while reading a file created on another platform. Hopefully fixed...

Change Summary

Incremental Difference

--- trunk/MolLib/Ruby_bind/ruby_bind.c (revision 598)
+++ trunk/MolLib/Ruby_bind/ruby_bind.c (revision 599)
@@ -1041,6 +1041,13 @@
10411041
10421042 #pragma mark ====== IO extension ======
10431043
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+
10441051 /*
10451052 * call-seq:
10461053 * gets_any_eol
@@ -1050,9 +1057,9 @@
10501057 static VALUE
10511058 s_IO_gets_any_eol(VALUE self)
10521059 {
1053- VALUE val, cval;
1060+ VALUE val, val2, cval;
10541061 char buf[1024];
1055- int i, c;
1062+ int i, c, status;
10561063 static ID id_getbyte = 0, id_ungetbyte;
10571064 if (id_getbyte == 0) {
10581065 id_getbyte = rb_intern("getbyte");
@@ -1089,7 +1096,9 @@
10891096 val = rb_str_new(buf, i);
10901097 else if (i > 0)
10911098 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;
10931102 if (cval != Qnil) {
10941103 /* Needs a end-of-line mark */
10951104 cval = rb_gv_get("$/");
--- trunk/wxSources/MyApp.cpp (revision 598)
+++ trunk/wxSources/MyApp.cpp (revision 599)
@@ -1340,9 +1340,9 @@
13401340 int nn = 0;
13411341 {
13421342 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);
13441344 free(dochome);
1345- fplog = fopen(buf, "w");
1345+ fplog = fopen(buf, "a");
13461346 if (fplog == NULL)
13471347 return -1;
13481348 }
Show on old repository browser