aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/intrinsics
diff options
context:
space:
mode:
Diffstat (limited to 'libgfortran/intrinsics')
-rw-r--r--libgfortran/intrinsics/string_intrinsics.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/libgfortran/intrinsics/string_intrinsics.c b/libgfortran/intrinsics/string_intrinsics.c
index f13d117..eed41d7 100644
--- a/libgfortran/intrinsics/string_intrinsics.c
+++ b/libgfortran/intrinsics/string_intrinsics.c
@@ -1,5 +1,5 @@
/* String intrinsics helper functions.
- Copyright 2002 Free Software Foundation, Inc.
+ Copyright 2002, 2005 Free Software Foundation, Inc.
Contributed by Paul Brook <paul@nowt.org>
This file is part of the GNU Fortran 95 runtime library (libgfortran).
@@ -89,12 +89,10 @@ copy_string (GFC_INTEGER_4 destlen, char * dest,
{
/* This will truncate if too long. */
memmove (dest, src, destlen);
- /*memcpy (dest, src, destlen);*/
}
else
{
memmove (dest, src, srclen);
- /*memcpy (dest, src, srclen);*/
/* Pad with spaces. */
memset (&dest[srclen], ' ', destlen - srclen);
}
@@ -304,35 +302,32 @@ GFC_INTEGER_4
string_scan (GFC_INTEGER_4 slen, const char * str, GFC_INTEGER_4 setlen,
const char * set, GFC_LOGICAL_4 back)
{
- int start;
- int last;
- int i;
- int delta;
+ int i, j;
if (slen == 0 || setlen == 0)
return 0;
if (back)
{
- last = 0;
- start = slen - 1;
- delta = -1;
+ for (i = slen - 1; i >= 0; i--)
+ {
+ for (j = 0; j < setlen; j++)
+ {
+ if (str[i] == set[j])
+ return (i + 1);
+ }
+ }
}
else
{
- last = slen - 1;
- start = 0;
- delta = 1;
- }
-
- i = 0;
- for (; start != last; start += delta)
- {
- for (i = 0; i < setlen; i++)
- {
- if (str[start] == set[i])
- return (start + 1);
- }
+ for (i = 0; i < slen; i++)
+ {
+ for (j = 0; j < setlen; j++)
+ {
+ if (str[i] == set[j])
+ return (i + 1);
+ }
+ }
}
return 0;
@@ -340,8 +335,8 @@ string_scan (GFC_INTEGER_4 slen, const char * str, GFC_INTEGER_4 setlen,
/* Verify that a set of characters contains all the characters in a
- string by indentifying the position of the first character in a
- characters that dose not appear in a given set of characters. */
+ string by identifying the position of the first character in a
+ characters that does not appear in a given set of characters. */
GFC_INTEGER_4
string_verify (GFC_INTEGER_4 slen, const char * str, GFC_INTEGER_4 setlen,