Skip to content
Snippets Groups Projects
  • Jonathan Schöbel's avatar
    9c9590e1
    Text: fetch a substring · 9c9590e1
    Jonathan Schöbel authored
    The function SH_Text_get_string returns a substring of text beginning at
    index and of length offset. If index is out of bounds, NULL is returned
    and an error is set. If offset is out of bounds, the existent part is
    returned. Also the length of the returned string can be set (optionally)
    to the out parameter length.
    If the original behaviour of SH_Text_get_string is achieved,
    SH_Text_get_string (text, length, error) has to be changed to
    SH_Text_get_string (text, 0, SIZE_MAX, length, error). The only
    difference will be that the function won't fail, when the text is longer
    than SIZE_MAX, because it is told to stop there. A text that is longer
    than SIZE_MAX is not possible to be returned, but that wasn't possible
    at anytime. Also I don't think handling char[] longer than SIZE_MAX is
    possible with the standard C library. Those in this case the text can
    only be returned in parts (By now only possible till 2*SIZE_MAX-1 with
    calling SH_Text_get_string (text, SIZE_MAX, SIZE_MAX, length, error))
    or has to be manipulated using the appropiate SH_Text methods, which are
    not implemented yet.
    9c9590e1
    History
    Text: fetch a substring
    Jonathan Schöbel authored
    The function SH_Text_get_string returns a substring of text beginning at
    index and of length offset. If index is out of bounds, NULL is returned
    and an error is set. If offset is out of bounds, the existent part is
    returned. Also the length of the returned string can be set (optionally)
    to the out parameter length.
    If the original behaviour of SH_Text_get_string is achieved,
    SH_Text_get_string (text, length, error) has to be changed to
    SH_Text_get_string (text, 0, SIZE_MAX, length, error). The only
    difference will be that the function won't fail, when the text is longer
    than SIZE_MAX, because it is told to stop there. A text that is longer
    than SIZE_MAX is not possible to be returned, but that wasn't possible
    at anytime. Also I don't think handling char[] longer than SIZE_MAX is
    possible with the standard C library. Those in this case the text can
    only be returned in parts (By now only possible till 2*SIZE_MAX-1 with
    calling SH_Text_get_string (text, SIZE_MAX, SIZE_MAX, length, error))
    or has to be manipulated using the appropiate SH_Text methods, which are
    not implemented yet.