General
- Added --disable-help option, affects acconfig.h, configure(.in),
winio.c:do_help, nano.c:help_init,help_text_init.
+ - Changed filename to no longer use PATH_MAX, so it can work on the
+ HURD. Changes in files.c:write_file(), new function
+ nano.c:clear_filename(), many changed in main(), a few other
+ places. Please test this!
- cut.c:
do_uncut_text()
- Fix renumbering bug when uncutting marked test at filebot.
- Change open call flags, basically copy joe's way of doing it so
a more recent version will actually be included in (un)stable.
- Remove useless fstat call.
- - Use MAX_PATH instead of static 132 for strncpy, at least until
- we no longer use MAX_PATH.
open_file()
- Added check for S_ISBLK and S_ISCHR, don't open device files!
- nano.c:
int write_file(char *name, int tmp)
{
long size, lineswritten = 0;
- char buf[PATH_MAX + 1];
+ static char *buf = NULL;
filestruct *fileptr;
int fd, mask = 0, realexists, anyexists;
struct stat st, lst;
if (realname != NULL)
free(realname);
+ if (buf != NULL)
+ free(buf);
+
#ifndef DISABLE_TABCOMP
realname = real_dir_from_tilde(name);
#else
}
/* Don't follow symlink. Create new file. */
else {
- if (strlen(realname) > (PATH_MAX - 7)) {
- statusbar(_("Could not open file: Path length exceeded."));
- return -1;
- }
-
- memset(buf, 0x00, PATH_MAX + 1);
- strcat(buf, realname);
+ buf = nmalloc(strlen(realname) + 8);
+ strncpy(buf, realname, strlen(realname)+1);
strcat(buf, ".XXXXXX");
if ((fd = mkstemp(buf)) == -1) {
if (ISSET(TEMP_OPT)) {
mask, realname, strerror(errno));
if (!tmp) {
- strncpy(filename, realname, PATH_MAX - 1);
+ filename = mallocstrcpy(filename, realname);
statusbar(_("Wrote %d lines"), lineswritten);
UNSET(MODIFIED);
titlebar();
WINDOW *edit; /* The file portion of the editor */
WINDOW *topwin; /* Top line of screen */
WINDOW *bottomwin; /* Bottom buffer */
-char filename[PATH_MAX]; /* Name of the file */
+char *filename = NULL; /* Name of the file */
int editwinrows = 0; /* How many rows long is the edit
window? */
filestruct *current; /* Current buffer pointer */
statusbar(_("Key illegal in VIEW mode"));
}
+void clear_filename(void)
+{
+ if (filename != NULL)
+ free(filename);
+ filename = nmalloc(1);
+ filename[0] = 0;
+}
/* Initialize global variables - no better way for now */
void global_init(void)
/* See if there's a non-option in argv (first non-option is the
filename, if +LINE is not given) */
if (argc == 1 || argc <= optind)
- strcpy(filename, "");
+ clear_filename();
else {
/* Look for the +line flag... */
if (argv[optind][0] == '+') {
startline = atoi(&argv[optind][1]);
optind++;
if (argc == 1 || argc <= optind)
- strcpy(filename, "");
+ clear_filename();
else
- strncpy(filename, argv[optind], 132);
- } else
- strncpy(filename, argv[optind], 132);
+ filename = mallocstrcpy(filename, argv[optind]);
+ } else
+ filename = mallocstrcpy(filename, argv[optind]);
}
extern int search_last_line;
extern WINDOW *edit, *topwin, *bottomwin;
-extern char filename[PATH_MAX];
+extern char *filename;
extern char *answer;
extern char *hblank, *help_text;
extern char *last_search;