nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 06bbc70d4a6b1bc924d7ad5b12febb4df806ce9d
parent d256d0cbc06cfeae95825da6a66e6f0160840dd3
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Sun, 13 Oct 2019 12:38:46 +0200

tweaks: use a string-copy function that checks for out-of-memory

Diffstat:
Msrc/files.c | 2+-
Msrc/help.c | 2+-
Msrc/rcfile.c | 8++++----
3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -2303,7 +2303,7 @@ char *real_dir_from_tilde(const char *path) if (userdata != NULL) tilded = mallocstrcpy(tilded, userdata->pw_dir); #else - tilded = strdup(""); + tilded = copy_of(""); #endif } diff --git a/src/help.c b/src/help.c @@ -103,7 +103,7 @@ void do_help(void) #ifdef ENABLE_COLOR char *was_syntax = syntaxstr; #endif - char *saved_answer = (answer != NULL) ? strdup(answer) : NULL; + char *saved_answer = (answer != NULL) ? copy_of(answer) : NULL; /* The current answer when the user invokes help at the prompt. */ unsigned stash[sizeof(flags) / sizeof(flags[0])]; /* A storage place for the current flag settings. */ diff --git a/src/rcfile.c b/src/rcfile.c @@ -175,7 +175,7 @@ void jot_error(const char *msg, ...) errors_tail = error; if (rcfile_with_errors == NULL) - rcfile_with_errors = strdup(nanorc); + rcfile_with_errors = copy_of(nanorc); if (lineno > 0) length = snprintf(textbuf, MAXSIZE, _("Error in %s on line %zu: "), @@ -326,7 +326,7 @@ void begin_new_syntax(char *ptr) /* Initialize a new syntax struct. */ live_syntax = (syntaxtype *)nmalloc(sizeof(syntaxtype)); live_syntax->name = copy_of(nameptr); - live_syntax->filename = strdup(nanorc); + live_syntax->filename = copy_of(nanorc); live_syntax->lineno = lineno; live_syntax->augmentations = NULL; live_syntax->extensions = NULL; @@ -1050,8 +1050,8 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only) continue; } - argument = strdup(ptr); keyword = ptr; + argument = copy_of(ptr); ptr = parse_next_word(ptr); /* File-matching commands need to be processed immediately; @@ -1064,7 +1064,7 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only) } else { newitem = nmalloc(sizeof(augmentstruct));; - newitem->filename = strdup(nanorc); + newitem->filename = copy_of(nanorc); newitem->lineno = lineno; newitem->data = argument; newitem->next = NULL;