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.
fprintf(output.stream, "%c", f_string_eol_s[0]);
+ fprintf(output.stream, " All numeric positions (indexes) start at 0 instead of one.%c", f_string_eol_s[0]);
+ fprintf(output.stream, " For example, a file of 17 lines would range from 0 to 16.%c", f_string_eol_s[0]);
+
+ fprintf(output.stream, "%c", f_string_eol_s[0]);
+
fprintf(output.stream, " When using the ");
f_color_print(output.stream, context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_read_long_depth);
fprintf(output.stream, " option, an order of operations is enforced on the parameters.%c", f_string_eol_s[0]);
#ifndef _di_fss_basic_read_main_
f_status_t fss_basic_read_main(f_console_arguments_t * const arguments, fss_basic_read_main_t *main) {
+
f_status_t status = F_none;
{
status = F_status_set_error(F_parameter);
}
+ else if (main->parameters[fss_basic_read_parameter_line].result == f_console_result_additional) {
+ f_color_print(main->error.to.stream, main->context.set.error, "%sCannot specify the '", fll_error_print_error);
+ f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_read_long_pipe);
+ f_color_print(main->error.to.stream, main->context.set.error, "' parameter with the '");
+ f_color_print(main->error.to.stream, main->context.set.notable, "%s%s", f_console_symbol_long_enable_s, fss_basic_read_long_line);
+ f_color_print(main->error.to.stream, main->context.set.error, "' parameter.%c", f_string_eol_s[0]);
+
+ status = F_status_set_error(F_parameter);
+ }
}
if (F_status_is_error_not(status) && main->parameters[fss_basic_read_parameter_delimit].result == f_console_result_additional) {
#endif // _di_fss_basic_read_defines_
/**
+ * FSS Delimit Parameter data.
*
- *
+ * fss_basic_read_delimit_mode_*:
+ * - all: All delimits are to be aplied.
+ * - content: Content are to have delimits applied.
+ * - content_greater: Content at this number or higher are to have delimits applied.
+ * - content_greater_object: Objects and Content at this number or higher are to have delimits applied.
+ * - content_lesser: Content at this number or lower are to have delimits applied.
+ * - content_lesser_object: Objects and Content at this number or lower are to have delimits applied.
+ * - content_object: Objects and Content are to have delimits applied
+ * - object: Objects arre to have delimits applied.
*/
#ifndef _di_fss_basic_read_delimit_mode_
#define fss_basic_read_delimit_mode_name_none "none"
/**
* A structure of parameters applied at some depth.
*
- * depth: the depth number in which this is to be processed at.
+ * depth: The depth number in which this is to be processed at.
*
- * index_at: position of the "--at" parameter value in the argv list, when 0 there is no parameter.
- * index_name: position of the "--name" parameter value in the argv list, when 0 there is no parameter.
+ * index_at: Position of the "--at" parameter value in the argv list, when 0 there is no parameter.
+ * index_name: Position of the "--name" parameter value in the argv list, when 0 there is no parameter.
*
- * value_at: the value of the "--at" parameter, already processed and ready to use, only when index_at > 0.
- * value_name: the value of the "--name" parameter, already processed and ready to use, only when index_name > 0.
+ * value_at: The value of the "--at" parameter, already processed and ready to use, only when index_at > 0.
+ * value_name: The value of the "--name" parameter, already processed and ready to use, only when index_name > 0.
*/
#ifndef _di_fss_basic_read_depth_t_
typedef struct {
/**
* An array of depth parameters.
*
- * array: the array of depths.
- * size: total amount of allocated space.
- * used: total number of allocated spaces used.
+ * array: The array of depths.
+ * size: Total amount of allocated space.
+ * used: Total number of allocated spaces used.
*/
#ifndef _di_fss_basic_read_depths_t_
typedef struct {
/**
* A structure for designating where within the buffer a particular file exists, using a statically allocated array.
*
- * name: The name of the file representing the range. Set string to NULL to represent the STDIN pipe.
+ * name: The name of the file representing the range. Set string to NULL to represent the STDIN pipe.
+ * range: A range within the buffer representing the file.
*/
#ifndef _di_fss_basic_read_file_t_
typedef struct {
* delimits: The positions within the buffer representing character delimits.
*/
#ifndef _di_fss_basic_read_data_t_
-
#define fss_basic_read_data_option_at 0x1
#define fss_basic_read_data_option_content 0x2
#define fss_basic_read_data_option_empty 0x4
return;
}
- if (data->contents.array[at].used || (data->option & fss_basic_read_data_option_empty)) {
-
- f_status_t (*print_object)(FILE *, const f_string_static_t, const f_string_range_t, const f_array_lengths_t) = &f_print_except_dynamic_partial;
-
- if (data->option & fss_basic_read_data_option_trim) {
- print_object = &fl_print_trim_except_dynamic_partial;
- }
-
+ if ((data->option & fss_basic_read_data_option_object) || (data->option & fss_basic_read_data_option_content) && (data->contents.array[at].used || (data->option & fss_basic_read_data_option_empty))) {
if (data->option & fss_basic_read_data_option_object) {
- print_object(main->output.stream, data->buffer, data->objects.array[at], delimits_object);
+ if (data->option & fss_basic_read_data_option_trim) {
+ fl_print_trim_except_dynamic_partial(main->output.stream, data->buffer, data->objects.array[at], delimits_object);
+ }
+ else {
+ f_print_except_dynamic_partial(main->output.stream, data->buffer, data->objects.array[at], delimits_object);
+ }
if (data->option & fss_basic_read_data_option_content) {
fss_basic_read_print_object_end(main);
f_print_except_dynamic_partial(main->output.stream, data->buffer, data->contents.array[at].array[0], delimits_content);
}
- if ((data->option & fss_basic_read_data_option_object) || (data->option & fss_basic_read_data_option_content) && (data->contents.array[at].used || (data->option & fss_basic_read_data_option_empty))) {
- fss_basic_read_print_set_end(main);
- }
+ fss_basic_read_print_set_end(main);
}
}
#endif // _di_fss_basic_read_print_at_
return F_none;
}
+ // This standard only has one line per Content; therefore, any line value greater than 0 equates to no line to print.
if (data->option & fss_basic_read_data_option_line) {
if (data->line) {
+ if (data->option & fss_basic_read_data_option_total) {
+ fss_basic_read_print_zero(main);
+ }
+
return F_none;
}
}
// This standard only supports one Content per Object so when using "--at", the only valid line is line 0.
if (data->option & fss_basic_read_data_option_total) {
if (data->line) {
- fss_basic_read_print_one(main);
+ fss_basic_read_print_zero(main);
}
else {
- fss_basic_read_print_zero(main);
+ fss_basic_read_print_one(main);
}
}
else if (!data->line) {
}
}
else if (data->option & fss_basic_read_data_option_total) {
- if (!data->contents.array[i].used) {
- fss_basic_read_print_zero(main);
+ if (data->contents.array[i].used) {
+ fss_basic_read_print_one(main);
}
else {
- fss_basic_read_print_one(main);
+ fss_basic_read_print_zero(main);
}
}
else {
f_array_lengths_t except_none = f_array_lengths_t_initialize;
f_array_lengths_t *delimits = fss_basic_read_delimit_object_is(0, data) ? &data->delimits : &except_none;
- f_array_length_t line_current = 0;
+ f_array_length_t line = 0;
for (f_array_length_t i = 0; i < data->contents.used; ++i) {
if (!data->contents.array[i].used) {
if (data->option & fss_basic_read_data_option_empty) {
- if (line_current == data->line) {
+ if (line == data->line) {
fss_basic_read_print_set_end(main);
+
break;
}
- ++line_current;
+ ++line;
}
continue;
}
- if (line_current == data->line) {
+ if (line == data->line) {
fss_basic_read_print_at(main, data, i, *delimits, except_none);
break;
}
- ++line_current;
+ ++line;
} // for
return F_none;
* @param arguments
* The console arguments passed to the program.
* @param main
- * The program specific main.
+ * The main data.
* @param parameter
* An ID representing the parameter.
* @param name
#endif // _di_fss_basic_read_print_at_
/**
- * Print the end of an Object (which is essentially the start of a Content).
+ * Print the end of an Object (which is essentially the start of Content).
*
* @param main
- * The program specific main.
+ * The main data.
*/
#ifndef _di_fss_basic_read_print_object_end_
extern void fss_basic_read_print_object_end(fss_basic_read_main_t * const main) f_attribute_visibility_internal;
* Print the number one and a newline.
*
* @param main
- * The program specific main.
+ * The main data.
*/
#ifndef _di_fss_basic_read_print_one_
extern void fss_basic_read_print_one(fss_basic_read_main_t * const main) f_attribute_visibility_internal;
* Print the end of an Object/Content set.
*
* @param main
- * The program specific main.
+ * The main data.
*/
#ifndef _di_fss_basic_read_print_set_end_
extern void fss_basic_read_print_set_end(fss_basic_read_main_t * const main) f_attribute_visibility_internal;
* Print the number zero and a newline.
*
* @param main
- * The program specific main.
+ * The main data.
*/
#ifndef _di_fss_basic_read_print_zero_
extern void fss_basic_read_print_zero(fss_basic_read_main_t * const main) f_attribute_visibility_internal;