]> Kevux Git Server - fll/commitdiff
Regression: Fix the preserve and offset calculation in Featureless Make.
authorKevin Day <Kevin@kevux.org>
Sun, 27 Apr 2025 22:18:00 +0000 (17:18 -0500)
committerKevin Day <Kevin@kevux.org>
Sun, 27 Apr 2025 22:19:59 +0000 (17:19 -0500)
This addresses the problems observed in commit 3befe37125e426d452a1b9b9a1fab97ab221c7f1.
I never got the time to investigate this before I made my end of day commit.
This now addresses the observed problems.

The offset application logic is accidentally reversed.
This is now corrected.

The new logic does not require the buffer because the directory is being created later on in the process.
Using the `f_string_append_nulless()` to easily copy the source path with the offset onto the destination path.

Update the documentation comments to better communicate this behavior.

level_3/fake/c/main/build.c
level_3/fake/c/main/build.h

index f51813ab50b03986cc17c232a07a6a73d14381ad..4956ec2270f101ff3aa0cfbf75775602e215aa26 100644 (file)
@@ -173,7 +173,6 @@ extern "C" {
 
     fake_main_t * const main = data->main;
 
-    f_string_static_t buffer = f_string_static_t_initialize;
     f_status_t failed = F_okay;
     fake_local_t local = macro_fake_local_t_initialize_1(main, &main->cache_map, &failed);
     uint8_t func = 0;
@@ -244,20 +243,13 @@ extern "C" {
       }
 
       if (F_status_is_error_not(main->setting.state.status)) {
-        if (preserve) {
-          func = 3;
-          main->setting.state.status = f_file_name_base(files.array[i], &main->cache_map.value);
+        if (preserve && offset < main->cache_map.key.used) {
+          func = 9;
+          main->setting.state.status = f_string_append_nulless(main->cache_map.key.string + offset, main->cache_map.key.used - offset, &main->cache_map.value);
         }
         else {
-          if (offset) {
-            buffer.string = files.array[i].string + offset;
-            buffer.used = files.array[i].used - offset;
-
-            main->setting.state.status = f_string_dynamic_append_nulless(buffer, &main->cache_map.value);
-          }
-          else {
-            main->setting.state.status = f_string_dynamic_append_nulless(files.array[i], &main->cache_map.value);
-          }
+          func = 3;
+          main->setting.state.status = f_file_name_base(files.array[i], &main->cache_map.value);
         }
       }
 
@@ -343,7 +335,9 @@ extern "C" {
                         ? macro_fake_f(f_file_name_directory)
                         : func == 7
                           ? macro_fake_f(fl_directory_create)
-                          : macro_fake_f(f_file_copy),
+                          : func == 8
+                            ? macro_fake_f(f_file_copy)
+                            : macro_fake_f(f_string_append_nulless),
           f_file_operation_copy_s,
           main->cache_map.key,
           main->cache_map.value,
index 04702da9cb848659544c1e9650dfed35c54ce120..8da450b2c455f16c102bbd438db12b8d19d066fb 100644 (file)
@@ -87,14 +87,15 @@ extern "C" {
  * @param file_stage
  *   The specific stage file path.
  * @param preserve
- *   Set to F_true to preserve the path.
- *   Set to F_False to only use the base name when copying.
+ *   Set to F_true to preserve the path and offset is used with the source path to construct the destination path.
+ *   Set to F_false to only use the file name as the destination.
  * @param offset
- *   When preserve is F_true, this represents the amount of characters at the front of each path to ignore.
+ *   When preserve is F_true, this offset represents the amount of characters at the front of each path to ignore.
  *   Everything after the offset is preserved, and directories are created if necessary.
+ *   The offset must be based on the source string.
  *
- *   Example: 'sources/c/level_0/fss.h' with a preseve of 10, would result in the path of 'level_0/fss.h' being preserved.
- *            Whereas a preseve is F_false, then the path used would instead be 'fss.h' (the 'sources/c/level_0/' directories are not preserved).
+ *   Example: 'sources/c/level_0/fss.h' a preserve F_true and an offset of 10 would result in the path of 'level_0/fss.h' being preserved.
+ *            Whereas when preseve is F_false, then the path used would instead be 'fss.h' (the 'sources/c/level_0/' directories are not preserved).
  *
  * @see f_directory_is()
  * @see f_file_copy()