52 Commits

Author SHA1 Message Date
Dan Cross
e548c94750 mail_menu.c: Remove external lines counter in editor.
The pointer vector maintaining `content` in `editor` already
keeps track of the number of lines and makes it available via
a call to `ptr_vector_len` (or one could look at th `len`
member of the ptr_vector struct...this is C, not some fancy
object oriented language with data hiding).  Delete the `lines`
local variable and just use ptr_vector_len where necessary.

Sorry; I should have done that in the first sweep through that
code.  My bad!

Signed-off-by: Dan Cross <patchdev@fat-dragon.org>
2018-10-12 10:12:36 +10:00
Andrew Pamment
37e728b749 Fix for line numbers on internal editor 2018-10-11 22:04:48 +10:00
Andrew Pamment
15d09ed57a Fix a couple of bugs, one in stralloc and one uninitialized ptr vector 2018-10-11 15:25:00 +10:00
Dan Cross
6d30116ed9 Import strlcpy/strlcat from OpenBSD, start using them.
strcpy()/strcat() are inherently dangerous, even when
used with great care.  strlcpy() and strlcat() are
much safer replacements, and are available from OpenBSD
under a very liberal license.  Import them and start
using them.

Between pointer vectors, malloz, stralloc and now
strlcpy/strlcat, Magicka has much safer, simpler and
more performant infrastructure for dealing with
strings and dynamic collections of various kinds.

Signed-off-by: Dan Cross <patchdev@fat-dragon.org>
2018-10-11 13:58:49 +10:00
Dan Cross
82b6ec3a3b More use of ptr_vector; avoid unnecessary copies.
Recast more code in terms of the ptr_vector abstraction.

The mail_menu.c code also made a lot of unnecessary copies
of strings.  For example, there was this code sequence:

    for (i = z; i < lines - 1; i++) {
            free(content[i]);
            content[i] = strdup(content[i + 1]);
    }
    free(content[i]);
    lines--;
    content = (char **)realloc(content, sizeof(char *) * lines);

Here, `content` represents an array of lines of text.
This code is removing an element from somewhere in that
array (possibly in the middle), and then shifting the
remaining elements over one position.

But observe the calls to `free` and `strdup` in the loop
body: the content is already dynamically allocated.  We
free whatever was in the selected position, and then make
*another copy* of the data in the next position to put
into the now-available slot in the array: repeat for the
remainder of the array's elements.

Instead, we could change this code to just shift things
down:

    free(content[z]);
    for (i = z; i < (lines - 1); ++i)
            content[i] = content[i + 1];
    --lines;
    ncontent = realloc(content, sizeof(char *) * lines);
    assert(ncontent == NULL);
    content = ncontent;

However, the ptr_vector abstraction provides us a function,
`ptr_vector_del` that deletes an element from the array and
returns the pointer, so we can rewrite this as simply:

    free(ptr_vector_del(&content, z));

No additional malloc()/free() required, which means less
pressure on the memory allocator and less copying of data.

Signed-off-by: Dan Cross <patchdev@fat-dragon.org>
2018-10-11 11:44:19 +10:00
Dan Cross
fa014f3a88 Simplify dynamic memory management.
Add utility routines and use them to simplify the
use of dynamically allocated memory.

Signed-off-by: Dan Cross <patchdev@fat-dragon.org>
2018-10-10 10:25:29 +10:00
Dan Cross
d6826137dd clang-format
Fix a bunch of trivial formatting issues by running
`clang-format`.

