fdoc

modulefdoc_util

String, date and path helpers shared by the rest of fdoc.

Uses

Graphs

Uses

Used by

Variables

NameTypeAttributesDefaultDescription
WHITESPACEcharacter(len=*)privateparameter''//achar(9)//achar(10)//achar(11)//achar(12)//achar(13)

Types

name_index_t

A hash table from names to positive integers, for lookups in long lists.

Functions

closing_parenpure

pure integer function closing_paren(s, open)

Position of the ) matching the ( at open in s, skipping strings, or 0.

contains_string

logical function contains_string(list, s)

True if s is in list.

count_blankspureprivate

pure integer function count_blanks(s)

Number of blanks and tabs in s.

day_of_yearpureprivate

pure integer function day_of_year(y, m, d)

Day of the year of a date, from 1.

ends_withpure

pure logical function ends_with(s, suffix)

True if s finishes with suffix.

expand_vars

character(len=:) function expand_vars(path) result(out)

path with $NAME and ${NAME} replaced by environment variables. Unset variables are left as written.

has_drivepureprivate

pure logical function has_drive(path)

True if path starts with a drive letter, as in C:.

has_rootpureprivate

pure logical function has_root(path)

True if path is absolute.

index_findpure

pure integer function index_find(table, name) result(value)

The value of name in table, or 0.

is_digitelemental

elemental logical function is_digit(c)

True if c is a digit.

joinpure

pure character(len=joined_length(list,sep)) function join(list, sep) result(text)

The strings of list with sep between them.

joined_lengthpureprivate

pure integer function joined_length(list, sep)

Length of the result of join.

last_separatorpure

pure integer function last_separator(path)

The position of the last separator in path, / or \, or 0.

lexical_cleanprivate

character(len=:) function lexical_clean(path) result(out)

Remove empty, . and .. components from absolute path.

lower_charelemental

elemental character(len=1) function lower_char(c) result(l)

c in lowercase.

name_hashpureprivate

pure integer function name_hash(name, size)

The hash of name, FNV-1a, as a position in 1:size, where size is a power of 2.

remove_blankspure

pure character(len=len(s)-count_blanks(s)) function remove_blanks(s) result(t)

s without blanks and tabs.

resolve_path

character(len=:) function resolve_path(base, path) result(out)

The absolute form of path relative to directory base, with variables expanded and . and .. removed, and with / as the separator on paths with a drive letter. Links are left as they are, and the path does not have to exist.

split_lines

type(string_t) function split_lines(text) result(lines)

The lines of text, ended by LF, CRLF or CR. As in Python's splitlines, a final line ending does not start another line.

split_on

type(string_t) function split_on(text, sep) result(parts)

The parts of text between the characters sep, including empty ones.

split_words

type(string_t) function split_words(text) result(words)

The blank-separated words of text.

starts_withpure

pure logical function starts_with(s, prefix)

True if s begins with prefix.

starts_wordpure

pure logical function starts_word(s, word)

True if s starts with word word: followed by anything but a letter, digit or _.

strftime

character(len=:) function strftime(format) result(out)

The current local time in a strftime format.

strippure

pure character(len=stripped_length(s)) function strip(s) result(t)

s without leading and trailing whitespace.

stripped_lengthpureprivate

pure integer function stripped_length(s)

Length of s without leading and trailing whitespace.

top_indexpure

pure integer function top_index(s, pattern)

Position of the first pattern in s outside brackets and strings, or 0.

top_split

type(string_t) function top_split(s, sep) result(parts)

The parts of s between the characters sep outside brackets and strings, each stripped.

weekdaypureprivate

pure integer function weekday(y, m, d)

Day of the week of a date: 0 for Sunday.

word_atpure

pure logical function word_at(s, at, word)

True if whole word word is at position at of s.

Subroutines

digits_valuepure

pure subroutine digits_value(text, value, stat)

The value of text, without an internal read, as those take a lock.

index_setpure

pure subroutine index_set(table, name, value)

Give name the value value in table.

lower_in_placepure

pure subroutine lower_in_place(text)

Make text lowercase, without a temporary, for text too long for the stack of a thread.

parse_bool

subroutine parse_bool(text, value, ok)

Read true or false, in any case.

parse_int

subroutine parse_int(text, value, ok)

Read a decimal integer.

push

subroutine push(list, s)

Append s to list, allocating it if needed.

push_intpure

pure subroutine push_int(list, value)

Append value to list, allocating it if needed.

read_whole_file

subroutine read_whole_file(path, text, stat, errmsg)

Read all of file path. This can be called from parallel code, as all file I/O of threads has to take turns: libgfortran 16 can crash otherwise (see example/io_race.f90).

remove_file

subroutine remove_file(path)

Delete file path, if it can be. This can be called from parallel code.

sort_strings

subroutine sort_strings(list)

Sort list by byte value, removing duplicates.

unique_tag

subroutine unique_tag(tag)

A number, as text, that another run at the same time is very unlikely to get, for temporary names.

write_whole_file

subroutine write_whole_file(path, text, stat, errmsg)

Replace the contents of file path. This can be called from parallel code.