[ruby-list:599] Re: NSUG ruby shoukai
From:
WATANABE Hirofumi <watanabe@...>
Date:
1996-09-26 06:41:35 UTC
List:
ruby-list #599
渡辺@ソニーです.
原さん:
:それから、BOW でもコンパイル出来ました。(Perl5 はだ
:めだったのに。)
とりあえず -i.bak に対する quick hack です. perl の真似. :-)
--
わたなべひろふみ
--- io.c.org Wed Sep 25 00:05:28 1996
+++ io.c Wed Sep 25 00:05:28 1996
@@ -1028,25 +1028,40 @@
#else
str_cat(str, inplace, strlen(inplace));
#endif
+#if defined(DOSISH) || defined(__BOW__)
+ (void)fclose(fr);
+ (void)unlink(RSTRING(str)->ptr);
+ (void)rename(fn, RSTRING(str)->ptr);
+ fr = rb_fopen(RSTRING(str)->ptr, "r");
+#else
if (rename(fn, RSTRING(str)->ptr) < 0) {
Warning("Can't rename %s to %s: %s, skipping file",
fn, RSTRING(str)->ptr, strerror(errno));
fclose(fr);
goto retry;
}
+#endif
}
- else if (unlink(fn) < 0) {
- Warning("Can't remove %s: %s, skipping file",
+ else {
+#if !defined(DOSISH) && !defined(__BOW__)
+ if (unlink(fn) < 0) {
+ Warning("Can't remove %s: %s, skipping file",
fn, strerror(errno));
- fclose(fr);
- goto retry;
+ fclose(fr);
+ goto retry;
+ }
+#else
+ Fatal("Can't do inplace edit without backup");
+#endif
}
fw = rb_fopen(fn, "w");
+#ifndef DJGPP
fstat(fileno(fw), &st2);
fchmod(fileno(fw), st.st_mode);
if (st.st_uid!=st2.st_uid || st.st_gid!=st2.st_gid) {
fchown(fileno(fw), st.st_uid, st.st_gid);
}
+#endif
rb_defout = prep_stdio(fw, FMODE_WRITABLE);
}
file = prep_stdio(fr, FMODE_READABLE);