From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10996 invoked by alias); 10 Jan 2015 15:39:37 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 10974 invoked by uid 89); 10 Jan 2015 15:39:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: mtaout27.012.net.il Received: from mtaout27.012.net.il (HELO mtaout27.012.net.il) (80.179.55.183) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 10 Jan 2015 15:39:33 +0000 Received: from conversion-daemon.mtaout27.012.net.il by mtaout27.012.net.il (HyperSendmail v2007.08) id <0NHY00600WEZ0400@mtaout27.012.net.il> for gdb-patches@sourceware.org; Sat, 10 Jan 2015 17:31:51 +0200 (IST) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by mtaout27.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NHY005PHWH3CO00@mtaout27.012.net.il>; Sat, 10 Jan 2015 17:31:51 +0200 (IST) Date: Sat, 10 Jan 2015 15:39:00 -0000 From: Eli Zaretskii Subject: Re: [PATCH] Append to input history file instead of overwriting it In-reply-to: <1420903108-24831-1-git-send-email-patrick@parcs.ath.cx> To: Patrick Palka Cc: gdb-patches@sourceware.org, patrick@parcs.ath.cx Reply-to: Eli Zaretskii Message-id: <83wq4u63wu.fsf@gnu.org> References: <1420903108-24831-1-git-send-email-patrick@parcs.ath.cx> X-IsSubscribed: yes X-SW-Source: 2015-01/txt/msg00259.txt.bz2 > From: Patrick Palka > Cc: Patrick Palka > Date: Sat, 10 Jan 2015 10:18:28 -0500 > > + local_history_filename = xstrprintf ("%s.%d", history_filename, getpid ()); > + old_chain = make_cleanup (xfree, local_history_filename); > + > + ret = rename (history_filename, local_history_filename); > + if (ret < 0) > + { > + /* If the rename failed then either the global history file never existed > + in the first place or another GDB process is currently appending to it > + (and has thus temporarily renamed it). Since we can't distinguish > + between these two cases, we have to conservatively assume the first > + case and therefore must write out (not append) our known history to > + our local history file and try to move it back anyway. Otherwise a > + global history file would never get created! */ > + write_history (local_history_filename); > + } > + else > + { > + append_history (command_count, local_history_filename); > + history_truncate_file (local_history_filename, history_max_entries); > + } > + > + ret = rename (local_history_filename, history_filename); > + saved_errno = errno; > + if (ret < 0) > + warning (_("Could not rename %s to %s: error %d"), > + local_history_filename, history_filename, saved_errno); > + > + do_cleanups (old_chain); On Windows, a call to 'rename' fails if the destination already exists. Does the logic here cope with that? Thanks.