summaryrefslogtreecommitdiffstats
path: root/src/recur.c
Commit message (Collapse)AuthorAgeFilesLines
* Refactor note removalLukas Fleischer2012-07-071-7/+1
| | | | | | | | Remove the note removal code from *_delete()/*_erase() and create a new wrapper function called day_item_erase_note() that is be used to drop the note being associated to an item. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Refactor *_dup()Lukas Fleischer2012-07-061-23/+35
| | | | | | | | * Actually duplicate an item instead of copying data only. * Properly clone an item without a note. * Mark *_dup() public. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Remove legacy cut/paste codeLukas Fleischer2012-06-301-30/+0
| | | | | | | Note that this doesn't remove *_dup() since these might still be needed later. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Revise cut/pastingLukas Fleischer2012-06-301-40/+25
| | | | | | | | | | | | | | | | Instead of calling type-specific duplication handlers and inserting clones of the original items when pasting, save the generic day item and remove the actual item from the linked list, so that it can be inserted anywhere else later. The cut/paste buffer is moved to the interaction unit, item-specific cut operations are changed to remove the item from the linked list only instead of copying and freeing it. An item is only freed if another item is cut before the current cut/paste buffer is pasted. All paste operations are changed and reinsert the actual item instead of creating a clone. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Make *_free() publicLukas Fleischer2012-06-301-2/+2
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Revise *_delete{,_bynum}()Lukas Fleischer2012-06-301-11/+5
| | | | | | | | Always pass an item instead of passing a date and a index. This makes use of the NULL callback that was added with one of the previous patches. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Allow passing more complex data to list callbacksLukas Fleischer2012-06-301-10/+10
| | | | | | | | Change the data type of the "data" parameter from "long" to "void *" in llist_find_*() signatures to allow for passing more complex objects. Change all llist_find_*() invocations and callbacks accordingly. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Move interaction functions to a separate fileLukas Fleischer2012-06-301-136/+0
| | | | | | | | | | | | | | | This is a first step to clean up several compilation units and separate the front end from back-end operations. All functions that require user interaction are moved to a new compilation unit "interaction.c". Also, following things are adjusted to the new layout: * Make day_item_get_*() and a few other functions public, so that it can be accessed from the new compilation unit. * Use apoint_hilt(), todo_hilt(), etc. instead of directly accessing static variables. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Remove unused functionsLukas Fleischer2012-06-301-26/+0
| | | | | | | Remove apoint_get(), event_get(), recur_get_apoint() and recur_get_event(), since they are no longer used. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Simplify recur_apoint_switch_notify()Lukas Fleischer2012-06-301-9/+1
| | | | | | | | | Pass the recurrent appointment itself instead of passing a date and an item number. This is quite simple as we can just pass the pointer that is contained in the generic item structure and don't have to LLIST_TS_FIND_*() the item first any more. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Rework generic item containerLukas Fleischer2012-06-301-4/+6
| | | | | | | | | Instead of copying all members of the individual item structures to a generic structure containing all fields, create compulsory fields only and set up a pointer to the actual item. This results in lower memory footprint and lets us clean up some code. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix incorrect i18n usage for some stringsBaptiste Jonglez2012-05-251-2/+2
| | | | | | | | | | | Some strings are initialized without wrapping them in _(); instead, _() is applied on the variable when it is used. This is incorrect, since these strings don't get added to the catalog. Fix that by applying _() only once, when the string is declared. Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Switch to Linux kernel coding styleLukas Fleischer2012-05-211-664/+549
| | | | | | | | | | | | | | Convert our code base to adhere to Linux kernel coding style using Lindent, with the following exceptions: * Use spaces, instead of tabs, for indentation. * Use 2-character indentations (instead of 8 characters). Rationale: We currently have too much levels of indentation. Using 8-character tabs would make huge code parts unreadable. These need to be cleaned up before we can switch to 8 characters. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use status_ask_choice() on more difficult casesBaptiste Jonglez2012-05-141-16/+29
| | | | | | | | | | | These cases are also candidates for the factorisation process, but they are somewhat more tricky to get right. Since we use a completely different approach, the result (from a user perspective) looks different. Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Miscellaneous small code cleanupsLukas Fleischer2012-04-061-1/+1
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Mark localized string literals constantLukas Fleischer2012-04-051-10/+10
| | | | | | | Translated strings returned by gettext() are statically allocated and shouldn't be modified. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Update copyright rangesLukas Fleischer2012-03-261-1/+1
| | | | | | Add 2012 to the copyright range for all source and documentation files. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use strcmp() instead of strncmp()Lukas Fleischer2012-03-121-1/+1
| | | | | | | | | strncmp() isn't intended to be a secure strcmp() replacement, it is designed to be used if you want to compare the first n characters of two strings. Since we always compare character pointers with string literals, switch to using strcmp() everywhere. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix up fscanf() format stringsLukas Fleischer2012-02-191-1/+1
| | | | | | | All members of the tm structure are signed integers. Stick to using the correct fscanf() format specifiers for these. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Trap fgets() failure in *_scan()Lukas Fleischer2012-02-181-2/+6
| | | | | | | | Ensure we don't read arbitrary data when fgets() returns a NULL string (meaning that either the EOF is encountered or an error occurred). This also fixes a couple of compiler warnings seen with "-Wunused-result". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use a global configuration variableLukas Fleischer2011-11-141-4/+4
| | | | | | | This is one of the few valid use cases for a global variable. No need to make it pseudo-local and pass it from one function to another. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Remove parentheses from return statementsLukas Fleischer2011-11-021-24/+24
| | | | | | | | | | | | | | No reason to use "return (x);" here. Refer to the GNU coding guidelines for details. Created using following semantic patch: @@ expression expr; @@ - return (expr); + return expr; Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Do not cast unused return values to voidLukas Fleischer2011-11-021-52/+46
| | | | | | | | | | | | | | | | | | | | 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-4/+4
| | | | | | | | | | | | | | | | 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/recur.c: Speed up recur_item_find_occurrence()Lukas Fleischer2011-11-021-0/+3
| | | | | | | Bail out early if we check for a date beyond the item's repetition end date. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Avoid unnecessary start time calculationsLukas Fleischer2011-10-211-11/+46
| | | | | | | | | | | | | | Rename recur_*_inday() to recur_*_find_occurrence() and use the new functions whenever we actually care about the start time of an occurrence. Reintroduce recur_*_inday() as wrappers to recur_*_find_occurrence() and pass NULL as start time buffer (which means "skip start time calculation"). Keep using these when we only want to know if a recurrent item belongs to a specific day but do not care about the actual start time. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/recur.c: Remove diff_weeks()Lukas Fleischer2011-10-211-10/+3
| | | | | | After our recur_item_inday() rewrite, this function is no longer used. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/recur.c: Support recurrent multi-day appointmentsLukas Fleischer2011-10-211-45/+50
| | | | | | | | | | | | | Completely rewrite our inday algorithm in recur_item_inday() and be more fine-grained. This version can deal with recurrent multi-day appointments unless they overlap. In case of overlapping appointments, only the last appointment that starts before the current day is shown. We will need to rewrite the whole recur_item_inday() interface in order to fix this - this relatively trivial patch is only the first step. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Pass item durations to recur_item_inday()Lukas Fleischer2011-10-211-5/+5
| | | | | | | | Having item's durations eventually allows for better parsing of recurrent appointments as we might be interested in how many days are covered by a multi-day appointment. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Make events start on 00:00 (12:00 a.m.)Lukas Fleischer2011-10-211-3/+3
| | | | | | | | There is absolutely no reason to make events start on noon, 12:00. Switching to 00:00 seems totally reasonable here, and makes event handling a bit easier, also. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Do not unlink() note files on note removalLukas Fleischer2011-10-051-17/+13
| | | | | | | | | | 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>
* Merge branch 'maint'Lukas Fleischer2011-07-301-8/+9
|\
| * 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-291-0/+4
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
| * Add "force" parameter to notify_check_next_app()Lukas Fleischer2011-07-291-2/+2
| | | | | | | | | | | | | | | | 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>
* | Make recur_*_write() publicLukas Fleischer2011-07-021-2/+2
|/ | | | | | | This allows one to serialize and send recurrent items to arbitrary output streams. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix whitespace issuesLukas Fleischer2011-06-091-2/+2
| | | | | | Strip trailing whitespaces in all source files. 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 generic lists for recurring item exceptions.Lukas Fleischer2011-04-221-108/+81
| | | | | | | | | 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>
* Use generic lists for recurring apointments and events.Lukas Fleischer2011-04-191-287/+216
| | | | | | | | 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-191-0/+14
| | | | | | | | | | | | 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>
* Compare pointers to "NULL" instead of "0".Lukas Fleischer2011-04-051-18/+18
| | | | | | "bad_zero.cocci" spatch from http://coccinelle.lip6.fr/impact_linux.php. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Remove dead assignments spotted by clang-analyzer.Lukas Fleischer2011-04-031-10/+4
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use upper case for macro names.Lukas Fleischer2011-03-151-4/+4
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Overall indentation fixes.Lukas Fleischer2011-03-141-200/+200
| | | | | | | Use spaces instead of tabs for source code indentation only, strip trailing whitespaces from lines. 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>
* 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-2/+2
| | | | | | | | | 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.