do_search(), do_replace(), nanogetstr(), and statusq();
removal of remove_node(), insert_node(), and
get_history_completion(). (DLR)
+ - Replace all instances of strncpy() with charcpy(), since the
+ only difference between them is that the former pads strings
+ with nulls when they're longer than the number of characters
+ specified, which doesn't appear to be used anywhere. Changes
+ to input_tab(), do_browser(), do_enter(), replace_regexp(),
+ replace_line(), and mallocstrncpy(). (DLR)
- cut.c:
cut_line()
- Set placewewant properly after cutting a line, to avoid a
since the first line in the file is 1. (DLR)
- Start the search for a line from fileage instead of current
(again). (DLR)
+ replace_regexp()
+ - Rename variable create_flag to create for consistency. (DLR)
replace_line()
- Make new_line_size and search_match_count size_t's, for
consistency. (DLR)
*lastwastab = FALSE;
buf = charealloc(buf, common_len + buflen - *place + 1);
charmove(buf + common_len, buf + *place, buflen - *place + 1);
- strncpy(buf, mzero, common_len);
+ charcpy(buf, mzero, common_len);
*place = common_len;
} else if (*lastwastab == FALSE || num_matches < 2)
*lastwastab = TRUE;
* mark it as such. */
if (stat(filelist[j], &st) == 0 &&
S_ISDIR(st.st_mode)) {
- strncpy(foo, _("(dir)"), foo_len);
+ charcpy(foo, _("(dir)"), foo_len);
foo[foo_len] = '\0';
} else
strcpy(foo, "--");
} else if (S_ISDIR(st.st_mode)) {
- strncpy(foo, _("(dir)"), foo_len);
+ charcpy(foo, _("(dir)"), foo_len);
foo[foo_len] = '\0';
} else if (st.st_size < (1 << 10)) /* less than 1 k. */
sprintf(foo, "%4u B", (unsigned int)st.st_size);
strcpy(&newnode->data[extra], current->data + current_x);
#ifndef NANO_SMALL
if (ISSET(AUTOINDENT)) {
- strncpy(newnode->data, current->data, extra);
+ charcpy(newnode->data, current->data, extra);
totsize += mbstrlen(newnode->data);
}
#endif
#endif
void replace_abort(void);
#ifdef HAVE_REGEX_H
-int replace_regexp(char *string, bool create_flag);
+int replace_regexp(char *string, bool create);
#endif
char *replace_line(const char *needle);
ssize_t do_replace_loop(const char *needle, const filestruct
}
#ifdef HAVE_REGEX_H
-int replace_regexp(char *string, bool create_flag)
+int replace_regexp(char *string, bool create)
{
- /* Split personality here - if create_flag is FALSE, just calculate
- * the size of the replacement line (necessary because of
+ /* We have a split personality here. If create is FALSE, just
+ * calculate the size of the replacement line (necessary because of
* subexpressions \1 to \9 in the replaced text). */
const char *c = last_replace;
if (*c != '\\' || num < 1 || num > 9 ||
num > search_regexp.re_nsub) {
- if (create_flag)
+ if (create)
*string++ = *c;
c++;
new_size++;
/* But add the length of the subexpression to new_size. */
new_size += i;
- /* And if create_flag is TRUE, append the result of the
+ /* And if create is TRUE, append the result of the
* subexpression match to the new line. */
- if (create_flag) {
- strncpy(string, current->data + current_x +
+ if (create) {
+ charcpy(string, current->data + current_x +
regmatches[num].rm_so, i);
string += i;
}
}
}
- if (create_flag)
+ if (create)
*string = '\0';
return new_size;
#ifdef HAVE_REGEX_H
if (ISSET(USE_REGEXP)) {
search_match_count = regmatches[0].rm_eo - regmatches[0].rm_so;
- new_line_size = replace_regexp(NULL, 0);
+ new_line_size = replace_regexp(NULL, FALSE);
} else {
#endif
search_match_count = strlen(needle);
copy = charalloc(new_line_size);
/* The head of the original line. */
- strncpy(copy, current->data, current_x);
+ charcpy(copy, current->data, current_x);
/* The replacement text. */
#ifdef HAVE_REGEX_H
free(dest);
dest = charalloc(n);
- strncpy(dest, src, n);
+ charcpy(dest, src, n);
return dest;
}