subroutineaddpure
pure subroutine add(b, text)
Append text to b.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| b | type(buffer_t) | inout | the buffer | |
| text | character(len=*) | in | the text |
Called by
- add_int
- add_words
- argument_table
- arithmetic
- asset_fdoc_css
- asset_fdoc_js
- badge
- binding_description
- binding_table
- breadcrumbs
- call_method
- call_text
- calls_section
- code_block_html
- collect_definitions
- common_sections
- describe
- doc_block
- encoded
- entity_page
- entity_title
- enum_sections
- explained_badge
- fold_line
- fold_output
- fold_region
- ford_link
- form_key
- format_string
- graph_heading
- graph_sections
- grouped
- highlight_data
- highlight_fortran
- html_escape
- implementation_line
- inline
- inline_abbreviation
- inline_angle
- inline_bracket
- inline_code
- inline_dollar
- inline_emphasis
- inline_entity
- inline_image
- inline_smart
- insert_toc
- line_start
- link_to
- math
- neighbour_chips
- normalize_lines
- number_cell
- page_foot
- page_head
- page_links
- parse_fstring
- parse_primary
- plain_text
- procedure_doc
- rank_label
- read_line_directive
- read_string
- render_call
- render_children
- render_footnotes
- render_heading
- render_node
- render_node
- render_table
- search_page
- shared_summary
- side_group
- side_icon
- signature
- signature_arguments
- size_text
- source_section
- specific_link
- stash_fenced_code
- stash_html_blocks
- static_page
- stats_cells
- stats_total
- substitute_aliases
- summary_item
- summary_section
- table_row
- unique_id
- unit_and_file
- unit_body
- unstash
- uses_section
- write_call_forms
- write_form
- write_graph
- write_link
- write_type
- write_value
Source
Show the code
pure subroutine add(b, text)
type(buffer_t), intent(inout) :: b !! the buffer
character(len=*), intent(in) :: text !! the text
character(len=:), allocatable :: grown
integer :: capacity
if (.not. allocated(b%s)) allocate (character(len=max(256, 2*len(text))) :: b%s)
capacity = len(b%s)
if (b%n + len(text) > capacity) then
allocate (character(len=max(2*capacity, b%n + len(text))) :: grown)
grown(1:b%n) = b%s(1:b%n)
call move_alloc(grown, b%s)
end if
b%s(b%n + 1:b%n + len(text)) = text
b%n = b%n + len(text)
end subroutine add