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