Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!munnari.oz.au!goanna!ok From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) Newsgroups: comp.lang.fortran Subject: Re: MS-FORTRAN bug in string concatenation Keywords: Fortran, strings, substrings Message-ID: <4787@goanna.cs.rmit.oz.au> Date: 19 Feb 91 10:33:36 GMT References: <2PWGG2@MPLVAX.SRI.COM> <22078@hydra.gatech.EDU> <1991Feb16.202213.10167@ariel.unm.edu> Organization: Comp Sci, RMIT, Melbourne, Australia Lines: 33 In article <1991Feb16.202213.10167@ariel.unm.edu>, scavo@cie.uoregon.edu (Tom Scavo) writes: > So how do I fix these nonstandard routines without having > to resort to local character variables (which would put an > unnecessary limit on the length of each argument)? C CALL PREPND(STRVAR, STRVAL) C has the effect that the non-standard statement C STRVAR = STRVAL // STRVAR C would have had if the right hand side were evaluated C before changing any part of the left hand side. C This subroutine uses a fixed amount of storage. SUBROUTINE PREPND(A, B) CHARACTER A*(*), B*(*) INTEGER ALEN, BLEN, KEEP, I CHARACTER TEMP*1 ALEN = LEN(A) BLEN = LEN(B) IF (BLEN .GE. ALEN) THEN A = B(1:ALEN) ELSE KEEP = ALEN-BLEN DO 10 I = 1, KEEP TEMP = A(KEEP+1-I:KEEP+1-I) A(ALEN+1-I:ALEN+1-I) = TEMP 10 CONTINUE A(1:BLEN) = B(1:BLEN) END IF END -- Professional programming is paranoid programming