commit 079a679431ad2c92c9fde9961928f9f8d4a9c7f8
parent 56d1214187fde97a9d3fd8d78f147943ff968fbd
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Wed, 15 Apr 2020 17:20:03 +0200
tweaks: rename two functions, to better indicate what they do
Diffstat:
4 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/src/files.c b/src/files.c
@@ -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));
diff --git a/src/history.c b/src/history.c
@@ -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';
diff --git a/src/proto.h b/src/proto.h
@@ -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
diff --git a/src/utils.c b/src/utils.c
@@ -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')