From: Kevin Day Date: Sat, 12 Dec 2020 03:01:53 +0000 (-0600) Subject: Cleanup: use "triple" instead of "tuple". X-Git-Tag: 0.5.2~23 X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=55110f531cf2862436552f06e3beeb4fd17c5ef9;p=fll Cleanup: use "triple" instead of "tuple". In mathematics, a "tuple" is an ordered set of some length. Here I was using a "tuple" specifically as a 3-tuple, which is wrong. Rename "tuple" to "triple" in these cases because a "triple" is the proper terminology for a 3-tuple. --- diff --git a/build/level_0/settings b/build/level_0/settings index 1882cdb..e1ad525 100644 --- a/build/level_0/settings +++ b/build/level_0/settings @@ -22,7 +22,7 @@ build_libraries -lc build_libraries-level build_sources_library account.c console.c conversion.c directory.c private-directory.c environment.c private-environment.c file.c private-file.c fss.c iki.c private-iki.c memory.c path.c private-path.c pipe.c print.c private-print.c process.c serialize.c private-serialize.c signal.c socket.c utf.c private-utf.c build_sources_program -build_sources_headers account.h account-common.h color.h console.h console-common.h conversion.h conversion-common.h directory.h directory_type.h directory-common.h environment.h environment-common.h file.h file-common.h fss.h fss-common.h fss_comment.h fss_delimit.h fss_named.h fss_nest.h fss_quote.h fss_set.h iki.h iki-common.h memory.h memory_structure.h path.h path-common.h pipe.h print.h process.h process-common.h serialize.h serialize-common.h signal.h signal-common.h socket.h socket-common.h status.h status_array.h string.h string-common.h string_dynamic.h string_map.h string_quantity.h string_range.h string_tuple.h type.h type_array.h utf.h utf-common.h +build_sources_headers account.h account-common.h color.h console.h console-common.h conversion.h conversion-common.h directory.h directory_type.h directory-common.h environment.h environment-common.h file.h file-common.h fss.h fss-common.h fss_comment.h fss_delimit.h fss_named.h fss_nest.h fss_quote.h fss_set.h iki.h iki-common.h memory.h memory_structure.h path.h path-common.h pipe.h print.h process.h process-common.h serialize.h serialize-common.h signal.h signal-common.h socket.h socket-common.h status.h status_array.h string.h string-common.h string_dynamic.h string_map.h string_quantity.h string_range.h string_triple.h type.h type_array.h utf.h utf-common.h build_sources_script build_sources_setting build_script yes diff --git a/build/monolithic/settings b/build/monolithic/settings index 5709ada..e1615e5 100644 --- a/build/monolithic/settings +++ b/build/monolithic/settings @@ -22,7 +22,7 @@ build_libraries -lc build_libraries-monolithic build_sources_library level_0/account.c level_0/console.c level_0/conversion.c level_0/directory.c level_0/private-directory.c level_0/environment.c level_0/private-environment.c level_0/file.c level_0/private-file.c level_0/fss.c level_0/iki.c level_0/private-iki.c level_0/memory.c level_0/path.c level_0/private-path.c level_0/pipe.c level_0/print.c level_0/private-print.c level_0/process.c level_0/serialize.c level_0/private-serialize.c level_0/signal.c level_0/socket.c level_0/utf.c level_0/private-utf.c level_1/color.c level_1/console.c level_1/conversion.c level_1/directory.c level_1/private-directory.c level_1/environment.c level_1/private-fss.c level_1/fss_basic.c level_1/fss_basic_list.c level_1/fss_embedded_list.c level_1/fss_extended.c level_1/fss_extended_list.c level_1/iki.c level_1/print.c level_1/private-print.c level_1/status.c level_1/string.c level_1/private-string.c level_1/type.c level_1/utf.c level_1/private-utf.c level_1/utf_file.c level_1/private-utf_file.c level_2/error.c level_2/private-error.c level_2/execute.c level_2/private-execute.c level_2/file.c level_2/private-file.c level_2/fss.c level_2/private-fss.c level_2/fss_basic.c level_2/fss_basic_list.c level_2/fss_embedded_list.c level_2/fss_extended.c level_2/fss_extended_list.c level_2/fss_status.c level_2/iki.c level_2/private-iki.c level_2/path.c level_2/program.c level_2/status.c build_sources_program -build_sources_headers level_0/account.h level_0/account-common.h level_0/color.h level_0/console.h level_0/console-common.h level_0/conversion.h level_0/conversion-common.h level_0/directory.h level_0/directory_type.h level_0/directory-common.h level_0/environment.h level_0/environment-common.h level_0/file.h level_0/file-common.h level_0/fss.h level_0/fss-common.h level_0/fss_comment.h level_0/fss_delimit.h level_0/fss_named.h level_0/fss_nest.h level_0/fss_quote.h level_0/fss_set.h level_0/iki.h level_0/iki-common.h level_0/memory.h level_0/memory_structure.h level_0/path.h level_0/path-common.h level_0/pipe.h level_0/print.h level_0/process.h level_0/process-common.h level_0/serialize.h level_0/serialize-common.h level_0/signal.h level_0/signal-common.h level_0/socket.h level_0/socket-common.h level_0/status.h level_0/status_array.h level_0/string.h level_0/string-common.h level_0/string_dynamic.h level_0/string_map.h level_0/string_quantity.h level_0/string_range.h level_0/string_tuple.h level_0/type.h level_0/type_array.h level_0/utf.h level_0/utf-common.h level_1/color.h level_1/console.h level_1/conversion.h level_1/directory.h level_1/environment.h level_1/fss.h level_1/fss_basic.h level_1/fss_basic_list.h level_1/fss_embedded_list.h level_1/fss_extended.h level_1/fss_extended_list.h level_1/fss_macro.h level_1/fss_status.h level_1/iki.h level_1/print.h level_1/status.h level_1/string.h level_1/type.h level_1/utf.h level_1/utf_file.h level_2/error.h level_2/error-common.h level_2/execute.h level_2/file.h level_2/fss.h level_2/fss_basic.h level_2/fss_basic_list.h level_2/fss_embedded_list.h level_2/fss_extended.h level_2/fss_extended_list.h level_2/fss_status.h level_2/iki.h level_2/path.h level_2/program.h level_2/status.h +build_sources_headers level_0/account.h level_0/account-common.h level_0/color.h level_0/console.h level_0/console-common.h level_0/conversion.h level_0/conversion-common.h level_0/directory.h level_0/directory_type.h level_0/directory-common.h level_0/environment.h level_0/environment-common.h level_0/file.h level_0/file-common.h level_0/fss.h level_0/fss-common.h level_0/fss_comment.h level_0/fss_delimit.h level_0/fss_named.h level_0/fss_nest.h level_0/fss_quote.h level_0/fss_set.h level_0/iki.h level_0/iki-common.h level_0/memory.h level_0/memory_structure.h level_0/path.h level_0/path-common.h level_0/pipe.h level_0/print.h level_0/process.h level_0/process-common.h level_0/serialize.h level_0/serialize-common.h level_0/signal.h level_0/signal-common.h level_0/socket.h level_0/socket-common.h level_0/status.h level_0/status_array.h level_0/string.h level_0/string-common.h level_0/string_dynamic.h level_0/string_map.h level_0/string_quantity.h level_0/string_range.h level_0/string_triple.h level_0/type.h level_0/type_array.h level_0/utf.h level_0/utf-common.h level_1/color.h level_1/console.h level_1/conversion.h level_1/directory.h level_1/environment.h level_1/fss.h level_1/fss_basic.h level_1/fss_basic_list.h level_1/fss_embedded_list.h level_1/fss_extended.h level_1/fss_extended_list.h level_1/fss_macro.h level_1/fss_status.h level_1/iki.h level_1/print.h level_1/status.h level_1/string.h level_1/type.h level_1/utf.h level_1/utf_file.h level_2/error.h level_2/error-common.h level_2/execute.h level_2/file.h level_2/fss.h level_2/fss_basic.h level_2/fss_basic_list.h level_2/fss_embedded_list.h level_2/fss_extended.h level_2/fss_extended_list.h level_2/fss_status.h level_2/iki.h level_2/path.h level_2/program.h level_2/status.h build_sources_script build_sources_setting build_script yes diff --git a/level_0/f_string/c/string.h b/level_0/f_string/c/string.h index fd7481a..58a55f9 100644 --- a/level_0/f_string/c/string.h +++ b/level_0/f_string/c/string.h @@ -27,7 +27,7 @@ #include #include #include -#include +#include #ifdef __cplusplus extern "C" { diff --git a/level_0/f_string/c/string_triple.h b/level_0/f_string/c/string_triple.h new file mode 100644 index 0000000..e4c12da --- /dev/null +++ b/level_0/f_string/c/string_triple.h @@ -0,0 +1,188 @@ +/** + * FLL - Level 0 + * + * Project: String + * API Version: 0.5 + * Licenses: lgplv2.1 + * + * Defines 3-tuple of string data called a triple (which is an ordered list of 3 strings). + * + * This is auto-included by string.h and should not need to be explicitly included. + */ +#ifndef _F_string_triple_h +#define _F_string_triple_h + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * A string triple consisting of a set of three strings. + * + * one: A string representing the first string in the triple. + * two: A string representing the second string in the triple. + * three: A string representing the third string in the triple. + */ +#ifndef _di_f_string_triple_t_ + typedef struct { + f_string_dynamic_t one; + f_string_dynamic_t two; + f_string_dynamic_t three; + } f_string_triple_t; + + #define f_string_triple_t_initialize { f_string_dynamic_t_initialize, f_string_dynamic_t_initialize, f_string_dynamic_t_initialize } + + #define f_macro_string_triple_t_clear(triple) \ + triple.one.array = 0; \ + triple.one.size = 0; \ + triple.one.used = 0; \ + triple.two.array = 0; \ + triple.two.size = 0; \ + triple.two.used = 0; \ + triple.three.array = 0; \ + triple.three.size = 0; \ + triple.three.used = 0; + + #define f_macro_string_triple_t_delete(status, triple) \ + f_macro_string_dynamic_t_delete(status, triple.one) \ + if (status == F_none) { \ + f_macro_string_dynamic_t_delete(status, triple.two) \ + } \ + if (status == F_none) { \ + f_macro_string_dynamic_t_delete(status, triple.three) \ + } + + #define f_macro_string_triple_t_destroy(status, triple) \ + f_macro_string_dynamic_t_destroy(status, triple.one) \ + if (status == F_none) { \ + f_macro_string_dynamic_t_destroy(status, triple.two) \ + } \ + if (status == F_none) { \ + f_macro_string_dynamic_t_destroy(status, triple.three) \ + } + + #define f_macro_string_triple_t_delete_simple(triple) \ + f_macro_string_dynamic_t_delete_simple(triple.one) \ + f_macro_string_dynamic_t_delete_simple(triple.two) \ + f_macro_string_dynamic_t_delete_simple(triple.three) + + #define f_macro_string_triple_t_destroy_simple(triple) \ + f_macro_string_dynamic_t_destroy_simple(triple.one) \ + f_macro_string_dynamic_t_destroy_simple(triple.two) \ + f_macro_string_dynamic_t_destroy_simple(triple.three) +#endif // _di_f_string_triple_t_ + +/** + * An array of string triples. + * + * array: the array of string triples. + * size: total amount of allocated space. + * used: total number of allocated spaces used. + */ +#ifndef _di_f_string_triples_t_ + typedef struct { + f_string_triple_t *array; + + f_array_length_t size; + f_array_length_t used; + } f_string_triples_t; + + #define f_string_triples_t_initialize f_string_statics_t_initialize + + #define f_macro_string_triples_t_clear(triples) \ + triples.array = 0; \ + triples.size = 0; \ + triples.used = 0; + + #define f_macro_string_triples_t_new(status, triples, length) \ + f_macro_string_triples_t_clear(triples) \ + status = f_memory_new((void **) & triples.array, sizeof(f_string_triple_t), length); \ + if (status == F_none) { \ + triples.size = length; \ + triples.used = 0; \ + } + + #define f_macro_string_triples_t_delete(status, triples) \ + status = F_none; \ + triples.used = triples.size; \ + while (triples.used) { \ + triples.used--; \ + f_macro_string_triple_t_delete(status, triples.array[triples.used]); \ + if (status != F_none) break; \ + } \ + if (status == F_none) status = f_memory_delete((void **) & triples.array, sizeof(f_string_triple_t), triples.size); \ + if (status == F_none) triples.size = 0; + + #define f_macro_string_triples_t_destroy(status, triples) \ + status = F_none; \ + triples.used = triples.size; \ + while (triples.used) { \ + triples.used--; \ + f_macro_string_triple_t_destroy(status, triples.array[triples.used]); \ + if (status != F_none) break; \ + } \ + if (status == F_none) status = f_memory_destroy((void **) & triples.array, sizeof(f_string_triple_t), triples.size); \ + if (status == F_none) triples.size = 0; + + #define f_macro_string_triples_t_delete_simple(triples) \ + triples.used = triples.size; \ + while (triples.used) { \ + triples.used--; \ + f_macro_string_triple_t_delete_simple(triples.array[triples.used]); \ + } \ + f_memory_delete((void **) & triples.array, sizeof(f_string_triple_t), triples.size); \ + triples.size = 0; + + #define f_macro_string_triples_t_destroy_simple(triples) \ + triples.used = triples.size; \ + while (triples.used) { \ + triples.used--; \ + f_macro_string_triple_t_destroy_simple(triples.array[triples.used]); \ + } \ + f_memory_destroy((void **) & triples.array, sizeof(f_string_triple_t), triples.size); \ + triples.size = 0; + + #define f_macro_string_triples_t_resize(status, triples, new_length) \ + status = F_none; \ + if (new_length < triples.size) { \ + for (f_array_length_t _macro__i = triples.size - new_length; _macro__i < triples.size; _macro__i++) { \ + f_macro_string_triple_t_delete(status, triples.array[_macro__i]); \ + if (status != F_none) break; \ + } \ + } \ + if (status == F_none) status = f_memory_resize((void **) & triples.array, sizeof(f_string_triple_t), triples.size, new_length); \ + if (status == F_none) { \ + if (new_length > triples.size) { \ + for (f_array_length_t _macro__i = triples.size; _macro__i < new_length; _macro__i++) { \ + memset(&triples.array[_macro__i], 0, sizeof(f_string_triple_t)); \ + } \ + } \ + triples.size = new_length; \ + if (triples.used > triples.size) triples.used = new_length; \ + } + + #define f_macro_string_triples_t_adjust(status, triples, new_length) \ + status = F_none; \ + if (new_length < triples.size) { \ + for (f_array_length_t _macro__i = triples.size - new_length; _macro__i < triples.size; _macro__i++) { \ + f_macro_string_triple_t_destroy(status, triples.array[_macro__i], f_string_triple_t); \ + if (status != F_none) break; \ + } \ + } \ + if (status == F_none) status = f_memory_adjust((void **) & triples.array, sizeof(f_string_triple_t), triples.size, new_length); \ + if (status == F_none) { \ + if (new_length > triples.size) { \ + for (f_array_length_t _macro__i = triples.size; _macro__i < new_length; _macro__i++) { \ + memset(&triples.array[_macro__i], 0, sizeof(f_string_triple_t)); \ + } \ + } \ + triples.size = new_length; \ + if (triples.used > triples.size) triples.used = new_length; \ + } +#endif // _di_f_string_triples_t_ + +#ifdef __cplusplus +} // extern "C" +#endif + +#endif // _F_string_triple_h diff --git a/level_0/f_string/c/string_tuple.h b/level_0/f_string/c/string_tuple.h deleted file mode 100644 index 3ab94ff..0000000 --- a/level_0/f_string/c/string_tuple.h +++ /dev/null @@ -1,188 +0,0 @@ -/** - * FLL - Level 0 - * - * Project: String - * API Version: 0.5 - * Licenses: lgplv2.1 - * - * Defines tuple string data. - * - * This is auto-included by string.h and should not need to be explicitly included. - */ -#ifndef _F_string_tuple_h -#define _F_string_tuple_h - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * A string tuple consisting of a set of three strings. - * - * one: A string representing the first string in the tuple. - * two: A string representing the second string in the tuple. - * three: A string representing the third string in the tuple. - */ -#ifndef _di_f_string_tuple_t_ - typedef struct { - f_string_dynamic_t one; - f_string_dynamic_t two; - f_string_dynamic_t three; - } f_string_tuple_t; - - #define f_string_tuple_t_initialize { f_string_dynamic_t_initialize, f_string_dynamic_t_initialize, f_string_dynamic_t_initialize } - - #define f_macro_string_tuple_t_clear(tuple) \ - tuple.one.array = 0; \ - tuple.one.size = 0; \ - tuple.one.used = 0; \ - tuple.two.array = 0; \ - tuple.two.size = 0; \ - tuple.two.used = 0; \ - tuple.three.array = 0; \ - tuple.three.size = 0; \ - tuple.three.used = 0; - - #define f_macro_string_tuple_t_delete(status, tuple) \ - f_macro_string_dynamic_t_delete(status, tuple.one) \ - if (status == F_none) { \ - f_macro_string_dynamic_t_delete(status, tuple.two) \ - } \ - if (status == F_none) { \ - f_macro_string_dynamic_t_delete(status, tuple.three) \ - } - - #define f_macro_string_tuple_t_destroy(status, tuple) \ - f_macro_string_dynamic_t_destroy(status, tuple.one) \ - if (status == F_none) { \ - f_macro_string_dynamic_t_destroy(status, tuple.two) \ - } \ - if (status == F_none) { \ - f_macro_string_dynamic_t_destroy(status, tuple.three) \ - } - - #define f_macro_string_tuple_t_delete_simple(tuple) \ - f_macro_string_dynamic_t_delete_simple(tuple.one) \ - f_macro_string_dynamic_t_delete_simple(tuple.two) \ - f_macro_string_dynamic_t_delete_simple(tuple.three) - - #define f_macro_string_tuple_t_destroy_simple(tuple) \ - f_macro_string_dynamic_t_destroy_simple(tuple.one) \ - f_macro_string_dynamic_t_destroy_simple(tuple.two) \ - f_macro_string_dynamic_t_destroy_simple(tuple.three) -#endif // _di_f_string_tuple_t_ - -/** - * An array of string tuples. - * - * array: the array of string tuples. - * size: total amount of allocated space. - * used: total number of allocated spaces used. - */ -#ifndef _di_f_string_tuples_t_ - typedef struct { - f_string_tuple_t *array; - - f_array_length_t size; - f_array_length_t used; - } f_string_tuples_t; - - #define f_string_tuples_t_initialize f_string_statics_t_initialize - - #define f_macro_string_tuples_t_clear(tuples) \ - tuples.array = 0; \ - tuples.size = 0; \ - tuples.used = 0; - - #define f_macro_string_tuples_t_new(status, tuples, length) \ - f_macro_string_tuples_t_clear(tuples) \ - status = f_memory_new((void **) & tuples.array, sizeof(f_string_tuple_t), length); \ - if (status == F_none) { \ - tuples.size = length; \ - tuples.used = 0; \ - } - - #define f_macro_string_tuples_t_delete(status, tuples) \ - status = F_none; \ - tuples.used = tuples.size; \ - while (tuples.used) { \ - tuples.used--; \ - f_macro_string_tuple_t_delete(status, tuples.array[tuples.used]); \ - if (status != F_none) break; \ - } \ - if (status == F_none) status = f_memory_delete((void **) & tuples.array, sizeof(f_string_tuple_t), tuples.size); \ - if (status == F_none) tuples.size = 0; - - #define f_macro_string_tuples_t_destroy(status, tuples) \ - status = F_none; \ - tuples.used = tuples.size; \ - while (tuples.used) { \ - tuples.used--; \ - f_macro_string_tuple_t_destroy(status, tuples.array[tuples.used]); \ - if (status != F_none) break; \ - } \ - if (status == F_none) status = f_memory_destroy((void **) & tuples.array, sizeof(f_string_tuple_t), tuples.size); \ - if (status == F_none) tuples.size = 0; - - #define f_macro_string_tuples_t_delete_simple(tuples) \ - tuples.used = tuples.size; \ - while (tuples.used) { \ - tuples.used--; \ - f_macro_string_tuple_t_delete_simple(tuples.array[tuples.used]); \ - } \ - f_memory_delete((void **) & tuples.array, sizeof(f_string_tuple_t), tuples.size); \ - tuples.size = 0; - - #define f_macro_string_tuples_t_destroy_simple(tuples) \ - tuples.used = tuples.size; \ - while (tuples.used) { \ - tuples.used--; \ - f_macro_string_tuple_t_destroy_simple(tuples.array[tuples.used]); \ - } \ - f_memory_destroy((void **) & tuples.array, sizeof(f_string_tuple_t), tuples.size); \ - tuples.size = 0; - - #define f_macro_string_tuples_t_resize(status, tuples, new_length) \ - status = F_none; \ - if (new_length < tuples.size) { \ - for (f_array_length_t _macro__i = tuples.size - new_length; _macro__i < tuples.size; _macro__i++) { \ - f_macro_string_tuple_t_delete(status, tuples.array[_macro__i]); \ - if (status != F_none) break; \ - } \ - } \ - if (status == F_none) status = f_memory_resize((void **) & tuples.array, sizeof(f_string_tuple_t), tuples.size, new_length); \ - if (status == F_none) { \ - if (new_length > tuples.size) { \ - for (f_array_length_t _macro__i = tuples.size; _macro__i < new_length; _macro__i++) { \ - memset(&tuples.array[_macro__i], 0, sizeof(f_string_tuple_t)); \ - } \ - } \ - tuples.size = new_length; \ - if (tuples.used > tuples.size) tuples.used = new_length; \ - } - - #define f_macro_string_tuples_t_adjust(status, tuples, new_length) \ - status = F_none; \ - if (new_length < tuples.size) { \ - for (f_array_length_t _macro__i = tuples.size - new_length; _macro__i < tuples.size; _macro__i++) { \ - f_macro_string_tuple_t_destroy(status, tuples.array[_macro__i], f_string_tuple_t); \ - if (status != F_none) break; \ - } \ - } \ - if (status == F_none) status = f_memory_adjust((void **) & tuples.array, sizeof(f_string_tuple_t), tuples.size, new_length); \ - if (status == F_none) { \ - if (new_length > tuples.size) { \ - for (f_array_length_t _macro__i = tuples.size; _macro__i < new_length; _macro__i++) { \ - memset(&tuples.array[_macro__i], 0, sizeof(f_string_tuple_t)); \ - } \ - } \ - tuples.size = new_length; \ - if (tuples.used > tuples.size) tuples.used = new_length; \ - } -#endif // _di_f_string_tuples_t_ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // _F_string_tuple_h diff --git a/level_0/f_string/data/build/settings b/level_0/f_string/data/build/settings index 550aa58..1accb18 100644 --- a/level_0/f_string/data/build/settings +++ b/level_0/f_string/data/build/settings @@ -22,7 +22,7 @@ build_libraries -lc build_libraries-individual -lf_memory build_sources_library build_sources_program -build_sources_headers string.h string-common.h string_dynamic.h string_map.h string_quantity.h string_range.h string_tuple.h +build_sources_headers string.h string-common.h string_dynamic.h string_map.h string_quantity.h string_range.h string_triple.h build_sources_script build_sources_setting build_script yes