public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch, libfortran] Fix EXECUTE_COMMAND_LINE error return
@ 2017-10-09 21:34 Thomas Koenig
  2017-10-10  5:52 ` Janne Blomqvist
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Koenig @ 2017-10-09 21:34 UTC (permalink / raw)
  To: fortran, gcc-patches

[-- Attachment #1: Type: text/plain, Size: 669 bytes --]

Hello world,

currently, EXECUTE_COMMAND_LINE aborts the program if the called program
is not found, if cmdstat is present, but cmdmsg isn't. This is a 6/7/8
regression.

This patch fixes the issue by simply removing the erronous call to
runtime_error.

Regression-tested.  OK for all affected branches?

Regards

	Thomas

2017-10-10  Thomas Koenig  <tkoenig@gcc.gnu.org>

         PR libfortran/82233
         * intrinsics/execute_command_line.c (execute_command_line):
         No call to runtime_error if cmdstat is present.

2017-10-10  Thomas Koenig  <tkoenig@gcc.gnu.org>

         PR libfortran/82233
         * gfortran.dg/execute_command_line_3.f90: New test.

[-- Attachment #2: p1.diff --]
[-- Type: text/x-patch, Size: 757 bytes --]

Index: intrinsics/execute_command_line.c
===================================================================
--- intrinsics/execute_command_line.c	(Revision 253525)
+++ intrinsics/execute_command_line.c	(Arbeitskopie)
@@ -125,15 +125,9 @@ execute_command_line (const char *command, bool wa
   free (cmd);
 
   /* Now copy back to the Fortran string if needed.  */
-  if (cmdstat && *cmdstat > EXEC_NOERROR)
-    {
-      if (cmdmsg)
-	fstrcpy (cmdmsg, cmdmsg_len, cmdmsg_values[*cmdstat],
+  if (cmdstat && *cmdstat > EXEC_NOERROR && cmdmsg)
+    fstrcpy (cmdmsg, cmdmsg_len, cmdmsg_values[*cmdstat],
 		strlen (cmdmsg_values[*cmdstat]));
-      else
-	runtime_error ("Failure in EXECUTE_COMMAND_LINE: %s",
-		       cmdmsg_values[*cmdstat]);
-    }
 }
 
 

[-- Attachment #3: execute_command_line_3.f90 --]
[-- Type: text/x-fortran, Size: 1010 bytes --]

! { dg-do  run }
! PR 82233 - there were program aborts for some of these commands.
! Original test case by Urban Jost.
program boom
implicit none
integer                       :: i,j 
character(len=256)            :: msg
character(len=:), allocatable :: command
   command='notthere'
   msg='' ! seems to only be defined if exitstatus.ne.0
   ! ok -- these work
   call execute_command_line(command , wait=.false., exitstat=i, cmdstat=j, cmdmsg=msg)
   if (j /= 0 .or. msg /= '') call abort
   call execute_command_line(command ,               exitstat=i, cmdstat=j, cmdmsg=msg )
   if (j /= 3 .or. msg /= "Invalid command line" ) call abort
   msg = ''
   call execute_command_line(command , wait=.false., exitstat=i,            cmdmsg=msg )
   print *,msg
   if (msg /= '') call abort
   call execute_command_line(command ,               exitstat=i, cmdstat=j             )
   if (j /= 3) call abort
   call execute_command_line(command , wait=.false., exitstat=i                        )

end program boom

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch, libfortran] Fix EXECUTE_COMMAND_LINE error return
  2017-10-09 21:34 [patch, libfortran] Fix EXECUTE_COMMAND_LINE error return Thomas Koenig
@ 2017-10-10  5:52 ` Janne Blomqvist
  0 siblings, 0 replies; 2+ messages in thread
From: Janne Blomqvist @ 2017-10-10  5:52 UTC (permalink / raw)
  To: Thomas Koenig; +Cc: fortran, gcc-patches

On Tue, Oct 10, 2017 at 12:34 AM, Thomas Koenig <tkoenig@netcologne.de> wrote:
> Hello world,
>
> currently, EXECUTE_COMMAND_LINE aborts the program if the called program
> is not found, if cmdstat is present, but cmdmsg isn't. This is a 6/7/8
> regression.
>
> This patch fixes the issue by simply removing the erronous call to
> runtime_error.
>
> Regression-tested.  OK for all affected branches?
>
> Regards
>
>         Thomas
>
> 2017-10-10  Thomas Koenig  <tkoenig@gcc.gnu.org>
>
>         PR libfortran/82233
>         * intrinsics/execute_command_line.c (execute_command_line):
>         No call to runtime_error if cmdstat is present.
>
> 2017-10-10  Thomas Koenig  <tkoenig@gcc.gnu.org>
>
>         PR libfortran/82233
>         * gfortran.dg/execute_command_line_3.f90: New test.

Ok, thanks for the patch.

-- 
Janne Blomqvist

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-10-10  5:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-09 21:34 [patch, libfortran] Fix EXECUTE_COMMAND_LINE error return Thomas Koenig
2017-10-10  5:52 ` Janne Blomqvist

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).