From 02d735f6bd9325efc25367cfd399557e19bb2532 Mon Sep 17 00:00:00 2001 From: Bud Davis Date: Wed, 25 Aug 2004 00:14:07 +0000 Subject: re PR libfortran/17164 (index function not working properly) 2004-08-24 Bud Davis PR fortran/17164 * runtime/string_intrinsics.c (string_index):check for substring longer than string. * gfortran.dg/pr17164.f90: New test. From-SVN: r86527 --- libgfortran/intrinsics/string_intrinsics.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libgfortran/intrinsics/string_intrinsics.c') diff --git a/libgfortran/intrinsics/string_intrinsics.c b/libgfortran/intrinsics/string_intrinsics.c index 2cd07a2b77b..5d231268ab6 100644 --- a/libgfortran/intrinsics/string_intrinsics.c +++ b/libgfortran/intrinsics/string_intrinsics.c @@ -221,6 +221,9 @@ string_index (GFC_INTEGER_4 slen, const char * str, GFC_INTEGER_4 sslen, if (sslen == 0) return 1; + if (sslen > slen) + return 0; + if (!back) { last = slen + 1 - sslen; -- cgit v1.2.1