Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/c/checklist.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ void checklist_add_items(char *name) {
}

void add_item(char *name) {
name = capitalize(trim_whitespace(name));
name = trim_whitespace(name);
name = trim_trailing_period(name);
name = capitalize(name);

if(s_checklist_length < MAX_CHECKLIST_ITEMS && strlen(name) > 0) {
strncpy(s_checklist_items[s_checklist_length].name, name, MAX_NAME_LENGTH - 1);
Expand Down
13 changes: 13 additions & 0 deletions src/c/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ char* trim_whitespace(char *str) {
return str;
}

char* trim_trailing_period(char *str) {
char *end;

end = str + strlen(str) - 1;

if (*end == '.') {
end--;
*(end+1) = 0;
}

return str;
}

/* find the next word starting at 's', delimited by characters
* in the string 'delim', and store up to 'len' bytes into *buf
* returns pointer to immediately after the word, or NULL if done.
Expand Down
1 change: 1 addition & 0 deletions src/c/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ bool menu_layer_menu_index_selected(MenuLayer *menu_layer, MenuIndex *index);
char is_space(char c);
char *capitalize(char *str);
char *trim_whitespace(char *str);
char *trim_trailing_period(char *str);
char *strwrd(char *s, char *buf, size_t len, char *delim);