Kevin Day [Sat, 11 Sep 2021 03:44:15 +0000 (22:44 -0500)]
Feature: Enable config.h, config.c, and config.cpp support in package generation.
There is a common practice of having a config.h for local build time changes to be applied.
Provide a skeleton structure for this by default when building the FLL packages.
These files will be empty.
The user need only populate these files as needed.
This could be done manually, but doing this by default effectively documents the proof of concept with a working/functional example.
Kevin Day [Fri, 10 Sep 2021 03:10:18 +0000 (22:10 -0500)]
Feature: Controller Program should support uninterruptable and define default behavior.
After designing the Controller to support operating directly as "init", it later occurred to me that the default behavior of uninterruptable makes sense for "init" but not for "controller".
Change the behavior to default to interruptable for the "controller" program.
This change further implies that the program needs an opposite to the "--interuptable" parameter.
Implement the "--uninterruptable" parameter for this purpose.
I also noticed that there is already an "interrupted" variable but that code is dead.
Oops.
Resurrect this variable and use it for identifying for this updated interruptable behavior.
Kevin Day [Fri, 10 Sep 2021 01:47:48 +0000 (20:47 -0500)]
Feature: Allow controller program to operate directly as "init program" by default.
The controller program already supports operating as an "init" program.
The design is generic enough to do this and a parameter exists already to explicitly set paths.
When running as "init" under normally circumstances, parameters might not be passed to it.
This is a good argument to support operating natively as an "init" without requiring the init parameter.
The design of the FLL programs allows them to be used as a library.
Take advantage of this and rewrite some of the code to save the "init" related differences in the main.c file.
The main.c file is not shared in the library and is therefore a safe candidate for holding differences.
This results in two programs "controller" and "init" which use the same library.
A stripped binary size of these two programs is each ~23K.
The stripped library shared between them is ~235K.
Having both programs on the system therefore only costs and additional ~23k.
To make this easy, provide an "as_init" mode that can be added to compile in this mode.
A compilation as "controller" might look like:
- "fake clean build -m monolithic"
A compilation as "init" might look like:
- "fake clean build -m monolithic -m as_init"
In both cases the program is built as "controller" under "build/programs/shared/controller".
When compiling "as_init", just rename this program when installing, such as:
- "cp -v build/programs/shared/controller /sbin/init".
The libraries and headers need only be installed once between the two programs.
This situation is a great example of the design principles of this project in use and working well.
Kevin Day [Tue, 7 Sep 2021 02:55:39 +0000 (21:55 -0500)]
Feature: Add support for -R/--raw parameters in FSS read programs.
The -R/--raw parameters designate that the quotes and the escapes should be preserved.
This allows for cleaning up a file and only pulling out valid FSS format and then provide that FSS in its originally escaped and quoted forms.
This further allows for maintaining quotes and escapes on Objects or Content individually.
When the static/dynamic string has used = 0 or the range.start > range.stop, then the string (or range) is empty.
The private function isn't aware of this and simply attempts to access the invalid ranges.
This will result in an invalid read.
Kevin Day [Sun, 5 Sep 2021 21:32:56 +0000 (16:32 -0500)]
Bugfix: FSS Basic and Extended List Read -a -n -l parameter fails to work as expected.
When -a, -n, and -l are used at the same time, the line position ends up being the wrong position within the file.
The -l (--line) should be relative to the --at index relative to the --name given.
This turned out to be a simple mistake where the wrong variable was being passed.
Kevin Day [Sun, 5 Sep 2021 20:49:06 +0000 (15:49 -0500)]
Bugfix: iki_read never implemented --at.
The --at parameter appears to have never been implemented or the implementation was somehow lost.
It should be possible to have the --total with the --at, however odd it may be.
The --whole, however, doesn't seem like it would be a good idea to allow supporting the --at paramter.
Add the "--" characters when displaying the error via fll_error_parameter_integer_print().
Kevin Day [Sat, 4 Sep 2021 05:03:18 +0000 (00:03 -0500)]
Security: Finish implementing string and convert changes.
The observation that some filesystems may have control characters in their names revealed a security issue in the design of this project.
There is no provided way to easily handle control characters or invalid UTF-8 sequences.
I have long been thinking about writing my own printf()/fprintf() functions but have not been willing to go that far.
With the discovery of this security issue, I finally decided to do so.
This then allows me to get rid of the rather messy f_color_print() and similar functions.
The color support and special FLL types, such as f_static_string_t, are now supported.
Due to the size of this change as well as my available time, I have broken up this process over several "Progress" commits.
This implementation is not complete.
I want to implement floating and double support, but I am not about to spend the research needed to properly handle floating and double digit processing logic.
While being similar, there are several differences between the fl_print_format() and fll_print_format() functions with the fprintf() functions.
Most notable of these is the the fl_print_format(), does not lock the file stream and fll_print_format() is a wrapper to fl_print_format() that does lock the file stream.
The format characters are significantly different, see the function documentation.
There are also improvements that need to be made.
Most notable is the digit to string conversion in which the algorithm I chose is a simple algorithm.
While the performance is acceptable for the time being, the performance can be greatly improved upon.
I need to spend time researching in order to improve this.
All of the programs (level 3) have been converted to use this and all of the many of the old ways of printing have been entirely removed.
I used safe printing where the string needs to be safely printing where I was able to identify such cases.
However, given the size of the refactoring, not to mention the work being spread out between days and weeks, I have concerns that I did not get all of the places that should be using safe printing.
Kevin Day [Thu, 2 Sep 2021 03:33:28 +0000 (22:33 -0500)]
Bugfix: Console parameter processing should handle unknown parameters with -/+ as regular parameters.
If the parameters are not found, then they should be added to the "remaining" set.
This allows unknown parameters to be used as regular parameters.
This is easily seen when using status_code or fss_status_code and attempting to pass a negative number, such as -200.
While -200 should be an out of range error for these programs, it is instead silently ignored.
Given that there is no reserved parameter with -200, then the -200 can be used normally.
There should also be a way to explicitly designate that all remaining parameters are processed as "remaining".
Add a comment by this.
There may also need to be a way to escape these parameters as an alternative.
Such changes are left to another time.
Kevin Day [Sat, 21 Aug 2021 05:21:48 +0000 (00:21 -0500)]
Progress: Continue string and convert changes, fixing bugs.
Convert the fake program.
Move the "%n" to "%in" to be consistent with how "%un" is used.
Change print string safely to ignore NULL rather than print the NULL character symbol.
This is done to be consistent with existing FLL design.
I realized printing the symbol is a problem when I test the fake build verbose setting.
Kevin Day [Tue, 17 Aug 2021 02:43:00 +0000 (21:43 -0500)]
Progress: Continue string and convert changes, fixing bugs.
The f_conversion_character_* functions should accept uint8_t instead of f_number_unsigned_t.
Implement the "/" character to designate the a partial range.
The "*_except*" string processing functions must accept an offset.
I was really hoping to avoid adding additional parameters but then I realized that I have to have a start offset.
The "except" positions and ranges are relative to the actual start and not the offset start.
The previous behavior of applying an offset to the string before passing results in the entire except positions and ranges to be invalid for any offset greater than 0.
Have F_eos (with error bit set) returned for when end of string is reached while calling fl_print_string_convert().
Rewrite the static/dynamic string argument printing logic.
Update private_fl_print_convert_number() to use bitwise operations rather than comparisons.
Convert the controller program.
Add missing "controller_string_value" and related to controller program.
Kevin Day [Sun, 8 Aug 2021 03:57:03 +0000 (22:57 -0500)]
Progress: Continue string and convert changes, fixing bugs.
Update all relevant dependencies.
Convert the error projects.
Convert control program.
Begin converting controller program.
I really wanted to get rid of those pesky mutex locks.
With the addition of explicit calls to flockfile() and funlockfile() this felt like a possibility.
Unfortunately, I still need to protect both stdout and stderr from both writing to the same destination (which is common for normal consoles).
Kevin Day [Sat, 7 Aug 2021 04:48:55 +0000 (23:48 -0500)]
Security: NULL dereferences discovered by GCC's -fanalyzer.
The socket bind is both missing the parameter check and is passing '&' when the variable is already a pointer.
The f_utf_character_to_char() is a mess.
Not sure what I was trying to do, but it is clearly wrong.
Redesign it to be more correct but I should revisit this for a more thorough review.
There are endianess situations that also need resolved so I added an @todo.
Kevin Day [Fri, 6 Aug 2021 03:45:17 +0000 (22:45 -0500)]
Progress: Continue string and convert changes, fixing bugs.
Document that the conversion operations are not ideal performance-wise.
Switch from fputc() to fwrite_unlocked() for the conversion print functions.
Use more bitwise operations rather than comparisons.
Explicitly handle binary print mode as it is easy to optimize.
(The binary optimization still uses much of the existing strategy and so likely can still be further optimized.)
Use correct digits for binary print in byte_dump.
Update the API documentation as it has fallen behind.
Preemptively update some of the API documentation where fputc/fputc_unlocked has not yet been fully updated to fwrite_unlocked.
Kevin Day [Wed, 4 Aug 2021 03:36:34 +0000 (22:36 -0500)]
Progress: Continue string and convert changes, fixing bugs.
Fix some bitwise operation comparison mistakes.
I used the wrong ASCII reference for the '@' and possibly others.
This broke octal representation.
This improves handling of Unicode characters in the safely print functions.
It seems there are Control characters with widths greater than one.
This complicates the code but what must be done, must be done.
Begin adding back some of the color print functions as f_print_color() etc...
There are still more to create.
Kevin Day [Sun, 1 Aug 2021 04:24:53 +0000 (23:24 -0500)]
Progress: Continue print development.
I've noticed that the performance can be quite poor in the custom fprintf functions.
Investigating this seems to be for several reasons:
1) No serious optimization developed into the logic as of yet.
2) The libc functions have serious optimization.
3) GCC/Clang are not properly identifying the register for unoptimized compilation.
4) I believe the libc functions are also parsing the data in a loop.
Some very basic optimizations are implemented:
1) Utilize "-O2" in every config by default to encourage the compiler to properly detect and set register (huge performance gained).
2) Use libc functions like strnlen() and fwrite() more often (more work to do in this regard).
3) Use grouping in the if..then.. logic to reduce the number of comparisons.
Fix bug where the number '11' is not being converted due to a typo.
Fix bug where an uppercase 'E' is printed when it should be a lower case 'e'.
There is no "end of enquiry".
Replace "end of enquiry" with "enquiry" because there is no "end of enquiry".
Organize print sequences and add (and utilize) a control sequence character map to avoid multiple if..then.. logic.
Re-organize the format flags, changing some entirely.
I decided not to so closely follow fprintf() functions and instead make things a little more consistent.
For example, "ul" and "ull" exist but the signed opposite is "l" and "ll".
This could instead be "ul" and "ull" as unsigned version of "il" and "ill".
Most of the FLL project is explicit about byte sizes, and so do the same with the format flags.
There is still a lot more work to do, but this is starting to stabilize a little.
Kevin Day [Fri, 30 Jul 2021 03:36:13 +0000 (22:36 -0500)]
Progress: continue string and convert changes, fixing bugs.
The byte comparison should be against 0xf and not 0x7.
As a result some numbers, such as 8, were being turned into 0.
The private convert function wasn't correctly converted when it was restructured.
Wrong parameters were used and the digits were being incorrectly set when the number is 0.
Looks like I needed a double pointer and not a single pointer.
I may redesign this to not depend on a double pointer.
The design will be to change the behavior to operate more like fprintf() in that a number of bytes printed is returned.
This would put the return type in a non-standard (non FLL standards that is) but acceptable state.
The byte_dump program had the parameters placed in the wrong location.
Another consideration is that I might implement f_print_color() (which would operate similar to the now removed f_color_print()).
This would only be for a single color for simplicity purpose and would only accept a single color set after the string.
Such as:
f_print_color("My name is %S.", main.context.set.title, main.output.stream, name);
Which is cleaner than:
f_print_string("%[My name is %S.%]", main.output.stream, main.context.set.title, name, main.context.set.title);
This is likely to cover a common case and so I believe is an acceptable compliment to f_print_string().
Kevin Day [Thu, 29 Jul 2021 03:17:12 +0000 (22:17 -0500)]
Progress: Continue working on print changes.
This begins replacing f_color code.
The byte_dump is migrated and has exposed bugs in the number processing.
For now, the number processing has been disabled solely for the purposes of this commit.
I will have to review and rethink the logic with the precision/width and number handling in printf.
Kevin Day [Wed, 28 Jul 2021 03:15:41 +0000 (22:15 -0500)]
Progress: Continue work on printing.
Use ";" and ":" for ignore_index and ignore_range.
I intend to reserve "<", ">", "(", ")", "{", and "}" for context related matters, which currently is only color context.
The handling of UTF-8 character codes with ignore indexes and ranges needs to be carefully considered and documented.
Print safely functions will need to convert, but what if the bits are being ignored?
Print raw functions should print as-is, even if invalid.
Print normally functions should validate and return error.
For now I just added some comments.
Oops! I include space as a "control" character.
I started to convert byte_dump printing as a way of testing the current state of the code.
I intend to slowly convert each level 3 project one at a time and test for problems.
This quickly convinced me to not follow the fprintf() standards practice and I moved the FILE * after the string rather than before.
Finish the trim functions.
This is done very quickly so I am confident that there is some logic bug somewhere.
This is just another reason for me to implement testing support.
There are several utf_character trim functions in fl_print.
Remove these for now.
The print is getting big and I believe that I now need an fl_utf_print and an fll_utf_print just like is done with how fl_string has fl_utf_string.
I want to get all of the bugs out of the print functions before I move to working on the utf_print functions.
This will likely get addressed during a unicode development pass.
This converts some of the fll_program print functions.
Looking at the color print functions, I now plan on merging a lot of the color printing functionality into the print functions.
Specifically, the fl_print_string() and related should support color context printing.
This will allow me to simplify some of the code.
The idea so far is that I can use "[" and "]" to accept an "f_color_set_t" and the "[" represents the "before" pointer and the "]" represents the "after" pointer.
For example the following:
fl_print_string(" %q%s%q%c", output.stream, *context.set.title.before, name, *context.set.title.after, f_string_eol_s[0]);
would be changed to:
fl_print_string(" %[%s%]%c", output.stream, context.set.title, name, context.set.title, f_string_eol_s[0]);
Kevin Day [Mon, 26 Jul 2021 03:02:20 +0000 (22:02 -0500)]
Progress: Redesign printing, redesign conversions, and some cleanup.
The print functions have been redesigned (work is incomplete as of this commit):
- Use unlocked printing where possible for all low level functions (like f_print()).
- Provide locked versions of all f_print* and fl_print* functions in newly added fll_print project.
- Redesign output variable to be at the end to be consistent with FLL practices (with an exception).
- Implement fprintf() alternative (very much incomplete, see below) and use a parameter structure to match fprintf() as an exception to the FLL practice mentioned above.
- Add *_raw() and *_safely() functions (see notes below).
The conversions are redesigned to better accommodate more flexibility as well as the newly added fprintf() alternatives (fl_print_string(), etc..).
- Provide a structure for more fine tuned control over convert process.
- Allow for literal designated of base 10 rather than making it solely the default base.
- Use bitwise operations and range comparisons more rather than switches and if then blocks for conversions.
There are some private headers being exposed to the installation (private headers should not be specified in the build_sources_headers build settings).
This commit all started with the observation that filenames could be created using control codes.
I tested using the backspace control code with the byte_dump program and found that it does perform backspace.
I consider this a security issue as I consider this undefined behavior.
To resolve this, I decided that I needed a "print safely" set of print functions.
After some consideration, I decided that providing my own fprintf() alternative is the way to go and has several advantages.
- Allow moving print locking to higher levels to avoid thread problems where multiple fprintf() like functions are called that should not be allowed for something else to print between them.
- The unlocked print functions also allow for better performance under the assumption or expectation allows for better control of the programmer to properly utilize this.
- Allow for having an unlocked fprintf() function.
- Still allow for locked versions of all unlocked print functions.
- Allow for passing FLL f_string_static_t, f_string_dynamic_t, and similar to the fprintf() alternative (which hopefully will make the code a lot cleaner and better maintainable).
- Allow for custom print options to "print safely".
- Allow for custom print options to "print rawly" (that is, allow printing NULL character and any control character as-is).
Working on this led to doing a rewrite of the conversion functions (which is needed anyway).
This also required major changes to the print functions and as per my completeness principle also requires a lot more functions to be implemented.
All of this resulted in a huge set of changes.
So big, that I am afraid of mistakes.
No, I expect there to be mistakes.
At this point, I spent enough time so I put the code in a state that compiles correctly and am saving as-is.
There are several @todos present and there are also a large number of incomplete areas of code.
Of particular note is the fprintf() compatibility.
I tried to stay as close to the fprintf() syntax as possible but I found that it is better to deviate in certain areas.
I do not plan on implementing the "type conversion" support.
I do plan on implementing the float/double support, but do to the additional complexity and my priorities, this functionality is being held off for a much later time.
I will get to documenting the fprintf() alternatives later on.
The fprintf() alternatives are being called fl_print_string() and fll_print_string() (including variations with different suffixes).
This is done to distinguish these between the normal f_print() and fll_print() type of functions.
Kevin Day [Fri, 9 Jul 2021 01:27:10 +0000 (20:27 -0500)]
Update: Add cygwin rough documentation.
I had access to a Windows box and was curious to see if I could compile my project on Windows.
To my surprise, with Cygwin and only a minor set of changes, the byte_dump program compiled and worked flawlessly.
Kevin Day [Fri, 9 Jul 2021 00:45:20 +0000 (19:45 -0500)]
Feature: Add support for specifying nano version numbers in FLL programs.
The programs display the version number and so it may be helpful for certain situations to specify nano version numbers for this project.
One such use case is if I were to release a development package for my own testing, I would like it to communicate the development status.
With this change I can now do this in one of two ways (to achieve something like "0.5.4-dev"):
1) Specify the custom nano on the command line like:
# fake clean build -d "-Dbyte_dump_nano_version_prefix=\"-\"" -d "-Dbyte_dump_nano_version=\"dev\""
2) Specify the custom nano verson in the data/buildsettings file, prepending the defines_all Object's Content like:
defines_all -Dbyte_dump_nano_version_prefix="-" -Dbyte_dump_nano_version="dev"
Kevin Day [Sat, 26 Jun 2021 03:59:54 +0000 (22:59 -0500)]
Feature: Featureless Make must support both version_target and version_file.
This separates version_target into version_target and version_file.
Previously, they were one in the same and the recent design change of version_target exposed a problem with this.
Libraries are traditionally linked (as in dynamic linker and not as in the filesystem "ln") to the major version number (such as: "-Wl,-soname,libfake.so.0") and have a file path set to the micro version (such as: libfake.so.0.5.4).
When the version_target was set to "micro", this instead results in "-Wl,-soname,libfake.so.0.5.4" and "libfake.so.0.5.4".
By breaking this up, the linker and the file can be setup appropriately.
The problem here is that they are both related to linking but in two different contexts:
1) Dynamic Linker (_wl,-soname,...).
2) System Linker (ln -vs a b).
To disambiguate these, the version_target is now used to refer to the Dynamic Linker and the version_file is used with the file name in which the system linker is used to link files against.
The Featureless Linux Library used Major.Minor.Micro such that Major.Minor could represent stable versions (for even Minor numbers).
Set this new setting to have version_target set to "minor" instead of the traditional "major" in the appropriate settings files.
When not specified in the build settings file, the defaults must always be provided which are:
1) version_target = "major"
2) version_file = "micro"
This aligns the default behavior to align with traditional practices while manually setting the build settings for all FLL projects to use different settings.
The bootstrap.sh script has been updated to be consistent with this.
The bootstrap.sh has also been updated to include the version prefixes.
Kevin Day [Fri, 25 Jun 2021 02:10:29 +0000 (21:10 -0500)]
Update: Redesign Featureless Make's -d/--define to append instead of overwrite.
The built in defines can be large and complex.
The defines passed through the program arguments should be for exceptional or situational purposes.
By using append instead of overwrite, the -d/--define better operates as an exceptional or situational process.
Kevin Day [Fri, 25 Jun 2021 00:35:30 +0000 (19:35 -0500)]
Update: Implement *_except_in* print functions, remove redundant UTF types, and have FSS read functions utilize *_except_in*.
When I wrote the *print_except* and *print_trim_except* functions I was hoping to avoid having to pass both individual positions as well as ranges for the "except" list.
Looking at how the FSS read functions are, I now realize that I must implement these.
Implement these as seperate functions where reasonable and in other cases implement the *_except_in* with the *_except* functions.
I added some of the UTF string types for consistency and completeness.
After looking at this later on I now believe the cost of the extra maintenance and resources is not worth it.
(It might, however, be worth implementing these as a define or a typedef of the string types.)
Replace f_utf_string_range_t with f_string_range_t (and related), removing all related functions.
Remove f_utf_string_quantity_t (and related), removing all related functions.
With the *_except_in* functions implemented, the relevant FSS read functions can now use them and properly not print valid comments.
Kevin Day [Wed, 23 Jun 2021 03:43:57 +0000 (22:43 -0500)]
Update: Restructure enum non-alphabetically and detect empty version for a specified version target.
If version_target is set to something, then that something should not be empty.
Detect this requirement.
In the case of the major/minor/micro/nano versioning, having the enum match the major/minor/micro/nano order makes more sense than alphabetical.
This then allows for using the enum as a relative position when detecting if one of these is required to not be empty.
Kevin Day [Wed, 23 Jun 2021 02:57:47 +0000 (21:57 -0500)]
Bugfix: Properly build version string.
The previous commit didn't properly to this.
When a version prefix is provided, the resulting name overwrites the string with the nano version at the wrong location in the string.
Kevin Day [Wed, 9 Jun 2021 02:01:29 +0000 (21:01 -0500)]
Progress: Incorrect linkage, not handling default values well, add version_nano, add version prefixes, and out of date documentation.
The documentation has version_target described as the target to build but the C source for Featureless Make is using it for the link file name.
Change this behavior to be consistent with the documentation.
Update all build settings to now be set to micro to be consistent with this change.
The default values should only be assigned if the Object is not provided at all.
This allows for the value to be set to empty (aka NULL).
The version_major, version_minor, and version_micro all are currently required to be defined and if empty will be set to 0.
Some projects use four versions and others like to add things like "-dev" or "-rc1".
Provide a way to do this by adding a version_nano as well as adding version prefixes.
For each version there is now a version_X_prefix such as version_major now has version_major_prefix.
For all version prefixes, except version_major_prefix, the prefix will be in place of the '.' in the version name.
The major version is an exception case as there is no value by default.
For example "1.2.3" would have version_major = "1", version_minor_prefix = ".", version_minor = "2", version_micro_prefix = "." version_micro = "3".
The default version continues to be a version_target of micro, such as "1.2.3".
The build settings documentation is out of date and needed some corrections to be made.
There is still more work to do in adding the prefixes and making the bootstrap.sh script and the fake program more consistent with the version numbers.
I simply ran out of time.
Kevin Day [Mon, 31 May 2021 22:43:44 +0000 (17:43 -0500)]
Update: Redesign FSS Identify to be more consistent with FSS Read and FSS Write programs.
This is not strictly required, but I believe making it as closely consistent with how FSS Read and FSS Write operate makes a lot of sense.
The FSS Identify and FSS Read/Write programs operate differently and not everything can be the same.
Summary of Redesign:
- The "name" and "type" are now renamed to "Object" and "Content".
- The parameter "-n/--name" is now "-o/--object".
- The parameter "-t/--type" is now "-c/--content".
- The parameter "-T/--total" is now "-t/--total".
- Add new parameter "-n/--name" that accepts a name to filter by (This selects an Object just like it does in FSS Read/Write).
- Add additional documentation to the "-h/--help" parameter message.
- The "-t/--total" parameter should could across all files and not the individual files/pipe (this provides a single total).
Kevin Day [Mon, 31 May 2021 05:02:58 +0000 (00:02 -0500)]
Update: Attempt to avoid libc/POSIX character array length limitations.
Define f_string_t_length to handle the special case max length.
Make the f_utf_string_t also operate in the same way (even it it might avoid the problem by being a different type than char).
The f_utf_string_t is changed in this way for consistency reasons.
Kevin Day [Mon, 31 May 2021 04:07:18 +0000 (23:07 -0500)]
Bugfix: FLL/FSS Identifier problems.
The strtol() function is being incorrectly used.
Redesign the code to accomodate the particular nature of that function.
Instead of doing math, just create a special structure that is friendly for strtol() and read str
The status is being incorrectly checked against F_false when the check should be against F_true (oops!).
Make sure the id->used is correctly calculated.
The calculation is truncating the name because the i variable is incremented in a start/stop range and not in a buffer used (start/stop ranges are inclusive and a buffer.used more akin to exclusive).
I forgot to allocate the FLL Identifiers array.
There are some cases where found_fss is not and should be tested for.
Kevin Day [Sun, 30 May 2021 18:09:51 +0000 (13:09 -0500)]
Progress: FLL/FSS related changes, populate more ASCII characters.
It occurred to me that I should follow the same practices as the FSS process where I use range for the FLL/FSS Identifier processing.
Change the behavior to do so.
It also occurred to me that I should try to avoid processing both a dynamic string's used as well as the range.
The FLL/FSS Identifier code only accepts a string for this reason.
It will likely be a good idea to change the other FSS code to accept a f_string_t instead of a f_string_static_t.
Add the initial support for FSS header processing with support for multiple FLL/FSS Identifiers.
Add and use the FSS specific default memory allocators.
Complete more of the hardcoded ASCII strings.
Unless I missed something, all that is left now is to consider adding the extended ASCII.
Kevin Day [Sun, 30 May 2021 03:22:45 +0000 (22:22 -0500)]
Update: Additional FLL Identifier changes along with type fixes.
I didn't like manually specifying the id.name[X] for all 64 X when clearing the f_fll_id_t.
Instead, take a minimalistic approach and set id.name[0] to NULL.
This is not a complete clear, but it is simple for use in macros.
Document that memset() should be used for a more complete/correct clear.
I completely forgot to implement the array and array of arrays support as is standard practice now.
While doing this I then noticed that the other type arrays and array of arrays were not fully migrated to having functions rather than be pure macros.
This further exposed some bugs being hidden by the macros.
There were some resize (or similar) macros that were using the wrong macro to initialize.
When macros were changed to expand to a function, this exposed that the wrong types were being used and there is a likelihood of incorrect allocations or deallocations.
Things may have previously worked due to the sizes potentially being coincidentally identical.
There is also a bug where some macros expanded the *_increase_by() macro to a *_increase() function.
These should instead expand to an appropriate *_increase_by() function.
Kevin Day [Sat, 29 May 2021 23:12:21 +0000 (18:12 -0500)]
Revert: Partially revert unsigned to signed change in "Bugfix: Compilation/Portability problems exposed when building against musl-libc.".
There were problems with the console parameter size, so switching that to signed seems fine.
However, switching the more general standard approach from unsigned to signed is more dangerous.
Signed operations are much more fickle when overflowing or when using bitwise operations.
In fact, the C standards leave a lot of this behavior as undefined.
Much of the logic used in operating and manipulating array lengths (as counters or with bitwise operations such as << or >>) is affected by the previous change from signed to unsigned.
Avoid these signed problems by reverting this behavario.
The console parameter length will remain as a signed.
Kevin Day [Sat, 29 May 2021 23:00:02 +0000 (18:00 -0500)]
Feature: Provide and implement f_fll_id_t and fl_string_fll_identify().
The Featureless Settings Specification identifiers are a decent format.
Make a more generalized structure for processing these for the entire project and not just FSS.
Kevin Day [Sat, 29 May 2021 16:29:49 +0000 (11:29 -0500)]
Feature: Allow controller program to run as a non-init (and then do so by default).
The controller program is written more generally.
Take one step further and make the default to run generally.
Then provide the option to operate as an init program.
This frees up the controller program's default behavior to just be a "controller" rather than an "init controller".
Furthermore, provide options to change easily override the "init controller" paths at compile time without redefining all of the other defines in the "_di_controller_defines_" block.
Kevin Day [Wed, 26 May 2021 02:42:46 +0000 (21:42 -0500)]
Update: Rewrite the enabled/disabled logic for the install.sh script.
The --disable-shared/--disable-static should override --enable-shared-program/--enable-static-program (and similar).
Apply build_shared and build_static if and only if shared/static parameters are not specified.
Fix minor bug where wrong string is printed when an error is supposed to be printed.
The code is printing $build_shared when it should be printing $path_shared.
The code is printing 'library' in cases that should print 'program'.
$build_shared and $build_static no longer need to be directly tested for.
This testing happens when checking and guaranteeing the individual program/library shared/static state.
Kevin Day [Wed, 26 May 2021 01:45:00 +0000 (20:45 -0500)]
Feature: The install.sh script should support disabling installation of headers.
If any headers exist, there still may be a desire to not install headers.
One such example is separately install static files to one location and shared to another using separate calls.
The headers may also be installed in only one of those or another separate call.
Kevin Day [Tue, 25 May 2021 23:27:30 +0000 (18:27 -0500)]
Feature: Add Unicode to/from UTF-8 translations and fix usage of function that should be private.
This logic has not actually been tested yet.
This needs to be reviewed for endianess correctness.
All of the UTF-8 processing code, in fact, needs to be reviewed for endianess so I decided to not test this further until I can review and correct the big vs little endianness support.
Kevin Day [Thu, 20 May 2021 02:39:45 +0000 (21:39 -0500)]
Regression: "fake skeleton" no longer works due to "file not found".
ERROR: Unable to create file 'data/build/defines', could not find file.
This error message is a bit nonsensical because it is supposed to create a file if it does not exist.
This is a regression in that at some point f_file_is() started returning F_file_found_not with error bit set and the skeleton program is only expecting F_file_found_not without the error bit set.
Make the test error-bit neutral.
Kevin Day [Wed, 19 May 2021 03:48:26 +0000 (22:48 -0500)]
Progress: Interrupt and memory allocation related changes.
I've noticed that when processing large files, the FSS programs cannot be interrupted using controlled interrupts rather than the standard interrupt signals.
The POSIX standard structure of interrupts, particularly in threads, is very poorly defined.
When a threaded program wishes to be triggered for an exit, the pthread_cancel() function works by immediately exiting the program rather than aborting.
This prevents proper deallocated and shutting down of programs, particularly those that handle interrupts.
This introduces a new f_state_t structure that allows passing a generalized state around that accepts (void *) arguments so that it is not tied to any particular implementation beyond the basic structure.
The FLL/FSS and IKI processing functions then take advantage of this and utilize the state.
There are performance concerns with this, but the need to have controlled interrupts is deemed far more important.
Furthermore, the generic function is open ended so that the caller can potentially implement some sort of optimization.
Now that an f_state_t structure exists I am finally compelled to move the allocation step functionality into this structure.
This will allow for more performance improvements (such as determining allocation step according to file size).
For large files (megabytes, gigabytes, etc..) the allocation step can be set to something large, such as 16384.
Doing so should reduce the amount of memory I/O needed for resize operations.
I have opted to use uint16_t, so there is a max step of 64k at this time.
This entire process needs additional reviewing before releasing.
I designed this with the intent to move the function parameters into the (void *) data property on the f_state_t structure.
This will allow for reducing the parameters passed.
This design will also allow for me to later on add additional state information that can be passed to the caller.
This also allows for better or more granular error handling and reporting.
More work is needed in this regard because many of the functions currently written need to utilize this (such as the recursive directory functions).
This focuses on the most basic utilization in the programs but I would like to perform file size tests so that I can at least have a very basic heuristic for determining the default allocation size for large (or small) files.
A new project fl_signal is provided with a basic interrupt callback for f_state_t as I believe a dirt simple callback will be commonly used.
The default allocation step is now broken up into large and small allocation steps.
Kevin Day [Tue, 11 May 2021 23:11:59 +0000 (18:11 -0500)]
Feature: The install.sh should helper script should allow more granular installations between shared and static.
Add new parameters "--disable-shared-programs", "--disable-shared-libraries", "--disable-static-programs", and "--disable-static-libraries".
These parameters will enable/disable shared/static libraries/programs.
Both shared and static may be compiled and this allows for choosing to install which of those to install.
Kevin Day [Sat, 8 May 2021 01:11:19 +0000 (20:11 -0500)]
Feature: Add support for determining columns in FSS Read programs.
Implement a new feature for determining how many columns total are available for some Content.
Update the specifications accordingly.
The term "columns" has been added to designate this concept of the now of column sets within some Content.
Previously, this was weakly named.
The select functionality "--select" allows for selecting these columns but there has been no way to know how many columns exist.
This is not a good design for scripting and similar usage.
By providing a total number of columns, the select function becomes more complete and useful.
When columns is specified without any particular Object specified, then the maximum columns length for all Content is printed.
Kevin Day [Fri, 7 May 2021 22:11:00 +0000 (17:11 -0500)]
Bugfix: The install.sh should allow for -w to be used when destination_prefix is invalid.
While buildin a system from scratch, the default destination does not exist.
This exposed a bug where the script complains about the destination directory even when the destination directory is not to be used (because the work directory is being used).
Kevin Day [Fri, 7 May 2021 05:22:33 +0000 (00:22 -0500)]
Update: Provide defines for disabling less-portable code exposed as a problem when using musl-libc.
The f_thread project utilizes several pthread functions that are non-portable.
Add some initial support for disabling these and do disable these by default.
I intend to expand upon this and adding more defines.
The current ones might be renamed.
Kevin Day [Fri, 7 May 2021 04:33:08 +0000 (23:33 -0500)]
Bugfix: Compilation/Portability problems exposed when building against musl-libc.
Some headers are missing.
Change the length types: f_console_parameter_size and f_array_length_t.
I have seen problems where the max allowed size is reached in f_array_length_t.
Compiling against musl-libc further exposes this problem and so I have reduced the practice to using a set length of 2^63 (aka: signed long).
Kevin Day [Fri, 7 May 2021 00:12:32 +0000 (19:12 -0500)]
Bugfix: Fix problems revealed when working on FSS Extended List Read.
Be sure to explicitly check data->objects.used is non-zero when counting total.
The Basic List and Extended List Object names, when being selected (via the --select parameter), should be trimmed by default.
This is because the Basic List nd Extended List standards define an Object name as beginning after on the first non-whitespace and ending at the last non-whitespace.
Minor syntax cleanups such as replaced "if (X > 0)" with "if (X)".
Kevin Day [Fri, 7 May 2021 00:09:32 +0000 (19:09 -0500)]
Security: FSS Read functions should check range before buffer.
The range may have exceeded the buffer or the stop point.
There is a string test that happens before this is checked.
If this string is checked with an out of range address, then a segfault could occur.
Kevin Day [Thu, 6 May 2021 22:40:43 +0000 (17:40 -0500)]
Bugfix: FSS Extended List is not detecting end properly.
If the content is something like:
example {
}
There is no Content.
This is not being detected correctly an the '}' is being included.
There are two problems here:
1) The current position at the end should be after the eol and not that last newline.
2) If the current position matches the start position, then it needs to be explicitly designated as empty.
Kevin Day [Thu, 6 May 2021 01:09:43 +0000 (20:09 -0500)]
Bugfix: FSS Basic Read and FSS Basic List Read problems and cleanups.
The delimit is not being calculated correctly.
The fss_basic_read_load() and fss_basic_list_read_load functions are out of place.
The parameter order for some functions like fss_basic_read_print_at() are not adhering to the ordering practices (constants on the left).
The total is not consistently being counted.
The FSS Basic Read is not taking into consideration when Content is empty and --object is or is not selected for some line specific processing.
When there is only --content, then whether or not Content is empty matters.
When there is --object (or both --object and --content), then whether or not Content is empty does not matter because Object is already taking up a given line.
Kevin Day [Wed, 5 May 2021 05:24:12 +0000 (00:24 -0500)]
Cleanup: Use number instead of word in FSS Basic Read help.
While committing the FSS Basic List changes to be in sync with this, I noticed that I had "..start at 0 instead of one..".
This is inconsistent.
I either need to use both words ("zero" and "one") or both numbers ("0" and "1").
I opted to use the numbers.
Kevin Day [Wed, 5 May 2021 05:13:35 +0000 (00:13 -0500)]
Update: Improvements and tweaks in FSS Basic Read.
Add additional help information.
Cleanup comments.
In some cases the total printing is inverted by accident.
The print_object function pointer doesn't really need to exist anymore.
Add missing print for when both total and line parameters are specified.
Kevin Day [Wed, 5 May 2021 05:00:40 +0000 (00:00 -0500)]
Bugfix: UTF-8 characters buffer is incorrectly returning an error.
The previous commit: "Bugfix: UTF-8 characters are not being fully printed" exposed that for UTF-8 characters (width 2 or greater), an error is always returned.
When the width properly fits in the requested range, return the appropriate success code instead of an error.
The previous implementation is weak in that there is no good way to just delimit Object or just delimit Content.
Redesign to allow for specifying the delimit parameter multiple times and therefore allow for customizing what to specify.
Rename "depth" to "content" in the delimit enum to better communicate that this is for "content" delimiting.
Examples:
- "fss_basic_read --delimit object": Results in delimited Objects but not Content.
- "fss_basic_read --delimit 0+": Results in delimited Content (position 0 and greater) but not Objects.
- "fss_basic_read --delimit object --delimit 1-": Results in delimited Objects and delimit Content (position 1 or less).
For this standard, there is no delimit support in Content so the use of the numeric range is superfluous.
Having this functionality, however, makes it consistent with the rest of the FSS Read programs.
Kevin Day [Mon, 3 May 2021 02:51:54 +0000 (21:51 -0500)]
Regression: FSS Basic read --select is always returning empty sting or 0.
After changing the code structure, the check to see if the select number is non-zero was lost.
As a result the code is always operating as if the select number is non-zero.
When the select number is zero, all existing operations should continue.
I seem to have forgotten to wrap these macro checks in parenthesis.
As a result something like "!macro_f_file_type_is_block()" would expand to "!macro_f_file_type_get(mode) == f_file_type_block".
What it should expand to should be logically equivalent to "macro_f_file_type_get(mode) != f_file_type_block".
The expansion with the parenthesis would be: "!(macro_f_file_type_get(mode) == f_file_type_block)" and that is indeed logically equivalent.
Kevin Day [Mon, 3 May 2021 02:10:40 +0000 (21:10 -0500)]
Cleanup: Disable parenthesis warning in GCC.
This is another case where the compiler is overstepping itself.
The programmer should understand the language and the order of operations.
Disable the warning by passing -Wno-parentheses.
(The warning only appears if -Wall is given, but if -Wall is passed then -Wno-parentheses should be already in place.)
Kevin Day [Mon, 3 May 2021 02:07:21 +0000 (21:07 -0500)]
Cleanup: Sloppy use of "main" inside of "main()", oops.
I cannot believe I let this one slip through (and so did the compilers).
When I refactored "data" to be "main" this included the refactor in the function called "main".
This is dangerous at worst and at best bad practice.
Given that "data" is no longer to be used in the main(), just rename the uses of "main" back to "data" for the variable name only (not the typedef structure name).