Removed arguments and have 1 file type bug to fix...

This commit is contained in:
Ognjen Milan Robovic 2024-02-23 11:04:24 -05:00
parent a8f8ef91fc
commit 5c07727a0a
2 changed files with 12 additions and 88 deletions

View File

@ -9,14 +9,6 @@
static char * log_notify = null;
static int argument_count = 0;
static char * * argument_nick = null;
static char * * argument_name = null;
static char * argument_input = null;
static char * argument_output = null;
static void (* * argument_function) (void) = null;
static int file_list_active = 0;
static int file_list_count = 0;
static int * file_list_mark = null;
@ -186,71 +178,6 @@ void * record (void) {
return (buffer);
}
void argument_define (char * nick, char * name, void (* function) (void)) {
fatal_failure (nick == null, "argument_define: Failed to define an argument, nick is null pointer.");
fatal_failure (name == null, "argument_define: Failed to define an argument, name is null pointer.");
fatal_failure (function == null, "argument_define: Failed to define an argument, function is null pointer.");
++argument_count;
argument_nick = reallocate (argument_nick, argument_count * (int) sizeof (* argument_nick));
argument_name = reallocate (argument_name, argument_count * (int) sizeof (* argument_name));
argument_function = reallocate (argument_function, argument_count * (int) sizeof (* argument_function));
argument_nick [argument_count - 1] = allocate (string_length (nick) + 1);
argument_name [argument_count - 1] = allocate (string_length (name) + 1);
string_copy (argument_nick [argument_count - 1], nick);
string_copy (argument_name [argument_count - 1], name);
argument_function [argument_count - 1] = function;
}
void argument_select (int count, char * * array) {
int index_a = 0;
int index_b = 0;
if ((count == 1) || (array == null)) {
return;
}
for (index_a = 1; index_a != count; ++index_a) {
for (index_b = 0; index_b != argument_count; ++index_b) {
if ((string_compare (array [index_a], "-h") != 0) || (string_compare (array [index_a], "--help") != 0)) {
for (index_b = 0; index_b != argument_count; ++index_b) {
echo ("\t"); echo (argument_nick [index_b]);
echo (" "); echo (argument_name [index_b]);
echo ("\n");
}
} else if ((string_compare (array [index_a], "-i") != 0) || (string_compare (array [index_a], "--input") != 0)) {
++index_a;
argument_input = array [index_a];
break;
} else if ((string_compare (array [index_a], "-o") != 0) || (string_compare (array [index_a], "--output") != 0)) {
++index_a;
argument_output = array [index_a];
break;
} else if ((string_compare (array [index_a], argument_nick [index_b]) != 0) || (string_compare (array [index_a], argument_name [index_b]) != 0)) {
argument_function [index_b] ();
break;
}
}
}
}
void argument_delete (void) {
int index;
for (index = 0; index != argument_count; ++index) {
argument_nick [index] = deallocate (argument_nick [index]);
argument_name [index] = deallocate (argument_name [index]);
}
argument_nick = deallocate (argument_nick);
argument_name = deallocate (argument_name);
argument_function = deallocate (argument_function);
}
int file_open (char * name, int mode) {
int descriptor = -1;
@ -309,8 +236,8 @@ int file_size (char * name) {
int file_type (char * name) {
char * file_type_data [file_type_count] = {
".txt", ".s", ".fasm", ".gasm", ".nasm", ".yasm", ".c", ".h",
".adb", ".ads", ".cpp", ".hpp"
".txt", ".s", ".fasm", ".gasm", ".nasm", ".yasm", ".c", ".h", ".adb", ".ads", ".cpp", ".hpp",
".f90", ".x"
};
int type = 0;
@ -320,7 +247,7 @@ int file_type (char * name) {
}
for (type = 0; type != file_type_count; ++type) {
if (string_compare (name, file_type_data [type]) != 0) {
if (string_compare (name, file_type_data [type])) {
return (type);
}
}
@ -520,11 +447,11 @@ int character_compare_array (char character, char * character_array) {
do {
if (character == character_array [i]) {
return (1);
return (true);
}
} while (++i != string_length (character_array));
return (0);
return (false);
}
int character_count (char * string, char this, int from, int to, char stop) {
@ -589,11 +516,11 @@ int string_compare (char * string_0, char * string_1) {
for (i = 0; (string_0 [i] != '\0') && (string_1 [i] != '\0'); ++i) {
if (string_0 [i] != string_1 [i]) {
return (0);
return (false);
}
}
return (1);
return (true);
}
char * string_copy (char * string_0, char * string_1) {
@ -634,11 +561,11 @@ int string_compare_limit (char * string_0, char * string_1, int limit) {
for (i = 0; i != limit; ++i) {
if (string_0 [i] != string_1 [i]) {
return (0);
return (false);
}
}
return (1);
return (true);
}
char * string_copy_limit (char * string_0, char * string_1, int limit) {
@ -745,11 +672,11 @@ int memory_compare (void * memory, void * source, int length) {
for (i = 0; (cast_0 [i] != '\0') && (cast_1 [i] != '\0'); ++i) {
if (cast_0 [i] != cast_1 [i]) {
return (0);
return (false);
}
}
return (1);
return (true);
}
void memory_copy (void * memory, void * source, int length) {

View File

@ -30,6 +30,7 @@ enum {
file_type_text, file_type_common_assembly, file_type_flat_assembly, file_type_gnu_assembly,
file_type_netwide_assembly, file_type_yet_another_assembly, file_type_c_source, file_type_c_header,
file_type_ada_body, file_type_ada_specification, file_type_cpp_source, file_type_cpp_header,
file_type_fortran_90, file_type_xolatile_script,
file_type_count
};
@ -88,10 +89,6 @@ extern void * deallocate (void * data);
extern void * record (void);
extern void argument_define (char * nick, char * name, void (* function) (void));
extern void argument_select (int count, char * * array);
extern void argument_delete (void);
extern int file_open (char * name, int mode);
extern int file_close (int file);
extern void file_read (int file, void * data, int size);