summaryrefslogtreecommitdiff
path: root/src/recur.c
AgeCommit message (Collapse)Author
2012-11-22Replace localtime() with localtime_r()Lukas Fleischer
Since the result of localtime() is stored in a statically allocated structure, data was overwritten when a context switch occurred during (or shortly after) the execution of localtime(), potentially resulting in critical data corruption. BUG#7 and BUG#8 are likely related. This patch converts all usages of localtime() with localtime_r(), which is thread-safe. Reported-by: Baptiste Jonglez <baptiste@jonglez.org> Reported-by: Erik Saule <esaule@bmi.osu.edu> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-05-25Fix incorrect i18n usage for some stringsBaptiste Jonglez
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>
2012-05-21Switch to Linux kernel coding styleLukas Fleischer
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>
2012-05-14Use status_ask_choice() on more difficult casesBaptiste Jonglez
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>
2012-04-06Miscellaneous small code cleanupsLukas Fleischer
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-05Mark localized string literals constantLukas Fleischer
Translated strings returned by gettext() are statically allocated and shouldn't be modified. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-03-26Update copyright rangesLukas Fleischer
Add 2012 to the copyright range for all source and documentation files. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-03-12Use strcmp() instead of strncmp()Lukas Fleischer
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>
2012-02-19Fix up fscanf() format stringsLukas Fleischer
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>
2012-02-18Trap fgets() failure in *_scan()Lukas Fleischer
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>
2011-11-14Use a global configuration variableLukas Fleischer
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>
2011-11-02Remove parentheses from return statementsLukas Fleischer
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>
2011-11-02Do not cast unused return values to voidLukas Fleischer
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>
2011-11-02Avoid use of printf()/fprintf()Lukas Fleischer
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>
2011-11-02src/recur.c: Speed up recur_item_find_occurrence()Lukas Fleischer
Bail out early if we check for a date beyond the item's repetition end date. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-21Avoid unnecessary start time calculationsLukas Fleischer
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>
2011-10-21src/recur.c: Remove diff_weeks()Lukas Fleischer
After our recur_item_inday() rewrite, this function is no longer used. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-10-21src/recur.c: Support recurrent multi-day appointmentsLukas Fleischer
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>
2011-10-21Pass item durations to recur_item_inday()Lukas Fleischer
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>
2011-10-21Make events start on 00:00 (12:00 a.m.)Lukas Fleischer
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>
2011-10-05Do not unlink() note files on note removalLukas Fleischer
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>
2011-07-30Merge branch 'maint'Lukas Fleischer
2011-07-29Fix recurrent appointment notificationLukas Fleischer
We probably broke this in 9fab24818a119aef08b9726f6c1cd31d5434ce34. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-29Update the notification item in *_paste_item()Lukas Fleischer
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-07-29Add "force" parameter to notify_check_next_app()Lukas Fleischer
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>
2011-07-02Make recur_*_write() publicLukas Fleischer
This allows one to serialize and send recurrent items to arbitrary output streams. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-06-09Fix whitespace issuesLukas Fleischer
Strip trailing whitespaces in all source files. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-04-22Update copyright notices in source files, documentation and "COPYING".Lukas Fleischer
* 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>
2011-04-22Use generic lists for recurring item exceptions.Lukas Fleischer
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>
2011-04-19Use generic lists for recurring apointments and events.Lukas Fleischer
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>
2011-04-19Add recur_apoint_inday() and recur_event_inday().Lukas Fleischer
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>
2011-04-05Compare pointers to "NULL" instead of "0".Lukas Fleischer
"bad_zero.cocci" spatch from http://coccinelle.lip6.fr/impact_linux.php. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-04-03Remove dead assignments spotted by clang-analyzer.Lukas Fleischer
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-03-15Use upper case for macro names.Lukas Fleischer
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-03-14Overall indentation fixes.Lukas Fleischer
Use spaces instead of tabs for source code indentation only, strip trailing whitespaces from lines. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-03-04Update website links to match the new URL.Lukas Fleischer
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-03-04Update mail addresses to match the new mailing lists.Lukas Fleischer
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-03-03Remove CVS "$Id" headers.Lukas Fleischer
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2011-03-03Fixed file permissions.Lukas Fleischer
2011-01-11Make parse_date accept several short forms.Lukas Fleischer
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.
2010-03-20All headers gathered into a single one. Typedefs suppressed.Frederic Culot
2010-03-08Patch to correct the wrong calculation of recurrent items' dates after aFrederic Culot
turn of year (submitted by Lukas Fleischer, thanks!).
2009-07-19Make use of erase_note() whenever possible.Frederic Culot
2009-07-05Switch to BSD license.Frederic Culot
2009-05-22The buffer should be allocated dynamically, but I am quite busy right now ↵Frederic Culot
:'( Anyway, thanks Kamil for feedback
2009-01-03more code cleanupFrederic Culot
2009-01-02various bugfixesFrederic Culot
2009-01-01cut/paste feature adedFrederic Culot
fixed a 2-years old bug that made repeated items with exceptions to load uncorrectly in some cases (thanks Jan for reporting it)
2008-12-28Added wrappers around libc's memory management functions, to easily debug ↵Frederic Culot
memory usage
2008-12-14small bugfixes and code cleanupFrederic Culot