From 82e79986482a13c271c28512a4196aadfddcd8f6 Mon Sep 17 00:00:00 2001 From: Paul Brook Date: Thu, 7 Oct 2004 20:19:32 +0000 Subject: [PATCH] string_intrinsics.c (string_verify): Fix off by one error. * intrinsics/string_intrinsics.c (string_verify): Fix off by one error. testsuite/ * gfortran.dg/intrinsic_verify_1.f90: New test. From-SVN: r88704 --- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gfortran.dg/intrinsic_verify_1.f90 | 12 ++++++++++++ libgfortran/ChangeLog | 5 +++++ libgfortran/intrinsics/string_intrinsics.c | 5 ++--- 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/intrinsic_verify_1.f90 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b4cd8d83274..b181df863b1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2004-10-07 Paul Brook + + * gfortran.dg/intrinsic_verify_1.f90: New test. + 2004-10-07 Paul Brook * gfortran.dg/empty_format_1.f90: Remove stray commas. diff --git a/gcc/testsuite/gfortran.dg/intrinsic_verify_1.f90 b/gcc/testsuite/gfortran.dg/intrinsic_verify_1.f90 new file mode 100644 index 00000000000..c894043de08 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/intrinsic_verify_1.f90 @@ -0,0 +1,12 @@ +! { dg-do run } +! Test the verify intrinsic. We were ignoring the last character. +program prog + character(len=1) :: c1 + character(len=4) :: c4 + c1 = "E" + if (verify(c1, "1") .ne. 1) call abort + c4 = "ABBA" + if (verify(c4, "A") .ne. 2) call abort + if (verify(c4, "A", back = .true.) .ne. 3) call abort + if (verify(c4, "AB") .ne. 0) call abort +end program diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 82b0577dec2..f361408a503 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,8 @@ +2004-10-07 Paul Brook + + * intrinsics/string_intrinsics.c (string_verify): Fix off by one + error. + 2004-10-06 Paul Brook PR libfortran/17709 diff --git a/libgfortran/intrinsics/string_intrinsics.c b/libgfortran/intrinsics/string_intrinsics.c index 5d231268ab6..ac70a9bb873 100644 --- a/libgfortran/intrinsics/string_intrinsics.c +++ b/libgfortran/intrinsics/string_intrinsics.c @@ -346,17 +346,16 @@ string_verify (GFC_INTEGER_4 slen, const char * str, GFC_INTEGER_4 setlen, if (back) { - last = 0; + last = -1; start = slen - 1; delta = -1; } else { - last = slen - 1; + last = slen; start = 0; delta = 1; } - i = 0; for (; start != last; start += delta) { for (i = 0; i < setlen; i++)