summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2012-05-02src/utils.c: Get rid of "semantic range checks" when parsing durationBaptiste Jonglez
Don't restrict ranges when entering durations. We now accept duration like "+1d42h600m". This might not seem very logical, but it's perfectly valid, and being able to enter "+36h" is useful when you don't want to do the maths yourself. Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-05-02src/apoint.c: Change the status message displayed when editing a durationBaptiste Jonglez
The duration format has recently changed to allow durations of the form "2d18h42m", but the status message didn't advertize this new possibility. Signed-off-by: Baptiste Jonglez <baptiste--git@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-21src/htable.h: Add missing prototypesLukas Fleischer
We only generated prototypes for a small subset of all supported functions in the HTABLE_PROTOTYPE macro. Add missing prototypes to allow for accessing corresponding functions if HTABLE_GENERATE is used in a separate compilation unit. This also fixes a couple of compiler warnings seen with "-Wmissing-prototypes". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-21Add prototypes for hash table functionsLukas Fleischer
These can be generated dynamically using the HTABLE_PROTOTYPE macro. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-21src/mem.c: Skip dbg_*() if memory stats are disabledLukas Fleischer
These functions only need to be compiled if calcurse is built with "--enable-memory-debug". Tell the preprocessor to strip them if memory debugging/stats are disabled. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-20Mark several functions staticLukas Fleischer
These are not needed outside of the corresponding compilation units. Spotted with "-Wmissing-prototypes". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-17Merge "%(start"{,str}")" and "%(end"{,str}")"Lukas Fleischer
Add "default" and "epoch" extended formats for dates. "default" is the same as "%H:%M", "epoch" prints the number of seconds since January 1, 1970. Also, change the semantics of "%(start)" to return dates in default format (same format that "%(startstr)" used to use before this patch). The old "%(start)" behavior can be emulated by using "%(start:epoch)". The same applies to "%(end)" and "%(endstr)". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-17Support extended date formatsLukas Fleischer
Add support for appending a strftime()-style format string to "%(start)" and "%(end)". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-17Allow passing extended formatsLukas Fleischer
Extended formats can be specified by adding custom format strings to the end of a long format specifier, separated by a colon (":"). This feature is currently unused. Extended format support for several format specifiers will be added in following patches. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-17Add support for long format specifiersLukas Fleischer
Adds following long format specifiers for each short format specifier: * s: (start) * S: (startstr) * d: (duration) * e: (end) * E: (endstr) * m: (message) * n: (noteid) * N: (note) * p: (priority) Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-17src/utils.c: Break out format specifier parsingLukas Fleischer
Move the format specifier parser to a separate function. This is done in preparation for supporting long format specifiers. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-12src/calcurse.c: Start all helper threads in one goLukas Fleischer
Makes our initialization code a tad cleaner and seems to reduce flicker when starting calcurse (the notification bar is no longer drawn before other windows are shown). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-12Refactor startup screen branchLukas Fleischer
Removes the pointless first parameter to io_startup_screen() and saves one wins_update() call if system dialogs are disabled. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-12Use percentage-based width for the sidebarLukas Fleischer
Use percentage-based widths internally. This slightly impairs (user) feedback but brings the sidebar configuration menu closer to the actual configuration format (the user now configures percentage-based widths, not absolute width values). As a bonus, the sidebar is now resized automatically on each window resize (based on the percentage values). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-06src/mem.c: Fix putchar() parameterLukas Fleischer
putchar() expects a single character, not a string. 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-05src/keys.c: Use generic list implementationLukas Fleischer
Be consistent and replace the custom linked list implementation we used here by the generic list implementation we use everywhere else. This reduces code complexity, while slightly improving memory overhead. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-04-05Mark some more variables/parameters constantLukas Fleischer
Fixes a couple of warnings seen with GCC 4.7. 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-30Do not use LLIST_*_CONT for appointmentsLukas Fleischer
This no longer works since we allow appointments lasting longer than 24 hours. This means that there might be an appointment that starts after another one and lasts until the selected day, even though the former doesn't. A simple example, where the old LLIST_TS_FOREACH_CONT approach fails, is: 03/29/2012 @ 19:00 -> 03/30/2012 @ 10:00 |Long event 03/29/2012 @ 21:00 -> 03/29/2012 @ 23:15 |Event 1 (shown) 03/30/2012 @ 14:00 -> 03/30/2012 @ 15:00 |Event 2 (not shown) Instead, allow incoherent appointments and only break if the current appointment *starts after* the selected day. Reported-by: Baptiste Jonglez <baptiste@jonglez.org> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-03-30Revert a bunch of strncmp() conversionsLukas Fleischer
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>
2012-03-29Fix semantics of "general."{systemdialogs,progressbar}Lukas Fleischer
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>
2012-03-29src/config.c: Detect legacy configuration filesLukas Fleischer
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>
2012-03-29src/config.c: Reorder configuration variablesLukas Fleischer
Sort configuration variables lexicographically. This makes changes easier to locate. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-03-27src/config.c: Rename configuration variablesLukas Fleischer
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>
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-12Do not strncpy() strings returned by gettext()Lukas Fleischer
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>
2012-03-12Get rid of string structuresLukas Fleischer
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>
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-03-12Avoid redundant window resets in config menuLukas Fleischer
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>
2012-03-12Avoid redundant virtual screen updatesLukas Fleischer
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>
2012-03-02Break out configuration main menuLukas Fleischer
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>
2012-03-02Revamp key bindings displayLukas Fleischer
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>
2012-02-24Add a read-only optionLukas Fleischer
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>
2012-02-20src/io.c: Remove C89 incompatible commentLukas Fleischer
Make commenting style consistent with everywhere else. Use "/* [...] */" instead of "// [...]". Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-02-19{src,test}/Makefile.am: Enable pedantic warningsLukas Fleischer
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>
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-19Fix hash table issues with ISO C99Lukas Fleischer
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>
2012-02-19Fix POSIX complianceLukas Fleischer
* "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>
2012-02-19Remove all usages of bzero() and bcopy()Lukas Fleischer
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>
2012-02-18Fix up strncat() usageLukas Fleischer
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>
2012-02-18src/io.c: Use fork_exec() instead of system()Lukas Fleischer
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>
2012-02-18Don't chomp on error in ical_readline_init()Lukas Fleischer
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>
2012-02-18Add stricter syntax checking to io_load_*()Lukas Fleischer
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>
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>
2012-02-17src/config.c: Add missing configuration variablesLukas Fleischer
Append missing configuration variables to the end of our configuration file instead of keeping them undefined. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-02-17src/config.c: Revamp configuration file parsingLukas Fleischer
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>
2012-02-17src/config.c: Add more parser/serialization wrappersLukas Fleischer
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>
2012-02-17src/config.c: Introduce config_parse_str()Lukas Fleischer
Be consistent with other parser helpers and with config_serialize_str(). Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-02-17src/config.c: Keep formatting and commentsLukas Fleischer
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>