aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* | test/: Add test case for "-S" (pattern search)Lukas Fleischer2012-01-222-1/+27
| | | | | | | | | | | | | | * search-001.sh: Compare the output of "-S <regex>" (using a regular expression) with hardcoded data. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | test/: Add test cases for "-a" and "-n"Lukas Fleischer2012-01-223-1/+39
| | | | | | | | | | | | | | * appointment-001.sh: Compare output of "-a" with hardcoded data. * next-001.sh: Compare output of "-n" with hardcoded data. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | test/: Add test cases for "-d" and "-s"/"-r"Lukas Fleischer2012-01-228-1/+804
| | | | | | | | | | | | | | | | | | | | | | * day-001.sh: Compare output of "-d<date>" with hardcoded data. * day-002.sh: Compare output of "-d<num>" with hardcoded data. * day-003.sh: Compare output of "-d<num>" with "-s<date> -r<num>". * range-001.sh: Compare output of "-r" with hardcoded data. * range-002.sh: Compare output of "-r<num>" with hardcoded data. * range-003.sh: Compare output of "-r<num>" with "-s<date> -r<num>". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | test/: Add generic tests for todo operationsLukas Fleischer2012-01-225-1/+235
| | | | | | | | | | | | | | | | | | | | | | * todo-001.sh: Tests the "-t" command line option (calculates expected output by parsing the todo data file). * todo-002.sh: Tests "-t<num>" in a way similar to todo-001.sh. * todo-003.sh: Tests "-t0" in a way similar to todo-001.sh. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | test/: Add three basic self testsLukas Fleischer2012-01-224-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * true-001.sh: Always returns true - this should never ever fail. * run-test-001.sh: Invokes run-test, passing itself as a parameter. Subsequently, it outputs the very same (hardcoded) expected and actual values. * run-test-002.sh: Tests run-test's negative assertion feature in a way similar to run-test-001.sh. However, output different (hardcoded) expected and actual values and invoke run-test with the negative test prefix ('!'). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | test/: Add initial configuration fileLukas Fleischer2012-01-221-0/+75
| | | | | | | | | | | | As a preparation for our test cases (needed for date formatting etc.) Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | test/run-test.c: Support negative assertionsLukas Fleischer2012-01-211-3/+14
| | | | | | | | | | | | | | | | | | | | | | Sometimes, we might want to make negative assertions (tests where expected and actual output are expected/known to be different). A test can be marked negative by prefixing it with an exclamation mark ('!'): $ ./run-test !test-negative Running test-negative... ok Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add a minimal test suiteLukas Fleischer2012-01-215-2/+253
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce a new "test/" sub-directory that contains tests for calcurse. Right now, it only includes the quick-and-dirty "run-test" helper that can be used to run and verify tests: $ ./run-test test-1 test-2 test-3 test-4 Running test-1... ok Running test-2... ok Running test-3... FAIL Each argument passed to run-test must be a test script located in the current directory. run-test invokes each script twice and passes the command line argument "expected" and "actual", respectively. A test case succeeds if both "expected" and "actual" instances return with a zero exit status and produce exactly the same output. It fails otherwise. run-test terminates with a non-zero exit status as soon as one of the test fails. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/calendar.c: Fix range check in calendar_move()Lukas Fleischer2012-01-211-12/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We added count prefix support to motion commands in commit 59e006e56d9f893506af56a4ca114fe53b537e49 but obviously forgot to check whether the range checks in calendar_move() still work correctly. Refactor out range checks and replace them by a single check that is performed *after* the new date is computed, but before we assign the new value to the actual selected date. This ensures we won't have to bother about these again when changing/adding functionality in/to calendar_move(), while keeping performance (date_change() is pretty cheap and range violations are corner cases anyway). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Split note file generation into separate functionLukas Fleischer2012-01-173-12/+23
| | | | | | | | | | | | | | We currently use this in one place only but might reuse this a couple of times later (when migrating to libical). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Break out different import/export formatsLukas Fleischer2012-01-075-1501/+1598
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extract iCal and pcal import/export routines into separate files. This reduces complexity of the super huge "io.c" source file and makes it easier to follow changes that affect the iCal and pcal routines only (commits affecting both formats are very uncommon). Before: $ wc -l src/io.c 2938 src/io.c After: $ wc -l src/{io,ical,pcal}.c 1445 src/io.c 1263 src/ical.c 317 src/pcal.c 3025 total Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/apoint.c: Update in-notify-bar help for new duration syntaxBaptiste Jonglez2012-01-071-2/+2
| | | | | | | | | | Signed-off-by: Baptiste Jonglez <baptiste@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/apoint.c: Fix a length bug introduced by new duration formatBaptiste Jonglez2012-01-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 4ff3bb9d introduced a new format for parsing durations, thus allowing a larger string to be retrieved from user input. However, the string used is still declared with the old length, leading to crashes when compiling with stack-smashing protection features (the default on Archlinux). Inputting a duration string of more than 8 characters (such as "+1d11h11m") would crash calcurse with a *** stack smashing detected *** message. Using a larger string from the start fixes the bug. Signed-off-by: Baptiste Jonglez <baptiste@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Merge branch 'maint'Lukas Fleischer2011-12-161-1/+5
|\| | | | | | | | | Conflicts: src/io.c
| * Format "DURATION" field properly on ical exportJérôme Pinot2011-12-161-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | Use days/hours/minutes/seconds instead of seconds in the DURATION field. It fixes interaction with other softwares like phpicalendar. Lukas: Remove use of dur-week. RFC 5545 states that you cannot use this in conjunction with dur-day. Also, fix formatting and use proper constants. Signed-off-by: Jerome Pinot <ngc891@gmail.com> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/config.c: Drop support for legacy color schemesLukas Fleischer2011-12-121-85/+36
| | | | | | | | | | | | | | | | | | We used different naming schemes in versions prior to 1.8. Given that calcurse 1.8 has been released more than 4.5 years ago, remove the legacy code that still handles these. Users upgrading from <1.8 to 3.0.0 might need to convert the appropriate config file variable manually. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/utils.c: Mark is_all_digit() parameter constLukas Fleischer2011-12-092-2/+2
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/config.c: Remove map for configuration variablesLukas Fleischer2011-12-091-169/+114
| | | | | | | | | | | | | | | | | | | | This patch kind of reverts what we did in commit 6377582841118688aee13aff98c9216403582e45. We were a tad off-base there since using a map doesn't improve maintainability, really. Using strcmp() at a central location seems perfectly fine and doesn't have the overhead of the map scanning algorithm. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Extract config file handlers into a separate fileLukas Fleischer2011-12-099-551/+596
| | | | | | | | | | | | | | | | 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/day.c: Nuke unneeded variableLukas Fleischer2011-12-091-4/+1
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/todo.c: Remove several unneeded variablesLukas Fleischer2011-12-091-19/+14
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/apoint.c: Remove several unneeded variablesLukas Fleischer2011-12-051-36/+30
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/utils.c: Support escape sequences in format stringsLukas Fleischer2011-11-221-0/+55
| | | | | | | | | | | | | | We support all simple escape sequences listed in the ANSI C standard, plus "\0" to allow for printing null characters. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Merge branch 'maint'Lukas Fleischer2011-11-151-2/+5
|\|
| * src/io.c: Avoid use of memcpy()Lukas Fleischer2011-11-111-2/+4
| | | | | | | | | | | | | | | | Use strncpy() and a proper limit, which ensures we never read more characters than the buffer can hold. Also, ensure we always null-terminate strings here. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
| * src/io.c: Null-terminate the ical_readline() bufferLukas Fleischer2011-11-111-0/+1
| | | | | | | | | | | | | | Ensure we always return with a null-terminated buffer, even if we read more than BUFSIZ characters. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/utils.c: Support printing '%' in format stringsLukas Fleischer2011-11-141-0/+9
| | | | | | | | | | | | This allows using "%%" to print the '%' character. 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-142-70/+70
| | | | | | | | | | | | | | | | | | | | | | | | * 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-143-13/+42
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* | src/apoint.c: Remove apoint_recur_s2apoint_s()Lukas Fleischer2011-11-142-17/+0
| | | | | | | | | | | | | | This one is hackish, obsolete and no longer used by any other function. Drop it! Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Use a dynamic method to print recurrent items to stdoutLukas Fleischer2011-11-143-7/+33
| | | | | | | | | | | | | | | | | | 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-143-3/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | 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-143-18/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-144-8/+7
| | | | | | | | | | | | This is no longer needed as of commit 2d89d336. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Use a global configuration variableLukas Fleischer2011-11-1411-162/+159
| | | | | | | | | | | | | | 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>
* | Merge branch 'maint'Lukas Fleischer2011-11-115-7/+20
|\| | | | | | | | | | | Conflicts: src/calcurse.h src/io.c
| * Cleanup joinable threads on terminationLukas Fleischer2011-10-043-3/+12
| | | | | | | | | | | | | | Always invoke pthread_join() when we blow up a thread via pthread_cancel() (avoid zombie threads). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
| * src/io.c: Update todo item count on iCal importLukas Fleischer2011-10-041-0/+3
| | | | | | | | | | | | | | Update the number of todo items when importing an iCal file to prevent some items from being inaccessible. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
| * 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>
* | Remove parentheses from return statementsLukas Fleischer2011-11-0214-80/+80
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-028-39/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0220-511/+489
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0213-143/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-215-23/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/day.c: Allow editing an item's durationLukas Fleischer2011-10-211-5/+47
| | | | | | | | | | | | | | | | We have the option to enter either an end time or a duration when creating an item - the same choice should be available when editing an item. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/day.c: Allow cancelling an editLukas Fleischer2011-10-211-22/+23
| | | | | | | | | | | | | | | | Once the user picked any property to edit, we didn't give him any chance to cancel editing. Abort if the user presses the escape key or enters an empty string. 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>