summaryrefslogtreecommitdiffstats
path: root/src/utils.c
Commit message (Collapse)AuthorAgeFilesLines
* Do not cast unused return values to voidLukas Fleischer2011-11-021-9/+9
| | | | | | | | | | | | | | | | | | | | A small style fix that removes all remaining "(void)" casts. Using these isn't encouraged in GNU coding guidelines and doesn't serve a certain purpose, except for satisfying a few static code analysis tools. We already nuked some of these in previous patches, but this semantic patch should fix what's left: @@ identifier func; @@ - (void)func ( + func ( ...); Long lines were re-formatted manually. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Avoid use of printf()/fprintf()Lukas Fleischer2011-11-021-1/+1
| | | | | | | | | | | | | | | | Use one of the following functions where appropriate: * puts() (whenever we print hard coded strings to stdout) * fputs() (whenever we print hard coded strings to a stream) * putchar() (whenever we print a single character to stdout) * fputc() (whenever we print a single character to a stream) * strncpy() (whenever we copy hard coded strings to a buffer) This removes the overhead introduced by the format string parser and reduces the number of false positive C-format strings spotted by xgettext(1)'s heuristics. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/utils.c: Support more powerful duration stringsLukas Fleischer2011-10-061-23/+100
| | | | | | | | | Add support for "1d23h42m"-like duration strings to parse_duration(). Also, switch to using a deterministic finite automaton to parse duration strings, as things tend to get unclear. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/utils.c: Remove check_time()Lukas Fleischer2011-10-061-31/+0
| | | | | | | Now that parse_time() and parse_duration() do all the validation work, this isn't used (nor needed) any longer. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/utils.c: Introduce parse_{time,duration}()Lukas Fleischer2011-10-061-0/+85
| | | | | | | | | These helpers can be used in a fashion similar to parse_date(). In addition to check_time(), parse_time() and parse_duration() support short forms such as "23:" (instead of "23:00") and ":45" (instead of "00:45"). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/utils.c: Mark input string of parse_date() constLukas Fleischer2011-10-061-4/+4
| | | | | | | We don't mess about with the date string here, so it should be declared const. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Do not unlink() note files on note removalLukas Fleischer2011-10-051-4/+4
| | | | | | | | | | Now that we use hash-based note file names, note files should never be unlinked as a note file might be shared. Also, remove the ERASE_FORCE_KEEP_NOTE flag that no longer makes any sense. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Refactor out note functionsLukas Fleischer2011-07-211-18/+0
| | | | | | | | | | * Add new note_edit() and note_view() helper functions. Use these instead of copy-pasted code in *_note_edit(). * Move all note-related functions (note_edit(), note_view(), note_erase()) to a new source file "note.c". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Merge branch 'maint'Lukas Fleischer2011-07-101-0/+15
|\
| * Honor "TMPDIR" environment variableLukas Fleischer2011-07-091-0/+15
| | | | | | | | | | | | | | | | | | Replace all hardcoded paths referring to "/tmp" with a new function that honors the "TMPDIR" environment variable as well as P_tmpdir and uses "/tmp" as a fallback. Thanks-to: Erik Saule <esaule@bmi.osu.edu> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add press_any_key() functionLukas Fleischer2011-07-051-0/+12
| | | | | | | | | | | | | | Displays "Press any key to continue..." in shell terminal mode and waits for a key stroke. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add shell_exec() functionLukas Fleischer2011-07-021-0/+8
| | | | | | | | | | | | Can be used to execute an external program in a shell. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add child_wait() functionLukas Fleischer2011-07-021-0/+16
| | | | | | | | | | | | Can be used to wait for the termination of a child process. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add fork_exec() functionLukas Fleischer2011-07-021-0/+71
| | | | | | | | | | | | | | Can be used to execute an external program. Provides the possibility to optionally create a pipe to the new process. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Split line editing functions into separate fileLukas Fleischer2011-06-291-183/+0
|/ | | | | | | Move getstring() related stuff into a separate file as a first step on our way to UTF-8 support for line editing helpers. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/utils.c: Make bell() staticLukas Fleischer2011-06-071-1/+1
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Update copyright notices in source files, documentation and "COPYING".Lukas Fleischer2011-04-221-1/+1
| | | | | | | | | * Update copyright dates (use 2004-2011 as date range everywhere). * Change copyright holder from "Frederic Culot" to "calcurse Development Team". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use mem_free() instead of xfree() in check_time().Lukas Fleischer2011-04-171-1/+1
| | | | | | | xfree() should never be used directly and only be called by one of the mem_*() wrappers. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix null pointer dereference in parse_date().Lukas Fleischer2011-04-121-9/+12
| | | | | | | | Passing a date in format "mm-dd-yy" where short forms are not allowed would lead to a null pointer dereference here. This one fixes that. Spotted by clang-analyzer. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Compare pointers to "NULL" instead of "0".Lukas Fleischer2011-04-051-3/+3
| | | | | | "bad_zero.cocci" spatch from http://coccinelle.lip6.fr/impact_linux.php. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Avoid assignment of undefined value in parse_date().Lukas Fleischer2011-04-031-4/+4
| | | | | | Spotted by clang-analyzer ("Assigned value is garbage or undefined"). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Try to stick to the GNU coding standards for the sake of consistency.Lukas Fleischer2011-03-151-133/+170
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use upper case for macro names.Lukas Fleischer2011-03-151-2/+2
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Overall indentation fixes.Lukas Fleischer2011-03-141-30/+30
| | | | | | | Use spaces instead of tabs for source code indentation only, strip trailing whitespaces from lines. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Clean up updatestring() in "utils.c".Lukas Fleischer2011-03-051-15/+18
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Simplify date_sec2date_fmt() in "utils.c".Lukas Fleischer2011-03-051-5/+1
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Clean up and simplify line editing functions.Lukas Fleischer2011-03-051-158/+100
| | | | | | | | | This greatly simplifies all line editing functions - especially getstring() and showstring(). showcursor() is removed and integrated into showstring(). del_char() and add_char() are simplified as well. add_char() is renamed to ins_char(). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Remove unnecessary casting variables from get_item_{hour,min}().Lukas Fleischer2011-03-041-4/+2
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Update website links to match the new URL.Lukas Fleischer2011-03-041-1/+1
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Update mail addresses to match the new mailing lists.Lukas Fleischer2011-03-041-1/+1
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Simplify date_sec2date_str() in "utils.c".Lukas Fleischer2011-03-041-11/+6
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Remove date_sec2hour_str() from "utils.c".Lukas Fleischer2011-03-041-16/+0
| | | | | | | | date_sec2hour_str() is superseded by date_sec2date_str() with "%H:%M" as date format string, so replace all invocations and remove that function from "utils.c". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Simplify date2sec() in "utils.c".Lukas Fleischer2011-03-041-13/+8
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Simplify check_time() in "utils.c".Lukas Fleischer2011-03-041-31/+14
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Simplify print_in_middle() in "utils.c".Lukas Fleischer2011-03-041-14/+9
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Reformat erase_window_part() in "utils.c".Lukas Fleischer2011-03-041-7/+4
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Simplify get_item_hour() and get_item_min() in "utils.c".Lukas Fleischer2011-03-041-16/+6
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Simplify str_toupper() in "utils.c".Lukas Fleischer2011-03-041-6/+3
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Simplify file_close() in "utils.c".Lukas Fleischer2011-03-041-4/+1
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Simplify now() and nowstr() in "utils.c".Lukas Fleischer2011-03-041-7/+3
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Remove CVS "$Id" headers.Lukas Fleischer2011-03-031-2/+0
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fixed file permissions.Lukas Fleischer2011-03-031-0/+0
|
* Make parse_date accept several short forms.Lukas Fleischer2011-01-111-41/+60
| | | | | | | | | Short forms are only accepted in interactive mode (e.g. when using the "Go to" function, editing a recurrent item's end date, and so on). Samples: "1/1/30" for "01/01/2030", "26" for the 26th of the currently selected month/year or "3/1" for Mar 01 (or Jan 03, depending on the date format) of the currently selected year.
* Added "backword-kill-word" functionality to getstring().Lukas Fleischer2010-11-041-1/+20
|
* is_all_digit() rewritten.Frederic Culot2010-10-231-12/+5
| | | | Patch submitted by Lukas Fleischer, thanks.
* Avoid concurrent screen refreshes.Frederic Culot2010-03-211-11/+10
|
* All headers gathered into a single one. Typedefs suppressed.Frederic Culot2010-03-201-22/+10
|
* Start and log daemon activity only if requested.Frederic Culot2009-08-011-2/+3
|
* Work on allocating and freeing memory associated with user's data for the ↵Frederic Culot2009-07-271-12/+18
| | | | daemon.
* --status flag addedFrederic Culot2009-07-261-8/+7
|