1297 Commits

Author SHA1 Message Date
Lukas Fleischer
ce93fa8adb Use a macro to determine the size of arrays
Use following macro instead of "sizeof(x) / sizeof(x[0])" everywhere:

    #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-05-04 20:32:26 +02:00
Lukas Fleischer
370c4031be recur.c: Refactor/Reformat recur_item_find_occurrence()
Fix a couple of whitespace and line breaks. Bail out early instead of
using nested if statements.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-05-02 15:38:57 +02:00
Lukas Fleischer
ec837150a0 recur_exc_scan(): Do not check time of exceptions
Exceptions do not contain a time field -- do not check time fields which
may be uninitialized.

Regression introduced in 9907069f442c56c90b67accb2d8fbd046dfce6db. This
fixes test/recur-*.sh.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-04-14 00:56:18 +02:00
Lukas Fleischer
694d28eb78 Use tabs instead of spaces for indentation
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>
2013-04-14 00:19:01 +02:00
Lukas Fleischer
9907069f44 Validate date/time when scanning items
Bail out when reading dates such as "02/30/2013" from the appointments
file. These *could* be converted into valid dates but since we never
write invalid dates to that file, these indicate a user error.

Fixes following test cases:

* appointment-009.sh
* appointment-012.sh
* appointment-016.sh
* appointment-019.sh
* event-003.sh

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-27 11:36:29 +01:00
Lukas Fleischer
43bdd12254 parse_{date,time}(): Split out date/time validation
Split date/time validation into separate functions check_date() and
check_time(). These will be used to validate date/time information when
reading items from the appointments file.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-27 11:36:28 +01:00
Lukas Fleischer
ba2c5c14f6 test/: Add default values for configuration variables
Add a small helper script called "test-init.sh" that is sourced in each
test case and initializes the CALCURSE and DATA_DIR environment
variables.

Update the test suite README to point out that setting these environment
variables is no longer required.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-27 11:36:28 +01:00
Lukas Fleischer
5501dae328 test/: Add a couple of black-box tests for items
This introduces five test suite failures which will be fixed in one of
the following patches.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-27 11:36:28 +01:00
Lukas Fleischer
3d7fdaec58 date_sec2date_str(): Add missing semicolon
Regression introduced in a363cb9b9111aed22d105adb0e7a8e9caab9bbe3.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-19 00:57:24 +01:00
Lukas Fleischer
a363cb9b91 Fix braces in if-else statements
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>
2013-02-17 09:19:04 +01:00
Lukas Fleischer
8e16853201 parse_duration(): Bail out early in final state
Bail out early if we are reading a character while being in a final
state.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-14 12:22:34 +01:00
Lukas Fleischer
de0092a1e9 ui-day.c: Several minor simplifications
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-14 12:12:08 +01:00
Lukas Fleischer
abca2f10b5 ui-todo.c: Refactor ui_todo_chg_priority()
Add the new item *before* deleting the old one and get rid of temporary
buffers for the item message and note.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-14 11:49:15 +01:00
Lukas Fleischer
8de7399360 Mark todo_get_position() public
This is needed in "ui-todo.c" now.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-14 11:10:38 +01:00
Lukas Fleischer
806673dd9b calendar.c: Rename to "ui-calendar.c"
This unit belongs to the presentation layer -- rename the file
accordingly.

Also, rename calendar_*() to ui_calendar_*().

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-14 11:08:03 +01:00
Lukas Fleischer
971df8d215 todo.c: Split out UI-related functions
* Move UI-related functions to "ui-todo.c".
* Rename UI-related functions to ui_todo_*().

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-14 11:08:03 +01:00
Lukas Fleischer
601709b173 apoint.c: Split out UI-related functions
* Move UI-related functions to "ui-day.c".
* Rename UI-related functions to ui_day_*().

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-14 10:43:40 +01:00
Lukas Fleischer
c7f3888607 Rename appointment/event-related UI functions
* Rename "interaction.c" to "ui-day.c" since it no longer contains
  todo-related UI functions.

