1440 Commits

Author SHA1 Message Date
Max Kunzelmann
343ba5bfdf Fix memory leak by freeing linked lists in recurrence rules
The function responsible for freeing a recurring appointment or event
did not free the linked lists contained in the `struct rpt` holding the
recurrence rules. This led to memory leaks if a user had recurring
appointments or events.

Found with ASAN.

Signed-off-by: Max Kunzelmann <max@mxzero.net>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2024-01-26 13:38:33 +01:00
Max Kunzelmann
81953ef75a Fix memory leak in keys initialization
Previous to this commit, a strdup took place for every key name
including those that were replaced with customized key names later on
while never calling free on the pointer returned by strdup.

This fix only calls strdup for key names that are not replaced with
custom key names.

Found with ASAN.

Signed-off-by: Max Kunzelmann <max@mxzero.net>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2024-01-26 13:38:32 +01:00
Max Kunzelmann
aa5ff07b61 Fix out of bounds memory access (off by one)
If fgets reads a line that only contains a `\n`, then the pointer `eol`
will point to the first byte in that buffer. The subsequent dereference
of `*(eol -1 )` will access the byte before that buffer.

This fix makes sure that that length of the current line read by fgets
is at least 2 bytes long.

Signed-off-by: Max Kunzelmann <max@mxzero.net>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2023-12-14 13:17:24 +01:00
Max
f6090c7e17 add missing call to va_end() for copied va_list
The man page stdarg(3) states that each invocation of `va_copy()` must
be matched by a corresponding invocation of `va_end()` in the same
function.

Signed-off-by: Max <max@mxzero.net>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2023-11-06 15:42:59 -05:00
Max
daa7da0d0b correctness: kill returns -1 on error
Signed-off-by: Max <max@mxzero.net>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2023-11-06 15:42:59 -05:00
Max
b9a0719117 remove unnecessary set of sidebar width
When the function is called, `col` is zero, which leads to setting the
sidebar width (in percent) to zero. As the variable holding the
percentage is `static unsigned sbarwidth_perc` it is initialized to zero
anyway and we set the percentage later to the value loaded from the
configuration, too.

Signed-off-by: Max <max@mxzero.net>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2023-11-06 15:42:59 -05:00
Benedikt Wildenhain
535088c809 Fix segmentation fault when exporting ical file
If a note file gets accidently deleted this leads to ical_export_note
trying to execute fclose(NULL) which leads to a segmentation fault on
current Debian GNU/Linux using libc6 (according to fclose's manpage, the
behaviour is undefined in this case).

The fix tests whether fopen returned a non-NULL-pointer before trying to
close it.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2023-11-05 14:14:51 -05:00
Lukas Fleischer
b8b7a3a734 Fix characters in weekly view
Fixes GitHub issue #441.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2023-04-15 09:47:30 -04:00
Lukas Fleischer
213e5f86a5 Update copyright ranges for 2023
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2023-04-11 17:04:24 -04:00
Marian Buschsieweke
5394e981d9 Fix segfault when importing iCal files
Previously, events / appointments without a description resulted in
a segfault. This provides a trivial fix by adding an `<emtpy>` as
description in this case.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2023-04-11 15:25:27 -04:00
Nicholas Johnson
4cd300f2c4 Check that note files open before reading them
This fixes the scenario where a note file referenced by a todo, event,
or appointment is modified from outside the program in such a way that
it cannot be opened by the program, resulting in a segmentation fault.

The least surprising way to proceed is to ignore the note.

Signed-off-by: Nicholas Johnson <nick@nicksphere.ch>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2023-01-31 19:27:57 -05:00
Lukas Fleischer
ac5113640d Fix handling of recurrent open-ended appointments at 00:00
Prior to this commit, a recurrent appointment ending at 00:00 on a given
day was not considered to span the day. This is the correct behavior for
all cases, except appointments without end time (both starting and
ending at midnight on a given day). Handle this edge case explicitly.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2023-01-01 11:47:49 -05:00
Lukas Fleischer
ce6f8bf85b Extend default description to all item types
Show default description "(empty description)" for all types of items
(appointments, events, recurring appointments/events, TODOs).

Follow-up to 7b350ac (Add text for displaying empty event description,
2022-06-21).

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2022-12-25 16:36:27 -05:00
Jonathan van der Steege
7b350ac58f Add text for displaying empty event description
Signed-off-by: Jonathan van der Steege <jonathan@jonakeys.nl>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2022-12-25 15:13:52 -05:00
Morgan Seltzer
a1d2faab26 Layout change recognizes changed appointment space
Before a layout change did not update the maximum number of appointments
visible, until the config menu was exited. Now the maximum number of
appointments are visible immediately after the layout screen is exited.

Addresses GitHub issue #381

