diff options
author | pbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-06-12 13:42:46 +0000 |
---|---|---|
committer | pbrook <pbrook@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-06-12 13:42:46 +0000 |
commit | 987727ef0723fe3f5c879b5e2af226888254d4e0 (patch) | |
tree | 9c48e29daf05d7e67525b21b88ec62b1f076a4f0 /libgfortran/intrinsics/args.c | |
parent | b9f02dbb0382be4a33401a285a767517968eaadd (diff) | |
download | gcc-987727ef0723fe3f5c879b5e2af226888254d4e0.tar.gz |
* intrinsics/args.c: Implement GETARG and IARGC.
* Makefile.am: Add it.
* Makefile.in: Regenerate.
testsuite/
* gfortran.fortran-torture/execute/getarg_1.f90: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@83027 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/intrinsics/args.c')
-rw-r--r-- | libgfortran/intrinsics/args.c | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/libgfortran/intrinsics/args.c b/libgfortran/intrinsics/args.c new file mode 100644 index 00000000000..da684fd99d4 --- /dev/null +++ b/libgfortran/intrinsics/args.c @@ -0,0 +1,58 @@ +/* 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; + int arglen; + 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 ) + { + arglen = strlen (argv[*pos]); + if (arglen > val_len) + arglen = val_len; + memcpy (val, argv[*pos], arglen); + } +} + +GFC_INTEGER_4 +prefix(iargc) () +{ + int argc; + char **argv; + + get_args (&argc, &argv); + + return argc; +} |