Rid nano of PATH_MAX\!
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@409 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
b04a98dc86
commit
1a6e904583
|
@ -2,6 +2,10 @@ CVS code -
|
|||
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.
|
||||
|
@ -14,8 +18,6 @@ General
|
|||
- 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:
|
||||
|
|
16
files.c
16
files.c
|
@ -306,7 +306,7 @@ int do_insertfile(void)
|
|||
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;
|
||||
|
@ -322,6 +322,9 @@ int write_file(char *name, int tmp)
|
|||
if (realname != NULL)
|
||||
free(realname);
|
||||
|
||||
if (buf != NULL)
|
||||
free(buf);
|
||||
|
||||
#ifndef DISABLE_TABCOMP
|
||||
realname = real_dir_from_tilde(name);
|
||||
#else
|
||||
|
@ -365,13 +368,8 @@ int write_file(char *name, int tmp)
|
|||
}
|
||||
/* 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)) {
|
||||
|
@ -472,7 +470,7 @@ int write_file(char *name, int tmp)
|
|||
mask, realname, strerror(errno));
|
||||
|
||||
if (!tmp) {
|
||||
strncpy(filename, realname, PATH_MAX - 1);
|
||||
filename = mallocstrcpy(filename, realname);
|
||||
statusbar(_("Wrote %d lines"), lineswritten);
|
||||
UNSET(MODIFIED);
|
||||
titlebar();
|
||||
|
|
2
global.c
2
global.c
|
@ -39,7 +39,7 @@ int center_x = 0, center_y = 0; /* Center of screen */
|
|||
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 */
|
||||
|
|
17
nano.c
17
nano.c
|
@ -146,6 +146,13 @@ void print_view_warning(void)
|
|||
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)
|
||||
|
@ -2161,19 +2168,19 @@ int main(int argc, char *argv[])
|
|||
/* 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]);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue