summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOskar <[email protected]>2024-04-20 00:23:28 +0200
committerOskar <[email protected]>2024-04-20 00:23:28 +0200
commite2c0feeb8b0b350d4c22f7786d08e28fff473bf0 (patch)
treea049d25debf5b3e48025bc79ebd4782af71c023e
parente7e9f3077f3dbbe31b22316a47980c417d915b49 (diff)
Moved modeskip label because pedantic compiler
-rw-r--r--7ed.c13
-rw-r--r--functions.c4
2 files changed, 14 insertions, 3 deletions
diff --git a/7ed.c b/7ed.c
index 3262bed..412a5f1 100644
--- a/7ed.c
+++ b/7ed.c
@@ -10,7 +10,9 @@
#define USAGE "7ed [OPTION] [FILENAME]\n" \
"\nVALID COMMAND-LINE OPTIONS:\n\n"\
" -v Prints out the version number\n"\
- " -i Input file\n\n"\
+ " -i Input file\n"\
+ " -y Answer YES when pressing enter button to [Y / N] questions in the program\n"\
+ " -n Answer NO when pressing enter button to [Y / N] questions in the program\n\n"\
"To use the text editor you need to enter appropriate commands.\n"\
"The prompt will display the current 'Focus' which is the line number\n"\
"that you are currently focused on. So for example the prompt can look like this:\n"\
@@ -47,6 +49,7 @@
" 'D', 'D+', 'D+1' Are all valid but do the same thing. \n"\
" 'D10' Would remove line 10 entirely.\n"\
" 'D+10' Would remove the current line entirely as well as entirely remove the next 9 lines.\n"\
+ " \n"\
#define PROGRAM_NAME "7ed"
@@ -120,7 +123,15 @@ int main (int argc, char *argv[]) {
free(optarg_copy);
}
if (v_used == TRUE_7ED) { // print version
+ free(optarg_copy);
fprintf(stdout, "7Editor Version %d\n", VERSION);
+ return EXIT_FAILURE;
+ }
+
+ if (n_used == TRUE_7ED || y_used == TRUE_7ED) {
+ free(optarg_copy);
+ fprintf(stderr, "%s", USAGE);
+ return EXIT_FAILURE;
}
return EXIT_SUCCESS;
diff --git a/functions.c b/functions.c
index 0b17512..9c0fbe7 100644
--- a/functions.c
+++ b/functions.c
@@ -24,10 +24,10 @@ int choice(uint8_t mode) {
while ('\n' != getchar());
- modeskip:
-
} while ( (choice != 'Y') && (choice != 'y') && (choice != 'N') && (choice != 'n') );
+ modeskip:
+
if ( (choice == 'Y') || (choice == 'y') )
{
return 0;