Kevin Day [Tue, 14 Jun 2022 12:25:18 +0000 (07:25 -0500)]
Update: Add unit tests in f_utf project.
These tests are created based on the comments in the code.
Unlike previous tests, I reviewed the Unicode database separate of my code.
This approach is faster but will not expose any Unicode Codepoints that I missed when writing the code.
This adds tests for the following:
- combining
- phonetic
- subscript
- superscript
- wide
Kevin Day [Tue, 14 Jun 2022 00:02:51 +0000 (19:02 -0500)]
Update: Add some unit tests for f_utf.
Add the structure for the remaining tests.
The (currently) unused tests are just copy and pastes and may need changes.
With the exception of the "valid" tests, these unit tests use statically generated data files containing bytesequences (unsigned 32-bit) in base-10 format.
The base-10 format representation of the bytesequence is used for easy reading using standard libc functions.
These static data files are generated using a combination of the Unicode database codepoints, a script I wrote, and the "unicode" program.
The Unicode codepoints used for each generated bytesequence set are also provided.
This implements the following tests:
- control
- digit
- emoji
- symbol
- valid
The intent of this is to test the entire spectrum of valid codepoints (except for the "valid" tests which tests every single possible value).
Due to every single value being tested by "valid" tests for both f_utf_is_valid() and f_utf_character_is_valid() results in a long running test.
Kevin Day [Sun, 12 Jun 2022 04:23:37 +0000 (23:23 -0500)]
Update: Add script for generating Unicode Codepoints from integers.
A simple script that I am using for generating a range of Unicode Codepoints in the format needed by the generate_unicode.sh script.
The private use area is represented by multiple sets of all values within some range.
These ranges are a massive list.
This script generates these.
The only thing I need to do is use a calculator program to convert hex to integer.
These integers are then passed to the script as an inclusive range.
Kevin Day [Sun, 12 Jun 2022 03:52:52 +0000 (22:52 -0500)]
Update: Generate Unicode script to support generating test data.
The test data is generated from a line separate Unicude Codepoint file.
The generated test data is in base-10 format rather than hexidecimal to make it easier for standard libc functions like atoll() to be used.
Kevin Day [Sat, 11 Jun 2022 19:09:39 +0000 (14:09 -0500)]
Bugfix: Last character of file after conversion from code point is not printed by utf8 program.
The algorithm doesn't print the character until it knows when the character is complete.
There are no checks for when end of file is reached.
This results in the last character not being printed, even if the code is complete.
Be sure to return the status rather than always returning F_none under certain circumstances in utf8_detect_codepoint().
Update documentation about return value in utf8_detect_codepoint().
Initialize the character.used to 0 rather than 4 (because it has no data!).
For better practice, compare using >= rather than ==.
Remove unnecessary i = 0 assignment.
Kevin Day [Fri, 10 Jun 2022 05:16:07 +0000 (00:16 -0500)]
Update: Finish adding Unicode symbol handling code.
I used a script that I wrote to assist.
Additional tweaks were still necessary.
There is a lot of room for error, but this saved me an enormous amount of time.
Kevin Day [Wed, 8 Jun 2022 04:38:07 +0000 (23:38 -0500)]
Bugfix: Problems exposed by unit tests for f_signal.
Fix ordering of functions.
Compare using "== -1" rather than "< 0" because the POSIX standard says "-1" rather than "less than zero".
The f_signal_read() function has several problems:
- Should be passing a pointer rather than an array to poll().
- Needs to check data_poll.revents.
- Missing the parameter checking.
Kevin Day [Tue, 7 Jun 2022 03:39:30 +0000 (22:39 -0500)]
Bugfix: Problems exposed by unit tests in f_conversion.
The unit tests were disabled due to previous problems that are not no longer a problem.
This exposed a few areas that could be improved.
Rename "output" to "stream".
Make sure to call ferror_unlocked() to test for error.
Add loops to handle when fwrite_unlocked() doesn't write all the data but also doesn't throw an error.
Use "negative_or_zero" instead of "negative" to be more verbose and less confusing.
Kevin Day [Sun, 5 Jun 2022 22:57:27 +0000 (17:57 -0500)]
Cleanup: Fully remove stale/unused variables.
I simply assumed the compiler warnings meant that the variables were not used at all.
Looks like this is an incorrect assumption.
The compilers appear to more intelligent than I expected and can detect that even though the variables are modified later on, they still are not used.
This is good news.
The bad news is that means I have bad code resulting from an incomplete clean up that need to be fixed.
This bad code is now fixed.
Kevin Day [Sun, 5 Jun 2022 22:40:11 +0000 (17:40 -0500)]
Bugfix: Fix problems exposed by unit tests in f_status.
The signal bit can be confused with the error and warning bits.
The tests for checking if the signal bit is set need to test exclusively for the signal bit being set.
The tests for the error and warning bits do not care if this is a signal.
This is done to simplify some of the logic.
In the cases where the signal bit is to be tested, first check the signal bit and then check for the othr bits.
Kevin Day [Sun, 5 Jun 2022 21:03:14 +0000 (16:03 -0500)]
Update: Improve the logic in the string comparison tests.
Several of the F_parameter errors do not need to be returned.
This logic is already handled by the called functions as not matched.
Make sure the stop range is not longer than the buffer used.
When the buffer used is smaller than the requested range stop, then use the buffer used rather than the stop point.
Kevin Day [Sat, 4 Jun 2022 03:40:29 +0000 (22:40 -0500)]
Update: Handle more cases of combining characters following white space.
The way UTF-8 combining characters works continues to give me a headache.
This is a pass at resolving the case, but the logic is unfortunate.
I have a strong feeling that there is a regression from this.
At this point I feel unit tests are necessary.
Perform the combining check after checking white space.
Make the code more flexible by not returning on any invalid character.
An invalid character cannot be a white space, so treat it as not a white space and continue.
The resulting code should be more robust.
Kevin Day [Sat, 4 Jun 2022 01:17:40 +0000 (20:17 -0500)]
Bugfix: The print functions are not printing the last letter in certain cases.
The overflow check is testing against >= stop or length.
The equal sign is the problem here.
If the character ends on the stop point or the length, then a whole character would have been printed.
This is not an error and should not result in a return.
Changing >= to > fixes the problem.
Because of this, the additional width check is unnecessary.
Kevin Day [Fri, 3 Jun 2022 03:46:36 +0000 (22:46 -0500)]
Bugfix: Finish addressing trimmed printing is not working as expected.
The previous commit c8c59e16bb4cb7936142bff4815b302ad57138de is incomplete.
Finish addressing the todos and also catch other cases where trimmed printing is not working as expected.
The addition of the combining character checks introduces additional complexity.
This complexity is stronger reason to write unit tests for fl_print.
There is a lot of room for error as a result of this additional logic.
Kevin Day [Fri, 3 Jun 2022 01:09:30 +0000 (20:09 -0500)]
Cleanup: Rename "output" to "stream".
Using the word "stream" is a better and more precise term.
The word "stream" is already in use elsewhere and using this makes the project more consistent.
Kevin Day [Thu, 2 Jun 2022 04:44:06 +0000 (23:44 -0500)]
Update: Unit tests, fixing minor problems and adding missing functionality.
Many of the testfile files have "tests" when they instead should have "test".
The f_print must have a clang specific define passed to work-around a clang problem.
I noticed that I forgot to implement several "returns_data_not" unit test while writing the f_fss unit tests.
Provide these missing unit tests for the f_type_array project unit tests.
This project is my de-facto standard for basing all of my standard data type unit tests and needs to be as correct and up to date as possible.
Kevin Day [Thu, 2 Jun 2022 04:07:33 +0000 (23:07 -0500)]
Update: Fixes and changes resulting from f_fss unit tests.
After reviewing the code I found that the logic is outdated.
The logic was written at the time when I was still far less familiar with Unicode.
The zero-width is being processed in the same way as combining characters.
This needs to change.
After reviewing the combining character logic, I realized that there are bigger problems.
The combining characters, for whatever reason, are processed from right to left.
This breaks normal streaming logic and requires post checks on all variables.
I am amazed that they let such a horrible idea get into the standard and I do not know why.
Regardless, the logic on many of these functions needs to change.
The logic is changed to more properly handle the combining characters and additional more explicit code comment documentation is added.
There will likely need to be follow up changes in the processing code but I am going to leave that for another time.
Change the code to be more consistent with how F_data_not is returned.
Rename functions to more consistently follow the naming strategy used (such as changing "_between" to "_range").
Add f_fss_is_combining() function.
Remove unused and unnecessary f_fss_shift_delimit() function.
Remove unused and unnecessary f_fss_skip_past_non_graph() function.
Update the FSS specifications to better clarify the combining character situation.
The combining character logic implies that I need to return status codes to designate that the return is happening at the start of some processing.
Create several "_start" status codes to address this need.
Fix a bug from a previous commit that is the result of a misplaced regex replace ("alphabeticbetic" should instead be "alphabetic").
Fix a bug where some files where missed when refactoring is_alpha() into is_alphabetic().
Kevin Day [Sun, 29 May 2022 03:04:46 +0000 (22:04 -0500)]
Bugfix: Fix problems exposed by unit tests in f_print.
Swap the length a string checks, the length has priority over string.
When performing the character safely prints, the F_utf should only be returned for UTF-8 characters whose width is greater than 1.
The ASCII characters are now no longer returning F_utf.
Some functions are missing the clearerr_unlocked() and ferror_unlocked() calls that are needed for proper fwrite_unlocked() error checks.
Update the documentation comments, adding missing information.
Some of the *_to* functions are not checking if the counter "i" exceeds the length before checking for NULL.
The *_to* functions for *_raw_safely* do not exist and should to be consistent with the regular print functions.
Add the missing *_to*_raw_safely* functions.
Several of the *_to_except* functions are missing the offset parameter which should be passed for consistency with the regular print functions.
Random functions are missing the final print that should exist outside of the loop.
The "total" needs to be checked and if it represents that unprinted data is present, then print that data.
One problem is a copy & paste mistake in the declaration of fake_make_parameter_variable_option_build_s where the wrong define is used.
Make sure to conditionally allocate the arguments array before operating on the "used" position.
The used_content variable should not be needed because the arguments.used should be 0.
After conditional allocation, ensure that the arguments.used is 0 before operation and remove the no longer needed used_content.
When the reserved IKI variables that represent program parameters are used and exist in isolation for their argument, then they should expand as separate variables.
Consider these four examples:
print 1 parameter:"build"
print 2 parameter:"build".
print 3 "parameter:"build""
print 4 "parameter:"build\" between parameter:"build""
Lets say fake is called with the following "fake make -b /tmp/".
The "print 1" example would have the following parameters:
1) 1
2) -b
3) /tmp/
The "print 2" example would have the following parameters:
1) 2
2) -b /tmp/.
The "print 3" example would have the following parameters:
1) 3
2) -b /tmp/
The "print 4" example would have the following parameters:
1) 3
2) -b /tmp/ between -b /tmp/
The "print 1" expands into 3 parameters because the IKI variable is by itself for that given argument.
The "print 2" expands into 2 parameters because the IKI variable is not by itself for the given argument (It has a period '.' at the end).
The "print 3" expands into 2 parameters because it is quoted and is treated as a single argument.
The "print 4" expands into 2 parameters because it is quoted and is treated as a single argument and the "between" should still be between the two substitutions.
A break is added at the end of one of the loops because that part of the loop is only reached after a match.
When a match is identified, the loop no longer needs further iterations.
Kevin Day [Wed, 25 May 2022 03:15:41 +0000 (22:15 -0500)]
Update: Additional test settings and add initial coverage support.
The goal of the coverage is to support gcov.
I am very unfamiliar with gcov at this time.
The settings are experimental at best.
There will likely be numerous changes relating to gcov in the future as I learn the tool and devised a process to build coverage reports.
Kevin Day [Wed, 25 May 2022 02:11:44 +0000 (21:11 -0500)]
Update: The fake "build" fakefile Object needs to support modes and fix a related bug.
The fakefile needs to be able to support being passed custom modes.
The default behavior is preserved with this change.
This requires supporting that an empty string is passed as Content.
It turns out that the quoted empty string is incorrectly being skipped.
Make sure the quoted empty strings are not skipped.
Kevin Day [Tue, 24 May 2022 04:31:37 +0000 (23:31 -0500)]
Cleanup: Existing unit tests, adjust status check behavior.
I was lazy with the previous behavior and always cleared the error bits when performing the comparison checks.
Change the behavior to properly check the status code for when the error bit is expected and when it is not.
Kevin Day [Mon, 23 May 2022 02:39:27 +0000 (21:39 -0500)]
Bugfix: Combining and Width detection for utf8 are not properly printing.
The wrong data is being passed to utf8_print_combining_or_width().
Change the behavior to send the correct string to the function.
Move the error printing to a single function and use this function in all such cases.
Kevin Day [Mon, 23 May 2022 02:07:07 +0000 (21:07 -0500)]
Cleanup: Rename bytecode to bytesequence.
The term "bytecode" already exists and is used for a slighty different purpoe (representing compiled or partially compiled data).
This is a different context.
To avoid using the term improperly, switch to a more proper term "bytesequence" (as one word).
A byte sequence is a term representing a sequence of bytes.
This is more specific than binary and effectively emphasis that this is in regards to bytes.
Avoiding the term binary, however correct or not the term may be, helps avoid confusion due to "binary" and "text" data being considered two separate things.
Kevin Day [Mon, 23 May 2022 01:51:29 +0000 (20:51 -0500)]
Cleanup: Use macro_f_string_static_t_initialize2() with macro_f_string_static_t_initialize().
Using macro_f_string_static_t_initialize2() was the old way and is now deemed incorrect.
The macro_f_string_static_t_initialize2() applies the length parameter to both the used and size.
For static strings the size is always 0 because nothing is dynamically allocated.
Therefore, using macro_f_string_static_t_initialize2() for static string initialization is incorrect.
Kevin Day [Mon, 23 May 2022 01:47:53 +0000 (20:47 -0500)]
Update: Tweak endiannes for f_utf_char_t.
I continue to forget that the f_utf_char_t is a big-endian format regardless of the host endiannes.
I then end up comparing the endiannes logic to normal operations and find discrepancies.
I waste a good bit of time to ultimately realize that the f_utf_char_t is not in host byte order.
Update the comments to better represent this situation.
I also noticed that the big endian bitwise operations are going in the wrong directory.
I could be wrong, but I think I need to do a left shift rather than a right shift.
Or perhaps, this only needs to be done on a big-endian system?
I need to test this logic on a big endian system.
Kevin Day [Mon, 23 May 2022 01:45:31 +0000 (20:45 -0500)]
Feature: Add missing functionality allowing the utf8 program to convert back to binary data with invalid codepoints.
Even when there are invalid codepoints produced, it should be possible to convert the entire output back to the original data.
This is possible because the codepoint output by default still prints the invalid data as a hex-digit representing up to 4 bytes of data.
The combining and width parameters are also supported.
Kevin Day [Sun, 22 May 2022 03:06:56 +0000 (22:06 -0500)]
Update: Use F_utf_not instead of F_utf and other resulting changes.
The F_utf_not is semantically more correct than F_utf when returning an error for an invalid UTF-8 sequence.
Use F_utf_fragment where appropriate as well.
Updating all of the appropriate comments revealed some documentation and code structure problems in the fss projects.
These are cleaned up as well.
Kevin Day [Sat, 21 May 2022 21:22:13 +0000 (16:22 -0500)]
Update: Project f_utf.
While investigating the utf8 program, I looked into the f_utf project and found that it is still very much lacking.
At some point in the process of me writing this, the Unicode 14 was released.
I started the process of updating parts of the code and have made it as far as Gujarati with this commit.
Remove unused functions.
Add new functions for detecting if something is a superscript or a subscript.
Update the comments in the private functions to make it explicitly clear when a particular private function expects that only characters of width 2 or greater are provided.
There are some "todo" comments that need to be addressed before the stable release.
I'm expecting another release candidate at this point and so I am pushing off some of the Unicode updates onto after the next release candidate.
I noticed that the unit tests for f_utf only address the structures.
While this is disappointing it does save me the effort of having to write more unit tests for the newly added functions.
Kevin Day [Fri, 20 May 2022 04:50:36 +0000 (23:50 -0500)]
Cleanup: Stale code, improve usage, replace macros.
The primary focus of this commit is to remove stale code exposed by compilers.
This pass I used clang with -Wall.
Fixed some usage cases where the variables can be replaced with other variables.
I happened to notice some macros didn't need to exist and added the appropriate methods.
I did not search for other cases like this.
I only fixed what happened to be in front of me at the time.
Kevin Day [Fri, 20 May 2022 04:07:28 +0000 (23:07 -0500)]
Security: Add missing NULL at the end of string.
I was seeing "-Wno-missing-bracess" and "-Wno-logical-op-parenthese".
This looks exactly like invalid sizes.
I could not find the code that misplaces the NULL but in the process I found a different place where a NULL is in fact missing.
This adds the missing NULL.
I guess if one looks hard enough, then they will find what they are looking for.
It turns out that my original problem is actually two typos in a configuration file.
Kevin Day [Thu, 19 May 2022 05:56:28 +0000 (00:56 -0500)]
Update: Rewrite the f_serialize functions.
The code is outdated and needs to be updated with the current practices.
I remember being uncertain on what to name several of these functions.
I didn't want an f_unserialize function because that would require a separate project (even if the naming makes sense).
Perhaps I may do that in the future, but for now just use the words "from" and "to".
Kevin Day [Wed, 18 May 2022 02:48:50 +0000 (21:48 -0500)]
Security: The realpath() calls malloc() and free() is not called (memory leak).
I change the code and didn't realize that realpath() conditionally calls malloc().
When I change th code to pass a variable initialized to 0, I ended up triggering realpath() to call malloc().
This results in a memory leak.
Kevin Day [Tue, 17 May 2022 02:47:06 +0000 (21:47 -0500)]
Update: Specifications.
Started using IKI format in the specification files.
Made changes and performed fixes as I noticed them while copying the specifications to the website.
Kevin Day [Mon, 16 May 2022 00:25:15 +0000 (19:25 -0500)]
Bugfix: The iki_read program is not handling verbosity correctly.
The newline should be printed at the end of the program unless in quiet mode.
This fails for two reasons:
1) The conditional checks before printing are wrong.
2) The quiet parameter is at the wrong position resulting in it being mixed up with the "no color" parameter.
Kevin Day [Sun, 15 May 2022 23:49:47 +0000 (18:49 -0500)]
Feature: The iki_read program should support wrapping a variable value.
One of the original design intentions of the IKI standard is to allow for substitution.
That substitution includes wrapping text with something like HTML markup.
The current design of iki_read falls short here.
While the substitution can be performed, the wrapping while preserving the existing value is not performed.
For example consider the following:
emphasis:"Some message."
This should be substituted with the HTML5 "<em>" tag.
The substitute parameter requires knowing the value.
The replace parameter also requires knowing the value.
The emphasis HTML5 markup needs to be prepended and appended without having to know every single value.
To solve this, the -W/--wrap option is now available.
This is a 3 parameter option that acts similar to the -r/--replace parameter.
However, it will instead accept a "before" and "after" representing the before and after strings.
Either the before or after string may be an empty string.
The design of this feature re-utilizes existing structures.
These structures have context in their names that do not match "before" and "after".
This can be confusing, but this is considered an inconvenince at this time.
The goal is to keep the changes simple if at all possible with a stable release around the corner.
I also do now know what words to use to share between the different types without creating a new one to make such a change.
This feature is necessesary to ensure completeness with the original intent and design of both the IKI standard and the iki_read program.
Kevin Day [Sun, 15 May 2022 21:31:11 +0000 (16:31 -0500)]
Feature: The iki_read program should support a more generalized substitution process called "replace".
In the distant past I mixed up having only two or three substitution parameters.
After getting confused, I decided to just have a 3 argument substitution.
The three argument substitution only substitutes if both the variable name and the variable value match.
This is great but it doesn't follow the completeness theorem.
The iki_read should also handle the general case in addition to the specific case.
Provide a two argument substitution called "replace" that handles the more general case.
When any variable name matches the given replace parameter, then the variable value is replaced for all matching variable names regardless of the existing variable value.
Fix small mistakes in the IKI specification.
I needed to refer to the "variable value" with this change and "variable variable" is simply not the correct way.
Use "variable names" rather than "object names" to be more consistent and clear in this regard.
Kevin Day [Sun, 15 May 2022 16:06:46 +0000 (11:06 -0500)]
Update: Add cmocka specific environment variables to the testfiles.
These environment variables are commented out by default.
The "define" "settings" Object defines the environment variable.
The "environment" "settings" Object exposes that environment variable to any called programs.
Kevin Day [Sun, 15 May 2022 00:57:19 +0000 (19:57 -0500)]
Update: The f_limit project is out of date.
Writing unit tests revealed that the f_limit project does not operate like the latest code.
Restructure and rewrite f_limit to be consistent with the latest practices and designs in the rest of the project.
Kevin Day [Sat, 14 May 2022 19:42:46 +0000 (14:42 -0500)]
Update: Add new status codes and fix problems with existing ones.
The API will be frozen on the stable release.
There are upcoming changes in the next development cycle that will focus on networking.
Provide additional status codes that will be used in networking to make transition and compatibility simpler and easier.
There are also plans in adding init support to the controller program.
Operations such as halt and terminate become necessary.
While working on this I noticed this introduces a discrepancy between "terminate" and "terminated".
The "terminated" is meant to focus on buffers, such as a terminated string.
To fix this conflict, I decided to favor the practice of trying to always use present tense.
This means replacing "terminated" with a present tense word.
I chose "end".
There already is an F_end, so break out a new status section and move all of the newly minted "end" types into that.
While making these changes I noticed and fixed a few problems.
There is both F_warn and F_warning.
Remove F_warn in favor of F_warning.
The F_string_too_large and F_string_too_small checks are incorrectly returning F_too_large_s and F_too_small_s, respectively, when they instead should be returning F_string_too_large_s and F_string_too_small_s.