Text: fetch a substring
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.
Showing
- sefht.geany 5 additions, 5 deletionssefht.geany
- src/main.c 3 additions, 2 deletionssrc/main.c
- src/text.c 136 additions, 18 deletionssrc/text.c
- src/text.h 1 addition, 0 deletionssrc/text.h
- tests/test_fragment.c 4 additions, 4 deletionstests/test_fragment.c
- tests/test_text.c 66 additions, 18 deletionstests/test_text.c
Loading
Please register or sign in to comment