* Rename appointment/event-related UI functions to ui_day_*().

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-14 10:34:00 +01:00
Lukas Fleischer
267bf0fc1c Split out UI functions for todo items
* Move todo-related UI functions from "interaction.c" to a new
  compilation unit "ui-todo.c".

* Rename all todo-related UI functions to todo_ui_*().

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-14 10:28:31 +01:00
Lukas Fleischer
720189d03f Merge branch 'maint' 2013-02-09 14:11:22 +01:00
Lukas Fleischer
6d6f76e76d Release 3.1.4
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-09 13:41:16 +01:00
Lukas Fleischer
b3280b8bca Do not ignore "--datarootdir" in "po/Makefile.in.in"
This fixes the "--datarootdir" warning seen with autotools >=2.59c. Note
that this is a workaround for a bug in autopoint(1).

Inspired by util-linux commit cc3c3fdd29719883605687fc0d11391386ab46c6.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-05 21:37:01 +01:00
Lukas Fleischer
b30ccc6319 Merge branch 'maint' 2013-02-04 20:11:58 +01:00
Lukas Fleischer
a7944d335e Update copyright ranges
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>
2013-02-04 20:10:14 +01:00
Michael Smith
ce22b13a4d Close key binding window when reassigning the same key
This allows for canceling a key reassignment. We cannot use a static key
here since every key could potentially be used in a binding. Instead,
just cancel if we are trying to reassign a key that has already been
used for that action before.

Signed-off-by: Michael Smith <crazedpsyc@mail4us.net>
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-04 20:06:09 +01:00
Lukas Fleischer
d5cbe794e9 Do not prompt for a todo after adding an appointment
We effectively turned the addition of an appointment into a fall through
case by deleting the break statement during refactoring. Revert this
deletion to skip the second prompt.

Regression introduced in f2dca7de3e8b164a4b3af3d58dde2f6776bfbee6.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-03 09:55:52 +01:00
Lukas Fleischer
9d667e06d8 Release 3.1.3
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-02 17:26:11 +01:00
Lukas Fleischer
308ba7c983 Merge branch 'maint' 2013-02-02 16:39:16 +01:00
Lukas Fleischer
9a6df45c4b day_process_storage(): Remove redundant parameter
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-01 18:42:45 +01:00
Lukas Fleischer
93767ce29c Properly skip spaces after exception list
Skip whitespace after obtaining the list of exceptions instead of
skipping the next character unconditionally.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-01 18:30:30 +01:00
Lukas Fleischer
e27cf190d0 Skip start time update if prompt is canceled
See commit 217e66729a249a638863a9cc2ff93b8368cd6094 for details.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-01 18:24:36 +01:00
Lukas Fleischer
217e66729a Skip duration update if the prompt is canceled
Do not update an appointment's duration if the user cancels the prompt
at day_edit_duration(). Note that day_edit_duration() does not touch the
buffer if the prompt was canceled or an invalid value was entered,
resulting in the buffer variable being uninitialized in these cases.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-02-01 18:14:32 +01:00
Lukas Fleischer
6e733b98d0 Delete TODO file
This is outdated and has been migrated to the bug tracker which turned
out to be a much better way of keeping track of tickets.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-01-30 15:58:59 +01:00
Lukas Fleischer
de73d96188 Use strncasecmp() for case-insensitive comparison
Instead of converting everything to upper case and then using strncmp(),
use strncasecmp() which does case-insensitive comparison out of the box.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-01-30 15:42:08 +01:00
Lukas Fleischer
ef961f4927 Remove unused function mystrtol()
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-01-30 15:39:58 +01:00
Lukas Fleischer
efa3589f78 custom.c: Fix sidebar configuration help text
* Use a format string instead of the TOSTRING() macro.
* Remove "xgettext:no-c-format" hack and use "%%" instead.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2013-01-30 15:38:13 +01:00
Lukas Fleischer
2ea91e1a8a test/: Use faketime -f
Use the advanced timestamp specification format for libfaketime.

