From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17778 invoked by alias); 2 Dec 2002 14:42:22 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 17770 invoked from network); 2 Dec 2002 14:42:21 -0000 Received: from unknown (HELO Cantor.suse.de) (213.95.15.193) by sources.redhat.com with SMTP; 2 Dec 2002 14:42:21 -0000 Received: from Hermes.suse.de (Charybdis.suse.de [213.95.15.201]) by Cantor.suse.de (Postfix) with ESMTP id 5404B145A8 for ; Mon, 2 Dec 2002 15:42:21 +0100 (MET) X-Authentication-Warning: sykes.suse.de: schwab set sender to schwab@suse.de using -f To: gdb-patches@sources.redhat.com Subject: gdb --args mishandles empty arguments X-Yow: Spreading peanut butter reminds me of opera!! I wonder why? From: Andreas Schwab Date: Mon, 02 Dec 2002 06:42:00 -0000 Message-ID: User-Agent: Gnus/5.090007 (Oort Gnus v0.07) Emacs/21.3.50 (ia64-suse-linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-SW-Source: 2002-12/txt/msg00016.txt.bz2 With the intruduction of --args it is possible to construct empty arguments that need to be transformed to ''. Andreas. 2002-12-02 Andreas Schwab * infcmd.c (construct_inferior_arguments): Handle empty arguments. --- gdb/infcmd.c.~1.64.~ 2002-12-02 11:00:11.000000000 +0100 +++ gdb/infcmd.c 2002-12-02 14:52:12.000000000 +0100 @@ -278,7 +278,7 @@ construct_inferior_arguments (struct gdb /* We over-compute the size. It shouldn't matter. */ for (i = 0; i < argc; ++i) - length += 2 * strlen (argv[i]) + 1; + length += 2 * strlen (argv[i]) + 1 + 2 * (argv[i][0] == '\0'); result = (char *) xmalloc (length); out = result; @@ -288,11 +288,20 @@ construct_inferior_arguments (struct gdb if (i > 0) *out++ = ' '; - for (cp = argv[i]; *cp; ++cp) + /* Need to handle empty arguments specially. */ + if (argv[i][0] == '\0') { - if (strchr (special, *cp) != NULL) - *out++ = '\\'; - *out++ = *cp; + *out++ = '\''; + *out++ = '\''; + } + else + { + for (cp = argv[i]; *cp; ++cp) + { + if (strchr (special, *cp) != NULL) + *out++ = '\\'; + *out++ = *cp; + } } } *out = '\0'; -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."