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
This commit is contained in:
Paul Brook 2004-10-07 20:19:32 +00:00 committed by Paul Brook
parent 94b9aa66d8
commit 82e7998648
4 changed files with 23 additions and 3 deletions

View File

@ -1,3 +1,7 @@
2004-10-07 Paul Brook <paul@codesourcery.com>
* gfortran.dg/intrinsic_verify_1.f90: New test.
2004-10-07 Paul Brook <paul@codesourcery.com>
* gfortran.dg/empty_format_1.f90: Remove stray commas.

View File

@ -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

View File

@ -1,3 +1,8 @@
2004-10-07 Paul Brook <paul@codesourcery.com>
* intrinsics/string_intrinsics.c (string_verify): Fix off by one
error.
2004-10-06 Paul Brook <paul@codesourcery.com>
PR libfortran/17709

View File

@ -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++)