Signed-off-by: Morgan Seltzer <MorganSeltzer000@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2022-04-03 12:24:55 -04:00
Lars Henriksen
ec38714bbc Allow newlines in SUMMARY by replacing them with blanks
Addresses Github issue #414 (Android calendar allows them).

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2022-03-19 20:21:09 -04:00
Lukas Fleischer
01ad848628 Update copyright ranges for 2022
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2022-03-11 11:33:19 -05:00
Lukas Fleischer
a03a4710cc Fix compiler warning in SHA1 implementation
Update the signature of sha1_final() to fix the following warning:

    sha1.c:208:43: warning: argument 2 of type ‘uint8_t[20]’ {aka
    ‘unsigned char[20]’} with mismatched bound [-Warray-parameter=]

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2022-03-11 11:29:51 -05:00
Lukas Fleischer
20b23cc32e Fix SHA1 calculation on big-endian systems
Add the AC_C_BIGENDIAN macro to determine endianness and set
WORDS_BIGENDIAN accordingly.

Fixes GitHub issue #397.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2022-03-11 11:23:47 -05:00
nobody
2b766040a9 Make Home/End keys work as expected in text input mode
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2021-08-07 13:52:53 -04:00
Morgan Seltzer
ee8ebebf92 First day of week can now be any day
Previously only Sunday and Monday were allowed as the first day of the
week, and this was internally treated as a binary variable.

This patch allows for users to change the first day of the week to any
day.

Addresses GitHub feature request #321.

Signed-off-by: Morgan Seltzer <MorganSeltzer000@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2021-08-07 13:42:28 -04:00
Morgan Seltzer
e3fc73e0c7 Backend changes for first day of week
Previously only Sunday and Monday were allowed for the first day of the
week, and was internally treated as a binary variable.

This patch changes the backend so all days are accepted, a future patch
will allow users to actually select other days.

Addresses GitHub feature request #321.

Signed-off-by: Morgan Seltzer <MorganSeltzer000@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2021-08-07 13:42:10 -04:00
Morgan Seltzer
61ed5f835c Fixed sidebar config sometime not increasing width
The sidebar has a numerical mimumum width that is statically defined,
and users may set the width of the sidebar in config by incrementing the
percentage of the screen between this minimum and a maximum value of
50%. However, internally the mimimum percentage could be set as low as
zero, and while that did not decrease the sidebar size below the
numerical minimum width, did mean that between 0 and the mimimum width
increasing the percentage had no visual effect to indicate change. Now
the mimimum percent is not decremented below the mimimum width.

Signed-off-by: Morgan Seltzer <MorganSeltzer000@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2021-08-07 13:37:29 -04:00
mercurialmoon
a49adf2db7 Allow configuration of appointment time format
Added the option to configure the format in which appointment time is
displayed. The setting is called "format.appointmenttime" under the
general settings menu. Setting defaults to previous behavior, which was
"%H:%M".

Signed-off-by: mercurialmoon <mercurialmoon@protonmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2021-04-11 19:52:02 -04:00
Aurora
9b148900b8 Add generic-prev-view key binding
This can be used to cycle backwards through windows (similarly to
generic-change-view).

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2021-04-11 19:48:17 -04:00
Lars Henriksen
338c640a19 Allow undefined actions in keys configuration file
In the keys file there are three possibilities for each action:

1. One or several keys are assigned to it
2. It is marked as UNDEFINED (new)
3. It is missing from the file

On load of the keys file, calcurse respectively

1. Assigns the key(s)
2. Assigns "UNDEFINED" (new)
3. Assigns a default key if possible

If default keys were assigned, the user is informed of the number of
actions affected, and the keys file is updated.

After load each action must either have keys assigned or be undefined.
If not, calcurse exits with a failure. If there are syntax/semantic
errors in the file, calcurse rejects the file and exits.

When an interactive user leaves the keys configuration menu, a warning
is issued if any action is UNDEFINED. The keys file is always updated.

Addresses GitHub issue #298.

Additionally: Description of concepts and data structures used for
keyboard keys and virtual keys (actions) as well as name changes and
comments to improve readability.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2021-04-11 19:46:11 -04:00
Lukas Fleischer
5398f3a24e Call setsid() for hook/notification commands
We do not want hook or notification commands to interact with the
terminal in any way. Create a new session for them.

Addresses GitHub issue #326.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2021-04-04 12:15:31 -04:00
Lukas Fleischer
193ad3415a Redirect standard descriptors for hook/notify commands
Disconnect stdin, stdout and stderr when running an external hook or
notification command. The previous solution of appending "<&- >&- 2>&-"
to the shell command line does not work if the command includes pipes.

Use shell_exec() in notify_launch_cmd() instead of a custom (and
incomplete) reimplementation of that command.

