Kevin Day [Tue, 15 Feb 2022 06:47:20 +0000 (00:47 -0600)]
Update: The build setting path_sources is not being properly used and improve skeleton process.
Resolve the fixme regarding the path_sources_object and similar.
Consolidate the static source build into functions.
The fake_build_setting_name_preserve_path_headers_s is in the wrong location, resulting in the incorrect loading of build settings data.
Provide default for path_sources.
Make the main->path_sources a prefix path where all sources exist (there will likely need to be a follow up commit to address this in bootstrap.sh).
Get rid of the path_source_* forr bash, c, and other custom paths.
Get rid of the redundant version default assignment in fake_build_load_setting_defaults().
Rename fake_build_load_setting_defaults() to fake_build_load_setting_override().
Kevin Day [Tue, 15 Feb 2022 03:24:44 +0000 (21:24 -0600)]
Refactor: Remove "_type" from f_type_array functions.
The f_type_array project is really just an exception case extension of f_type.
It's purpose is to provide the array functions for the associated array structures in f_type.
These cannot be stored in f_type due to circular dependency needs for the f_memory project.
I used f_type_* to prefix these functions but the inconsistency between the structure names has shown to be a problem.
Rename these functions to not have the "_type" within them.
Kevin Day [Mon, 14 Feb 2022 05:34:15 +0000 (23:34 -0600)]
Refactor: path_standard to has_path_standard.
Just like with the preserve_path_headers, change path_standard to has_path_standard.
This hopefully makes the terminology easier to understand by maintaining that all path_* Objects represent paths.
The commit changing path_headers_preserve to preserve_path_headers could have made more changes.
Further update preserve_path_headers to handle what was missed.
Kevin Day [Mon, 14 Feb 2022 04:58:26 +0000 (22:58 -0600)]
Regression: The path_headers_preserve isn't properly being processed and refactor it to preserve_path_headers.
It seems that I changed the path_sources.used to path_headers.used, probably thinking that I had previously made a mistake.
Rename the preserve to preserve_offset to make the intent and purpose more obvious.
The preserve_offset represents and offset to skip before performing the preserve.
The path_sources is the path that should be ignored (path_headers is not used here!).
Refactor path_headers_preserve to preserve_path_headers to make it clearer that this is not a path but instead a property related to a path.
Kevin Day [Mon, 14 Feb 2022 04:04:15 +0000 (22:04 -0600)]
Feature: Fake build settings now supports compiling only object files.
I've observed that many programs like to compile each source file separately by passing "-c" to GCC.
Then the linking is done separately.
I believe unit tests may benefit from compiling individual object files for cases when mocking needs to be performed only for select functions.
With an upcoming stable release planned, I felt that now is the time to get this in.
Due to limitations of the compilers, only a single object file may be generated at a time.
Multiple generated object files may be combined into either a library or a program.
Object file generation is shared vs static aware.
Custom defines and flags may be specified for building objects.
It is now possible to compile different objects files for the generated library and for the generated program.
These are improvements to the build settings build process.
The make build process is still available for more advanced compiling.
An example project, called "example-objects", is provided to demostrate how to utilize the build settings and a fakefile to compile multiple objects separately and then combine them into a single program.
Additional fixes and improvement were necessary to properly complete this feature.
Summary of additional fixes and improvements:
- Improve default handling behavior in both fake and bootstrap.sh.
- Provide more defaults, such as having "compiler" default to "gcc".
- Massive cleanup of the bootstrap.sh (bootstrap.sh is now much closer to matching the functionality of the fake build settings).
- Update documentation.
- Add an error message for when an unknown build mode is passed to the boostrap-example.sh script.
- Fix bug in f_path_directory_cleanup() where the termnating NULL is being included in the count.
Kevin Day [Sat, 12 Feb 2022 00:25:16 +0000 (18:25 -0600)]
Refactor: project_name t build_name.
Originally the build settings files are meant for projects.
I now believe that these should represent "builds".
Replace "project_name" with "build_name".
Kevin Day [Fri, 11 Feb 2022 04:32:22 +0000 (22:32 -0600)]
Progress: Continue mass converting to f_string_static_t.
This should get all of the programs compiling again.
There is still more work to do with switching to f_string_static_t, but the current pass is considered complete.
Another pass will follow up shortly.
Kevin Day [Fri, 11 Feb 2022 00:14:01 +0000 (18:14 -0600)]
Refactor: fl_console_parameter_to_string_dynamic_directory() to f_path_directory_cleanup().
I decided to improve the mentioned function and realized that it could be further generalized and move into the f_path project.
There is nothing else in fl_console and as such the fl_console project is entirely removed.
Kevin Day [Thu, 10 Feb 2022 03:45:28 +0000 (21:45 -0600)]
Bugfix: The prepend option is being incorrectly applied.
This is a bug that results from a naming context conflict where the "prepend" string must be "appended" to the buffer.
The f_string_dynamic_append() should be called instead of f_string_dynamic_prepend().
Kevin Day [Wed, 9 Feb 2022 04:53:22 +0000 (22:53 -0600)]
Progress: Continue mass converting to f_string_static_t.
Some of the append functions use *_adjust() functions and are now using *_resize() functions.
The f_string_dynamicss_t and similar structures are added.
This is done hastily with the expectation that I will get to writing unit tests eventually and will better review this code.
Kevin Day [Wed, 9 Feb 2022 04:49:03 +0000 (22:49 -0600)]
Security: Invalid read in private_f_print().
The variable "i" is incremented inside the loop without checking that i < length.
This potentially results in an invalid read (such as when the string is not NULL terminated after the designated length).
Kevin Day [Tue, 8 Feb 2022 05:39:57 +0000 (23:39 -0600)]
Bugfix: Bugs and regressions in recent "Progress:.." commits as well as in the Fake program.
This is in a way a continuation of the "Progress: Continue mass converting to f_string_static_t." commits.
However, there were some notable bugs that needed to be brought out and I feel they deserved to be treated as a bug rather than in-progress code changes.
Put the testfile context in a quote and fix the color context to perform the reset rather than leak red all over the console.
NULL terminate some f_environment functions to make compatibility with working with NULL terminated string functions more straight-forward.
This is noticed with the libc/POSIX execute family of functions.
The fl_console_parameter_to_string_dynamic_directory() needed to be converted in regards to the mass converting to f_string_static_t.
Make sure NULL termination is performed, which is previously may not have been (prior to transition to f_string_static_t, making this a bug).
I accidentally over-fixed "c1906053 Bugfix: File stream read inefficiency, allocation f_string_t instead of char, and actually use state.step_small.".
There is a case where the array is in fact an array of f_string_t and I incorrectly changed it to "char", resulting in a regression.
Have the fll_fss_snatch_apart() use *_increase_by() and similar functions rather than *_resize().
The *_resize() functions are more expensive in that the *_increase_by() only perform reallocations when necessary whereas the *_resize() almost always performs reallocations.
Make sure fll_fss_snatch_apart() calls f_string_dynamic_terminate_after().
I started to convert some of the macro delete functions in the Fake program to actual functions, but this process is very incomplete.
Add a couple of cache objects to th Fake program.
There are a lot of areas where caching can be used for increasing memory use efficiency, but much of this is ignore for now.
I hope to do more work in more completely utilizing caches in the Fake program before the upcoming stable release.
The Fake program needs to use the fake_default_allocation_small_d more consistently rather than F_memory_default_allocation_small_d.
Miscellaneous "Progress: Continue mass converting to f_string_static_t." related changes in the Fake program.
Some of these are just f_print_format() string fixes where '%S' is changed to '%Q' or '%r'.
The fake_make_operate_process_run() can be optimized to just perform an offset on the array rather than making an entirely new copy.
This should save a notable amount of memory.
Kevin Day [Mon, 7 Feb 2022 03:03:52 +0000 (21:03 -0600)]
Bugfix: File stream read inefficiency, allocation f_string_t instead of char, and actually use state.step_small.
The file stream reader requires the buffer to be pre-allocated.
Prevent the resize from resizing an extra time if the resulting size read is smaller than the requested size.
The caller can then optimize this by setting the read size to 1 digit larger than the actual file size.
Also switch to fread_unlocked() and handle the locks manually.
The strings are being allocated as f_string_t.
The f_string_t type definition is actually a "char *".
This is the size of a memory address (and could be as large as 64-bit type on 64-bit architectures).
This is a huge mistake because this should only be using size of char, which is 1.
I provided a state.step_large and state.step_small to the FSS functions as a quick solution for more control over memory management.
It turns out this is not being used and for very large files this can be very wasteful.
In the long term, I believe a better fix is needed where the files are pre-processed to determine the objects and contents.
Then, the structures can be allocated with a known size.
The reason for this is that it seems that memory resizes are significantly more expensive than processing an arbitrarily large string.
Increasing the cost of processing that string from one time to two times is likely worth the cost to save time and resources lost due to memory re-allocations.
Kevin Day [Sun, 6 Feb 2022 17:13:06 +0000 (11:13 -0600)]
Progress: Continue mass converting to f_string_static_t.
I've noticed several things that need cleaning and improvement, such as:
- I should make an f_string_dynamic_partial_rip() and have f_string_dynamic_rip() be consistent with other functions lie f_string_dynamic_append().
- iki_read is a bit sloppy in memory, I need to figure out why (and I imagine other are too).
- I've started clearing out old uses of object and content but I am concerned that I overdid the cleanup (I need to re-check some of this in the FSS programs).
There will most definitely need to be another cleanup pass on all of the programs focusing on cleaning up and improving the programs before I make my stable releases.
For now, I am ignoring those problems so I can better focus on f_string_static_t conversions.
Once the programs are updated with the current set of f_string_static_t, I still need to go through all of the remaining level_2 and lower functions to convert many of the functions still using f_string_t that should now be f_string_static_t.
Kevin Day [Sun, 6 Feb 2022 00:57:37 +0000 (18:57 -0600)]
Progress: Continue mass converting to f_string_static_t.
Of particular note are:
- Implementation of fll_program_data_t to provide a standard structure for basic use.
- f_color deallocation function with appropriate unit tests.
Kevin Day [Mon, 31 Jan 2022 04:40:58 +0000 (22:40 -0600)]
Progress: Continue mass converting to f_string_static_t.
The console program has been changed to populate an argv as a f_string_static_t.
This avoids having to run strlen() and strnlen() everywhere for console parameter processing.
The program that processes the parameters already does this, so save the values in an f_string_static_t.
Kevin Day [Fri, 28 Jan 2022 02:05:50 +0000 (20:05 -0600)]
Progress: Begin mass converting to f_string_static_t.
While working on the control and controller programs I realized that I should move from f_string_t to f_string_static_t.
This is a major change but it must be done before the API freeze for the stable release.
A long time ago, early in the design process of FLL, I considered using f_string_static_t (which was only f_string_dynamic_t at that time).
I had decided for simplicity and stuck with f_string_t.
In practice I have found that I was doing a lot of working creating f_string_static_t only to do more work to move it back to f_string_t.
This is an overall simplification of the project at the cost of some resources and some flexibility.
I've only just begun but I am already seeing what I believe to be is simpler code.
The biggest gotcha will be this will likely introduce bugs due to the sheer size of the changes.
The primary bug that will not be easily detected are the formatted print where '%s' needs to now become '%q' and '%S' needs to now become '%Q'.
There are also numerous potential optimizations that I am ignoring for now due to the size of this commit.
This work is by far not done and I expect all programs to fail.
I only tested compiling fake and I got it as far as running the help program.
Kevin Day [Wed, 26 Jan 2022 03:26:26 +0000 (21:26 -0600)]
Update: Add f_conversion unit tests.
There are far more permutations than what are handled within this commit.
Focus on only the most basic set of checks to write the unit tests for.
There are problems with mocking fwrite_unlocked() via the wrap strategy used by the linker.
I do not know why this is not working so I commented out the code and moved on.
Several problems are exposed and are solved.
- This exposed the fwrite_unlocked() return results problems.
- Add support for big endian (untested).
- Zero values are not correctly built (see below).
Make sure to count the zero number as a single digit.
Get rid of the "used" count and rely only on the digits.
Do not include the 0 digit when determining the padding.
Change the prefix append function to accommodate 0 and consistently call the prefix append function.
Kevin Day [Mon, 24 Jan 2022 01:33:55 +0000 (19:33 -0600)]
Update: Fix incorrect documentation and remove pointless code.
The documentation for some functions do not accurately reflect what the documentation does.
This is likely a copy and paste over sight.
The f_string_dynamic_resize() is adding one to destination->used.
It then updates the used to be that new number minus one.
This is pointless.
Don't bother with the "total" variable at all.
Also use the F_memory_default_allocation_small_d by rather than 1 when resizing.
Kevin Day [Wed, 19 Jan 2022 00:37:32 +0000 (18:37 -0600)]
Update: Use libc functions more in f_color.
The f_string_dynamic_increase_by() guarantees the size is allocated.
The f_string_dynamic_append() doesn't need to be called when the simple memcpy() can be directly called.
Doing this saves the status check and the additional function calls.
This likely increases performance but this performance increase potential has neither been tested nor confirmed.
Kevin Day [Mon, 17 Jan 2022 17:44:14 +0000 (11:44 -0600)]
Bugfix: The f_console project after writing unit tests.
Rename has_values to values_total to better communicate the intent of the property.
Expand out the macros across lines.
In f_console_identify() the strnlen() function is not properly handling when the character pointer is NULL, resulting in a segfault.
While this might be considered a bug in strnlen(), just make sure that a NULL pointer is not sent to strnlen().
Kevin Day [Mon, 17 Jan 2022 05:28:08 +0000 (23:28 -0600)]
Cleanup: Add back the two spaces before the "-" in the comments.
When in the comments with the " * " at the start, the behavior of not having the extra space seems fine.
When looking at the documentation and specification FSS files, I find that it is easier to read with the extra spaces.
I have decided to switch back and follow what I am doing in the documentation and specification FSS files.
This makes the style more consistent.
Kevin Day [Mon, 17 Jan 2022 03:01:44 +0000 (21:01 -0600)]
Update: Rewrite f_color functions and use f_string_static_t instead of f_string_t for global constant strings.
Switch to using the f_string_static_t so that the size does not have to be constantly tested via an strnlen() or similar call.
The f_string_static_t by default uses 64-bit types for size and used so there may be a performance hit due to this over the normal 32-bit numbers in strnlen().
Originally macros were used to reduce code repition.
This was done long before I decided to make f_string an exception that can be depended on by all level 0 projects.
The dynamic string functions can now be used, significantly simplifying the code.
The macros can be replaced with functions 1 through 5 to allow for only passing the required arguments.
This should reduce the cost of the function call by having fewer arguments when not necessary to have them.
The documentation comments are now present when they were not before.
Change the order of the function parameters to be more consistent with the latest practices.
Kevin Day [Sun, 16 Jan 2022 22:52:25 +0000 (16:52 -0600)]
Cleanup: Add additional initializer for f_string_static_t to allow initializing all parts.
Another acceptable practice is to set the used to some value greater than zero and size to zero to better designate that this is a static string and is not dynamically allocated.
Kevin Day [Sun, 16 Jan 2022 21:15:09 +0000 (15:15 -0600)]
Cleanup: Rename f_account functions in attempt to be easier to read.
I originally tried to group the logic by "name" and "id".
This becomes confusing when there is "group name" and "user name" or "group id" and "user id".
The function name with the structure "f_account_id_group_by_name" is intended to be understood as get id of group by name for account.
However, because account is in front (part of f_account) it could be easily misread as get account id by name with some spurious "group" injected.
This is clearly a bad interpretation but that interpretation is easy to think of.
Drop "user" because "account" and "user" should be synonymous.
Move "group" to the left in all cases to designate that this is about "group" associated with account.
Now f_account_group_id_by_name sounds more like get id of group by name for account.
Change the logic to not require format strings to be defined thereby avoiding potential segfaults.
Avoid using strnlen() and instead use memcpy().
More memory is used when specifying the sizes, but strnlen() calls probably does this to some extent.
Doing this reduces the number of calls to copying ranges of strings.
Kevin Day [Sat, 15 Jan 2022 23:01:53 +0000 (17:01 -0600)]
Update: Lay out the foundation for proper endianness support.
The endianness support is not currently a direct goal of the 0.4 versions.
The 0.6 versions will deal with networking and will most certainly need proper endianness support.
Ultimate the FLL needs to properly handle endianness.
Provide the initial functionality needed to make this possible.
The BIG_ENDIAN and LITTLE_ENDIAN cannot be directly relied on.
Provide custom _is_F_endian_big and _is_F_endian_little macros where when BIG_ENDIAN is not defined default to little endian.
By using the custom _is_F_endian_big and _is_F_endian_little, allow for the endianness to be explicit set at compile time.
This should make it easy to configure in cases where BIG_ENDIAN and LITTLE_ENDIAN are not defined.
Kevin Day [Fri, 14 Jan 2022 01:45:39 +0000 (19:45 -0600)]
Bugfix: IKI variables are not substituting consistently.
There appears to be a logic flaw where when more than one IKI variables are present, they start overwriting.
I changed the logic to focus more on the content loop.
The arguments array is only incremented for the content row.
When the resulting row is empty and is not quoted, then do not increment the arguments array.
Remove unnecessary NULL insertions.
The only time the NULL needs to be inserted is at the end when done adding all of the characters to the argument buffer.
Kevin Day [Thu, 13 Jan 2022 00:14:57 +0000 (18:14 -0600)]
Update: Provide more details in the documentation on if/else logic.
With the logic being different from normal conditional logic, I figured that it would be a good idea to add more documentation to further clarify the design.
Traditional logic is:
A and B or C and D
Where order of operations would be:
1) If A and B are TRUE...
2) If C and D are TRUE...
3) If (1) or (2) are TRUE...
The logic used by this program would be:
A and B or C and D
Where order of operations would be:
1) If A and B are TRUE...
2) If (1) or C are TRUE...
3) If (2) and D are TRUE...
Kevin Day [Wed, 12 Jan 2022 23:57:19 +0000 (17:57 -0600)]
Bugfix: More cases where if/else is not working as intended.
In the previous commit I accidentally removed the "or" condition.
I also found that I needed to be more thorough with the logic.
The condition result needs to be returned and handled when immediately returning.
This then allows for subsequent conditions to use the condition result.
The condition result gets reset on each pass of the loop.
The block result needs to then retrieve the condition result to ensure the result is preserved across loop passes.
Kevin Day [Wed, 12 Jan 2022 03:48:43 +0000 (21:48 -0600)]
Regression: The "failure" operation if condition type is not working as intended.
The documentation and specification is out of date and refers to this as "fail".
This is instead the word "failure".
This is also different from the setting "fail" that designates what to do on failure.
With one of the recent re-designs of the process logic, the failure status is no longer being passed.
When the "fail" setting is set to "warn" or "ignore", the status code of F_none is returned.
Change the return status to "F_failure" without the error bit to designate that this is a failure but it is not being treated as an error due to the state of the "fail" setting.
Then process the "F_failure" without the error bit to remember the state that a failure occurred.
This then allows for the "failure" if condition type to get triggered.
The recent if/else logic changes introduced behavior where a failure in the processing of the if/else commands should also trigger the "failure" if condition type.
This failure is not associated with the if condition results.
When an if condition results in either true or false, then this is considered a "success" rather than a "failure".
Generally, syntax failures are what trigger the "failure" state.
Programs that are executed, such as when using the "run" operation, will result in "failure" if a non-zero value is returned by the program.
Kevin Day [Wed, 12 Jan 2022 02:30:28 +0000 (20:30 -0600)]
Bugfix: If/else condition logic is incorrect or incomplete.
The if/else logic is not properly traversing.
I believe the original design is to just have if and else be a single set rather than a chain.
At some point I changed this to be chainable (or maybe I am incorrectly thinking that I did).
It made sense to use this if/then chain logic for my unit test files.
The Fake make unit test files are not working as I want them to because if/else chaining is not working.
As a big disclaimer, this does not support nesting.
I continue to refuse to design nesting of the if/else condition logic as I want to keep this as simple as possible.
Which, by the way, this is not simple.
I attempt to cut corners when I did my recent rewrite of the if/else logic.
Redesign this (again) but this time attempt to do this more properly.
The block process state now exclusively uses a special block process state enumeration rather than relying on a synthetic rule type.
The synthetic rule type is now removed.
The goal with this design is to:
1) On syntax error, bail out of the entire if/else chain.
2) On comparison error, continue an if/else chain passes or the end of chain is reached.
3) When any if/else chain passes, all subsequent conditions in the chain are not run.
Replace the "done" condition result with an "error" condition result to more accurately communicate its use.
Isolate the block and block result from the operate processing as much as possible so that all modifications of the variable are done outside of the operate processing.
When the "fail" is set to "exit" the if/else should fail appropriately on syntax error.
When the "fail" is set to "warn" or "ignore", then continue on after skipping the entire chain.
The operate process still needs to check the if/else chain states to determine if it should skip or not.
When an if/else condition terminates unexpectedly due to an end of file (or section) an error is more consistently reported regardless of place in the if/else chain.
This still needs real testing to confirm that all of the possible permutations work as expected.
Unit tests for this will need to be written but this is a long way away from being done.
Kevin Day [Mon, 10 Jan 2022 03:35:03 +0000 (21:35 -0600)]
Update: Implement f_capability unit tests and improve existing unit tests.
Add tests for f_capability functions.
This includes my first go at mocking functions using function wrapping.
It seems that the linker is limited on how it handles function wrapping.
I cannot simply wrap functions pulled in via a library.
To work around this I implemented another Fake build settings file for handling this.
This is not an ideal situation and adds a bit of extra work.
The environment variable settings for LD_LIBRARY_PATH needs to also support the work parameter.
These changes expose a logic flaw in the if/else logic of the Fake program.
That bug is not fixed in this commit, it is simply noted in this commit log.
Kevin Day [Mon, 10 Jan 2022 03:30:55 +0000 (21:30 -0600)]
Bugfix: Fix problems exposed by unit testing and perform cleanups.
f_capability_ambient_set() should not be testing for (!value_flag).
Te flags pointer test should be "flags" and not "*flags".
Explicitly cast capability to void * for cap_free().
Use "value" rather than "code" for "f_capability_value_t".
Expand out CAP_IS_SUPPORTED() and CAP_AMBIENT_SUPPORTED() to explicitly set F_true and F_false.
This is better than relying on the direct result of those macros.
Make sure f_type support "weak" compiler attributes.
Rename the compiler attributes to be more than just for visibility.
Kevin Day [Sun, 9 Jan 2022 03:48:52 +0000 (21:48 -0600)]
Cleanup: Simplify structure using more basic file names and using separate print files.
These are private files and are not intended to be exposed.
This allows for the names to be more generic.
Break out the print functions into their own separate files.
This will also make the code more multi-lingual friendly in the respect that much of the code that might need to be swapped out exists in a single file.
This is still very far from multi-lingual friendly with many print code still not in the isolated print functions file.
Kevin Day [Thu, 6 Jan 2022 05:08:59 +0000 (23:08 -0600)]
Update: Have fss-000e Payload be more specific about payload handling.
Because payload may be anything, especially a binary blob, having it always be last as a requirement makes the most sense.
This then allows me to guarantee comments and other lists may not be after or inside.
This allows for the payload to not have to have comments or delimited code to deal with.
The payload will be a complete virgin binary blob until EOF or a designated length is reached.
Kevin Day [Thu, 6 Jan 2022 04:40:45 +0000 (22:40 -0600)]
Bugfix: Valid comment lines are keeping leading white space.
Any line that ends up being a valid comment line may have white space on the left.
For lists, such as FSS Basic List, the leading white space is being printed.
This is not correct at all.
This is easily solved by getting the last new line and add one.
Update the specification to make the expected behavior clear.
Cleanup comment lines and other related code while its convenient.