From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12515 invoked by alias); 3 Apr 2002 13:12:39 -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 12503 invoked from network); 3 Apr 2002 13:12:32 -0000 Received: from unknown (HELO frigg.inter.net.il) (192.114.186.16) by sources.redhat.com with SMTP; 3 Apr 2002 13:12:32 -0000 Received: from zaretsky (diup-217-78.inter.net.il [213.8.217.78]) by frigg.inter.net.il (Mirapoint Messaging Server MOS 2.9.3.2) with ESMTP id BHS45608; Wed, 3 Apr 2002 16:12:22 +0300 (IDT) Date: Wed, 03 Apr 2002 05:12:00 -0000 From: "Eli Zaretskii" To: brobecker@ACT-Europe.FR Message-Id: <7458-Wed03Apr2002160810+0300-eliz@is.elta.co.il> CC: gdb-patches@sources.redhat.com In-reply-to: <20020402172232.C25687@act-europe.fr> (message from Joel Brobecker on Tue, 2 Apr 2002 17:22:33 +0200) Subject: Re: [RFC] xfullpath and new regression test xfullpath.exp Reply-to: Eli Zaretskii References: <20020401105021.A13168@act-europe.fr> <20020402172232.C25687@act-europe.fr> X-SW-Source: 2002-04/txt/msg00061.txt.bz2 > Is the following style more in line with the GNU project style? > > /* Return a copy of FILENAME, with its directory prefix canonicalized > by gdb_realpath. */ Yes. > Ah, Ok, I did not know this, I thought that d:foo and d:/foo were > equivalent. Shouldn't xfullpath return d:/foo instead? What do you > think of the following pseudo-code? > > [...] > dir_name = alloca ((size_t) (base_name - filename + 2)); > /* Allocate enough space to store the dir_name + plus one extra > character sometimes needed under Windows (see below), and > then the closing \000 character */ > strncpy (dir_name, filename, base_name - filename); > dir_name[base_name - filename] = '\000'; > > #if defined(__CYGWIN__) || defined(__MINGW32__) > if (strlen (dir_name) == 2 && > is_letter (dir_name[0]) && dir_name[1] == ':') > { > dir_name[2] = '.'; > dir_name[3] = '\000'; > } > #endif > > real_path = gdb_realpath (dir_name); Yes, this is okay, but please don't use system-dependent symbols like __CYGWIN__ etc. if you can avoid that: we want to avoid system-dependent preprocessor symbols as much as we can. In this case, include/filename.h already defines a non-zero value for the macro HAVE_DOS_BASED_FILE_SYSTEM on systems that need that special code. So please use HAVE_DOS_BASED_FILE_SYSTEM instead. > Is this better if I modify the last part of the function to be > > if (IS_DIR_SEPARATOR (real_path[strlen (real_path) - 1])) > result = concat (real_path, base_name, NULL); > else > result = concat (real_path, SLASH_STRING, base_name, NULL); Yes, I think this is better, thanks. > (can I consider that SLASH_STRING will always be one character long?): Where does the code assume it's a single character? `concat' conses up a new string, right? If so, the length of SLASH_STRING shouldn't matter, I think. Or am I missing something?