From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8710 invoked by alias); 10 May 2007 13:07:43 -0000 Received: (qmail 8605 invoked by uid 22791); 10 May 2007 13:07:41 -0000 X-Spam-Check-By: sourceware.org Received: from dmz.mips-uk.com (HELO dmz.mips-uk.com) (194.74.144.194) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 10 May 2007 13:07:37 +0000 Received: from internal-mx1 ([192.168.192.240] helo=ukservices1.mips.com) by dmz.mips-uk.com with esmtp (Exim 3.35 #1 (Debian)) id 1Hm8Mo-0007Cz-00; Thu, 10 May 2007 14:07:34 +0100 Received: from perivale.mips.com ([192.168.192.200]) by ukservices1.mips.com with esmtp (Exim 3.36 #1 (Debian)) id 1Hm8Lo-0001GF-00; Thu, 10 May 2007 14:06:32 +0100 Received: from macro (helo=localhost) by perivale.mips.com with local-esmtp (Exim 4.63) (envelope-from ) id 1Hm8Lo-00018T-AB; Thu, 10 May 2007 14:06:32 +0100 Date: Thu, 10 May 2007 13:07:00 -0000 From: "Maciej W. Rozycki" To: gdb-patches@sourceware.org cc: Chris Dearman , "Maciej W. Rozycki" Subject: Remove a trailing space resulting from file name completion Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-MIPS-Technologies-UK-MailScanner: Found to be clean X-MIPS-Technologies-UK-MailScanner-From: macro@mips.com 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 X-SW-Source: 2007-05/txt/msg00157.txt.bz2 Hi, There is an annoying problem with file name completion when it comes to internal variables. When a command like: (gdb) set logging file log.txt is issued ( here denoting a stroke of the named key) and "log.txt" already exists, then a space is appended (of course it may not make too much sense to use completion at the very end of the "log.txt" string, but it may earlier). After issuing the command as is, this space is included in the variable holding the log file name and consequently, if the log file is subsequently written, it is created with the trailing space, i.e. as "log.txt ". The space has to be explicitly deleted if this is not desired. As a file with a trailing space is indeed not desired in about any case, I propose the following change to be included. 2007-05-10 Chris Dearman Maciej W. Rozycki * cli/cli-setshow.c (do_setshow_command): Remove trailing whitespace when setting a var_filename. This change was tested natively for mips-unknown-linux-gnu and remotely for mipsisa32-sde-elf, using mips-sim-sde32/-EB and mips-sim-sde32/-EL as the targets, with no regressions. OK to apply? Maciej 12227.diff Index: gdb/src/gdb/cli/cli-setshow.c =================================================================== --- gdb.orig/src/gdb/cli/cli-setshow.c 2007-02-13 13:51:14.000000000 +0000 +++ gdb/src/gdb/cli/cli-setshow.c 2007-02-13 13:51:29.000000000 +0000 @@ -192,6 +192,13 @@ error_no_arg (_("filename to set it to.")); if (*(char **) c->var != NULL) xfree (*(char **) c->var); + { + /* Clear trailing whitespace of filename. */ + char *ptr = arg + strlen (arg) - 1; + while (ptr >= arg && (*ptr == ' ' || *ptr == '\t')) + ptr--; + *(ptr + 1) = '\0'; + } *(char **) c->var = tilde_expand (arg); break; case var_boolean: