From patchwork Sun Jan 20 19:49:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 213989 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 DEF842C0082 for ; Mon, 21 Jan 2013 06:49:56 +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=1359316197; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=42KI4ye AeRlfMX3KUQaeRD9KtQE=; b=RlkwSQe6fkpk8gGhqQkJhGTWX8lqlxU2LREDnOz BaBeHZd4QQHLWXs50/r98Z5BZb8t9WfsRSYHkhzycgLXv3RlCv166ZXjfXg6BSRf w9NFDL2FxB56T3DFrQICOpJ1GkmkLndMxi62fv/NefBRs8iLv5ZZO4QDcCIJuvza 2/jo= 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:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=m24DDWGnzB8gXPQE0o5r95AO/4pVl6QTpDZx5p1ic5gBKfrYiwYO2tX6RX0jxL wK8iwSwlv4Awfc7Yaap2kDxgbfJGeoz2z1XZUjP812CwZ2JSUT1uU8xAYSM4ihHH fbd3608LR6JCWL+GdJWYnxPXEY+qE856J/zJ5KzMk+57Q=; Received: (qmail 6576 invoked by alias); 20 Jan 2013 19:49:49 -0000 Received: (qmail 6557 invoked by uid 22791); 20 Jan 2013 19:49:48 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, TW_CP X-Spam-Check-By: sourceware.org Received: from cc-smtpout1.netcologne.de (HELO cc-smtpout1.netcologne.de) (89.1.8.211) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 20 Jan 2013 19:49:42 +0000 Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id BEE4A1222E; Sun, 20 Jan 2013 20:49:40 +0100 (CET) Received: from [192.168.0.104] (xdsl-78-35-133-155.netcologne.de [78.35.133.155]) by cc-smtpin3.netcologne.de (Postfix) with ESMTPSA id 623BD11DBD; Sun, 20 Jan 2013 20:49:39 +0100 (CET) Message-ID: <50FC4A52.8010201@netcologne.de> Date: Sun, 20 Jan 2013 20:49:38 +0100 From: Thomas Koenig User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130105 Thunderbird/17.0.2 MIME-Version: 1.0 To: "fortran@gcc.gnu.org" , gcc-patches Subject: [patch, fortran] Fix PR 55919 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 Hello world, the attached patch fixes a regression where -J dirpath/ would issue a warning on Windows because of the trailing dir separator. Regression-tested, but only on Linux. I would appreciate if somebody could also test it on Windows (and run the test case, of course). OK for trunk? Thomas 2013-01-20 Thomas Koenig PR fortran/55919 * add_path_to_list: Copy path to temporary and strip trailing directory separators before calling stat(). 2013-01-20 Thomas Koenig PR fortran/55919 * gfortran.dg/include_8.f90: New test. Index: scanner.c =================================================================== --- scanner.c (Revision 195319) +++ scanner.c (Arbeitskopie) @@ -310,14 +310,26 @@ add_path_to_list (gfc_directorylist **list, const { gfc_directorylist *dir; const char *p; + char *q; struct stat st; + size_t len; + int i; p = path; while (*p == ' ' || *p == '\t') /* someone might do "-I include" */ if (*p++ == '\0') return; - if (stat (p, &st)) + /* Strip trailing directory separators from the path, as this + will confuse Windows systems. */ + len = strlen (p); + q = (char *) alloca (len + 1); + memcpy (q, p, len + 1); + i = len - 1; + while (i >=0 && IS_DIR_SEPARATOR(q[i])) + q[i--] = '\0'; + + if (stat (q, &st)) { if (errno != ENOENT) gfc_warning_now ("Include directory \"%s\": %s", path,