This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gfortran] intrinsic GETARG and IARGC


below is the run-time part of these intrinsics.  GETARG works, but IARGC
is broken in the front-end.  GETARG has been tested, IARGC has not but
it "should work". :) 


the problem with IARGC is PR 15655.  


tested with no additional regression on i686/gnu/linux FC1.


--bud



test file


       CHARACTER*10 ARGS
       INTEGER*4 I
       I = 0
       CALL GETARG(I,ARGS)
! don't know exactly what name the OS  will return
! so this test is weak
! it is supposed to return the invoking command,
! which will include the entire path.
! a blank string is wrong no matter what.
       if (args.eq.'') call abort
       I = 1
       CALL GETARG(I,ARGS)
       if (args.ne.'') call abort
       I = -1
       CALL GETARG(I,ARGS)
       if (args.ne.'') call abort
       I = 4
       CALL GETARG(I,ARGS)
       if (args.ne.'') call abort
       I = 1000
       CALL GETARG(I,ARGS)
       if (args.ne.'') call abort
       end


ChangeLog:

2004-06-09  Bud Davis  <bdavis9659@comcast.net>

	* intrinsics/args.c: Implement GETARG and IARGC.

Index: gcc/libgfortran/Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libgfortran/Makefile.am,v
retrieving revision 1.6
diff -c -3 -p -r1.6 Makefile.am
*** gcc/libgfortran/Makefile.am	30 May 2004 21:58:09 -0000	1.6
--- gcc/libgfortran/Makefile.am	8 Jun 2004 13:28:49 -0000
*************** io/io.h
*** 36,41 ****
--- 36,42 ----
  gfor_helper_src= \
  intrinsics/associated.c \
  intrinsics/abort.c \
+ intrinsics/args.c \
  intrinsics/cpu_time.c \
  intrinsics/cshift0.c \
  intrinsics/eoshift0.c \
Index: gcc/libgfortran/intrinsics/args.c
===================================================================
RCS file: gcc/libgfortran/intrinsics/args.c
diff -N gcc/libgfortran/intrinsics/args.c
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- gcc/libgfortran/intrinsics/args.c	8 Jun 2004 13:28:49 -0000
***************
*** 0 ****
--- 1,52 ----
+ /* Implementation of the IARG/ARGC intrinsic(s).
+    Copyright (C) 2004 Free Software Foundation, Inc.
+ 
+ This file is part of the GNU Fortran 95 runtime library (libgfortran).
+ 
+ Libgfortran is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+ 
+ Libgfortran is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU Lesser General Public License for more details.
+ 
+ You should have received a copy of the GNU Lesser General Public
+ License along with libgfor; see the file COPYING.LIB.  If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite
330,
+ Boston, MA 02111-1307, USA.  */
+ 
+ #include "config.h"
+ #include <sys/types.h>
+ #include <string.h>
+ #include "libgfortran.h"
+ 
+ void 
+ prefix(getarg) (GFC_INTEGER_4 *pos, char  *val, GFC_INTEGER_4 val_len)
+ {
+   int argc;
+   char **argv;
+ 
+   get_args (&argc, &argv);
+ 
+   if (val_len < 1 || !val )
+     return;   /* something is wrong , leave immediately */
+   
+   memset( val, ' ', val_len);
+ 
+   if ((*pos) + 1 <= argc  && *pos >=0 )
+     strncpy (val, argv[*pos], (size_t) val_len);
+ }
+ 
+ void
+ prefix(iargc) ()
+ {
+   int argc;
+   char **argv;
+ 
+   get_args (&argc, &argv);
+ 
+   return argc;
+ } 



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]