Before using that, some tests failed on 32-bit systems due to integer
overflows. It seems like faketime translates absolute dates to relative
dates by default. Moreover, libfaketime is not able to handle relative
dates that exceed the maximum value of a signed integer. Using "-f"
skips the conversion to relative dates.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-12-22 01:09:17 +01:00
Lukas Fleischer
c054182890 test/: Do not error out if libfaketime is missing
If the faketime library is missing, show a warning and skip the test.
However, do not error out to make sure the test suite is able to
terminate successfully on systems without libfaketime.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-12-22 01:06:20 +01:00
Lukas Fleischer
0cda64a234 Release 3.1.2
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-12-16 11:06:03 +01:00
Lukas Fleischer
574306ff85 do_storage(): Unset highlighted item if list is empty
Check if the appointment panel contains any items and unset the
highlight counter if it doesn't. Not doing this resulted in core dumps
if the edit command was invoked after switching to a day without any
appointments/events.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-12-16 02:27:39 +01:00
Lukas Fleischer
82942938be Display correct startup messages
These messages have been swapped accidentally during refactoring.
Regression introduced in 691f8a6015bafcf6ed4f99a3649d428fb7a8e915.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-12-16 02:27:39 +01:00
Lukas Fleischer
e492ac6f95 Add hidden key handler window
After BUG#6 had apparently been closed with the screen locks introduced
in commit a80f8dcf2c6eb3b54658218bc081ee9694204dd5, some people still
had problems with random characters appearing in the notification bar.
This was obviously caused by wgetch() refreshing the screen if the
status panel was changed. From wgetch(3):

    If the window is not a pad, and it has been moved or modified since
    the last call to wrefresh, wrefresh will be called before another
    character is read.

Since the wgetch(3) isn't thread-safe, there were race conditions
between the notification bar thread drawing to the notification bar and
wgetch() updating the screen. Introduce a (hidden) window that handles
all key presses and never gets changed in order to avoid this.

Also, call wins_wrefresh() explicitly in status_mesg(), since we can no
longer rely on wgetch() updating windows automatically.

Fixes reopened BUG#6. Note that this is a hotfix -- FR#26 has been
opened to ensure we fix this properly in the next major release.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-12-16 02:27:36 +01:00
Lukas Fleischer
aa7844942e Release 3.1.1
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-12-06 22:01:48 +01:00
Lukas Fleischer
64662ff2ce Fix two enumeration types in function signatures
Spotted with clang and "-Wconversion".

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-12-06 20:41:19 +01:00
Lukas Fleischer
db51503b64 keys.c: Remove several unneeded assertions
Seen when compiling with clang and "-Wtautological-compare".

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-12-06 20:32:41 +01:00
Lukas Fleischer
599b01b06d wins_show(): Fix size of the slave window array
The slave window array was just big enough to hold a single element,
whereas two elements are written/accessed. Fix this off-by-one error in
the array declaration.

Note that this messed up the panel layout when using clang as a
compiler.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-12-06 20:20:30 +01:00
Lukas Fleischer
36a447b8b9 Release 3.1.0
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-12-05 16:04:11 +01:00
Lukas Fleischer
0f8fe2cf40 io_load_keys(): Skip legacy entry
This binding was used pre-3.1.0. Simply ignore it and avoid showing a
needlessly complicated error message.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-12-05 16:02:04 +01:00
Lukas Fleischer
db8886a34c keys_save_bindings(): Skip unset key bindings
Saving unset key bindings currently results in a segmentation fault or
invalid key specifiers being stored. Skip these entries to avoid this.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-12-05 15:57:29 +01:00
Lukas Fleischer
a9cbf27536 po/: Translation updates from Transifex
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
2012-12-05 12:28:55 +01:00