From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 45206 invoked by alias); 16 Jun 2015 14:47:15 -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 45186 invoked by uid 89); 16 Jun 2015 14:47:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_SOFTFAIL autolearn=no version=3.3.2 X-HELO: mtaout22.012.net.il Received: from mtaout22.012.net.il (HELO mtaout22.012.net.il) (80.179.55.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 16 Jun 2015 14:47:12 +0000 Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0NQ100400KUQYZ00@a-mtaout22.012.net.il> for gdb-patches@sourceware.org; Tue, 16 Jun 2015 17:47:09 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NQ10044NL2LZB10@a-mtaout22.012.net.il>; Tue, 16 Jun 2015 17:47:09 +0300 (IDT) Date: Tue, 16 Jun 2015 14:47:00 -0000 From: Eli Zaretskii Subject: Re: [PATCH 1/5] Introduce build_debug_file_name In-reply-to: <1434447768-17328-2-git-send-email-gbenson@redhat.com> To: Gary Benson Cc: gdb-patches@sourceware.org, cedric.buissart@gmail.com Reply-to: Eli Zaretskii Message-id: <83zj3zn21q.fsf@gnu.org> MIME-version: 1.0 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 8BIT References: <1434447768-17328-1-git-send-email-gbenson@redhat.com> <1434447768-17328-2-git-send-email-gbenson@redhat.com> X-IsSubscribed: yes X-SW-Source: 2015-06/txt/msg00346.txt.bz2 > From: Gary Benson > Cc: Cédric Buissart > Date: Tue, 16 Jun 2015 10:42:44 +0100 > > +/* Build the filename of a separate debug file from an arbitrary > + number of components. Returns an xmalloc'd string that must > + be be freed by the caller. The final argument of this function > + must be NULL to mark the end the argument list. */ > + > +static char * > +build_debug_file_name (const char *first, ...) > +{ > + va_list ap; > + const char *arg, *last; > + VEC (char_ptr) *args = NULL; > + struct cleanup *back_to = make_cleanup_free_char_ptr_vec (args); > + int bufsiz = 0; > + char *buf, *tmp; > + int i; > + > + va_start (ap, first); > + for (arg = first; arg; arg = va_arg (ap, const char *)) > + last = arg; > + va_end (ap); > + > + va_start (ap, first); > + for (arg = first; arg; arg = va_arg (ap, const char *)) > + { > + if (arg == last) > + tmp = xstrdup (arg); > + else > + { > + int len; > + > + /* Strip leading separators from subdirectories. */ > + if (arg != first) > + { > + while (*arg != '\0' && IS_DIR_SEPARATOR (*arg)) > + arg++; > + } > + > + /* Strip trailing separators. */ > + len = strlen (arg); > + > + while (len > 0 && IS_DIR_SEPARATOR (arg[len - 1])) > + len--; Was this logic tested with Windows-style "d:/foo" file names? E.g., what will happen if the first component is "d:/"? Thanks.