From patchwork Wed Jan 11 14:04:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 135390 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 196CAB6F65 for ; Thu, 12 Jan 2012 01:05:31 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1326895532; h=Comment: DomainKey-Signature:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject: References:In-Reply-To:Content-Type:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=+IAdbbEQimfnl8n7BR2j4zN0ENw=; b=Y1M2g4SFDRz5YsO nT8b851s2kvpdv73D9uu7RZG9keW2yTJXae4gDlTODtx5zHOA+oYagrgJT8VlBnS SI6TaXvKR2ZaBG9PY2puwfIXRMZfBK9bajCsfraA7W9cQHAdaM0ehpOCf+PLCuDr I2zhqy7vQmgUB9/up+5RGBpSKCPE= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=O06bbDMQhU2s7u4BO+0EkLjtN7Qm0zen3Rtm6uobvTGXBA37zUkhw4SNBq7rS7 k4FgpC7Aa+23awi7M5zBp3L6ll4ziEEej6EQfluVCASX5bxSbMAcYXUIimkJjCxa LJAtBcwYPXv/xpU9iLCBztx46LGmIoWFevRwdQsEs8Dmk=; Received: (qmail 18849 invoked by alias); 11 Jan 2012 14:05:15 -0000 Received: (qmail 18755 invoked by uid 22791); 11 Jan 2012 14:05:14 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, TW_RG X-Spam-Check-By: sourceware.org Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 11 Jan 2012 14:04:59 +0000 Received: from [192.168.178.22] (port-92-204-59-150.dynamic.qsc.de [92.204.59.150]) by mx01.qsc.de (Postfix) with ESMTP id 164513DB43; Wed, 11 Jan 2012 15:04:56 +0100 (CET) Message-ID: <4F0D9708.509@net-b.de> Date: Wed, 11 Jan 2012 15:04:56 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111220 Thunderbird/9.0 MIME-Version: 1.0 To: Janne Blomqvist CC: Fortran List , GCC Patches Subject: Re: [Patch libfortran] PR 51803 getcwd() failure References: <4F0D424F.4030808@net-b.de> <4F0D86B2.1080509@net-b.de> In-Reply-To: Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org On 01/11/2012 02:08 PM, Janne Blomqvist wrote: > Checking for an absolute path is already done a few lines up. So if > you prefer the kind of approach that you have in your patch, IMHO a > more correct patch would be I had a quick chat with Kai and decided to leave the lower part as is. However, I realized that the check for an absolute path is not correct for Windows. With the help of Kai I came up with the attached version. OK for the trunk? Tobias 2012-01-11 Tobias Burnus * runtime/main.c (store_exe_path): Fix absolute path detection for Windows. Index: libgfortran/runtime/main.c =================================================================== --- libgfortran/runtime/main.c (revision 183093) +++ libgfortran/runtime/main.c (working copy) @@ -105,15 +105,22 @@ store_exe_path (const char * argv0) } #endif - /* On the simulator argv is not set. */ - if (argv0 == NULL || argv0[0] == '/') + /* If the path is absolute or on an simulator where argv is not set. */ +#ifdef __MINGW32__ + if (argv0 == NULL + || ('A' <= argv0[0] && argv0[0] <= 'Z' && argv0[1] == ':') + || ('a' <= argv0[0] && argv0[0] <= 'z' && argv0[1] == ':') + || (argv0[0] == '/' && argv0[1] == '/') + || (argv0[0] == '\\' && argv0[1] == '\\')) +#else + if (argv0 == NULL || argv0[0] == DIR_SEPARATOR) +#endif { exe_path = argv0; please_free_exe_path_when_done = 0; return; } - memset (buf, 0, sizeof (buf)); #ifdef HAVE_GETCWD cwd = getcwd (buf, sizeof (buf)); if (!cwd)