* [gfortran] intrinsic GETARG and IARGC
@ 2004-06-09 4:35 Bud Davis
2004-06-12 15:43 ` Paul Brook
0 siblings, 1 reply; 5+ messages in thread
From: Bud Davis @ 2004-06-09 4:35 UTC (permalink / raw)
To: gcc-patches, gfortran
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;
+ }
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [gfortran] intrinsic GETARG and IARGC
2004-06-09 4:35 [gfortran] intrinsic GETARG and IARGC Bud Davis
@ 2004-06-12 15:43 ` Paul Brook
2004-06-12 17:59 ` Tobias Schlüter
2004-06-14 22:27 ` Toon Moene
0 siblings, 2 replies; 5+ messages in thread
From: Paul Brook @ 2004-06-12 15:43 UTC (permalink / raw)
To: fortran; +Cc: Bud Davis, gcc-patches
> 2004-06-09 Bud Davis <bdavis9659@comcast.net>
>
> * intrinsics/args.c: Implement GETARG and IARGC.
I've applied this with one minor change.
This implementation breaks when the default integer kind is not 4, but we can
probably fix that in the frontend.
Paul
> + void
> + prefix(iargc) ()
Should return GFC_INTEGER_4.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [gfortran] intrinsic GETARG and IARGC
2004-06-12 15:43 ` Paul Brook
@ 2004-06-12 17:59 ` Tobias Schlüter
2004-06-12 18:15 ` Paul Brook
2004-06-14 22:27 ` Toon Moene
1 sibling, 1 reply; 5+ messages in thread
From: Tobias Schlüter @ 2004-06-12 17:59 UTC (permalink / raw)
To: Paul Brook; +Cc: fortran, Bud Davis, gcc-patches
Paul Brook wrote:
>>2004-06-09 Bud Davis <bdavis9659@comcast.net>
>>
>> * intrinsics/args.c: Implement GETARG and IARGC.
>
>
> I've applied this with one minor change.
>
I added the PR to the ChangeLog entries. Is all of PR 15665 fixed now?
- Tobi
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [gfortran] intrinsic GETARG and IARGC
2004-06-12 17:59 ` Tobias Schlüter
@ 2004-06-12 18:15 ` Paul Brook
0 siblings, 0 replies; 5+ messages in thread
From: Paul Brook @ 2004-06-12 18:15 UTC (permalink / raw)
To: Tobias Schlüter; +Cc: fortran, Bud Davis, gcc-patches
On Saturday 12 June 2004 15:52, Tobias Schlüter wrote:
> Paul Brook wrote:
> >>2004-06-09 Bud Davis <bdavis9659@comcast.net>
> >>
> >> * intrinsics/args.c: Implement GETARG and IARGC.
> >
> > I've applied this with one minor change.
>
> I added the PR to the ChangeLog entries. Is all of PR 15665 fixed now?
No, iargc still ICEs.
Paul
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [gfortran] intrinsic GETARG and IARGC
2004-06-12 15:43 ` Paul Brook
2004-06-12 17:59 ` Tobias Schlüter
@ 2004-06-14 22:27 ` Toon Moene
1 sibling, 0 replies; 5+ messages in thread
From: Toon Moene @ 2004-06-14 22:27 UTC (permalink / raw)
To: Paul Brook; +Cc: fortran, Bud Davis, gcc-patches
Paul Brook wrote:
> I've applied this with one minor change.
>
> This implementation breaks when the default integer kind is not 4, but we can
> probably fix that in the frontend.
Oh, yeah, that's a pet peeve of mine.
On almost all systems where we have to compile our code with -i8 -r8 we
also have to supply routines like:
INTEGER*8 FUNCTION IARGC8()
INTEGER*4 IARGC
IARGC8 = IARGC()
END
and
SUBROUINE GETARG8(I, ARG)
INTEGER*8 I
INTEGER*4 J
CHARACTER*(*) ARG
J = I
CALL GETARG(J, ARG)
END
[sigh]
--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
A maintainer of GNU Fortran 95: http://gcc.gnu.org/fortran/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-06-14 20:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-09 4:35 [gfortran] intrinsic GETARG and IARGC Bud Davis
2004-06-12 15:43 ` Paul Brook
2004-06-12 17:59 ` Tobias Schlüter
2004-06-12 18:15 ` Paul Brook
2004-06-14 22:27 ` Toon Moene
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).