tweaks: rename two functions, to better indicate what they do

master
Benno Schulenberg 2020-04-15 17:20:03 +02:00
parent 56d1214187
commit 079a679431
4 changed files with 11 additions and 11 deletions

View File

@ -609,7 +609,7 @@ void close_buffer(void)
* and return a dynamically allocated copy of the resultant string. */
char *encode_data(char *buf, size_t buf_len)
{
unsunder(buf, buf_len);
recode_NUL_to_LF(buf, buf_len);
buf[buf_len] = '\0';
return copy_of(buf);
@ -1878,12 +1878,12 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
size_t wrote;
/* Decode LFs as the NULs that they are, before writing to disk. */
sunder(line->data);
recode_LF_to_NUL(line->data);
wrote = fwrite(line->data, sizeof(char), data_len, thefile);
/* Re-encode any embedded NULs as LFs. */
unsunder(line->data, data_len);
recode_NUL_to_LF(line->data, data_len);
if (wrote < data_len) {
statusline(ALERT, _("Error writing %s: %s"), realname, strerror(errno));

View File

@ -311,7 +311,7 @@ void load_history(void)
line[--read] = '\0';
if (read > 0) {
/* Encode any embedded NUL as 0x0A. */
unsunder(line, read);
recode_NUL_to_LF(line, read);
update_history(history, line);
} else if (history == &search_history)
history = &replace_history;
@ -339,7 +339,7 @@ bool write_list(const linestruct *head, FILE *hisfile)
size_t length = strlen(item->data);
/* Decode 0x0A bytes as embedded NULs. */
sunder(item->data);
recode_LF_to_NUL(item->data);
if (fwrite(item->data, sizeof(char), length, hisfile) < length)
return FALSE;
@ -402,7 +402,7 @@ void load_poshistory(void)
/* Read and parse each line, and store the extracted data. */
while ((read = getline(&line, &buf_len, hisfile)) > 5) {
/* Decode NULs as embedded newlines. */
unsunder(line, read);
recode_NUL_to_LF(line, read);
/* Find where the x index and line number are in the line. */
xptr = revstrstr(line, " ", line + read - 3);
@ -472,7 +472,7 @@ void save_poshistory(void)
length = strlen(path_and_place);
/* Encode newlines in filenames as NULs. */
sunder(path_and_place);
recode_LF_to_NUL(path_and_place);
/* Restore the terminating newline. */
path_and_place[length - 1] = '\n';

View File

@ -548,8 +548,8 @@ int digits(ssize_t n);
#endif
bool parse_num(const char *str, ssize_t *val);
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column);
void unsunder(char *string, size_t length);
void sunder(char *string);
void recode_NUL_to_LF(char *string, size_t length);
void recode_LF_to_NUL(char *string);
#if !defined(ENABLE_TINY) || defined(ENABLE_TABCOMP) || defined(ENABLE_BROWSER)
void free_chararray(char **array, size_t len);
#endif

View File

@ -160,7 +160,7 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
}
/* In the given string, recode each embedded NUL as a newline. */
void unsunder(char *string, size_t length)
void recode_NUL_to_LF(char *string, size_t length)
{
while (length > 0) {
if (*string == '\0')
@ -171,7 +171,7 @@ void unsunder(char *string, size_t length)
}
/* In the given string, recode each embedded newline as a NUL. */
void sunder(char *string)
void recode_LF_to_NUL(char *string)
{
while (*string != '\0') {
if (*string == '\n')