From: Kevin Day Date: Mon, 6 Jul 2020 03:49:56 +0000 (-0500) Subject: Progress: featureless make. X-Git-Tag: 0.5.0~105 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=82096500636b7af4eb0595916f736e7dd54896a8;p=fll Progress: featureless make. Update appropriate f_utf_ functions. Implement "define" and "parameter" IKI variables as per IKI-0002. These variables will be substituted with settings value if found or removed if not found. This expansion will happen before performing operation. rename fake_make_load_setting() to fake_make_load_fakefile() to be more explicit. Minor cleanups. --- diff --git a/level_3/fake/c/private-fake.c b/level_3/fake/c/private-fake.c index 4e800a7..e5d8e0f 100644 --- a/level_3/fake/c/private-fake.c +++ b/level_3/fake/c/private-fake.c @@ -569,7 +569,7 @@ extern "C" { for (j = 0; j < length; j++) { width_max = length - j; - status = f_utf_is_word_dash_plus(arguments.argv[location] + j, width_max); + status = f_utf_is_word_dash_plus(arguments.argv[location] + j, width_max, F_false); if (F_status_is_error(status)) { if (fake_print_error(data->context, data->verbosity, F_status_set_fine(status), "f_utf_is_word_dash_plus", F_false) == F_unknown && data->verbosity != fake_verbosity_quiet) { @@ -749,7 +749,7 @@ extern "C" { for (j = 0; j < data->define.array[i].used; j++) { width_max = data->define.array[i].used - j; - status = f_utf_is_word(data->define.array[i].string + j, width_max); + status = f_utf_is_word(data->define.array[i].string + j, width_max, F_false); if (F_status_is_error(status)) { if (fake_print_error(data->context, data->verbosity, F_status_set_fine(status), "f_utf_is_word", F_false) == F_unknown && data->verbosity != fake_verbosity_quiet) { @@ -804,7 +804,7 @@ extern "C" { for (j = 0; j < data->mode.array[i].used; j++) { width_max = data->mode.array[i].used - j; - status = f_utf_is_word_dash_plus(data->mode.array[i].string + j, width_max); + status = f_utf_is_word_dash_plus(data->mode.array[i].string + j, width_max, F_false); if (F_status_is_error(status)) { if (fake_print_error(data->context, data->verbosity, F_status_set_fine(status), "f_utf_is_word_dash_plus", F_false) == F_unknown && data->verbosity != fake_verbosity_quiet) { diff --git a/level_3/fake/c/private-make.c b/level_3/fake/c/private-make.c index 12637c3..60b1111 100644 --- a/level_3/fake/c/private-make.c +++ b/level_3/fake/c/private-make.c @@ -10,8 +10,8 @@ extern "C" { #endif -#ifndef _di_fake_make_load_setting_ - void fake_make_load_setting(const fake_data data, fake_make_data *data_make, f_status *status) { +#ifndef _di_fake_make_load_fakefile_ + void fake_make_load_fakefile(const fake_data data, fake_make_data *data_make, f_status *status) { if (F_status_is_error(*status)) return; *status = fake_file_buffer(data, data.file_data_build_fakefile.string, &data_make->buffer); @@ -103,8 +103,7 @@ extern "C" { data_make->fakefile.array[data_make->fakefile.used].name = list_objects.array[i]; - content_range.start = list_contents.array[i].array[0].start; - content_range.stop = list_contents.array[i].array[0].stop; + content_range = list_contents.array[i].array[0]; *status = fll_fss_extended_read(&data_make->buffer, &content_range, &data_make->fakefile.array[data_make->fakefile.used].objects, &data_make->fakefile.array[data_make->fakefile.used].contents); if (F_status_is_error(*status)) { @@ -139,12 +138,12 @@ extern "C" { return; } - // look for load_build to determine if settings from the build settings file should be loaded. - const f_string_range range_load_build = f_macro_string_range_initialize(fake_make_setting_load_build_length); - data_make->setting_make.load_build = F_true; if (settings.objects.used) { + // look for load_build to determine if settings from the build settings file should be loaded. + const f_string_range range_load_build = f_macro_string_range_initialize(fake_make_setting_load_build_length); + const f_string_range range_yes = f_macro_string_range_initialize(fake_common_setting_bool_yes_length); const f_string_range range_no = f_macro_string_range_initialize(fake_common_setting_bool_no_length); @@ -209,7 +208,7 @@ extern "C" { f_macro_fss_set_delete_simple(settings); } } -#endif // _di_fake_make_load_setting_ +#endif // _di_fake_make_load_fakefile_ #ifndef _di_fake_make_operate_ f_return_status fake_make_operate(const fake_data data) { @@ -226,7 +225,7 @@ extern "C" { f_macro_mode_set_default_umask(mode, data.umask); - fake_make_load_setting(data, &data_make, &status); + fake_make_load_fakefile(data, &data_make, &status); fake_make_operate_section(data, data_make.main, &data_make, &list_stack, &status); @@ -267,12 +266,28 @@ extern "C" { } } + const f_string_static vocabulary_define = f_macro_string_static_initialize(iki_vocabulary_0002_define, iki_vocabulary_0002_define_length); + const f_string_static vocabulary_parameter = f_macro_string_static_initialize(iki_vocabulary_0002_parameter, iki_vocabulary_0002_parameter_length); + + const f_string_range range_define = f_macro_string_range_initialize(iki_vocabulary_0002_define_length); + const f_string_range range_parameter = f_macro_string_range_initialize(iki_vocabulary_0002_parameter_length); + f_iki_variable iki_variable = f_iki_variable_initialize; f_iki_vocabulary iki_vocabulary = f_iki_vocabulary_initialize; f_iki_content iki_content = f_iki_content_initialize; + f_string_range range = f_string_range_initialize; - for (f_array_length i = 0; i < content.used; i++) { + f_string_map_multis *map_multis = 0; + + f_array_length i = 0; + f_array_length j = 0; + f_array_length k = 0; + f_array_length l = 0; + + f_string_length previous = 0; + + for (; i < content.used; i++) { if (content.array[i].start > content.array[i].stop) { continue; } @@ -303,7 +318,7 @@ extern "C" { } if (iki_variable.used) { - if (content.array[i].start < iki_variable.array[0].start) { + if (iki_variable.array[0].start > 0 && content.array[i].start < iki_variable.array[0].start) { range.start = content.array[i].start; range.stop = iki_variable.array[0].start - 1; @@ -312,50 +327,90 @@ extern "C" { fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_dynamic_partial_append_nulless", F_true); break; } - - *status = fl_string_append_assure(" ", 1, &arguments->array[arguments->used]); - if (F_status_is_error(*status)) { - fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_append_assure", F_true); - break; - } } - for (f_array_length j = 0; j < iki_variable.used; j++) { - if (j > 0) { - *status = fl_string_append_assure(" ", 1, &arguments->array[arguments->used]); + for (j = 0, previous = iki_variable.array[0].start; j < iki_variable.used; j++) { + + if (previous + 1 < iki_variable.array[j].start) { + range.start = previous + 1; + range.stop = iki_variable.array[j].start - 1; + + *status = fl_string_dynamic_partial_append_nulless(data_make->buffer, range, &arguments->array[arguments->used]); if (F_status_is_error(*status)) { - fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_append_assure", F_true); + fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_dynamic_partial_append_nulless", F_true); break; } } - // @todo: compare vocabulary name against known set. - // then use that value to determine how to substitute. + *status = fl_string_dynamic_partial_compare(vocabulary_define, data_make->buffer, range_define, iki_vocabulary.array[j]); - // these next few blocks are just examples for testing. - *status = fl_string_append_assure("@todo:", 6, &arguments->array[arguments->used]); - if (F_status_is_error(*status)) { - fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_append_assure", F_true); - break; + if (*status == F_equal_to_not) { + *status = fl_string_dynamic_partial_compare(vocabulary_parameter, data_make->buffer, range_parameter, iki_vocabulary.array[j]); + + if (*status == F_equal_to) { + map_multis = &data_make->setting_make.parameter; + } + } + else if (*status == F_equal_to) { + map_multis = &data_make->setting_make.define; } - range.start = iki_content.array[j].start; - range.stop = iki_content.array[j].stop; + if (*status == F_equal_to_not) { + *status = fl_string_dynamic_partial_append_nulless(data_make->buffer, iki_variable.array[j], &arguments->array[arguments->used]); + if (F_status_is_error(*status)) { + fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_dynamic_partial_append_nulless", F_true); + break; + } - *status = fl_string_dynamic_partial_append_nulless(data_make->buffer, range, &arguments->array[arguments->used]); - if (F_status_is_error(*status)) { - fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_dynamic_partial_append_nulless", F_true); + previous = iki_variable.array[j].stop; + continue; + } + else if (F_status_is_error(*status)) { + fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_dynamic_partial_compare", F_true); break; } - } // for - if (iki_variable.array[iki_variable.used - 1].stop < content.array[i].stop) { - *status = fl_string_append_assure(" ", 1, &arguments->array[arguments->used]); - if (F_status_is_error(*status)) { - fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_append_assure", F_true); - break; + // @todo: consider designing a way to designate appending map as a single value string or multiple separate strings. + // this could potential be done by considering single vs double quotes. + // then arguments->used would have to be incremented based on this number. + if (map_multis->used) { + for (k = 0; k < map_multis->used; k++) { + *status = fl_string_dynamic_partial_compare_dynamic(map_multis->array[k].name, data_make->buffer, iki_content.array[j]); + + if (*status == F_equal_to) { + for (l = 0; l < map_multis->array[k].value.used; l++) { + if (l > 0) { + *status = fl_string_append(" ", 1, &arguments->array[arguments->used]); + if (F_status_is_error(*status)) { + fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_append", F_true); + break; + } + } + + *status = fl_string_dynamic_append_nulless(map_multis->array[k].value.array[l], &arguments->array[arguments->used]); + if (F_status_is_error(*status)) { + fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_dynamic_append_nulless", F_true); + break; + } + } // for + + break; + } + else if (F_status_is_error(*status)) { + fake_print_error(data.context, data.verbosity, F_status_set_fine(*status), "fl_string_dynamic_compare", F_true); + break; + } + } // for + + if (F_status_is_error(*status)) break; } + previous = iki_variable.array[j].stop; + } // for + + if (F_status_is_error(*status)) break; + + if (iki_variable.array[iki_variable.used - 1].stop < content.array[i].stop) { range.start = iki_variable.array[iki_variable.used - 1].stop + 1; range.stop = content.array[i].stop; @@ -365,8 +420,6 @@ extern "C" { break; } } - - // @todo there needs to always expand into multiple values using whitespace to determine separation, by supporting single and double quote detection (and escaping). } else { *status = fl_string_dynamic_partial_append_nulless(data_make->buffer, content.array[i], &arguments->array[arguments->used]); diff --git a/level_3/fake/c/private-make.h b/level_3/fake/c/private-make.h index c0d8bdc..82ce457 100644 --- a/level_3/fake/c/private-make.h +++ b/level_3/fake/c/private-make.h @@ -257,9 +257,9 @@ extern "C" { * * @see fake_build_load_setting() */ -#ifndef _di_fake_make_load_setting_ - extern void fake_make_load_setting(const fake_data data, fake_make_data *data_make, f_status *status) f_gcc_attribute_visibility_internal; -#endif // _di_fake_make_load_setting_ +#ifndef _di_fake_make_load_fakefile_ + extern void fake_make_load_fakefile(const fake_data data, fake_make_data *data_make, f_status *status) f_gcc_attribute_visibility_internal; +#endif // _di_fake_make_load_fakefile_ /** * Execute the make operation.