summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@iohq.net>2015-03-22 17:43:42 -0600
committerAaron Ball <nullspoon@iohq.net>2015-03-22 17:43:42 -0600
commit9118fb887063b94bf7efbaecce3de75ec1717e2e (patch)
tree9aeaa7270c582e6d244e916e97e0835000b8f7a3
parent465601bb1185d8b2e90aa0fb8407c4583aed4454 (diff)
downloadnoteless-9118fb887063b94bf7efbaecce3de75ec1717e2e.tar.gz
noteless-9118fb887063b94bf7efbaecce3de75ec1717e2e.tar.xz
Fixed scenario where no commands specified
Was segfaulting because the argument count check (>1) was occuring much later than it should have.
-rw-r--r--src/main.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/main.c b/src/main.c
index d7e3d25..9ee10f9 100644
--- a/src/main.c
+++ b/src/main.c
@@ -75,6 +75,13 @@ void list_notes(note_list_t* list) {
int main(int argc, char* argv[]) {
+ // Print helptext if no commands specified
+ if(argc == 1) {
+ printf("\nNo command specified. Printing help text.\n");
+ get_help();
+ return 1;
+ }
+
/**
* Config variables
*/
@@ -98,7 +105,10 @@ int main(int argc, char* argv[]) {
strcat(conf_path, "/.config/noteless.conf");
config_t c;
- config_new(&c, conf_path);
+ int config_status = config_new(&c, conf_path);
+ if(config_status == -1) {
+ printf("Config file could not be found.\n");
+ }
// Override where notes are to be stored
// The local version of note path, in case it isn't set in the config
@@ -126,13 +136,6 @@ int main(int argc, char* argv[]) {
editor = tmp_editor;
}
- // Print helptext if no commands specified
- if(argc == 1) {
- printf("\nNo command specified. Printing help text.\n");
- get_help();
- return 1;
- }
-
// // If the init command was passed, we want to init before checking if the
// // note path exists, otherwise the error will display and the store will
// // never be initialized.
@@ -193,6 +196,8 @@ int main(int argc, char* argv[]) {
return 1;
}
+ // DANGER WILL ROBINSON!!!
+
// Clean up
note_list_free(&list);
config_free(&c);

Generated by cgit