summaryrefslogtreecommitdiffstats
path: root/src/args.c
Commit message (Collapse)AuthorAgeFilesLines
* Allow for merging data files when reloadingLukas Fleischer2014-07-161-2/+2
| | | | | | | | This allows for merging the (unsaved) items with the items from the data files when invoking the reload operation. To this end, an external merge tool (defaults to vimdiff) is used. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix segmentation faultLukas Fleischer2014-06-251-1/+1
| | | | | | | | | | This adds some more accurate checks to avoid a segmentation fault that occurred when accessing a nonexistent item. Fixes GitHub issue #7. Reported-by: Bromind <martin.vassor@hotmail.fr> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Reintroduce heading and separator in appointmentsLukas Fleischer2014-05-181-1/+1
| | | | | | | This re-introduces the heading (showing the POM and the current date) as well as the separating line between events and appointments. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* ui-day: Large-scale refactoringLukas Fleischer2014-05-181-1/+3
| | | | | | | | | | Use the generic list box implementation for the appointments panel. This results in some major changes to how the items are printed. Note that this temporarily removes the heading showing the POM and the date as well as the separating line between events and appointments. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add -l/--limit optionWilliam Pettersson2013-07-161-16/+39
| | | | | | | | Adds the -l/--limit command line option. Limits the number of appointments and/or ToDo items displayed. Signed-off-by: William Pettersson <william.pettersson@gmail.com> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use tabs instead of spaces for indentationLukas Fleischer2013-04-141-541/+566
| | | | | | | | | | | This completes our switch to the Linux kernel coding style. Note that we still use deeply nested constructs at some places which need to be fixed up later. Converted using the `Lindent` script from the Linux kernel code base, along with some manual fixes. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix braces in if-else statementsLukas Fleischer2013-02-171-4/+5
| | | | | | | | | | From the Linux kernel coding guidelines: Do not unnecessarily use braces where a single statement will do. [...] This does not apply if one branch of a conditional statement is a single statement. Use braces in both branches. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Update copyright rangesLukas Fleischer2013-02-041-2/+2
| | | | | | | Add 2013 to the copyright range for all source and documentation files. Reported-by: Frederic Culot <frederic@culot.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* io_check_*()/io_file_exist(): Fix signaturesLukas Fleischer2012-11-261-16/+16
| | | | | | | This was broken in commit 87fb8cfec0d8e8fc901746095458bd316314b6ee. Fix function signatures and update all invocations accordingly. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* args.c: Several minor simplificationsLukas Fleischer2012-11-251-27/+13
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Merge branch 'maint'Lukas Fleischer2012-11-231-5/+5
|\ | | | | | | | | | | Conflicts: src/day.c src/recur.c
| * Replace localtime() with localtime_r()Lukas Fleischer2012-11-221-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Allow passing both "-D" and "-c"Lukas Fleischer2012-06-301-12/+3
| | | | | | | | | | | | | | | | | | | | This is particularly useful if one wants to use configuration and key bindings from a specific directory, while using an appointment file from somewhere else. "-c" has precedence over "-D". Also update the usage message, man page and documentation. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | day_store_items(): Return the number of items foundLukas Fleischer2012-06-301-2/+2
| | | | | | | | | | | | | | | | | | Return the total number of items found instead of the pad length, since this is used to store items in non-interactive mode as well now. The pad length can still be calculated by using the appointment and event count parameters. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/args.c: Revise app_arg()Lukas Fleischer2012-06-301-110/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This kills the hackish code we used to filter and display appointments and events in non-interactive mode. From now on, the same algorithm that is used in interactive mode (read day_store_items() for details) is called, resulting in code that is much easier to maintain. The resulting performance loss is rather small. Here are the run times of `calcurse -s01/01/1902 -r18250 -D ../test/data >/dev/null` before and after the patch was applied: 0.30user 0.26system 0:01.22elapsed 46%CPU (0avgtext+0avgdata 1340maxresident)k 0inputs+0outputs (0major+398minor)pagefaults 0swaps 0.33user 0.21system 0:01.18elapsed 46%CPU (0avgtext+0avgdata 1360maxresident)k 0inputs+0outputs (0major+395minor)pagefaults 0swaps Note that this also fixes a few bugs that were encountered in non-interactive mode, most notably BUG#2. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Make day_store_items() publicLukas Fleischer2012-06-301-1/+0
|/ | | | | | | | | Remove the "static" keyword from day_store_items(), so that it is accessible from other compilation units. Also, allow for discarding the event/appointment counters by passing NULL pointers and move the "regex.h" header inclusion to "calcurse.h". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/args.c: Fix bugs address in usage messageLukas Fleischer2012-06-181-12/+11
| | | | | | | | | | | * Point out that bug reports should be sent to the bugs mailing list, not to misc in help and usage messages. * Call more_info() when displaying the help message instead of copy-pasting strings to avoid double translation. Reported-by: rafael ff1 <rafael.f.f1@gmail.com> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Directly use fprintf() where applicableBaptiste Jonglez2012-05-311-12/+4
| | | | | | | | | | For some reasons, we were using snprintf() to format a string into a buffer, and then displaying this buffer to stdout using fputs(). That's exactly what fprintf() is here for, so use it. Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Fix incorrect i18n usage for some stringsBaptiste Jonglez2012-05-251-4/+4
| | | | | | | | | | | 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-636/+541
| | | | | | | | | | | | | | 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>
* Document removal of the "-N" command line optionLukas Fleischer2012-05-171-4/+1
| | | | | | | This option was removed in 6b95f7b67dc8e29072fed4e05efa450422661348. Update the usage message, the man page and the manual accordingly. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Declare several parameters/variables constantLukas Fleischer2012-05-081-6/+7
| | | | | | | | | | | | Add the "const" keyword to parameters and variables that are never modified. Most of these were spotted by "-Wwrite-strings". We cast the second parameter to execvp() explicitly as it expects a "char *const[]" where it should expect a "const char *const[]" (according to the documentation, this is due to compatibility reasons). This should be changed once we come up with a better solution. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/args.c: Add "void" in some function declarationsLukas Fleischer2012-05-081-4/+4
| | | | | | | | | These functions don't take any parameters, "void" is the right parameter signature to use here. Fixes some warnings seen with "-Wstrict-prototypes". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/args.c: Add a mention of "--read-only" in "calcurse --help"Baptiste Jonglez2012-05-021-1/+4
| | | | | Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Mark some more variables/parameters constantLukas Fleischer2012-04-051-1/+1
| | | | | | Fixes a couple of warnings seen with GCC 4.7. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Mark localized string literals constantLukas Fleischer2012-04-051-2/+2
| | | | | | | 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-2/+2
| | | | | | Add 2012 to the copyright range for all source and documentation files. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add a read-only optionLukas Fleischer2012-02-241-1/+6
| | | | | | | We don't save any configuration nor items if this is set. This should be used with care, and hence there's no short option for this. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Extract config file handlers into a separate fileLukas Fleischer2011-12-091-2/+2
| | | | | | | | We used custom_load_conf() to load the configuration file and io_save_conf() to save configuration. Move these functions, including all helpers, to a central location. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/args.c: Remove obsolete "-N" flagLukas Fleischer2011-11-141-4/+0
| | | | | | This is superseded by custom format strings. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* src/args.c: Allow for specifying custom format stringsLukas Fleischer2011-11-141-23/+66
| | | | | | | | | | | | | Following long command line options can be used to override the default format strings: * --format-apt * --format-recur-apt * --format-event * --format-recur-event * --format-todo Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* print_*(): Add format specifier to print notesLukas Fleischer2011-11-141-70/+9
| | | | | | | | | | | | * Move print_notefile() from "src/args.c" to "src/utils.c". * Add a "%N" format specifier to print_*(). This invokes print_notefile() and prints the content of an item's note file. * src/args.c: Use the new format specifier instead of print_notefile() everywhere. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use a dynamic method to print todo items to stdoutLukas Fleischer2011-11-141-13/+7
| | | | | | | | | | | | This goes in line with the other commits adding print_*() support. Following format specifiers are allowed: * p: Print the priority of the item * m: Print the description of the item * n: Print the name of the note file belonging to the item Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use a dynamic method to print recurrent items to stdoutLukas Fleischer2011-11-141-7/+3
| | | | | | | | | Add print_recur_apoint() and print_recur_event() helper functions to print recurrent items to stdout and use them everywhere. Currently, these are only wrapper functions to print_apoint() and print_event() that create temporary, non-recurrent items. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use a dynamic method to print events to stdoutLukas Fleischer2011-11-141-3/+1
| | | | | | | | | | | | | Add a flexible helper function print_event() and use it whenever we print events to stdout. This reduces the number of copy-pasted code and eventually allows for specifying custom format strings. Following format specifiers are supported: * m: Print the description of the item * n: Print the name of the note file belonging to the item Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use a dynamic method to print appointments to stdoutLukas Fleischer2011-11-141-18/+2
| | | | | | | | | | | | | | | | | | Add a flexible helper function print_apoint() and use it whenever we print appointments to stdout. This reduces the number of copy-pasted code and eventually allows for specifying custom format strings. Following format specifiers are supported: * s: Print the start time of the appointment as UNIX time stamp * S: Print the start time of the appointment using the "hh:mm" format * d: Print the duration of the appointment in seconds * e: Print the end time of the appointment as UNIX time stamp * E: Print the end time of the appointment using the "hh:mm" format * m: Print the description of the item * n: Print the name of the note file belonging to the item Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Removed unused parameter from apoint_sec2str()Lukas Fleischer2011-11-141-3/+2
| | | | | | This is no longer needed as of commit 2d89d336. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Use a global configuration variableLukas Fleischer2011-11-141-30/+28
| | | | | | | 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-2/+2
| | | | | | | | | | | | | | 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>
* Make use of the NULL macroLukas Fleischer2011-11-021-16/+16
| | | | | | | | | | | | | | | Use this constant everywhere when referring to a null pointer instead of casting 0 to various types of pointers. Created using following semantic patch: @@ type type; @@ - (type *)0 + NULL Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Do not cast unused return values to voidLukas Fleischer2011-11-021-13/+13
| | | | | | | | | | | | | | | | | | | | 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>
* Avoid unnecessary start time calculationsLukas Fleischer2011-10-211-1/+3
| | | | | | | | | | | | | | 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>
* Use LLIST_{,TS}_FIND_FOREACH_CONT where appropriateLukas Fleischer2011-10-061-1/+1
| | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Add command line argument to run the GC manuallyLukas Fleischer2011-10-051-2/+21
| | | | | | | | Adds a "-g" option that allows for running the garbage collector for note files manually. This is useful for users that do not use note files at all or rarely edit/remove them. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* Merge branch 'maint'Lukas Fleischer2011-09-061-3/+9
|\ | | | | | | | | Conflicts: src/io.c
| * 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>
* | Merge branch 'maint'Lukas Fleischer2011-07-301-52/+78
|\|
| * 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>
* | src/args.c: Mark various constant strings constLukas Fleischer2011-07-281-4/+4
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>