aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
...
* | Revert a bunch of strncmp() conversionsLukas Fleischer2012-03-302-23/+23
| | | | | | | | | | | | | | | | | | | | | | All strncmp() usages were replaced by (evidently) equivalent strcmp() invocations in commit 2c9499bf272e06a62902711c6c20621ef3f80e64. However, some of the strncmp() calls were perfectly justified and we actually broke iCal import and "C-"-style key bindings by converting them to strcmp(). Fix this by reverting all affected conversions. Reported-by: Baptiste Jonglez <baptiste@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | README: Update with recent changesLukas Fleischer2012-03-301-6/+11
| | | | | | | | Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Fix semantics of "general."{systemdialogs,progressbar}Lukas Fleischer2012-03-298-23/+31
| | | | | | | | | | | | | | | | | | These were renamed from "skip_"* to *. However, we only changed syntax and didn't invert their semantic meaning. Fix this by negating the semantics of those variables. Also, negate these in the configuration file automatically when running `calcurse-upgrade`. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/config.c: Detect legacy configuration filesLukas Fleischer2012-03-291-0/+27
| | | | | | | | | | | | | | | | | | Check configuration variable names against a list of pre-3.0.0 configuration keys and display a warning if such a variable is found. This reduces the chance of users going wild due to the non-backwards compatible configuration file changes. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | test/data/conf: Update variable namesLukas Fleischer2012-03-291-22/+22
| | | | | | | | | | | | | | Update the default configuration file used in our test suite to match the new configuration variable naming scheme. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add a configuration file upgrade scriptLukas Fleischer2012-03-294-3/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This isn't ready for distribution but allows users of the -git version of calcurse to easily update their configuration files without having to edit them manually. Following things are still missing here: * A command line parameter to specify a custom data directory. * A backup file that is created automatically before upgrading. * Debug output. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/config.c: Reorder configuration variablesLukas Fleischer2012-03-291-15/+15
| | | | | | | | | | | | | | Sort configuration variables lexicographically. This makes changes easier to locate. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/config.c: Rename configuration variablesLukas Fleischer2012-03-271-22/+22
| | | | | | | | | | | | | | | | | | | | Classify configuration options into different sections. Use consistent names and formatting. This was discussed on the mailing lists. A script that updates configuration files will come in following patches. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Update copyright rangesLukas Fleischer2012-03-2637-40/+40
| | | | | | | | | | | | Add 2012 to the copyright range for all source and documentation files. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Do not strncpy() strings returned by gettext()Lukas Fleischer2012-03-126-26/+20
| | | | | | | | | | | | | | | | Translated strings returned by gettext() are statically allocated. There's no need to copy them to a buffer, we can use the pointers returned by gettext() instead. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Get rid of string structuresLukas Fleischer2012-03-123-77/+71
| | | | | | | | | | | | | | | | These were only used to construct constant strings with additional length fields. However, we can just use standard constant character arrays instead and let the compiler calculate the string length. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Use strcmp() instead of strncmp()Lukas Fleischer2012-03-125-36/+36
| | | | | | | | | | | | | | | | | | 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>
* | Avoid redundant window resets in config menuLukas Fleischer2012-03-121-1/+4
| | | | | | | | | | | | | | There's no need to reset windows unless the layout was changed. Move wins_reset() to a separate branch to reflect this. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Avoid redundant virtual screen updatesLukas Fleischer2012-03-122-3/+0
| | | | | | | | | | | | | | | | | | | | Remove some redundant wnoutrefresh() invocations. There's no need to copy a window to the virtual screen unless doupdate() is invoked immediately afterwards. This reduces flicker when browsing in the calendar panel. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Break out configuration main menuLukas Fleischer2012-03-023-49/+58
| | | | | | | | | | | | | | This was the only big block of code left in our main loop. Move it to a separate function, making the main loop a bit clearer. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Revamp key bindings displayLukas Fleischer2012-03-024-69/+96
| | | | | | | | | | | | | | | | | | | | | | | | | | Refactor the logic inside keys_display_bindings_bar() and remove the need to place the "show next page" key binding at the right positions. This used to be a pain to maintain, since we always had to move key bindings around when introducing a new key. Fix this by passing the actual key bindings in an array and using a separate parameter for the "show next page" key binding (which is automatically inserted at the right places from now on). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | test/: Run calcurse in read-only modeLukas Fleischer2012-02-2412-14/+15
| | | | | | | | | | | | | | | | We don't change any configuration nor do we modify items here, so we can safely invoke calcurse in read-only mode. Fixes a couple of permission errors seen with `make distcheck`. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add a read-only optionLukas Fleischer2012-02-247-18/+50
| | | | | | | | | | | | | | 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>
* | test/: Use correct calcurse binary and data dirLukas Fleischer2012-02-2413-17/+21
| | | | | | | | | | | | | | | | | | | | We really don't want to use the calcurse(1) binary from "$PATH" here. Introduce an environment variable "$CALCURSE" which can be used specify the binary to use and set this variable to the binary located in the build directory by default. Similarly, add another environment variable "$DATA_DIR" that can be used to specify a data directory. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | test/Makefile.am: Add tests to "EXTRA_DIST"Lukas Fleischer2012-02-241-0/+1
| | | | | | | | | | | | | | | | Add tests and the dummy data directory to "EXTRA_DIST" since we want these to be shipped in distribution tarballs. Spotted with `make distcheck`. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/io.c: Remove C89 incompatible commentLukas Fleischer2012-02-201-1/+1
| | | | | | | | | | | | | | Make commenting style consistent with everywhere else. Use "/* [...] */" instead of "// [...]". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | {src,test}/Makefile.am: Enable pedantic warningsLukas Fleischer2012-02-192-0/+4
| | | | | | | | | | | | | | | | Now that we're fully POSIX compliant and fixed up some minor issues with ISO C99, use "-std=c99 -pedantic -D_POSIX_C_SOURCE=200809L" as default build flags for calcurse and the test suite. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | test/run-test.c: Check fgets() return value properlyLukas Fleischer2012-02-191-2/+2
| | | | | | | | | | | | | | Not sure what we were doing here. fgets() returns a pointer, not an integer! Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Fix up fscanf() format stringsLukas Fleischer2012-02-192-4/+4
| | | | | | | | | | | | | | 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>
* | Fix hash table issues with ISO C99Lukas Fleischer2012-02-193-13/+18
| | | | | | | | | | | | | | | | | | | | ISO C99 forbids unnamed structs/unions and nested functions. Move the "HTABLE_HEAD" and "HTABLE_GENERATE" parts out of the function body and place them at the very top of the file (where function definitions are allowed). Also, remove the unnamed struct from "htable.h" (which was useless anyway). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Fix POSIX complianceLukas Fleischer2012-02-192-0/+6
| | | | | | | | | | | | | | | | | | | | | | * "WAIT_MYPGRP" isn't POSIX'ish. Relying on this caused compilation issues in certain environments (e.g. under Cygwin). As a workaround, define "WAIT_MYPGRP" explicitly if it's undefined. * "P_tmpdir" is an XSI extension. Don't try use it if it isn't available. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Remove all usages of bzero() and bcopy()Lukas Fleischer2012-02-195-13/+13
| | | | | | | | | | | | | | | | | | The bzero() and bcopy() functions are deprecated and were removed from the POSIX standard in IEEE Std. 1003.1-2008. Remove all usages of bzero()/bcopy() and replace them by appropriate memset()/memmove() calls. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Fix up strncat() usageLukas Fleischer2012-02-184-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The last argument to strncat() should not be the total buffer length; it should be the space remaining: The strncat() function shall append not more than n bytes (a null byte and bytes that follow it are not appended) from the array pointed to by s2 to the end of the string pointed to by s1. The initial byte of s2 overwrites the null byte at the end of s1. A terminating null byte is always appended to the result. This patch fixes a couple of potential buffer overflow vulnerabilities. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/io.c: Use fork_exec() instead of system()Lukas Fleischer2012-02-181-3/+4
| | | | | | | | | | | | | | Speeds up execution, prevents failures when pager or log file contains spaces, fixes a warning seen with "-Wunused-result". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Don't chomp on error in ical_readline_init()Lukas Fleischer2012-02-181-4/+6
| | | | | | | | | | | | | | Skip the newline check if fgets() returns a NULL string. Fixes another warning seen with "-Wunused-result". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Add stricter syntax checking to io_load_*()Lukas Fleischer2012-02-181-33/+41
| | | | | | | | | | | | | | | | | | | | Be more restrictive with what we allow in data files and bail out if a line doesn't conform to our specification, especially in regard to separators. This prevents unexpected behavior when a data file is edited manually. As a bonus, this fixes a whole pile of compiler warnings previously seen with "-Wunused-result". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | Trap fgets() failure in *_scan()Lukas Fleischer2012-02-183-4/+12
| | | | | | | | | | | | | | | | 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>
* | src/config.c: Add missing configuration variablesLukas Fleischer2012-02-171-15/+42
| | | | | | | | | | | | | | Append missing configuration variables to the end of our configuration file instead of keeping them undefined. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/config.c: Revamp configuration file parsingLukas Fleischer2012-02-171-130/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reintroduce a map for configuration variable parsing. We use a different approach this time: Each map entry contains * a key, * a callback that can be used to parse that variable, * a callback that can be used to serialize that variable and * a target buffer that the parsed value is written to/read from. Commits 4f4891bdb88410ae04225f3d6acfa31d73a3901a and 6377582841118688aee13aff98c9216403582e45 show that we are pretty undecided on using a map or not. However, now that we use parser and serialization wrappers for every variable, having a central map makes everything much cleaner. The runtimes of config_load() and config_save() are slightly increased (by a constant factor). This will also allow us for implementing proper detection of missing configuration variables in the configuration file. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/config.c: Add more parser/serialization wrappersLukas Fleischer2012-02-171-67/+133
| | | | | | | | | | | | | | | | | | | | | | | | Add convenience parser/serialization wrappers for all configuration variables that don't use the default config_parse_*() and config_serialize_*() helpers yet. This is nothing but a dirty hack and should be refactored later (e.g. by separating configuration variable parsing and validation or by adding optional validation functions). It makes it easier to switch to a more generic configuration parser, though. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/config.c: Introduce config_parse_str()Lukas Fleischer2012-02-171-13/+14
| | | | | | | | | | | | Be consistent with other parser helpers and with config_serialize_str(). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/config.c: Keep formatting and commentsLukas Fleischer2012-02-171-131/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | Switch to using the new config_file_walk() helper in config_save() and update existing configuration variables instead of blindly overwriting the existing configuration file. Note: This breaks configuration setting storage if one or more settings are missing in the configuration file. We need to refactor our parser and serialization routines another time before this can be implemented properly, though. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/config.c: Add serialization helperLukas Fleischer2012-02-171-53/+184
| | | | | | | | | | | | | | Add config_serialize_conf() which can be used to serialize the value of a configuration setting (counterpart to config_parse_conf()). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/config.c: Add junk callback to config_file_walk()Lukas Fleischer2012-02-161-3/+9
| | | | | | | | | | | | | | | | | | | | This can be used if we care about junk, such as empty lines and comments. Currently unused since we skip these when parsing configuration settings. This makes sense if we want to make slight modifications to the configuration file without losing formatting and comments, though. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/config.c: Make config file reading more flexibleLukas Fleischer2012-02-161-11/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds one level of abstraction to config_load() by splitting out the actual reading routine and the variable setter into two separate functions. config_file_walk() can be used to read the configuration file, strip comments and pass every key/value pair to a callback. config_load_cb() is the new callback used in config_load(). Rationale: It makes sense to reuse the key/value parser to allow for a much saner config_save() routine that changes single values only instead of rewriting (and overwriting) the whole configuration file every time. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | src/llist.c: Bail out early on negative indexesLukas Fleischer2012-02-161-1/+7
| | | | | | | | | | | | | | Make sure we don't return bogus list elements if negative indexes are used in llist_{,find_}nth(). Bail out early and return NULL instead. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
* | 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>