Kevin Day [Sat, 25 Dec 2021 22:38:31 +0000 (16:38 -0600)]
Feature: Add support for "context" IKI in Fakefiles.
This updates the IKI-0002 specification to support "context".
This allows for color context and ideally any future context to make software more accessible.
Update the existing testfiles to utilize this context.
Kevin Day [Fri, 24 Dec 2021 05:49:32 +0000 (23:49 -0600)]
Cleanup: Append "_e" to all enums, update status types, and update status strings.
A new practice is to have "_e" at the end of all enums.
Update all of the existing enums to follow this practice.
I noticed some fixme comments about moving the status codes to a lower level.
Do this.
Update all code accordingly.
The status code strings are only for special cases, so make this its own project directory (for both Status and FSS Status).
These are f_status_string and fll_fss_status_string.
Kevin Day [Thu, 23 Dec 2021 17:43:57 +0000 (11:43 -0600)]
Update: Use 'shell' rather than 'run' in testfile.
I apparently missed this line.
The 'run' operation will attempt to execute based on PATH environment.
The 'shell' operation expects local files, which is what these tests are.
Kevin Day [Thu, 23 Dec 2021 17:38:21 +0000 (11:38 -0600)]
Update: Add tests for f_type_array.
Given the size of the task and my relative inexperience with cmocka, I opted to keep the tests as simple as possible.
This means that my tests are likely not thorough.
These are intended to be good enough for a first pass tests.
After all, I have the entire rest of the FLL projects to write tests for (as well as for the programs).
Kevin Day [Thu, 23 Dec 2021 04:58:47 +0000 (22:58 -0600)]
Update: Move main data into the data make structure.
The goal here is to reduce the number arguments passed to functions in a consistent manner.
This has a downside of having another pointer and the costs of dereferencing it for each access.
Rename the "main" property to "id_main" to be clearer as well as to not conflict with the new "main" property that points to the main data.
Remove a stale header that has no associated function implemented.
Kevin Day [Thu, 23 Dec 2021 03:59:47 +0000 (21:59 -0600)]
Update: Add "and" and "or" operations, operation if-then-else logic, and some cleanups.
Add the "and" and "or" operations to make the "if" and "else" operations more complete.
The current design still does not support directly nested multiple operations underneath an "if" or an "else".
Using an "operate" operation is still the only way to do this.
The reason for this is to keep the logic and design simple.
This has a cost of causing complicated design to be even more complicated than they otherwise could be if I allowed "if" and "else" to contain blocks of commands or even be nested.
While I am at it, this cleans up the if-then-else logic.
This needed to be done for some time.
My original design was patched at some point to add unexpected functionality that I had not originally planned but later realized I needed.
The patch was just a good enough for now.
This resulted in the logic being a bit ugly and confusing.
The new logic is a lot better, but there are still some things that might be confusing.
To that end, I decided to only perform simple tests.
I instead intend to write unit tests that will perform all of the possible combinations that I can reasonably come up with.
This should help me find logic flaws in my current design.
This now uses a structure to pass the process state data.
This further simplifies the design to allow for fewer parameters in the relevant functions.
Several of the duplicated print calls are consolidated into a single print function.
Kevin Day [Thu, 23 Dec 2021 03:40:54 +0000 (21:40 -0600)]
Security: Invalid memory access in interrupt handlers.
When I converted the data_main into a pointer from a value, I failed to remove the references on these variables.
The compiler does not catch these because they are cast to a void *.
Kevin Day [Mon, 20 Dec 2021 05:19:23 +0000 (23:19 -0600)]
Update: Add support for if "not", add support for "parameter".
The "parameter" is already supported under "settings" in a fakefile.
Extend the operations to also support "parameter".
This allows for defining the parameter anywhere within the file and it can be overridden.
There exists several "if" operations that would make sense to have the inverse.
This is now supported via the if "not" operation.
To keep the logic more consistent with the previous design, just extend the existing code to handle "if not" behavior rather than adding new structures.
To achieve this, the pre-processor identifies "not" and then parses that to identify the particular "if" operation that is being negated.
The "if" operation is then change to a new operation type to reflect this.
Anything that already supports an inverse through some means are omitted from this.
This list includes:
- fail (opposite of success).
- success (opposite of fail).
- integer/math comparisons: ==, <>, <, <=, >, >=.
Fix the order of several of the functions that are not alphabetical.
Kevin Day [Sun, 19 Dec 2021 18:36:24 +0000 (12:36 -0600)]
Update: Relocate fake_main_t position in function arguments and make it a constant pointer.
The standard practice is all constants on the left and all updatable variables on the right of a functions parameters.
At some point I switched to passing the structures as a pointer rather than directly.
For these, I made them pointer constants.
That is, the pointer itself is constant but what the pointer is pointing to is not.
This allowed for me to move this type further to the left.
Keeping the main data and the fake data on the left side of the functions is a lot more consistent.
Kevin Day [Sun, 19 Dec 2021 18:18:03 +0000 (12:18 -0600)]
Bugfix: The "if defined parameter .." is not supporting reserved parameters.
There are several reserved parameters that are supposed to be supported.
Add code checking for the reserved words for the "if defined parameter" operation.
Update the documentation to better communicate these reserved words and how they operate.
Kevin Day [Sun, 19 Dec 2021 05:49:40 +0000 (23:49 -0600)]
Security: Segfault when "load_build yes" and "build settings".
When the fakefile settings is setup to have "load_build yes" and the fakefile operations has a build operation like "build settings" a segfault occurs.
This appears to be the result of casting the main path_sources to a constant pointer type from a reference.
Kevin Day [Sat, 18 Dec 2021 17:03:30 +0000 (11:03 -0600)]
Update: Improve IKI support, various cleanups, and a few bug fixes.
Allow for getting just the parameter option or parameter value for the special reserved IKI parameters.
This allows form something like:
define LD_LIBRARY_PATH "build/libraries/shared:parameter:'work:value'"
When populating the special parameters, the parameters not specified are getting saved.
This is incorrect.
Skip parameter that are not specified (f_console_result_none).
Kevin Day [Sat, 18 Dec 2021 02:11:34 +0000 (20:11 -0600)]
Update: IKI improvements, cleanups, and bugfixes.
The IKI project has fallen behind in some of the practices and is more consistent.
- Expose the delimit array to the caller rather than operating on it internally.
- This makes IKI more consistent with FSS and improves extensibility.
- Fix the global string names and macro need to follow the appropriate naming structure.
- Use strings rather than characters in the defines.
- Get rid of some macros, replacing them with functions.
- Use the *_increase() and *_increase_by() functions.
The FSS projects are now passing the delimit management to the callers.
IKI is now updated to do the same.
New data types, such as f_iki_delimit_t, are provided to achieve this.
When there are multiple separators, a colon ':', a valid IKI data might be skipped.
This is happening for two reasons:
1) Incorrect increment of the location after identifying a non-IKI defining colon.
2) The seek function is not stopping on special characters like a colon.
The iki_read program is updated to reflect these changes.
A new structure, called iki_data_t, is provided to simplify the arguments being passed around.
The iki_write program is updated to reflect these changes.
The make program is updated to reflect these changes.
Kevin Day [Wed, 15 Dec 2021 02:39:03 +0000 (20:39 -0600)]
Update: Switch to simple string and cleanup syntax and comments.
The f_string_static_t operations_name array can be converted to just an array of f_string_t.
Then the f_string_range_t operations_range can become f_array_length_t operations_length.
Then the operation_name can be removed (it appears to be unused).
Finally The fl_string_dynamic_partial_compare() can become fl_string_dynamic_partial_compare_string().
Update comments and add additional inline comments to help clarify situations.
Kevin Day [Wed, 15 Dec 2021 02:34:21 +0000 (20:34 -0600)]
Update: Don't bother checking, just always update pointer.
At this point the pointer has been allocated.
If the pointer addresses are the same, then there is no problem.
If they are different, then this properly replaces.
Assigning this just removes the extra step of checking.
Kevin Day [Sun, 12 Dec 2021 15:41:16 +0000 (09:41 -0600)]
Update: Restructure fake settings, moving examples into a new projects directory.
Create a projects directory to store some real replacements of other projects build systems.
The bzip2 build system was used as just an example and is now treated as a real use case.
I am planning on trying to use cmocka to provide unit tests for this project.
The cmocka uses that rather unpleasant cmake.
Provide a cmocka fake build setting file for building cmocka.
Kevin Day [Sun, 12 Dec 2021 05:59:06 +0000 (23:59 -0600)]
Update: Improve performance by removing redundant memset().
The calloc() program is supposed to guarantee 0 filled data.
Either the libc or the kernel know how to optimize this automatically using numerous tricks based on architecture or lack thereof.
This makes calloc() potentially faster than malloc()+memset().
Calling calloc()+memset() is just ridiculous.
Remove the calls to memset() that follow a calloc() call.
This is guaranteed to be a performance increase (but how much? I didn't bother trying to find out).
Kevin Day [Sun, 12 Dec 2021 05:50:23 +0000 (23:50 -0600)]
Update: Use C11's aligned_alloc() by default, but keep posix_memalign() via macro _f_memory_USE_posix_memalign_.
The C11 standard introduced aligned_alloc() making it better practice than posix_memalign().
In case the compiler being used doesn't have aligned_alloc() or the user compiling just wants to posix_memalign() this behavior is preserved via _f_memory_USE_posix_memalign_ macro.
I didn't actually test this beyond confirming that it compiles.
I'm flying blind here.
Kevin Day [Sun, 12 Dec 2021 01:14:05 +0000 (19:14 -0600)]
Cleanup: Utilize 'void' inside of function declarations.
It seems that by adding 'void' (without a parameter variable name) instructs the compiler that this function is not allowed to take arguments.
When the parameters are empty such as '()', the compiler simply disable checking what the parameters are.
By adding void this results in instructing the compiler to verify that there are no parameters.
This increases the code integrity.
This change may be a problem for older C compilers.
Kevin Day [Sat, 11 Dec 2021 22:31:08 +0000 (16:31 -0600)]
Update: Add documentation.
This is yet another reminder to me to try and avoid accidental commits.
I should have already had the documentation written up and be committed along with the initial commit.
Given that this project was accidentally committed before it was ready to, this left the project in less than ideal state.
As a reminder to myself to help encourage avoiding this mistake, I am constantly adding this oops notice to my commits.
With this documentation written, I once more believe that I have wrapped everything up that I need to consider this ready.
I previously thought this was the case, but as is seen by recent previous commits, this was not the case.
Going forward, I plan on investigating writing tests for this project and to use this project as an example of writing tests for the entire FLL probject.
This will hopefully allow me to find any remaining bugs and make this program production ready.
Kevin Day [Sat, 11 Dec 2021 22:06:37 +0000 (16:06 -0600)]
Feature: Support outputting width or combining state of characters.
The width is reported as one of: '0', '1', or '2'.
The following is used for unknown or invalid '?'.
The private use area is consider valid but unknown.
The combining state is reported as either 'C' or 'N'.
The 'N' can be considered either 'Not' or 'No' as the meaning is synonymous in this case.
The to_combining and to_width may be used together.
Now that I know how this is to be implemented, remove unneeded functions.
This is failing for two reasons:
1) Not using the original string data when printing detected invalid characters.
2) Performing the from codepoint check before checking the binary output check in the function utf8_print_character().
Also remove a redundant not zero check in the error print function utf8_print_character_invalid().
the function utf8_print_character_invalid() is a wrapper to utf8_print_character(), where that check is already performed.
Kevin Day [Sat, 11 Dec 2021 03:57:44 +0000 (21:57 -0600)]
Bugfix: Error handling should not exit for certain errors.
When a process signal is being received, F_signal is being set with the error bit.
This should not have the error bit set.
Move the conditional logic inside the appropriate printing functions.
Add utf8_print_character_invalid() for printing an error character.
Invalid UTF-8 fragments should not result in an exit on error.
Instead, these should be handled by either appropriate printing or by setting the is valid property on exit.
Kevin Day [Sat, 11 Dec 2021 03:36:42 +0000 (21:36 -0600)]
Bugfix: Raw formatted print sometimes prints trailing NULL.
A logic flaw is resulting in the last NULL after the max length is reached to be printed.
When the strnlen() calculates the length and the calculated length is the requested max length, the subsequent line attempts to print any NULLs.
This is normally fine, except that it needs to check to make sure that "i" is less than the requested max length.
Kevin Day [Fri, 10 Dec 2021 01:36:39 +0000 (19:36 -0600)]
Bugfix: Do not print leading zero's in large Unicode codepoints.
Also cleanup the code moving some generic print functions into utf8-specific print functions.
Use character rather than text to better communicate that the string is intended to represent a single Unicode character.
Kevin Day [Fri, 10 Dec 2021 01:17:43 +0000 (19:17 -0600)]
Bugfix: Codepoint to Binary is not working.
The wrong variable is being processed.
The codepoint (which is the Unicode representation, such as U+8C78 the codepoint is for the character '豸') is being width checked.
The binary character is what should be getting the width check.
A second situation where the codepoint is not being printed at all is with the files.
It seems that I forgot to finish writing this code (another problem caused by my original accidental commit of this project).
While investigating this I saw some opportunity for some cleanup.
- Move the width detection into a separate function utf8_process_text_width().
- Use character.string[0] instead of *character.string.
- Rename 'character' to 'current' to make more semantic sense (At the time I wasn't sure what to call it and 'text' was already unavailable).
- The 'text' in private-utf8_codepoint.c is now initialized in a simpler way.
Kevin Day [Thu, 9 Dec 2021 05:43:42 +0000 (23:43 -0600)]
Bugfix: Performance is slow due to process signal checks (more).
This is a follow up to the previous commit similarly named.
I forgot to hit the save button for the changes to FSS Basic List files in my editor.
The cost of the system call for checking if a signal is received is more expensive than I have previously imagined.
I also was not sure where I should handle the signals and I arbitrarily put them inside loops.
Reduce the number of checks.
Reduce the number of the system call to check the process signal using modulus math.
The performance difference is most notable when using the byte_dump program.
This focuses on solving the immediate performance bug.
I still have not done any extensive performance investigations and I expect this to still have significant room for improvement.
Kevin Day [Thu, 9 Dec 2021 05:21:57 +0000 (23:21 -0600)]
Bugfix: Performance is slow due to process signal checks.
The cost of the system call for checking if a signal is received is more expensive than I have previously imagined.
I also was not sure where I should handle the signals and I arbitrarily put them inside loops.
Reduce the number of checks.
Reduce the number of the system call to check the process signal using modulus math.
The performance difference is most notable when using the byte_dump program.
This focuses on solving the immediate performance bug.
I still have not done any extensive performance investigations and I expect this to still have significant room for improvement.
Kevin Day [Tue, 7 Dec 2021 03:51:02 +0000 (21:51 -0600)]
Update: Add missing function in f_utf needed for completeness and reduce repeated code.
As per my completeness principle, the f_utf_unicode_string_to() must have the f_utf_character_unicode_string_to() compliment.
This function only allows for ASCII characters to represent the number and returns errors as appropriate for non-ASCII values.
Unicode number values are not treated as the ASCII numbers for representing a Unicode code sequence.
The f_utf_character_unicode_to() and f_utf_unicode_to() now has code reduced by utilizing private_f_utf_character_unicode_to().
Kevin Day [Sat, 4 Dec 2021 23:03:56 +0000 (17:03 -0600)]
Update: Wrap up utf8 program.
This seems to be a good point to stop.
The program is only intended to be simple.
Complete the functionality and consider all future problems bugs.
Some of the parameters are not used correctly.
The strip-invalid is not being used.
The verify is being used as strip-invalid (this is likely the result of the previously incomplete code being accidentally committed).
Add a separate parameter to optionally separate by newlines when headers are not being printed.
The verify should disable printing.
The quiet verbosity should not hide printed headers as those are considered data.
Remove redundant newline being printed when headers parameter is used.
I had originally accidentally committed the utf8 program before it was ready.
I followed up with a cleanup after I noticed this.
It seems that there is still more work to finish.
Looking at what I need to do to finish this it has become clear to me that I was originally working on this and realized I should move functionality into the level_0 f_utf project.
When I did this, I probably noticed a Unicode bug and stopped what I was doing to fix it.
I then forgot to come back and fix this code, leaving it in this incomplete and broken state.
I also noticed that the f_utf_unicode_string_from() function is mis-named.
The is a "to" function rather than a "from" function because it is creating to a Unicode codepoint.
The "raw" print mode is now supported so use the fl_print_format() to print.
Move the printing of "append" to after the closing color context.
This makes more sense, but I have not bothered to check to see if the design logic is intended to be used this way.
Kevin Day [Fri, 3 Dec 2021 23:58:53 +0000 (17:58 -0600)]
Bugfix: f_utf_unicode_string_from() is not functioning correctly.
The code in this function is incomplete and incorrect.
I have a feeling I got distracted and came back later to work on it, forgetting what I was doing.
Use while loops rather than for loops for cases where the for loop would essentially have empty content.
It is clear that I intended to test for both upper case and lower case U but I didn't actually test against lower case.
The code is not incrementing after confirming there is a 'u' or 'U".
Kevin Day [Tue, 30 Nov 2021 04:14:00 +0000 (22:14 -0600)]
Update: More unicode improvements, byte_dump improvements.
Get rid of the use of declaring a byte_first, byte_second, byte_third, and byte_fourth variable.
The allocation of the variable is costly and consumes memory.
I am more recently of the opinion that the bitwise check is cheaper than defining a variable and then comparing.
Implement a significant portion of the blocks/planes for the unassigned detection function.
Have the byte_dump program treat unassigned as invalid.
This results in a cleaner display.
Kevin Day [Tue, 30 Nov 2021 02:42:06 +0000 (20:42 -0600)]
Update: Finish implementing combining character detection.
I consider this done.
There will be a pass sometime in the future where I review all of the codepoints before making the stable release.
I suspect, given the size of these kinds of changes, that there will be mistakes and oversights.
Kevin Day [Sat, 27 Nov 2021 05:06:30 +0000 (23:06 -0600)]
Progress: Major UTF-8 changes and optimization.
Add more combining characters.
As usual, with the UTF-8 codes I am focusing on getting it supported rather than getting it optimal.
Add wide character detection.
Any mistakes aside, this appears complete.
There are a lot of blocks within some sequence ranges, so I used ".." in the comments to designate that this is a range of blocks.
Update the byte_dump program to utilize both of these.
Kevin Day [Sat, 20 Nov 2021 03:26:18 +0000 (21:26 -0600)]
Progress: Major UTF-8 changes and optimization, begin updating byte_dump and utf8, and miscellaneous changes.
A previous commit accidentally include the utf8 level 3 program while it was being heavily developed.
As it is already committed, commit the latest changes.
The utf8 program is still not done.
While working on the utf program, I noticed that there are some things in the UTF-8 code that is not yet done or correct and is needed.
I also noticed that the byte_dump program needs to handle the narrow and wide widths to assure consistent column line ups.
Such a change requires new functionality in the UTF-8 code for processing the widths.
These two significant needs resulted in me finally getting around to some of the UTF-8 cleanup that I have been needing to do.
- Get rid of the width parameter, and calculate the width as needed (bitwise is chip and allocated a variable and then passing it along parameters is not as cheap).
- Swap some of the conditions to avoid using "!", saving a single operation though structural changes.
- Break out the utf string functions into its own utf_string.c, utf_string.h, private-utf_string.c, and private-utf_string.h.
- Numerous documentation comment cleanups and update (I think there is still more to do).
- Provide F_utf_fragment and F_utf_fragment_not for improved communication of UTF-8 fragments in error responses (rather than re-using F_utf).
- Provide f_utf_unicode_string_from() (I have not yet written a f_utf_unicode_string_to() but I plan to).
- Update endianess detection to use macros (I am include <endian.h>, but I may also provide custom macros to disable and explicitly designate endianess).
The UTF-8 is wide functions are drafted out, but there are a lot of wide character codes that I need to add.
This will be grunt work that will take a notable amount of time.
For now, just add a comment and I will get back to this.
The byte_dump program is depending on the is wide functions and so currently incompletely implements the narrow and wide support.
Try to use present tense in error message.
There are likely many more places, but this is a start.
Add F_first, F_first_not, F_last, F_last_not, F_next, F_next_not, F_previous, and F_previous_not for providing position return codes.
Fix a bug where width is being define by a uint8_t but the calculates are f_array_length_t.
How did this ever work before, by accident?
Kevin Day [Mon, 15 Nov 2021 23:34:06 +0000 (17:34 -0600)]
Regression: Previous byte_dump cleanup resulted in an extra space for one character.
The character 0xd89d is being handled in a special case.
This is previous code that is now identifiable as removable.
Stop handling this as a special case, avoiding the need to print extra spaces.
Kevin Day [Sun, 14 Nov 2021 04:39:06 +0000 (22:39 -0600)]
Update: Improve UTF-8 Control detecting, expanding to distinguish Control Code and Control Format.
There seem to be "Control Format".
Create functions for "Control Code" and "Control Format" (is_control_code and is_control_format functions).
The is_control functions now check for both.
Kevin Day [Sat, 13 Nov 2021 22:36:17 +0000 (16:36 -0600)]
Update: Implement double support in print functions and add missing functionality.
This implements the double support as a wrapper to the printf() functionality.
Future versions will ideally impliment this internally.
I observed that there is some incorrect logic with the "width" and the "precision".
The logic appears to be asserting that they are XOR to each other.
In actuality they are OR to each other and both can be provided.
Rename "output" to "stream".
This seems slightly more accurate to me.
I considered using "file" but that is heavily used by the f_file_t rather than the FILE *.
Kevin Day [Sat, 13 Nov 2021 16:07:53 +0000 (10:07 -0600)]
Bugfix: The print safely functions are not fully UTF-8 aware.
The f_print_character_safely_get() can only handle a single byte.
This makes it impossible to be UTF-8 aware.
Provide a new function f_print_safely_get() that accepts a string and a max width.
This string is intended to represent a single character, but can be multi-byte based on max width.
This function checks to see if the character is invalid or a control character, in which case it is replaced.
Kevin Day [Fri, 12 Nov 2021 05:04:37 +0000 (23:04 -0600)]
Update: Signal related updates, consistency improvements, and miscellaneous code cleanups.
Add support for setting the timeout via f_signal_read().
I am using both F_signal and F_interrupt.
The F_signal is more general and in this since is more accurate.
However, F_interrupt is more accurate to the intent in the design.
When an interrupt is received exit.
All signals being treated as an interrupt will need to exit, so just pass F_interrupt.
Provide a consistent reporting of handling the signals.
Setup all programs to catch and handle signals, allowing for a clean exit.
There are so many changes in this regard, I went for a quick approach.
In every loop that at glance look like it would be a good point to check for signal, the code now checks for signal.
There is likely a need for performance consideration in this.
There is likely a need for invetigating this further to make sure it is still responsive (as in, investigate to see if I need to add additional signal checks).
Programs like fake and controller already handle the signal.
These programs are update to be consistent with this newer design.
The "main" structure used in the programs is sometimes a constant variable and other times a pointer.
While there are performance and security reasons, I am finding that consistency is better at this point in time.
Pass all of the "main" structures as either a constant pointe or a pointer.
At some point in the future, I can see myself reviewing these and making performance improvements that might result in reverting some of this.
Having be more consistent will make the code a bit more mangeable during this highly active development and design period.
Miscellaneous syntax cleanups of any code that I happened to notice needs cleaning and can be easily cleaned on the spot.
When interrupting, flush the output and print a new line.
This is effective in properly cleaning the console (to some reasonable extent), which can be messy when exiting due to an interrupt.
I did not get a change to utilize the signal handling function callbacks in the FSS processing functions.
I will need to follow up this commit with such a change.
I need to see if the IKI processing functions also can do this and need to do this as well.
I haven't had a chance to really look at each of the programs after this change.
I will need to spend time making suring there are no regressions.
Kevin Day [Tue, 9 Nov 2021 02:36:22 +0000 (20:36 -0600)]
Update: Experimentall cast characters to uint8_t in UTF-8 processing code.
I've noticed with calls like printf("%d", string[0]) the printed number might be a negative huge number.
Explicitly casting it to uint8_t (rather than char) seems to be a way to avoid this and allow for the number to be better printed.
I am suspecting that this should be done in general rather than just to the print functions.
This is an experimental commit designed to make it so.
This also has an affect on bitwise operations because bitwise shifts respond differently between signed and unsigned integers.
Kevin Day [Tue, 9 Nov 2021 02:26:17 +0000 (20:26 -0600)]
Update: Fix print function bugs and add missing functions.
There are some cases where the logic is flawed and fails to print correctly.
Given a bash binary, passing it through the print functions and back to the disk in raw format resulted in a different binary.
The binary should be identical to the original and is not.
It seems that when I attempted to reduce the number of variables in the print function I failed to account for certain details.
This essentially reverts some of the previous logic and puts back the variables.
Many off these functions are almost identical but their differences result in requiring slightly different code.
This makes the code less manageable and easy to get lost in.
The code has been tweaked somewhat to be more consistent across the board, where possible.
This might come at a cost of some slight performance.
To make the code easier to read, separate the print functions into two groups:
1) The print functions that use file streams.
2) The print functions that use file descriptors.
This code is slightly different and while I could use macros to make this simpler, I opted to avoid macros at the cost of duplication.
Move these two groups into separate files, significantly improving code readability.
There is a mistake in the previous code where errno is being processed for file stream errors.
The libc file stream functions do not utilize errno.
Change the affected code to just return F_output with the error bit set.
I am unable to find a discrete list of error codes returned by ferror().
I will need to additional work to get these codes so I can properly map them to more verbose error codes.
The documentation is no longer out of sync.
There should be a file descriptor function equivalent for nearly every file stream function.
In this regard, several missing functions are now added.
This is an unplanned change that is rather large.
I am concerned with oversights and regressions.
Just keep an eye out for regressions and hope that there are none.
Kevin Day [Fri, 5 Nov 2021 01:53:17 +0000 (20:53 -0500)]
Bugfix: UTF-8 functions fail to properly handle ASCII.
This seems to be a problem where there are two ways of processing ASCII detection of UTF-8 code.
The macro_f_utf_byte_width() will return the width of 1 for ASCII.
The macro_f_utf_byte_width_is() will return a width of 0 for ASCII.
The affected code is assuming a width of 0, but some functions send a width of 1 for ASCII.
These are private functions, so it is relatively safe to just allow both.
Change the behavior to accept both 0 and 1 and treat them as ASCII.
Update comment about Unicode 12.1, setting it to 14.0.
Kevin Day [Thu, 4 Nov 2021 05:12:12 +0000 (00:12 -0500)]
Update: Add "success" color context and initialize color "set" in programs.
There is an "error" and a "warning" but no "success".
Make this complete by adding "success".
The programs aren't initializing the "set".
Attempting to use these always results in no color context.
Fix this by initializing these in each program.
The output context also needs to be initialized just like the error and warning.
Kevin Day [Tue, 2 Nov 2021 03:49:49 +0000 (22:49 -0500)]
Cleanup: Break apart controller sources.
The functions have gotten too large an are in a need of cleanup.
Create additional source files and move functions around as appropriate.
Do some function renaming as well.
Move the print functions into separate print source files.
This is done only for functions whose sole purpose is printing and is not nor should it be done for functions that happen to have printing within them.
The entry pre-process and process functions should be in the entry source files.
Fix the name of those functions to start with "controller_entry_" rather than starting with "controller_process_".
Move any structure construct and destruct functions into the common.h and common.c that are not already there.
Break out the build settings file settings into multiple lines.
I prefer not to have too many extra lines, but there is a point when the lines get absurdly too long.
The lines are broken up by some context or pattern.