Partially addresses GitHub issue #326.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2021-04-04 12:15:31 -04:00
Lukas Fleischer
5710a8bd7f Add parameter to redirect stderr to shell_exec()
Add a function parameter to allows redirecting stderr in addition to
stdin and stdout. The parameter will be used with a follow-up change.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2021-04-04 12:15:26 -04:00
Lars Henriksen
4777c60056 Todo resort() optimization
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2021-01-31 09:55:44 -05:00
Lars Henriksen
b44307cc83 Keep a linked list sorted
A general linked list function, llist_reorder(), is introduced that will reorder
a list after a list element has changed.

Some refactoring to avoid code dupliction.

Background

The four linked lists of appointment panel items (appointments, recurring
appointments, events, recurring events) are kept sorted by inserting elements
in order, either when they are first loaded from disk or when new are added.
The ordering is by start time (numerical) and description (alphabetical).

The user is allowed to change start time as well as description. A change is
committed directly to the list item (unlike cut/paste where an item is deleted
and then inserted). This may break the order.

The order property is used when events are loaded from the evenlist into the
day_item vector, see LLIST_FIND_FOREACH_CONT, and when looking for the next
upcoming appointment, see apoint_check_next().

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2021-01-16 22:37:24 -05:00
Tim Gates
67068c1ac3 docs: fix simple typo, mulitple -> multiple
There is a small typo in src/wins.c.

Should read `multiple` rather than `mulitple`.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-12-19 13:49:31 -05:00
Lars Henriksen
1efe24105e Improve performance of recur_prev_occurrence()
And fix item start day for prev command

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-12-19 09:19:59 -05:00
Lars Henriksen
3599766cee Introduce macro DAY
DAY(t) is midnight (the day) of time_t t.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-12-19 09:19:59 -05:00
Lars Henriksen
0af69778b5 Fix parsing of UNTIL in iCal import
Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-12-19 09:19:59 -05:00
Lars Henriksen
e3dd92ef71 Do not remove an empty note file after edit session
Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-11-15 12:11:27 -05:00
Lukas Fleischer
e1b5580bdf Avoid double free on iCal import errors
Set pointers to NULL after calling free() to prevent double free on
cleanup.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-11-07 19:53:21 -05:00
Lars Henriksen
97df01b534 Return failure if import skips any item
Other items may have been imported succesfully.

Adresses Github issue #323, last part.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-11-07 19:50:23 -05:00
Lars Henriksen
d126696999 Make iCal event import independent of property ordering
Refactoring of ical.c: properties DTSTART, DTEND, DURATION, RRULE and EXDATE are
saved and only processed after encountering END:VEVENT.

Adresses Github issue #323, follow-up question.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-11-07 19:50:23 -05:00
Lukas Fleischer
d25b9c0f37 Use dynamically allocated string in struct io_file
Avoid using fixed-size buffers and strncpy().

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-10-11 09:59:37 -04:00
Ambika Eshwar
5f47194b3b Implemented rendering of notes in events/appts as well
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-10-11 09:59:37 -04:00
Ambika Eshwar
b144b19964 Implemented rendering of notes in todo view
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-10-11 09:59:37 -04:00
Lukas Fleischer
1b40844aa3 Fix memory leak in run_hook()
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-10-11 09:59:37 -04:00
Lukas Fleischer
47fb9b740f Redesign the item deletion menu
Instead of the previous inconsistent and potentially nested menus, the
following message is now displayed when deleting an item:

    Delete (s)elected occurrence, (a)ll occurrences, or only the (n)ote?

Options that are not available (e.g. because the item is not recurrent
or does not have a note) are omitted. For a non-recurrent item without a
note the message becomes

    Delete (s)elected occurrence?

and is skipped if general.confirmdelete is disabled.

Implements GitHub feature request #308.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-10-11 09:59:37 -04:00
Lars Henriksen
95151e3f0c Add p(revious) command
The p(rev) command finds the previous occurrence of a recurrent item, analogous
to the n(ext) command.

A bug in the next command is corrected..

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-10-11 09:59:35 -04:00
Lars Henriksen
4d9d50722a Replace 'ical_rpt_t' with 'struct rpt'
Refactoring and simplification only, no functional change. All error checking
and logging done before call of ical_store_event/apoint().

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-10-07 17:36:55 -04:00
Lars Henriksen
1cecfead43 Always exit with failure in case of option parsing errors
Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-10-07 17:36:55 -04:00
Lars Henriksen
f2a7eea311 Extend icalendar export
Export now covers advanced recurrence rules and properties imported to a note
file.

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-08-26 07:52:08 -04:00
Lars Henriksen
e3cfca7568 Update use of note file for import
Removes the parts of commit 'Extend use of note file for ical import' that
relate to STATUS. The STATUS property is (partly) supported for todos already.

Corrects insertion of a separator: always insert it before imported properties
(also when there is no description).

Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-08-26 07:52:08 -04:00
Lars Henriksen
7b28e38d13 Improve event text for cancelled periodic save
Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
2020-07-26 10:31:34 -04:00