sled

Једноставни уређивач текста
git clone https://git.sr.ht/~strahinja/sled
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 48d828e53c6ccf3ba27de89d727fb9633273277e
родитељ db20cfc29f809131216f83d2ae59c0c429602985
Аутор: Страхиња Радић <sr@strahinja.org>
Датум:   Sun, 25 Jan 2026 22:06:37 +0100

sled.c: Simplified the error handling code near the end of main

Diffstat:
MTODO | 8--------
MTODO.done | 23+++++++++++++++++++++++
Msled.c | 13+++----------
измењених датотека: 3, додавања: 26(+), брисања: 18(-)

diff --git a/TODO b/TODO @@ -7,14 +7,6 @@ TODO that termbox has a function for getting characters from the display buffer -[x] Make backup creation able to be disabled through a command-line - parameter? - - Rationale: usage in specific privilege-restricted scenarios - -[ ] Hypothetical: editing a symlink to a file which gets deleted mid-editing, - then a save is attempted. Bail out (current behavior)? - - What if a file was on a USB flash which was pulled out? - [ ] Investigate: pressing C-S on work laptop (possibly in the case when editing a symlink) diff --git a/TODO.done b/TODO.done @@ -1,6 +1,29 @@ Done or canceled todos ====================== +[x] Hypothetical: editing a symlink to a file which gets deleted mid-editing, + then a save is attempted. Bail out (current behavior)? + - That is not the current behavior. Currently: + - If the target is deleted, it is recreated. + - If the symlink is deleted, it is recreated as a regular file. + (This behavior is the same as in vim.) + - What if a file was on a USB flash which was pulled out? + - vim writes the file under /mnt/filename + - ENOENT is returned by fopen(3), sled bails out. + - Interesting, since "the file" should be "created if it + doesn't exist" according to fopen(3), and open(2) + states that ENOENT is returned only if O_CREAT is not + specified, or a component of the pathname is not + present (/mnt is still present after removing the USB + flash drive) + - Decided to leave bailing out, printing an error, present for + now in this case. + +[x] Make backup creation able to be disabled through a command-line + parameter? + - Rationale: usage in specific privilege-restricted scenarios + - Added -b/-B. + [x] Errors out on st-256color -> send patch for st upstream; improve termbox2 error handling - Why: tb_init was returning -17 (TB_ERR_UNSUPPORTED_TERM) under diff --git a/sled.c b/sled.c @@ -3233,18 +3233,11 @@ main_done: exit(CUSTOM_ERROR_START + saved_errno); } - if (errno) - perror(PROGRAM_NAME); + tb_shutdown(saved_errno != ENOMEM); - if (saved_errno == ENOMEM) - { - tb_shutdown(0); - print_error(1, errors[state.error]); - exit(saved_errno); - } + if (saved_errno) + perror(PROGRAM_NAME); - tb_shutdown(1); - errno = saved_errno; if (state.error == ERR_NOTREG_FILE) print_error(1, errors[state.error], state.filename); else if (state.error)