- Jun 05, 2023
-
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
-
- Jun 04, 2023
-
-
Jonathan Schöbel authored
Two alternatives are provided: remove_attr and pop_attr. While the former free's the Attr's data, the latter allocates a new Attr, to store and return the data. Both functionality is provided by a single (internal) static method.
-
- Jun 03, 2023
-
-
Jonathan Schöbel authored
This method needs to be used in places where freeing the src-pointer is not possible, as it may be not allocated. If freeing is needed, it is now in the responsibility of the caller. As it turns out this approach is not even more useful, it is also less work, as it can be determined from the fact, that adjusting the tests to the new behavior means actually removing lines, that were previously working around the quirks, that the old approach introduced.
-
Jonathan Schöbel authored
Until now, the configure script just checked for check to be installed, which is needed to compile the tests. Now, configure provides a conditional (MISSING_CHECK) depending on its presence for use by automake. If check is missing, the tests aren't compiled. Instead a special script is executed to inform the user of the problem and stops the testsuite. Note, that it was not possible to directly stop the generation of the testsuite by injecting a rule to a Makefile without relying on implementation details of automake. See: https://stackoverflow.com/questions/76376806/automake-how-to-portably-throw-an-error-and-aborting-the-target/76382437 To allow the script to issue messages to stderr, AM_TESTS_FD_REDIRECT is used, because the parallel test harness redirects output of its tests to logfiles. This isn't used for the serial test harness, because there is no redirection to logfiles, but there AM_TESTS_FD_REDIRECT is also not taken into account. See: https://www.gnu.org/software/automake/manual/html_node/Testsuite-Environment-Overrides.html Additionaly configure also provides an argument to enforce both behaviours. When specifying --enable-tests=no the tests are not compiled regardless of the presence of check. If --enable-tests=yes, it is assumed, that tests are really needed and the mandantory check for check is performed thus providing the former behaviour. If not specified --enable-tests default to auto, which results in the same behaviour as --enable-tests=yes, if check is present, and like --enable-tests=no otherwise.
-
Jonathan Schöbel authored
The prepend_child and append_child methods were previously not tested. They are now added to testing.
-
Jonathan Schöbel authored
Hand in still missing tests.
-
- Jun 02, 2023
-
-
Jonathan Schöbel authored
added tests for getter
-
Jonathan Schöbel authored
Sometimes it is interesting to know, whether to Attr are referring to the same attribute. Note that it is not intended to provide a method for the values, as that would be meaningless on its own and if it is used in a more complex tasks, this is still possible with the current set of methods, which is prefered as the complex task can then be implemented on the outside completely.
-
Jonathan Schöbel authored
A method to compare two Attr's for exact equality was added both to internal and external methods.
-
- Mar 20, 2023
-
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
Added the allocation part of the implementation of attributes. Also some tests were improved. The functions to add and remove attributes are not implemented, as well as the generation of the html for the attributes. Thats why also test can't really test the attributes as it is not possible to add attributes.
-
Jonathan Schöbel authored
-
- Mar 17, 2023
-
-
Jonathan Schöbel authored
When used with care, it is possible to bypass many strdup calls.
-
Jonathan Schöbel authored
When used with care, it is possible to bypass many strdup calls. To also save the instructions for the call, which are a lot of overhead now, link time optimization is turned on. (-flto)
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
-
Jonathan Schöbel authored
Sometimes a copy is useful.
-
Jonathan Schöbel authored
As usual it should be also possible to bypass calls to strdup, while also taking care.
-
Jonathan Schöbel authored
The structure SH_Attr implements an HTML Attribute.
-
Jonathan Schöbel authored
The function get_alloc_size was renamed to get_child_alloc_size as the attributes will need another function.
-
- Mar 16, 2023
-
-
Jonathan Schöbel authored
Various remove methods were added, which are all implemented by an static method, analog to the last commit.
-
Jonathan Schöbel authored
The single method (formerly SH_NodeFragment_append_child) to add a child at the end of the child list was replaced, by a bunch of methods to insert a child at the beginning (SH_NodeFragment_prepend_child), at the end (SH_NodeFragment_append_child), at a specific position (SH_NodeFragment_insert_child) and directly before (SH_NodeFragment_insert_child_before) or after another child (SH_NodeFragment_insert_child_after). All these methods are implemented by a single internal one (insert_child), as there isn't really much difference in inserting one or the other way. But this internal method doesn't check whether this insertion request is actually doable, to save overhead as not every insertion method requires this check. This is done by the respective method. However if the check is not done correctly the internal method will attempt to write at not allocated space, which will hopefully result in a segfault. The child list is implemented as an array. To reduce the overhead to realloc calls, the array is allocated in chunks of childs. The calculation how many has to be allocated is done by another static method and determined by the macro CHILD_CHUNK. This is set to 5, which is just a guess. It should be somewhere around the average number of childs per html element, to reduce unused overhead. Also some predicates (SH_NodeFragment_is_parent, SH_NodeFragment_is_ancestor) were added to check whether a relationship exists between to nodes, thus whether they are linked through one or multiple levels. These functions could replace the old ones (SH_NodeFragment_is_child, SH_NodeFragment_is_descendant) semantically. Furthermore they are more efficient as this is now possible to check over the parent pointer. The internal insert method also uses these methods to check whether the child node is actually a parent of the parent node, which would result in errors later one. The old test is now obsolete but remained, as it is not bad to test more.
-
- Mar 13, 2023
-
-
Jonathan Schöbel authored
Removed some unnecessary type casts. Added some forgotten calls to free.
-
Jonathan Schöbel authored
Every fragment has a parent now, this is useful for both traversing the tree and checking for cycles when a node is added, which would cause problems, like freeing things twice or similar nice bugs. Both wouldn't be possible otherwise. These features are not implemented yet.
-
Jonathan Schöbel authored
The library provides a way to directly access the tag in a read-only way, which saves an call to strdup. This is useful if only reading is necessary , but needs special care by developers, as it is neither allowed to modify it nor to free it. Disregarding this will lead to a segfault in the best, and to silent data corruption and security bugs in the worst case.
-
- Jan 09, 2023
-
-
Jonathan Schöbel authored
-
- Jan 06, 2023
-
-
Jonathan Schöbel authored
-
- Jan 05, 2023
-
-
Jonathan Schöbel authored
-
- Jan 04, 2023
-
-
Jonathan Schöbel authored
An array index should be of size_t instead of unsigned int.
-
Jonathan Schöbel authored
Internal struct definitions shouldn't be exported by header files.
-
Jonathan Schöbel authored
The validator was used to check that every created tag is validate. However I now think that validation should take place at a later time, so it is not mandatory. Thus developing the validator is now discontinued.
-
- Nov 16, 2022
-
-
Jonathan Schöbel authored
The Validator saves the tags as an array. Now also another information is added, which slots aren't used currently to spare expensive calls to realloc. This led to a mere reimplementation of the functions. Tags can't be deleted by now, but the adding function supports reusing empty slots. Also the reading functions have to determine, whether a slot can be read or is empty. The tests were adjusted, but are buggy, so they should be rewritten in the future. Additionaly some annotations for splint were added.
-
- Nov 15, 2022
-
-
Jonathan Schöbel authored
Instead of the trivial structure SH_Error, SH_Status is used. The name was chosen, because error/status is set independently whether an error has occurred. Beside the error type, it also contains the associated errno and an error message. The error message is also printed, when it is set. Generating error messages with variadic arguments is now also supported. There are also macros to check for a set status. The exception handling was removed for the *_free methods, because they can't fail predictably during runtime. Unfortunately the compiler reports, that inside the macro set_status printf may be called with NULL [printf (NULL)], although, this is explicitly debarred.
-
- Oct 17, 2022
-
-
Jonathan Schöbel authored
The make process was restructured to create a library. For this libtool is used to provide both static and dynamic linking. Also header inclusion guards were introduced, to prevent clients of the library to include some single file without including others. The types were exported with forward declarations for better abstraction. When compiling the library, the macro LIB_SEFHT_COMPILATION is defined and symbol declarations are exported fully. For compiling the tests this macro is also defined, as the tests not only tests the API, but also the internal state, because a lot of errors couldn't be detected otherwise.
-
- Oct 16, 2022
-
-
Jonathan Schöbel authored
The method SH_Text_print just prints the whole string to stdout.
-
Jonathan Schöbel authored
The function SH_Text_get_length returns the length of the text. As the text also supports being longer than SIZE_MAX, this method can fail on runtime. If the text is longer then SIZE_MAX, the Text returns SIZE_MAX and sets error to DOMAIN_ERROR. Note, that due to the implementation, this is a non trivial function, so don't use it to exhaustively.
-
- Oct 15, 2022
-
-
Jonathan Schöbel authored
The function SH_Text_get_range returns a string begining at start and ending at end. Note that end specifies the char, that is not returned anymore. Thus the function implements something similar, as the pythonic slice syntax (text[start:end]). In opposition to the behaviour there, calling SH_Text_get_range with start > end is undefined behaviour. If start == end, the empty string is returned. If start is out of bounds, NULL is returned and an error is set. If end 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.
-
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.
-
Jonathan Schöbel authored
The method SH_Text_get_char returns a single character by a given index. If the index is out of range, NULL is returned and error->type is set to VALUE_ERROR.
-