]> Kevux Git Server - fll/commitdiff
Progress: featureless make.
authorKevin Day <thekevinday@gmail.com>
Fri, 17 Jul 2020 04:05:43 +0000 (23:05 -0500)
committerKevin Day <thekevinday@gmail.com>
Fri, 17 Jul 2020 04:05:43 +0000 (23:05 -0500)
Begin adding the path stack functionality.

level_3/fake/c/private-make.c
level_3/fake/c/private-make.h

index 1dc47cc1902f266a9064387436f6964d8a27dd6c..92b04c0ee8af5739d7ef9206106739a35fc80a0b 100644 (file)
@@ -314,6 +314,28 @@ extern "C" {
     f_string_lengths list_stack = f_string_lengths_initialize;
     fake_make_data data_make = fake_make_data_initialize;
 
+    f_macro_string_dynamics_new(status, data_make.path.stack, f_memory_default_allocation_step);
+    if (F_status_is_error(status)) {
+      fake_print_error(data.context, data.verbosity, F_status_set_fine(status), "f_macro_string_dynamics_new", F_true);
+      return status;
+    }
+
+    status = f_path_current(F_true, &data_make.path.stack.array[0]);
+    if (F_status_is_error(status)) {
+      fake_print_error(data.context, data.verbosity, F_status_set_fine(status), "f_path_current", F_true);
+
+      fake_macro_make_data_delete_simple(data_make);
+      return status;
+    }
+
+    status = f_directory_open(data_make.path.stack.array[0].string, F_false, &data_make.path.top);
+    if (F_status_is_error(status)) {
+      fake_print_error(data.context, data.verbosity, F_status_set_fine(status), "f_directory_open", F_true);
+
+      fake_macro_make_data_delete_simple(data_make);
+      return status;
+    }
+
     f_macro_mode_set_default_umask(mode, data.umask);
 
     data_make.fail = fake_make_operation_fail_type_exit;
@@ -322,6 +344,24 @@ extern "C" {
 
     fake_make_operate_section(data, data_make.main, &data_make, &list_stack, &status);
 
+    if (data_make.path.current > 0) {
+      f_file_close(&data_make.path.current);
+    }
+
+    {
+      f_status status_path = f_path_change_at(data_make.path.top);
+      if (F_status_is_error(status_path) && data.verbosity == fake_verbosity_verbose) {
+        fprintf(f_type_warning, "%c", f_string_eol[0]);
+        fl_color_print(f_type_warning, data.context.warning, data.context.reset, "WARNING: Failed change back to orignal path '");
+        fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%s", data_make.path.stack.array[0].string);
+        fl_color_print(f_type_warning, data.context.warning, data.context.reset, "', status code = ");
+        fl_color_print(f_type_warning, data.context.notable, data.context.reset, "%llu", F_status_set_fine(status_path));
+        fl_color_print_line(f_type_warning, data.context.warning, data.context.reset, ".");
+      }
+    }
+
+    f_file_close(&data_make.path.top);
+
     f_macro_string_lengths_delete_simple(list_stack);
     fake_macro_make_data_delete_simple(data_make);
 
index 6c0575c58a7ceaeab55afbd1ed7f490d5ed4eed6..b0a3330c84a57f1b83472aa24a464000c90b4ff4 100644 (file)
@@ -242,13 +242,33 @@ extern "C" {
     f_macro_string_dynamics_delete_simple(parameter.work)
 #endif // _di_fake_make_parameter_
 
+#ifndef _di_fake_make_path_
+  typedef struct {
+    int top;
+    int current;
+
+    f_string_dynamics stack;
+  } fake_make_path;
+
+  #define fake_make_path_initialize { \
+    0, \
+    0, \
+    f_string_dynamics_initialize, \
+  }
+
+  #define fake_macro_make_path_delete_simple(path) \
+    f_macro_string_dynamics_delete_simple(path.stack)
+#endif // _di_fake_make_path_
+
 #ifndef _di_fake_make_data_
   typedef struct {
     fake_build_setting setting_build;
     fake_make_setting setting_make;
 
     fake_environment environment;
+
     fake_make_parameter parameter;
+    fake_make_path path;
 
     f_fss_nameds fakefile;
     f_string_dynamic buffer;
@@ -263,6 +283,7 @@ extern "C" {
     fake_make_setting_initialize, \
     fake_environment_initialize, \
     fake_make_parameter_initialize, \
+    fake_make_path_initialize, \
     f_fss_nameds_initialize, \
     f_string_dynamic_initialize, \
     0, \
@@ -274,6 +295,7 @@ extern "C" {
     fake_macro_make_setting_delete_simple(data.setting_make) \
     fake_macro_environment_delete_simple(data.environment) \
     fake_macro_make_parameter_delete_simple(data.parameter) \
+    fake_macro_make_path_delete_simple(data.path) \
     f_macro_fss_nameds_delete_simple(data.fakefile) \
     f_macro_string_dynamic_delete_simple(data.buffer)
 #endif // _di_fake_make_data_