Signed-off-by: Dan Cross <patchdev@fat-dragon.org>
2018-10-09 15:48:42 +10:00
Andrew Pamment
991b1c4368 Update to v0.12-alpha and add area headers 2018-10-04 10:05:04 +10:00
Andrew Pamment
a9c73f15a6 another fix 2018-09-02 18:27:22 +10:00
Andrew Pamment
db4eeff587 Fix for empty messages 2018-09-02 18:23:47 +10:00
Andrew Pamment
1b661f4f5b Fiddling with unread messages 2018-07-31 10:42:56 +10:00
Andrew Pamment
ecb1c986f0 Start on qwknet support 2018-06-24 10:28:18 +10:00
Andrew Pamment
42fdc30972 maginet 2018-05-22 21:02:22 +10:00
Andrew Pamment
f9b13fa515 fix flagging 2018-05-22 09:02:35 +10:00
Andrew Pamment
798bec221d Message Flagging 2018-05-22 08:55:44 +10:00
Andrew Pamment
275a60d0d4 Fix crash in mail menu 2018-05-16 13:44:04 +10:00
Andrew Pamment
8c9111fa17 modify to and subject on reply 2018-05-09 13:19:49 +10:00
Andrew Pamment
371aa84ea0 Fix for undefined string in mail scan 2018-02-27 13:24:24 +10:00
Andrew Pamment
ac4c525415 still working on this 2018-02-23 14:43:26 +10:00
Andrew Pamment
94d6b3396a fix unreadcount again 2018-02-23 14:34:42 +10:00
Andrew Pamment
4e195fe0e3 fix unread count 2018-02-23 14:31:31 +10:00
Andrew Pamment
7ca1148ff8 Improve personal Mail Scan 2018-02-23 14:27:36 +10:00
Andrew Pamment
532e1a6861 revert change 2018-02-20 15:05:45 +10:00
Andrew Pamment
c98ad14aef Fixed wordwrap bug in internal editor 2018-02-20 15:02:39 +10:00
Andrew Pamment
aa21b714e5 fix personal mail 2018-02-18 14:11:34 +10:00
Andrew Pamment
9390dedc82 Add personal mail scan 2018-02-18 13:51:39 +10:00
Andrew Pamment
66da53eb85 lots of leaks fixed 2018-02-10 16:01:30 +10:00
Andrew Pamment
29ebb8277a Initial nodelist parsing 2018-02-06 08:05:02 +10:00
Andrew Pamment
3ec7305cbe Allow pointers to be set, read, unread or at msg no 2018-02-03 11:44:36 +10:00
Andrew Pamment
b1c77445d9 Added new lua functions for reading mail 2018-01-29 15:20:13 +10:00
Andrew Pamment
2fcf6305c0 add a * next to areas that have new messages 2018-01-25 09:37:22 +10:00
Andrew Pamment
c5b754e135 Fix for broken msgs? 2018-01-22 12:48:43 +10:00
Andrew Pamment
6c3df730aa PageUp / Page Down Home / End in lists 2018-01-20 12:46:50 +10:00
Andrew Pamment
4c446797d8 Tweaks to file area chooser 2018-01-18 08:58:32 +10:00
Andrew Pamment
85fc0d57cd File area choosers now use lightbars 2018-01-17 16:03:15 +10:00
Andrew Pamment
1aeaee5031 EXPERIMENTAL lightbar area/conference selection 2018-01-17 14:54:04 +10:00
Andrew Pamment
dd1d4d4eaa Add signature capability 2018-01-13 19:17:22 +10:00
Andrew Pamment
5543f94e01 Magicka now builds and runs on SunOS 2017-10-20 07:27:58 +10:00
Andrew Pamment
7feead5819 Fix reply-id 2017-10-16 11:50:40 +10:00
Andrew Pamment
7dba74f514 Fix semaphore updating on netbsd/evbarm 2017-10-13 22:13:00 +10:00
Andrew Pamment
653f116660 Fix enter to quit sub tagging 2017-10-13 16:58:25 +10:00
Andrew Pamment
aa01e574df Toggle all or none subs. 2017-10-13 16:55:33 +10:00
Andrew Pamment
c07eb6825a Got J and Q mixed up 2017-10-13 15:41:43 +10:00
Andrew Pamment
20b95ed1a2 Cleanup 2017-10-13 13:20:42 +10:00
Andrew Pamment
af4cca2529 Fix strings for real 2017-10-13 13:17:25 +10:00
Andrew Pamment
3b50587d1a Fix strings again 2017-10-13 13:15:46 +10:00
Andrew Pamment
1ae8c26054 Improve new message scan 2017-10-13 13:03:06 +10:00
Andrew Pamment
ce65048a98 New experimental full mail scan 2017-10-12 20:24:55 +10:00
Andrew Pamment
180c124b80 Check for new mail in subscribed areas 2017-10-10 11:16:34 +10:00
Andrew Pamment
2d7f759a7c Fix type #1 2017-10-03 12:11:59 +10:00