tweaks: reassign a copy of a string to a variable more economically

master
Benno Schulenberg 2021-10-12 09:33:08 +02:00
parent 42610db847
commit e51f6596d4
1 changed files with 9 additions and 9 deletions

View File

@ -1565,7 +1565,7 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
#endif #endif
#ifdef ENABLE_OPERATINGDIR #ifdef ENABLE_OPERATINGDIR
if (strcmp(option, "operatingdir") == 0) if (strcmp(option, "operatingdir") == 0)
operating_dir = free_and_assign(operating_dir, copy_of(argument)); operating_dir = mallocstrcpy(operating_dir, argument);
else else
#endif #endif
#ifdef ENABLED_WRAPORJUSTIFY #ifdef ENABLED_WRAPORJUSTIFY
@ -1583,12 +1583,12 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
else if (mbstrlen(argument) % 2 != 0) else if (mbstrlen(argument) % 2 != 0)
jot_error(N_("Even number of characters required")); jot_error(N_("Even number of characters required"));
else else
matchbrackets = free_and_assign(matchbrackets, copy_of(argument)); matchbrackets = mallocstrcpy(matchbrackets, argument);
} else if (strcmp(option, "whitespace") == 0) { } else if (strcmp(option, "whitespace") == 0) {
if (mbstrlen(argument) != 2 || breadth(argument) != 2) if (mbstrlen(argument) != 2 || breadth(argument) != 2)
jot_error(N_("Two single-column characters required")); jot_error(N_("Two single-column characters required"));
else { else {
whitespace = free_and_assign(whitespace, copy_of(argument)); whitespace = mallocstrcpy(whitespace, argument);
whitelen[0] = char_length(whitespace); whitelen[0] = char_length(whitespace);
whitelen[1] = char_length(whitespace + whitelen[0]); whitelen[1] = char_length(whitespace + whitelen[0]);
} }
@ -1599,26 +1599,26 @@ void parse_rcfile(FILE *rcstream, bool just_syntax, bool intros_only)
if (has_blank_char(argument)) if (has_blank_char(argument))
jot_error(N_("Non-blank characters required")); jot_error(N_("Non-blank characters required"));
else else
punct = free_and_assign(punct, copy_of(argument)); punct = mallocstrcpy(punct, argument);
} else if (strcmp(option, "brackets") == 0) { } else if (strcmp(option, "brackets") == 0) {
if (has_blank_char(argument)) if (has_blank_char(argument))
jot_error(N_("Non-blank characters required")); jot_error(N_("Non-blank characters required"));
else else
brackets = free_and_assign(brackets, copy_of(argument)); brackets = mallocstrcpy(brackets, argument);
} else if (strcmp(option, "quotestr") == 0) } else if (strcmp(option, "quotestr") == 0)
quotestr = free_and_assign(quotestr, copy_of(argument)); quotestr = mallocstrcpy(quotestr, argument);
else else
#endif #endif
#ifdef ENABLE_SPELLER #ifdef ENABLE_SPELLER
if (strcmp(option, "speller") == 0) if (strcmp(option, "speller") == 0)
alt_speller = free_and_assign(alt_speller, copy_of(argument)); alt_speller = mallocstrcpy(alt_speller, argument);
else else
#endif #endif
#ifndef NANO_TINY #ifndef NANO_TINY
if (strcmp(option, "backupdir") == 0) if (strcmp(option, "backupdir") == 0)
backup_dir = free_and_assign(backup_dir, copy_of(argument)); backup_dir = mallocstrcpy(backup_dir, argument);
else if (strcmp(option, "wordchars") == 0) else if (strcmp(option, "wordchars") == 0)
word_chars = free_and_assign(word_chars, copy_of(argument)); word_chars = mallocstrcpy(word_chars, argument);
else if (strcmp(option, "guidestripe") == 0) { else if (strcmp(option, "guidestripe") == 0) {
if (!parse_num(argument, &stripe_column) || stripe_column <= 0) { if (!parse_num(argument, &stripe_column) || stripe_column <= 0) {
jot_error(N_("Guide column \"%s\" is invalid"), argument); jot_error(N_("Guide column \"%s\" is invalid"), argument);