summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorYukihiro Matsumoto <matz@ruby-lang.org>1995-04-03 15:19:41 +0900
committerTakashi Kokubun <takashikkbn@gmail.com>2019-08-17 22:09:32 +0900
commit4e65eab7abf53838579600e3dcc99a43012c45c2 (patch)
tree0938fcd2882eca4965a218bbb0c48f25d068a783 /io.c
parentd349889e770a2078c247d9d28070e86a54b856f4 (diff)
version 0.71v0_71
https://cache.ruby-lang.org/pub/ruby/1.0/ruby-0.71.tar.gz Mon Apr 3 15:19:41 1995 Yukihiro Matsumoto (matz@ix-02) * regexp.c(re_match): バグがあった.match_2を削除した時にenbugして いたのだった. Mon Mar 27 15:41:43 1995 Yukihiro Matsumoto (matz@ix-02) * dict.c: Dict->Hashに全面的に移行. Thu Mar 23 20:30:00 1995 Yukihiro Matsumoto (matz@ix-02) * dbm.c,socket.c: extディレクトリに分離. * configure: dln周りのチェックの強化 * dln.c: initの呼び出しをdlopen()版に合わせた. Mon Mar 20 17:45:08 1995 Yukihiro Matsumoto (matz@ix-02) * configure: autoconf 2.2に対応(一部). Fri Mar 17 15:56:44 1995 Yukihiro Matsumoto (matz@ix-02) * dln.c: dlopenのあるマシンではそちらを使うように.ただし,ちゃん と動いているかどうかは自信がない. * regex.c: virtual concatinationをやめた. Thu Mar 16 11:32:57 1995 Yukihiro Matsumoto (matz@ix-02) * version 0.70 * eval.c,regex.c: gccでのコンパイルエラー. * io.c: inplace-editで拡張子が指定されない場合,もとのファイルを削 除する.
Diffstat (limited to 'io.c')
-rw-r--r--io.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/io.c b/io.c
index 583353c609..8b7fb21542 100644
--- a/io.c
+++ b/io.c
@@ -816,18 +816,23 @@ next_argv()
VALUE str;
FILE *fw;
- if (!*inplace) {
- Fatal("Can't do inplace edit without backup");
- }
if (rb_defout != rb_stdout) {
Fio_close(rb_defout);
}
fstat(fileno(fr), &st);
- str = str_new2(fn);
- str_cat(str, inplace, strlen(inplace));
- if (rename(fn, RSTRING(str)->ptr) < 0) {
- Warning("Can't rename %s to %s: %s, skipping file",
- fn, RSTRING(str)->ptr, strerror(errno));
+ if (*inplace) {
+ str = str_new2(fn);
+ str_cat(str, inplace, strlen(inplace));
+ 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;
+ }
+ }
+ else if (unlink(fn) < 0) {
+ Warning("Can't remove %s: %s, skipping file",
+ fn, strerror(errno));
fclose(fr);
goto retry;
}