summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Ball <nullspoon@iohq.net>2015-03-31 20:22:10 -0600
committerAaron Ball <nullspoon@iohq.net>2015-03-31 20:22:10 -0600
commitd1ab070dd1b7902356b74f192eb0fbecb6437b51 (patch)
tree76a3532ff6898221c7b2c081d7089cf7d8c13a35
parent9118fb887063b94bf7efbaecce3de75ec1717e2e (diff)
downloadnoteless-d1ab070dd1b7902356b74f192eb0fbecb6437b51.tar.gz
noteless-d1ab070dd1b7902356b74f192eb0fbecb6437b51.tar.xz
Implemented extension removal from list operations
Was printing extensions, which are not required when interracting with the given note. This was a bit confusing, despite fuzzy name matching. This strips the extension from the file/note names when listening notes.
-rw-r--r--src/common.c18
-rw-r--r--src/common.h2
-rw-r--r--src/main.c5
3 files changed, 24 insertions, 1 deletions
diff --git a/src/common.c b/src/common.c
index e2ca4f4..65eb1ad 100644
--- a/src/common.c
+++ b/src/common.c
@@ -292,3 +292,21 @@ int str_contains_case_sensitive(char* str, char* term) {
}
return 0;
}
+
+/**
+ * Removes the extension from the given string filename
+ *
+ * @param filename Filename/path to strip extension from
+ *
+ * @return int Result of the strip operation
+ */
+int strip_extension(char* filename) {
+ for(int i = strlen(filename); i > 0; i--) {
+ if(filename[i] == '.') {
+ filename[i] = '\0';
+ return 0;
+ }
+ }
+ return -1;
+}
+
diff --git a/src/common.h b/src/common.h
index c462a80..5a3deea 100644
--- a/src/common.h
+++ b/src/common.h
@@ -38,4 +38,6 @@ int str_contains_case_sensitive(char*, char*);
int str_contains_case_insensitive(char*, char*);
+int strip_extension(char*);
+
#endif
diff --git a/src/main.c b/src/main.c
index 9ee10f9..f5558ff 100644
--- a/src/main.c
+++ b/src/main.c
@@ -54,7 +54,10 @@ void get_help() {
void list_notes(note_list_t* list) {
// List notes
for(int i = 0; i < list->count; i++) {
- printf("* %s\n", list->names[i]);
+ char name[128];
+ strcpy(name, list->names[i]);
+ strip_extension(name);
+ printf("* %s\n", name);
}
}

Generated by cgit