read_file()
- Remove apparently unneeded logic to handle a case where
current is NULL, since it shouldn't be NULL there. (DLR)
+ get_next_filename()
+ - Store the value of digits(ULONG_MAX) in a static, since it
+ doesn't change and hence doesn't need to be recalculated.
+ (DLR)
- nano.c:
do_verbatim_input()
- Move to text.c, since it's an advanced text-based operation.
* extension exists, we return "". */
char *get_next_filename(const char *name, const char *suffix)
{
+ static int ulmax_digits = -1;
unsigned long i = 0;
char *buf;
size_t namelen, suffixlen;
assert(name != NULL && suffix != NULL);
+ if (ulmax_digits == -1)
+ ulmax_digits = digits(ULONG_MAX);
+
namelen = strlen(name);
suffixlen = strlen(suffix);
- buf = charalloc(namelen + suffixlen + digits(ULONG_MAX) + 2);
+ buf = charalloc(namelen + suffixlen + ulmax_digits + 2);
sprintf(buf, "%s%s", name, suffix);
while (TRUE) {