To: J3 J3/19-196 From: Dan Nagle Subject: edits for ISO_FORTRAN_STRINGS US03 Date: 2019-August-05 Reference: 18-007r1, 19-160 Introduction At meeting 218, paper 19-160 was passed supporting specifications of the Part 2 procedures in the main standard. The edits in this paper propose to add a new 16.10.3 following the 16.10.2 subclause describing the ISO_FORTRAN_ENV intrinsic module. Syntax The results of straw votes taken at 218 regarding the names of the module and its contained procedures are assumed; these may be changed by new straw votes. However, this paper does not propose new straw votes. The reasons given for these decisions are existing usage, and clarity of the part 2 names. This paper attempts to craft edits. Edits to 18-007r1 { in the Introduction, in the paragraph for Intrinsic procedures and modules } [xiii] add "A new ISO_FORTRAN_STRINGS intrinsic module has been defined to supply intrinsic procedures previously defined by ISO/IEC 1589 (2)." { the introduction briefly describes new features } { describe the module and the procedures } { edit to describe the whole new intrinsic module } [432:3+] add a new subcluase " 16.10.3 The ISO_FORTRAN_STRINGS intrinsic module 16.10.3.1 General The intrinsic module ISO_FORTRAN_STRINGS provides public entities for character manipulation. The processor shall provide the named procedures described in 16.10.3. In the detailed descriptions below, procedure names are generic and not specific. They may have character arguments of any character kind supported by the processor. 16.10.3.2 EXTRACT ( STRING [, START, FINISH] ) <> Extracts a specified substring from a string. <> Elemental function. <> STRING shall be of type CHARACTER. START (optional) shall be of type INTEGER. FINISH (optional) shall be of type INTEGER. <> Of type CHARACTER. <> The result value is a copy of the characters of the argument STRING between positions START and FINISH, inclusive. If START is absent or less than one, the value one is used for START. If FINISH is absent or greater than LEN(STRING), the value LEN(STRING) is used for FINISH. If FINISH is less than START, the result is a zero-length string. 16.10.3.3 INSERT (STRING, START, SUBSTRING) <> Inserts a substring into a string at a specified position. <> Elemental function. <> STRING shall be type CHARACTER. START shall be type INTEGER. SUBSTRING shall be type CHARACTER. <> Type CHARACTER. <> The result value is a copy of the characters of the argument STRING with the characters of SUBSTRING inserted into the copy of STRING before the character at the character position START. If START is greater than LEN(STRING), the value LEN(STRING)+1 is used for START and SUBSTRING is appended to the copy of STRING. If START is less than one, the value one is used for START and SUBSTRING is inserted before the first character of the copy of STRING. 16.10.3.4 REMOVE (STRING [, START, FINISH]) <> Removes a specified SUBSTRING from a STRING. <> Elemental function. <> STRING shall be of type CHARACTER START (optional) shall be of type INTEGER. FINISH (optional) shall be of type INTEGER. <> Of type CHARACTER. <> The result value is a copy of the characters of STRING with the characters between positions START and FINISH, inclusive, removed. If START is absent or less than one, the value one is used for START. If FINISH is absent or greater than LEN(STRING), the value LEN(STRING) is used for FINISH. If FINISH is less than START, the characters of STRING are delivered unchanged as the result. 16.10.3.5 REPLACE (STRING, START, SUBSTRING) or REPLACE (STRING, START, FINISH, SUBSTRING) or REPLACE (STRING, TARGET, SUBSTRING [,EVERY, BACK]) <> Replaces a subset of the characters in a string by a given substring. The subset may be specified either by position or by content. <> Elemental function. <> STRING shall be of type CHARACTER. START shall be of type INTEGER. FINISH shall be of type INTEGER. SUBSTRING shall be of type CHARACTER. TARGET shall be of type CHARACTER. It shall not be of zero length. EVERY (optional) shall be of type LOGICAL. BACK (optional) shall be of type LOGICAL. <> Of type CHARACTER. <> The result value is a copy of the characters in STRING modified as per one of the cases below. Case(i): For a reference of the form REPLACE(STRING, START, SUBSTRING) the characters of the argument SUBSTRING are inserted into the copy of STRING beginning with the character at the character position START. The characters in positions from START to MIN(STRING+LEN(SUBSTRING)-1,LEN(STRING)) are deleted. If START is greater than LEN(STRING), the value LEN(STRING)+1 is used for START and SUBSTRING is appended to the copy of STRING. If START is less than one, the value one is used for START. Case(ii): For a reference of the form REPLACE(STRING, START, FINISH, SUBSTRING) the characters in the copy of STRING between positions START and FINISH, including those at START and FINISH, are deleted and replaced by the characters of SUBSTRING. If start is less than one, the value one is used for START. If FINISH is greater than LEN(STRING), the value LEN(STRING) is used for FINISH. If FINISH is less than START, the characters of SUBSTRING are inserted before the character at START and no characters are deleted. Case(iii): For a reference of the form REPLACE(STRING, TARGET, SUBSTRING, EVERY, BACK) the copy of STRING is searched for occurrences of TARGET. The search is done in the backward direction if the argument BACK is present with the value true, and in the forward direction otherwise. If TARGET is found, it is replaced by SUBSTRING. If EVERY is present with the value true, the search and replace is continued from the character following TARGET in the search direction specified until all occurrences of TARGET in the copy STRING are replaced; otherwise only the first occurrence of TARGET is replaced. 16.10.3.6 SPLIT (STRING, WORD, SET [, SEPARATOR, BACK]) <> Splits a string into two substrings with the substrings separated by the occurrence of a character from a specified separator set. <> Elemental subroutine. <> STRING shall be of type CHARACTER. It is an INTENT(INOUT) argument. WORD shall be of type CHARACTER. It is an INTENT(OUT) argument. SET shall be of type CHARACTER. It is an INTENT(IN) argument. SEPARATOR (optional) shall be of type CHARACTER. It is an INTENT(OUT) argument. BACK (optional) shall be of type LOGICAL. It is an INTENT(IN) argument. <> The effect of the procedure is to divide STRING at the first occurrence of a character that is in SET. The STRING is searched in the forward direction unless BACK is present with the value true, in which case the search is in the backward direction. The characters passed over in the search are returned in the argument WORD and the remainder of STRING, not including the SEPARATOR character, is returned in the argument STRING. If the argument SEPARATOR is present, the actual character found which separates WORD from the remainder of STRING is returned in SEPARATOR. If no character from SET is found or SET is of zero length, the whole STRING is returned in WORD, STRING is returned as zero length, and SEPARATOR (if present) is returned as zero length. The effect of the procedure is such that, on return, either WORD//SEPARATOR//STRING is the same as the initial STRING for a forward search, or STRING//SEPARATOR//WORD is the same as the initial STRING for a backward search. " { describe the module and procedures } ==end==