To: J3 J3/19-196r2 From: Dan Nagle Subject: edits for ISO_FORTRAN_STRINGS US03 Date: 2019-August-07 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. However, there now appears to be little support for doing so. Therefore, this revision of this paper proposes a straw vote: 1. Standardize only the SPLIT routine 2. Do nothing. 3. Undecided. Future revisions (or not) of this paper will depend on the outcome. The last version of this paper is included below for reference only. 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 module procedures previously defined by ISO/IEC 1589 (2)." { the introduction briefly describes new features } { the introduction to subclause 16.10 needs to mention the new module } [426:25]p1 16.10.1 General replace the sentence fragment "This document defines five standard intrinsic modules: a Fortran environment module, a set" with "This document defines six standard intrinsic modules: a Fortran environment module, a Fortran string module, a set" [426:29-30]p2 replace the sentence "The module procedures described in 16.10.2 are pure." with the sentence "The module procedures described in 16.10.2 and 16.10.3 are pure." { correctly introduce the subclause } { describe the module and the procedures } { edit to describe the whole new intrinsic module } [432:3+] add a new subclause " 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 substring. <> Elemental function. <> STRING shall be of type CHARACTER. The corresponding actual argument shall not be an unallocated allocatable, an unassociated pointer, or an optional dummy argument. START (optional) shall be of type INTEGER. FINISH (optional) shall be of type INTEGER. <> Of type CHARACTER and of the same kind as STRING. <> The result value is a copy of the characters of the argument STRING between positions START and FINISH, inclusive. If START is absent or its value is less than one, the result value is the same as if it were present with the value one. If FINISH is absent or its value is greater than LEN(STRING), the result value is the same as if it were present with the value LEN(STRING). If FINISH is less than START, the result value is a zero-length string. 16.10.3.3 INSERT (STRING, START, SUBSTRING) <> Inserts a substring. <> Elemental function. <> STRING shall be type CHARACTER. The corresponding actual argument shall not be an unallocated allocatable, an unassociated pointer, or an optional dummy argument. START shall be type INTEGER. The corresponding actual argument shall not be an unallocated allocatable, an unassociated pointer, or an optional dummy argument. SUBSTRING shall be type CHARACTER of the same kind as STRING. The corresponding actual argument shall not be an unallocated allocatable, an unassociated pointer, or an optional dummy argument. <> 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 the value of START is greater than LEN(STRING), the result value is the same as if it were LEN(STRING) and SUBSTRING is appended to the copy of STRING. If the value of START is less than one, the result value is the same as if it were the value one 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. <> Elemental function. <> STRING shall be of type CHARACTER. The corresponding actual argument shall not be an unallocated allocatable, an unassociated pointer, or an optional dummy argument. START (optional) shall be of type INTEGER. FINISH (optional) shall be of type INTEGER. <> Of type CHARACTER of the same kind as STRING. <> 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 result value is the same as if it were present with the value one. If FINISH is absent or its value is greater than LEN(STRING), the result value is the same as if it were present with the value LEN(STRING). If the value of FINISH is less than the value of START, the result value is the characters of STRING 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 a string. <> Elemental function. <> STRING shall be of type CHARACTER. The corresponding actual argument shall not be an unallocated allocatable, an unassociated pointer, nor an optional dummy argument. START shall be of type INTEGER. The corresponding actual argument shall not be an unallocated allocatable, an unassociated pointer, nor an optional dummy argument. FINISH shall be of type INTEGER. The corresponding actual argument shall not be an unallocated allocatable, an unassociated pointer, nor an optional dummy argument. SUBSTRING shall be of type CHARACTER of the same kind as STRING. The corresponding actual argument shall not be an unallocated allocatable, an unassociated pointer, nor an optional dummy argument. TARGET shall be of type CHARACTER of the same kind as STRING. It shall not be of zero length. The corresponding actual argument shall not be an unallocated allocatable, an unassociated pointer, nor an optional dummy argument. EVERY (optional) shall be of type LOGICAL. BACK (optional) shall be of type LOGICAL. <> Of type CHARACTER of the same kind as STRING. <> 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 the value of START is greater than LEN(STRING), the result value is as if it were the value LEN(STRING)+1 and SUBSTRING is appended to the copy of STRING. If the value of START is less than one, the result value is as if it were the value one. 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 the value of START is less than one, the result value is as if it were the value one. If the value of FINISH is greater than LEN(STRING), the result value is as if it were LEN(STRING). 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. <> Elemental subroutine. <> STRING shall be of type CHARACTER. It is an INTENT(INOUT) argument. The corresponding actual argument shall not be an unallocated allocatable, an unassociated pointer, or an optional dummy argument. WORD shall be of type CHARACTER of the same kind as STRING. It is an INTENT(OUT) argument. The corresponding actual argument shall not be an unallocated allocatable, an unassociated pointer, nor an optional dummy argument. SET shall be of type CHARACTER of the same kind as STRING. It is an INTENT(IN) argument. The corresponding actual argument shall not be an unallocated allocatable, an unassociated pointer, or an optional dummy argument. SEPARATOR (optional) shall be of type CHARACTER of the same kind as STRING. 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 as if by intrinsic assignment and the remainder of STRING, not including the SEPARATOR character, is returned in the argument STRING as if by intrinsic assignment. If the argument SEPARATOR is present, the actual character found which separates WORD from the remainder of STRING is returned in SEPARATOR as if by intrinsic assignment. If no character from SET is found or SET is of zero length, the whole STRING is returned in WORD as if by intrinsic assignment, 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==