summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Do not hardcode paths to the default editor/pagerLukas Fleischer2011-10-042-4/+5
| | | | | | | | | | | | | | | Use "vi" instead of "/usr/bin/vi" and "less" instead of "/usr/bin/less". Hardcoding absolute paths is a bad idea: $ uname -rsv Linux 3.0-ARCH #1 SMP PREEMPT Tue Aug 30 07:32:23 UTC 2011 $ which less /bin/less The "$PATH" environment variable will almost always have a better idea of where these binaries are located. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Rework indentation code in print_notefile()Lukas Fleischer2011-08-261-3/+9
| | | | | | | Do not use snprintf() here as printf() behaviour is undefined if the destination pointer is used as a parameter. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/io.c: iCal content line folding correctnessLukas Fleischer2011-08-261-112/+69
| | | | | | | | | | | | | | | | | | | This is a rather invasive change that introduces correct line folding to our iCal parser. From now on, ical_readline() should be used instead of fgets() to read lines from an iCal file as it unfolds lines automatically. We also need to use shared buffers as each ical_readline() invocation eats up the first part of the next line and stores it in the "lstore" buffer. Subsequent ical_readline() invocations copy the contents of this buffer and append continuation lines. We currently use a single buffer pair that is allocated in io_import_data() and pass it to all subroutines. ical_readline_init() needs to be called once for every buffer pair. It reads the first part of the current line and writes to "lstore", clearing the target buffer at the same time. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix sort order in app_arg()Lukas Fleischer2011-07-301-52/+78
| | | | | | | | | | | | We used to iterate over the list of regular appointments and the list of recurrent appointments in separate loops, thus leading to recurrent appointments being printed first and regular appointments being printed afterwards, regardless of their start and end times. Merge these loops to coerce precedence of the start time. There's still a fair bit of hackery in here - we will fix that later. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix apoint_get() call in apoint_switch_notify()Lukas Fleischer2011-07-291-1/+1
| | | | | | | We passed the function arguments the wrong way round. This regression was introduced in commit 77ef3fe76e4ce4c9a990e8a5904ad2d83420ca02. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix notify_check_repeated()Lukas Fleischer2011-07-291-1/+1
| | | | | | | | | | Remove the "current_time" check from the first if condition. As "greater than" relations (">") have higher precedence than assignments ("=") in C, this caused "real_app_time" to always be one or zero which definitely isn't what we want here. Reading further down, it turns out that we don't even need this comparison here, so we should be fine removing it. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix recurrent appointment notificationLukas Fleischer2011-07-291-6/+3
| | | | | | We probably broke this in 9fab24818a119aef08b9726f6c1cd31d5434ce34. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Update the notification item in *_paste_item()Lukas Fleischer2011-07-292-0/+8
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Update the notification item in day_edit_item()Lukas Fleischer2011-07-291-0/+11
| | | | | | | | | | | Ensure the start time as well as the description of the notification appointment are synced after editing it. We use notify_check_next_app()'s force parameter to ensure that the notification item is updated even if only the description was modified. Reported-by: Andraž 'ruskie' Levstik <ruskie@codemages.net> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add "force" parameter to notify_check_next_app()Lukas Fleischer2011-07-294-11/+13
| | | | | | | | This allows to force notify_check_next_app() to update the notification appointment, even if start times are equal (e.g. if the item description was changed). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* io.c: Accept resource parameters in iCal importLukas Fleischer2011-07-281-2/+2
| | | | | | | | | Remove colons from the "SUMMARY:" and "DURATION:" search patterns in ical_read_event() to allow for additional parameters (such as language parameters, cf. RFC 5545). Reported-by: Andraž 'ruskie' Levstik <ruskie@codemages.net> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Invoke vars_init() before importing data with "-i"Lukas Fleischer2011-07-281-0/+2
| | | | | | | | | | | | We forgot to call vars_init() when importing an item using the "-i" command line argument, which led to the pager configuration variable being unset and hence the pager invocation (triggered to show the log in case there are any errors during import) failing. Fix this by calling vars_init() before io_import_data(). Reported-by: Andraž 'ruskie' Levstik <ruskie@codemages.net> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Honor "TMPDIR" environment variableLukas Fleischer2011-07-093-2/+20
| | | | | | | | | 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>
* Handle resize properly in the sidebar config menuLukas Fleischer2011-06-291-5/+16
| | | | | | | | | There used to be no resize handler in custom_sidebar_config() which resulted in a messed up screen if the terminal was resized during sidebar configuration. Doing a simple wins_reset() if the terminal was resized works around this problem. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Do not try to display items with negative widthLukas Fleischer2011-06-281-0/+3
| | | | | | | Don't display anything rather than segfault if the appointment panel becomes too small (e.g. during a terminal resize). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Always work with new window dimensions on resizeLukas Fleischer2011-06-281-35/+27
| | | | | | | | | | | | This one came up after improving resizing behaviour in commit fec37db06bbbdff79bc9816046a76e0b29e173b4. We used to use outdated width and height values at various places without noticing it due to the resize algorithm being called several times on every resize. This patch ensures we retrieve the new window dimensions *before* doing any layout calculations. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Avoid redundant redraws on resizeLukas Fleischer2011-06-287-77/+106
| | | | | | | | | | Use a global flag to record whether the terminal was resized instead of redrawing everything each time a KEY_RESIZE is read. Add some additional checks to help_write_pad() as invalid actions may be passed now due to using signals instead of virtual key presses. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/llist.c: Use stable insertion algorithmLukas Fleischer2011-06-201-2/+2
| | | | | | | Ensure the relative order of elements with equal keys is maintained when inserting into a sorted list. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix whitespace issuesLukas Fleischer2011-06-095-17/+17
| | | | | | Strip trailing whitespaces in all source files. 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>
* Add missing llist header files to "_SOURCES".Lukas Fleischer2011-05-171-0/+2
| | | | | | | | We forgot to add those to the "_SOURCES" variable in commit 0eb1da8dd7fa3ae9d95e12df6058fb41a5ec1c11 and d668963e2056027526374098efe2869a0d389b92. Spotted by `make distcheck`. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Update copyright notices in source files, documentation and "COPYING".Lukas Fleischer2011-04-2224-26/+26
| | | | | | | | | * 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>
* Ignore daemon lock file if the daemon process died.Lukas Fleischer2011-04-221-1/+1
| | | | | | | Do this in a fashion similar to what was done in commit 6ff95238766656c5ea9d5c65c35d3aef93499f60. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Return -1 in io_file_is_empty() if file cannot be accessed.Lukas Fleischer2011-04-223-3/+3
| | | | | | | Ensure files don't appear as empty if fopen() fails (e.g. on temporary EACCES failures). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use "event" structure when iterating over events in app_arg().Lukas Fleischer2011-04-221-1/+1
| | | | | | | Regression introduced in commit 5b174ba5d46c256f41c1cfb952d46f49a088db8a. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add comments to linked list functions.Lukas Fleischer2011-04-221-0/+39
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* llist.c: Nullify pointers after free()'ing.Lukas Fleischer2011-04-221-1/+6
| | | | | | | | | | | | | * Set all data members to "NULL" in llist_free_inner() after freeing them. Altough we normally shouldn't continue working with a list that already went through llist_free_inner(), this will protect against dangling pointer bugs in case anyone will ever come up with the idea of doing so. * Set list head to "NULL" in llist_free(), basically to put the list into an initialized state. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use generic lists for recurring item exceptions.Lukas Fleischer2011-04-224-174/+142
| | | | | | | | | Rename "days" structure to "excp" which seems to be a better name here. Use generic linked lists of excp structures instead of using the "days" structure which again contains a linked list implementation. Do some cleanups and invocation fixes. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Remove "next" member from "recur_apoint" structure.Lukas Fleischer2011-04-191-1/+0
| | | | | | | | | | | | Field seems to be unused. Verify using following spatch: ---- @@ struct recur_apoint *rapt; @@ * rapt->next ---- Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use generic lists for recurring apointments and events.Lukas Fleischer2011-04-195-466/+373
| | | | | | | | Use them instead of "recur_apoint_list" and "next" pointers in "recur_event" type variables. Includes some code simplifications and cleanups. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add recur_apoint_inday() and recur_event_inday().Lukas Fleischer2011-04-192-0/+16
| | | | | | | | | | | | To be used with llist_fn_match_t callbacks later. I feel a bit ill adding those functions. This definitely is a hack. Ultimately, there should be some generic recur_item_inday() function that accepts both recurring apointments and events (or some wrapper structure) instead of parameter galeere. This is not the right place to fix that tho. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use generic lists for generic day items.Lukas Fleischer2011-04-192-101/+88
| | | | | | | Use the new generic list implementation instead of "next" pointers in day_item type variables. Includes some cleanups and fixes. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use generic lists for todo items.Lukas Fleischer2011-04-196-130/+103
| | | | | | | Use the new generic list implementation instead of "next" pointers in todo items. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use generic lists for events.Lukas Fleischer2011-04-197-121/+105
| | | | | | | Use the new generic list implementation instead of those insane "next" pointers in events. Includes some cleanups. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Remove "next" member from "apoint" structure.Lukas Fleischer2011-04-191-1/+0
| | | | | | | | | | | | Field seems to be unused. Verify using following spatch: ---- @@ struct apoint *apt; @@ * apt->next ---- Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use generic lists for appointments.Lukas Fleischer2011-04-195-227/+177
| | | | | | | Use the new generic list implementation instead of "apoint_list" everywhere. Simplify stuff and drop unused variables as well. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add macros to use for thread-safe linked lists.Lukas Fleischer2011-04-192-0/+88
| | | | | | | | | Add LLIST_TS_* macros in a fashion similar to the already existing LLIST_* macros. Unlike the non-thread-safe version, these include LLIST_TS_LOCK and LLIST_TS_UNLOCK which can be used to lock (and unlock) a list (hence the thread-safety). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add macros for linked list operations.Lukas Fleischer2011-04-191-0/+26
| | | | | | | | | | | Mostly in preparation to the pending thread-safe list macros. This way, we have a similar interface to thead-safe and non-thread-safe lists. This also adds LLIST_FOREACH and LLIST_FIND_FOREACH macros which can be used as shortcuts when iterating over all list items or a subset of list items that is accepted by a callback function. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add linked lists implementation.Lukas Fleischer2011-04-194-0/+287
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As discussed on the mailing lists, the various linked list implementations we currently use at a dozen of different places in the calcurse source tree are inconvenient and should be replaced by a single generic solution. This is a first approach to introduce such a generic implemetation. It provides following functions: * llist_init(): Initialize a list. * llist_free_inner(): Loop through a list and free all items. * llist_free(): Free the list itself (but not the individual items). * llist_first(): Get the first item of a list. * llist_nth(): Get the nth item of a list. * llist_next(): Get the successor of a list item. * llist_find_first(): Find an item using a callback function. * llist_find_next(): Find the next match using a callback function. * llist_find_nth(): Find the nth item in a list (using a callback). * llist_get_data(): Get a pointer to the actual data of a list item. * llist_add(): Add an item at the end of a list. * llist_add_sorted(): Add an item to a sorted list (using a comparison callback function). * llist_remove(): Remove an item from a list. Linked lists are stored in "llist_t" structures, list items are to be stored in "llist_item_t" structs. All of the llist_*() functions either expect a pointer to a llist_t structure (in case the function operates on the list itself) or a pointer to a llist_item_t (llist_*_next() and llist_get_data()). 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 io_file_is_empty() behaviour when file starts with a newline.Lukas Fleischer2011-04-121-1/+1
| | | | | | | Read second byte if the first byte is a newline character to ensure the file doesn't contain any further data. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use do-while loops when reading start time and duration in apoint_add().Lukas Fleischer2011-04-121-2/+5
| | | | | | | | Using do-while loops seems more appropriate here as "item_time" hasn't even been read when either of the loops are entered. Spotted by clang-analyzer. 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>
* Remove some more dead assignments spotted by clang-analyzer.Lukas Fleischer2011-04-122-2/+0
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Declare exit_calcurse() "noreturn".Lukas Fleischer2011-04-121-1/+1
| | | | | | | | Functions that never return should be declared "noreturn" to tell the compiler this fact. Also, clang-analyzer will detect this attribute and take it into account when running scan-build. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Drop empty notes after editing.Lukas Fleischer2011-04-124-0/+32
| | | | | | | | | Keeping empty notes doesn't make sense here. Also, there doesn't seem to be a simple way to erase notes yet. This will make calcurse delete any notes that are empty (meaning that they are either 0-byte files or contain nothing but a newline character) when returning from the editor. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix bad use of unsigned integers.Lukas Fleischer2011-04-052-4/+3
| | | | | | | | Unsigned values should never be compared to values less than zero. Detected with "find_unsigned.cocci" spatch from http://coccinelle.lip6.fr/impact_linux.php. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Compare pointers to "NULL" instead of "0".Lukas Fleischer2011-04-0512-93/+93
| | | | | | "bad_zero.cocci" spatch from http://coccinelle.lip6.fr/impact_linux.php. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Remove unused variables from wins_show().Lukas Fleischer2011-04-031-4/+1
| | | | | | Seen with "-Wunused-but-set-variable". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Remove dead assignments spotted by clang-analyzer.Lukas Fleischer2011-04-038-40/+17
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>