[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nano-devel] nanothings.patch update
From: |
David Lawrence Ramsey |
Subject: |
[Nano-devel] nanothings.patch update |
Date: |
Sun, 3 Feb 2002 17:11:14 -0800 (PST) |
Changes from last time:
I've finally made M-], M-<, and M-> true meta-based
shortcuts instead of fake toggles, in the process undoing
my original hack to allow those fake toggles. I've also
made the -N option able to be toggled via M-N, and made
various cleanups. This was a major overhaul; I'm still
testing it, although it's working so far.
Sorry about the patch size; I'd normally put it online,
but due to time constraints, I have to just send it here.
_____________________________________________________________
Sluggy.Net: The Sluggy Freelance Community!
diff -urN nano-1.1.6-cvs/files.c nano-1.1.6-cvs-fixed/files.c
--- nano-1.1.6-cvs/files.c Fri Jan 4 12:57:40 2002
+++ nano-1.1.6-cvs-fixed/files.c Sun Feb 3 20:05:25 2002
@@ -141,8 +141,9 @@
strcpy(fileptr->data, buf);
#ifndef NANO_SMALL
- /* If it's a DOS file (CRLF), strip out the CR part*/
- if (buf[strlen(buf) - 1] == '\r') {
+ /* If it's a DOS file (CRLF), and file conversion isn't disabled,
+ strip out the CR part */
+ if (!ISSET(NO_CONVERT) && buf[strlen(buf) - 1] == '\r') {
fileptr->data[strlen(buf) - 1] = 0;
totsize--;
@@ -211,8 +212,9 @@
buf[0] = 0;
i = 0;
#ifndef NANO_SMALL
- /* If it's a Mac file (no LF just a CR), handle it! */
- } else if (i > 0 && buf[i-1] == '\r') {
+ /* If it's a Mac file (no LF just a CR), and file conversion
+ isn't disabled, handle it! */
+ } else if (!ISSET(NO_CONVERT) && i > 0 && buf[i-1] == '\r') {
fileformat = 2;
fileptr = read_line(buf, fileptr, &line1ins);
num_lines++;
@@ -770,6 +772,13 @@
return 0;
}
+/* This function is used by the shortcut list. */
+int open_prevfile_void(void)
+{
+ open_prevfile(0);
+ return 0;
+}
+
/*
* Open the next entry in the open_files structure. If closing_file is
* zero, update the current entry before switching from it. Otherwise, we
@@ -825,6 +834,13 @@
return 0;
}
+/* This function is used by the shortcut list. */
+int open_nextfile_void(void)
+{
+ open_nextfile(0);
+ return 0;
+}
+
/*
* Delete an entry from the open_files filestruct. After deletion of an
* entry, the next or previous entry is opened, whichever is found first.
@@ -852,9 +868,9 @@
display_main_list();
return 0;
}
-#endif
+#endif /* MULTIBUFFER */
-#if defined (ENABLE_MULTIBUFFER) || !defined (DISABLE_OPERATINGDIR)
+#if defined (ENABLE_MULTIBUFFER) || !defined (DISABLE_SPELLER) || !defined
(DISABLE_OPERATINGDIR)
/*
* When passed "[relative path]" or "[relative path][filename]" in
* origpath, return "[full path]" or "[full path][filename]" on success,
@@ -863,7 +879,7 @@
* yet on disk); it is not done if the relative path doesn't exist (since
* the first call to chdir() will fail then).
*/
-char *get_full_path(char *origpath)
+char *get_full_path(const char *origpath)
{
char *newpath = NULL, *last_slash, *d_here, *d_there, *d_there_file, tmp;
int path_only, last_slash_index;
@@ -1003,7 +1019,127 @@
return newpath;
}
-#endif /* ENABLE_MULTIBUFFER || !DISABLE_OPERATINGDIR */
+#endif /* ENABLE_MULTIBUFFER || !DISABLE_SPELLER || !DISABLE_OPERATINGDIR */
+
+#ifndef DISABLE_SPELLER
+/*
+ * This function accepts a path and a pointer to an integer, and returns
+ * the full path (via get_full_path()). It also sets the integer
+ * pointer's referenced value to 1 if the full path is writable, and 0
+ * otherwise. On error, it returns NULL, and sets the pointer's
+ * referenced value to 0.
+ */
+char *check_writable_directory(const char *path, int *writable) {
+
+ char *full_path = get_full_path(path);
+ struct stat fileinfo;
+
+ /* if get_full_path() failed, set *writable to 0 and return NULL */
+ if (!full_path) {
+ *writable = 0;
+ return NULL;
+ }
+ else {
+ /* otherwise, stat() the full path to see if it's writable by the
+ user; set *writable to 1 if it is, or 0 if it isn't */
+ stat(path, &fileinfo);
+ if (fileinfo.st_mode & S_IWUSR)
+ *writable = 1;
+ else
+ *writable = 0;
+ }
+
+ /* if the full path doesn't end in a slash (meaning get_full_path()
+ found that it isn't a directory) or isn't writable, return NULL */
+ if (full_path[strlen(full_path) - 1] != '/' || *writable == 0)
+ return NULL;
+
+ /* otherwise, return the full path */
+ return full_path;
+}
+
+/*
+ * This function accepts a directory name and filename prefix the same
+ * way that tempnam() does, determines the location for its temporary
+ * file the same way that tempnam() does, safely creates the temporary
+ * file there via mkstemp(), and returns the name of the temporary file
+ * the same way that tempnam() does.
+ */
+char *safe_tempnam(const char *dirname, const char *filename_prefix) {
+
+ char *buf, *tempdir = NULL, *full_tempdir = NULL;
+ int writable = 0, filedesc;
+
+ /* if $TMPDIR is set and non-empty, set tempdir to it, run it through
+ get_full_path(), and save the result in full_tempdir; otherwise,
+ leave full_tempdir set to to NULL */
+ if (getenv("TMPDIR") && strcmp(getenv("TMPDIR"),"")) {
+
+ /* store the value of $TMPDIR in tempdir, run its value through
+ get_full_path(), and save the result in full_tempdir */
+ tempdir = charalloc(strlen(getenv("TMPDIR")) + 1);
+ sprintf(tempdir, "%s", getenv("TMPDIR"));
+ full_tempdir = check_writable_directory(tempdir, &writable);
+
+ /* we don't need the value of tempdir anymore */
+ free(tempdir);
+ }
+
+ if (!full_tempdir) {
+
+ /* if $TMPDIR is blank or isn't set, or isn't a writable
+ directory, and dirname isn't NULL, try it; otherwise, leave
+ full_tempdir set to NULL */
+ if (dirname) {
+ tempdir = charalloc(strlen(dirname) + 1);
+ strcpy(tempdir, dirname);
+ full_tempdir = check_writable_directory(tempdir, &writable);
+
+ /* we don't need the value of tempdir anymore */
+ free(tempdir);
+ }
+ }
+
+ /* if $TMPDIR is blank or isn't set, or if it isn't a writable
+ directory, and dirname is NULL, try P_tmpdir instead */
+ if (!full_tempdir) {
+ tempdir = charalloc(strlen(P_tmpdir) + 1);
+ strcpy(tempdir, P_tmpdir);
+ full_tempdir = check_writable_directory(tempdir, &writable);
+
+ /* we don't need the value of tempdir anymore */
+ free(tempdir);
+ }
+
+ /* if P_tmpdir didn't work, use /tmp instead */
+ if (!full_tempdir) {
+ full_tempdir = charalloc(6);
+ strcpy(full_tempdir, "/tmp/");
+ }
+
+ buf = charalloc(strlen(full_tempdir) + 12);
+ sprintf(buf, "%s", full_tempdir);
+
+ /* like tempnam(), use only the first 5 bytes of the prefix */
+ snprintf(buf, 5, "%s", filename_prefix);
+
+ strcat(buf, "XXXXXX");
+ filedesc = mkstemp(buf);
+
+ /* if mkstemp() failed, get out */
+ if (filedesc == -1)
+ return NULL;
+
+ /* otherwise, close the resulting file; afterwards, it'll be 0 bytes
+ long, so delete it; finally, return the filename (all that's left
+ of it) */
+ else {
+ close(filedesc);
+ unlink(buf);
+ return buf;
+ }
+}
+#endif /* !DISABLE_SPELLER */
#ifndef DISABLE_OPERATINGDIR
/*
diff -urN nano-1.1.6-cvs/global.c nano-1.1.6-cvs-fixed/global.c
--- nano-1.1.6-cvs/global.c Wed Jan 9 19:50:38 2002
+++ nano-1.1.6-cvs-fixed/global.c Sun Feb 3 20:09:33 2002
@@ -136,13 +136,11 @@
#ifndef NANO_SMALL
/* Initialize the toggles in the same manner */
-void toggle_init_one(toggle * t, int val, char *desc, int flag,
- char override_ch)
+void toggle_init_one(toggle * t, int val, char *desc, int flag)
{
t->val = val;
t->desc = desc;
t->flag = flag;
- t->override_ch = override_ch;
}
#endif
@@ -152,17 +150,16 @@
char *toggle_const_msg, *toggle_autoindent_msg, *toggle_suspend_msg,
*toggle_nohelp_msg, *toggle_picomode_msg, *toggle_mouse_msg,
*toggle_cuttoend_msg, *toggle_wrap_msg, *toggle_case_msg,
- *toggle_backwards_msg, *toggle_dos_msg, *toggle_mac_msg,
- *toggle_smooth_msg;
-
-#ifdef ENABLE_MULTIBUFFER
- char *toggle_load_msg, *nano_openprev_msg, *nano_opennext_msg;
-#endif
+ *toggle_backwards_msg, *toggle_noconvert_msg, *toggle_dos_msg,
+ *toggle_mac_msg, *toggle_smooth_msg;
#ifdef HAVE_REGEX_H
char *toggle_regexp_msg;
#endif
+#ifdef ENABLE_MULTIBUFFER
+ char *toggle_load_msg;
+#endif
toggle_const_msg = _("Constant cursor position");
toggle_autoindent_msg = _("Auto indent");
@@ -173,62 +170,58 @@
toggle_cuttoend_msg = _("Cut to end");
toggle_backwards_msg = _("Backwards search");
toggle_case_msg = _("Case sensitive search");
- toggle_dos_msg = _("Writing file in DOS format");
- toggle_mac_msg = _("Writing file in Mac format");
- toggle_smooth_msg = _("Smooth scrolling");
#ifdef HAVE_REGEX_H
- toggle_regexp_msg = _("Regular expressions");
+ toggle_regexp_msg = _("Regular expression search");
#endif
+
+ toggle_noconvert_msg = _("No conversion from DOS/Mac format");
+ toggle_dos_msg = _("Writing file in DOS format");
+ toggle_mac_msg = _("Writing file in Mac format");
+ toggle_smooth_msg = _("Smooth scrolling");
toggle_wrap_msg = _("Auto wrap");
#ifdef ENABLE_MULTIBUFFER
toggle_load_msg = _("Multiple file buffers");
- nano_openprev_msg = _("Open previously loaded file");
- nano_opennext_msg = _("Open next loaded file");
#endif
toggle_init_one(&toggles[0], TOGGLE_CONST_KEY, toggle_const_msg,
- CONSTUPDATE, 0);
+ CONSTUPDATE);
toggle_init_one(&toggles[1], TOGGLE_AUTOINDENT_KEY,
- toggle_autoindent_msg, AUTOINDENT, 0);
+ toggle_autoindent_msg, AUTOINDENT);
toggle_init_one(&toggles[2], TOGGLE_SUSPEND_KEY, toggle_suspend_msg,
- SUSPEND, 0);
+ SUSPEND);
toggle_init_one(&toggles[3], TOGGLE_NOHELP_KEY, toggle_nohelp_msg,
- NO_HELP, 0);
+ NO_HELP);
toggle_init_one(&toggles[4], TOGGLE_PICOMODE_KEY, toggle_picomode_msg,
- PICO_MODE, 0);
+ PICO_MODE);
toggle_init_one(&toggles[5], TOGGLE_WRAP_KEY, toggle_wrap_msg,
- NO_WRAP, 0);
+ NO_WRAP);
toggle_init_one(&toggles[6], TOGGLE_MOUSE_KEY, toggle_mouse_msg,
- USE_MOUSE, 0);
+ USE_MOUSE);
toggle_init_one(&toggles[7], TOGGLE_CUTTOEND_KEY, toggle_cuttoend_msg,
- CUT_TO_END, 0);
+ CUT_TO_END);
toggle_init_one(&toggles[8], TOGGLE_BACKWARDS_KEY, toggle_backwards_msg,
- REVERSE_SEARCH, 0);
+ REVERSE_SEARCH);
toggle_init_one(&toggles[9], TOGGLE_CASE_KEY, toggle_case_msg,
- CASE_SENSITIVE, 0);
- toggle_init_one(&toggles[10], TOGGLE_DOS_KEY, toggle_dos_msg,
- DOS_FILE, 0);
- toggle_init_one(&toggles[11], TOGGLE_MAC_KEY, toggle_mac_msg,
- MAC_FILE, 0);
- toggle_init_one(&toggles[12], TOGGLE_SMOOTH_KEY, toggle_smooth_msg,
- SMOOTHSCROLL, 0);
-
-#ifdef ENABLE_MULTIBUFFER
- toggle_init_one(&toggles[13], TOGGLE_LOAD_KEY, toggle_load_msg,
- MULTIBUFFER, 0);
- toggle_init_one(&toggles[14], NANO_OPENPREV_KEY, nano_openprev_msg,
- 0, '<');
- toggle_init_one(&toggles[15], NANO_OPENNEXT_KEY, nano_opennext_msg,
- 0, '>');
-#endif
-
+ CASE_SENSITIVE);
#ifdef HAVE_REGEX_H
- toggle_init_one(&toggles[TOGGLE_LEN - 1], TOGGLE_REGEXP_KEY,
- toggle_regexp_msg, USE_REGEXP, 0);
+ toggle_init_one(&toggles[10], TOGGLE_REGEXP_KEY, toggle_regexp_msg,
+ USE_REGEXP);
#endif
+#ifdef ENABLE_MULTIBUFFER
+ toggle_init_one(&toggles[11], TOGGLE_LOAD_KEY, toggle_load_msg,
+ MULTIBUFFER);
#endif
+ toggle_init_one(&toggles[TOGGLE_LEN - 4], TOGGLE_NOCONVERT_KEY,
+ toggle_noconvert_msg, NO_CONVERT);
+ toggle_init_one(&toggles[TOGGLE_LEN - 3], TOGGLE_DOS_KEY,
+ toggle_dos_msg, DOS_FILE);
+ toggle_init_one(&toggles[TOGGLE_LEN - 2], TOGGLE_MAC_KEY,
+ toggle_mac_msg, MAC_FILE);
+ toggle_init_one(&toggles[TOGGLE_LEN - 1], TOGGLE_SMOOTH_KEY,
+ toggle_smooth_msg, SMOOTHSCROLL);
+#endif /* !NANO_SMALL */
}
void shortcut_init(int unjustify)
@@ -253,6 +246,9 @@
#ifdef HAVE_REGEX_H
char *nano_regexp_msg = "", *nano_bracket_msg = "";
#endif
+#ifdef ENABLE_MULTIBUFFER
+ char *nano_openprev_msg = "", *nano_opennext_msg = "";
+#endif
nano_help_msg = _("Invoke the help menu");
nano_writeout_msg = _("Write the current file to disk");
@@ -301,7 +297,11 @@
nano_regexp_msg = _("Use Regular expressions");
nano_bracket_msg = _("Find other bracket");
#endif
+#ifdef ENABLE_MULTIBUFFER
+ nano_openprev_msg = _("Open previously loaded file");
+ nano_opennext_msg = _("Open next loaded file");
#endif
+#endif /* !NANO_SMALL */
sc_init_one(&main_list[0], NANO_HELP_KEY, _("Get Help"),
nano_help_msg, 0, NANO_HELP_FKEY, 0, VIEW, do_help);
@@ -443,6 +443,14 @@
NANO_BRACKET_KEY, 0, 0, VIEW, do_find_bracket);
#endif
+#ifdef ENABLE_MULTIBUFFER
+ sc_init_one(&main_list[27], -9, _("Previous File"),
+ nano_openprev_msg,
+ NANO_OPENPREV_KEY, 0, 0, VIEW, open_prevfile_void);
+ sc_init_one(&main_list[28], -9, _("Next File"),
+ nano_opennext_msg,
+ NANO_OPENNEXT_KEY, 0, 0, VIEW, open_nextfile_void);
+#endif
sc_init_one(&whereis_list[0], NANO_HELP_KEY,
_("Get Help"), nano_help_msg, 0, 0, 0, VIEW, do_help);
@@ -474,7 +482,7 @@
sc_init_one(&whereis_list[REPLACE_LIST_LEN - 1], TOGGLE_REGEXP_KEY,
_("Regexp"), nano_regexp_msg, 0, 0, 0, VIEW, 0);
#endif
-#endif /* NANO_SMALL */
+#endif /* !NANO_SMALL */
sc_init_one(&replace_list[0], NANO_HELP_KEY,
@@ -507,7 +515,7 @@
sc_init_one(&replace_list[REPLACE_LIST_LEN - 1], TOGGLE_REGEXP_KEY,
_("Regexp"), nano_regexp_msg, 0, 0, 0, VIEW, 0);
#endif
-#endif /* NANO_SMALL */
+#endif /* !NANO_SMALL */
sc_init_one(&replace_list_2[0], NANO_HELP_KEY,
diff -urN nano-1.1.6-cvs/nano.c nano-1.1.6-cvs-fixed/nano.c
--- nano-1.1.6-cvs/nano.c Fri Jan 25 16:59:02 2002
+++ nano-1.1.6-cvs-fixed/nano.c Sun Feb 3 20:05:25 2002
@@ -428,10 +428,9 @@
printf
(_
(" -M --mac Write file in Mac format\n"));
-#endif
-#ifdef HAVE_REGEX_H
- printf(_
- (" -R --regexp Use regular expressions
for search\n"));
+ printf
+ (_
+ (" -N --noconvert Don't convert files from
DOS/Mac format\n"));
#endif
#ifndef NANO_SMALL
printf(_
@@ -1736,7 +1735,7 @@
char *temp;
int spell_res;
- if ((temp = tempnam(0, "nano.")) == NULL) {
+ if ((temp = safe_tempnam(0, "nano.")) == NULL) {
statusbar(_("Could not create a temporary filename: %s"),
strerror(errno));
return 0;
@@ -2414,7 +2413,7 @@
#ifndef DISABLE_HELP
void help_init(void)
{
- int i, sofar = 0, helplen;
+ int i, sofar = 0, meta_shortcut = 0, helplen;
long allocsize = 1; /* How much space we're gonna need for
the help text */
char buf[BUFSIZ] = "", *ptr = NULL;
@@ -2511,12 +2510,10 @@
for (i = 0; i <= TOGGLE_LEN - 1; i++)
if (toggles[i].desc != NULL)
allocsize += strlen(toggles[i].desc) + 30;
-
}
allocsize += strlen(ptr);
-
if (help_text != NULL)
free(help_text);
@@ -2529,34 +2526,52 @@
/* Now add our shortcut info */
for (i = 0; i <= helplen - 1; i++) {
if (currshortcut[i].val > 0 && currshortcut[i].val < 'a')
- sofar = snprintf(buf, BUFSIZ, "^%c ", currshortcut[i].val + 64);
- else
- sofar = snprintf(buf, BUFSIZ, " ");
+ sofar = snprintf(buf, BUFSIZ, "^%c ", currshortcut[i].val + 64);
+ else {
+ if (currshortcut[i].altval > 0) {
+ sofar = 0;
+ meta_shortcut = 1;
+ }
+ else
+ sofar = snprintf(buf, BUFSIZ, " ");
+ }
- if (currshortcut[i].misc1 > KEY_F0 && currshortcut[i].misc1 <=
KEY_F(64))
- sofar += snprintf(&buf[sofar], BUFSIZ - sofar, "(F%d) ",
- currshortcut[i].misc1 - KEY_F0);
- else
- sofar += snprintf(&buf[sofar], BUFSIZ - sofar, " ");
+ if (!meta_shortcut) {
+ if (currshortcut[i].misc1 > KEY_F0 && currshortcut[i].misc1 <=
KEY_F(64))
+ sofar += snprintf(&buf[sofar], BUFSIZ - sofar, "(F%d) ",
+ currshortcut[i].misc1 - KEY_F0);
+ else
+ sofar += snprintf(&buf[sofar], BUFSIZ - sofar, " ");
+ }
- if (currshortcut[i].altval > 0 && currshortcut[i].altval < 91)
- sofar += snprintf(&buf[sofar], BUFSIZ - sofar, "(M-%c) ",
- currshortcut[i].altval - 32);
+ if (currshortcut[i].altval > 0 && currshortcut[i].altval < 91 &&
(currshortcut[i].altval - 32) > 32)
+ sofar += snprintf(&buf[sofar], BUFSIZ - sofar,
+ (meta_shortcut ? "M-%c " : "(M-%c) "),
+ currshortcut[i].altval - 32);
else if (currshortcut[i].altval > 0)
- sofar += snprintf(&buf[sofar], BUFSIZ - sofar, "(M-%c) ",
- currshortcut[i].altval);
+ sofar += snprintf(&buf[sofar], BUFSIZ - sofar,
+ (meta_shortcut ? "M-%c " : "(M-%c) "),
+ currshortcut[i].altval);
/* Hack */
else if (currshortcut[i].val >= 'a')
- sofar += snprintf(&buf[sofar], BUFSIZ - sofar, "(M-%c) ",
- currshortcut[i].val - 32);
+ sofar += snprintf(&buf[sofar], BUFSIZ - sofar,
+ (meta_shortcut ? "M-%c " : "(M-%c) "),
+ currshortcut[i].val - 32);
else
- sofar += snprintf(&buf[sofar], BUFSIZ - sofar, " ");
+ sofar += snprintf(&buf[sofar], BUFSIZ - sofar,
+ (meta_shortcut ? " " : " "));
+ if (meta_shortcut) {
+ if (currshortcut[i].misc1 > KEY_F0 && currshortcut[i].misc1 <=
KEY_F(64))
+ sofar += snprintf(&buf[sofar], BUFSIZ - sofar, "(F%d) ",
+ currshortcut[i].misc1 - KEY_F0);
+ else
+ sofar += snprintf(&buf[sofar], BUFSIZ - sofar, " ");
+ }
if (currshortcut[i].help != NULL)
snprintf(&buf[sofar], BUFSIZ - sofar, "%s", currshortcut[i].help);
-
strcat(help_text, buf);
strcat(help_text, "\n");
}
@@ -2564,26 +2579,15 @@
/* And the toggles... */
if (currshortcut == main_list)
for (i = 0; i <= TOGGLE_LEN - 1; i++) {
- if (toggles[i].override_ch != 0)
- sofar = snprintf(buf, BUFSIZ,
- "M-%c ",
toggles[i].override_ch);
- else
sofar = snprintf(buf, BUFSIZ,
"M-%c ", toggles[i].val - 32);
-
if (toggles[i].desc != NULL) {
- if (toggles[i].flag != 0)
snprintf(&buf[sofar], BUFSIZ - sofar, _("%s
enable/disable"),
toggles[i].desc);
- else
- snprintf(&buf[sofar], BUFSIZ - sofar, "%s",
- toggles[i].desc);
}
-
strcat(help_text, buf);
strcat(help_text, "\n");
}
-
}
#endif
@@ -2715,6 +2719,7 @@
{"cut", 0, 0, 'k'},
{"dos", 0, 0, 'D'},
{"mac", 0, 0, 'M'},
+ {"noconvert", 0, 0, 'N'},
{"autoindent", 0, 0, 'i'},
#endif
{"tempfile", 0, 0, 't'},
@@ -2761,11 +2766,11 @@
#endif /* ENABLE_NANORC */
#ifdef HAVE_GETOPT_LONG
- while ((optchr = getopt_long(argc, argv,
"h?CDFKMRST:Vabcefgijklmo:pr:s:tvwxz",
+ while ((optchr = getopt_long(argc, argv,
"h?CDFKMNRST:Vabcefgijklmo:pr:s:tvwxz",
long_options, &option_index)) != EOF) {
#else
while ((optchr =
- getopt(argc, argv, "h?CDFKMRST:Vabcefgijklmo:pr:s:tvwxz")) != EOF) {
+ getopt(argc, argv, "h?CDFKMNRST:Vabcefgijklmo:pr:s:tvwxz")) != EOF)
{
#endif
switch (optchr) {
@@ -2790,14 +2795,10 @@
case 'M':
SET(MAC_FILE);
break;
-#endif
- case 'T':
- tabsize = atoi(optarg);
- if (tabsize <= 0) {
- usage(); /* To stop bogus data for tab width */
- finish(1);
- }
+ case 'N':
+ SET(NO_CONVERT);
break;
+#endif
#ifdef HAVE_REGEX_H
case 'R':
SET(USE_REGEXP);
@@ -2808,6 +2809,13 @@
SET(SMOOTHSCROLL);
break;
#endif
+ case 'T':
+ tabsize = atoi(optarg);
+ if (tabsize <= 0) {
+ usage(); /* To stop bogus data for tab width */
+ finish(1);
+ }
+ break;
case 'V':
version();
exit(0);
@@ -3178,6 +3186,7 @@
break;
}
break;
+
#ifdef ENABLE_MULTIBUFFER
case NANO_OPENPREV_KEY:
case NANO_OPENPREV_ALTKEY:
@@ -3190,6 +3199,14 @@
keyhandled = 1;
break;
#endif
+
+#if !defined (NANO_SMALL) && defined (HAVE_REGEX_H)
+ case NANO_BRACKET_KEY:
+ do_find_bracket();
+ keyhandled = 1;
+ break;
+#endif
+
default:
/* Check for the altkey defs.... */
for (i = 0; i <= MAIN_LIST_LEN - 1; i++)
diff -urN nano-1.1.6-cvs/nano.h nano-1.1.6-cvs-fixed/nano.h
--- nano-1.1.6-cvs/nano.h Fri Jan 25 16:59:02 2002
+++ nano-1.1.6-cvs-fixed/nano.h Sun Feb 3 20:05:25 2002
@@ -105,8 +105,6 @@
e.g. "Pico Messages"; we'll append Enabled or
Disabled */
int flag; /* What flag actually gets toggled */
- char override_ch; /* The character to display on the help screen,
- if it isn't NULL */
} toggle;
#ifdef ENABLE_NANORC
@@ -163,6 +161,7 @@
#define DISABLE_CURPOS (1<<24) /* Damn, we still need it */
#define ALT_KEYPAD (1<<25) /* Damn, we still need it */
#define RELATIVECHARS (1<<26)
+#define NO_CONVERT (1<<27)
/* Control key sequences, changing these would be very very bad */
@@ -306,18 +305,19 @@
#define TOGGLE_DOS_KEY NANO_ALT_D
#define TOGGLE_MAC_KEY NANO_ALT_O
#define TOGGLE_SMOOTH_KEY NANO_ALT_S
+#define TOGGLE_NOCONVERT_KEY NANO_ALT_N
/* Toggle stuff, these static lengths need to go away RSN */
#ifndef HAVE_REGEX_H
#define NO_REGEX 1
-#define SMALL_TOO 0
+#define NO_BRACKET_SEARCH 0
#else
#define NO_REGEX 0
#ifdef NANO_SMALL
-#define SMALL_TOO 1
+#define NO_BRACKET_SEARCH 1
#else
-#define SMALL_TOO 0
+#define NO_BRACKET_SEARCH 0
#endif /* NANO_SMALL */
#endif /* HAVE_REGEX_H */
@@ -337,26 +337,27 @@
#define NO_TOGGLES 0
#endif /* NANO_SMALL */
-#ifdef ENABLE_MULTIBUFFER
-#define MULTI_TOGGLES 3
+#ifndef ENABLE_MULTIBUFFER
+#define NO_MULTI 2
+#define NO_MULTI_TOGGLE 1
#else
-#define MULTI_TOGGLES 0
+#define NO_MULTI 0
+#define NO_MULTI_TOGGLE 0
#endif
#define WHEREIS_LIST_LEN (9 - NO_REGEX - NO_TOGGLES)
#define REPLACE_LIST_LEN (9 - NO_REGEX - NO_TOGGLES)
-#define TOGGLE_LEN (14 - NO_REGEX + MULTI_TOGGLES)
+#define TOGGLE_LEN (16 - NO_REGEX - NO_MULTI_TOGGLE)
#define WRITEFILE_LIST_LEN (4 - NO_BROWSER)
#define INSERTFILE_LIST_LEN (3 - NO_BROWSER)
#define BROWSER_LIST_LEN 5
-#define MAIN_LIST_LEN (27 - NO_REGEX - SMALL_TOO)
+#define MAIN_LIST_LEN (29 - NO_BRACKET_SEARCH - NO_MULTI)
#define MAIN_VISIBLE 12
#define REPLACE_LIST_2_LEN 4
#define GOTO_LIST_LEN 4
#define GOTODIR_LIST_LEN 2
#define HELP_LIST_LEN 3
#define SPELL_LIST_LEN 2
-
#define VIEW 1
#define NOVIEW 0
diff -urN nano-1.1.6-cvs/nanorc.sample nano-1.1.6-cvs-fixed/nanorc.sample
--- nano-1.1.6-cvs/nanorc.sample Fri Jan 25 22:34:06 2002
+++ nano-1.1.6-cvs-fixed/nanorc.sample Sun Feb 3 20:05:25 2002
@@ -55,6 +55,12 @@
# Use smooth scrolling as the default
# set smooth
+# Use alternate keypad routines
+# set keypad
+
+# Don't convert files from DOS/Mac format
+# set noconvert
+
# Allow multiple file buffers (using ^R inserts into separate buffer)
# You must have configured with --enable-multibuffer or --enable-extra for
# this to work
diff -urN nano-1.1.6-cvs/proto.h nano-1.1.6-cvs-fixed/proto.h
--- nano-1.1.6-cvs/proto.h Tue Jan 8 10:00:24 2002
+++ nano-1.1.6-cvs-fixed/proto.h Sun Feb 3 20:05:25 2002
@@ -194,7 +194,6 @@
void do_credits(void);
#endif
-
int do_writeout_void(void), do_exit(void), do_gotoline_void(void);
int do_insertfile_void(void), do_search(void);
@@ -214,12 +213,18 @@
#ifdef ENABLE_MULTIBUFFER
int open_file_dup_fix(int update);
int open_prevfile(int closing_file), open_nextfile(int closing_file);
+int open_prevfile_void(void), open_nextfile_void(void);
#endif
char *charalloc (size_t howmuch);
-#if defined (ENABLE_MULTIBUFFER) || !defined (ENABLE_OPERATINGDIR)
-char *get_full_path(char *origpath);
+#if defined (ENABLE_MULTIBUFFER) || !defined (DISABLE_SPELLER) || !defined
(DISABLE_OPERATINGDIR)
+char *get_full_path(const char *origpath);
+#endif
+
+#ifndef DISABLE_SPELLER
+char *check_writable_directory(const char *path, int *writable);
+char *safe_tempnam(const char *dirname, const char *filename_prefix);
#endif
#ifndef DISABLE_BROWSER
diff -urN nano-1.1.6-cvs/rcfile.c nano-1.1.6-cvs-fixed/rcfile.c
--- nano-1.1.6-cvs/rcfile.c Fri Jan 25 16:59:02 2002
+++ nano-1.1.6-cvs-fixed/rcfile.c Sun Feb 3 20:05:25 2002
@@ -40,11 +40,7 @@
#define _(string) (string)
#endif
-#ifndef DISABLE_WRAPJUSTIFY
-#define NUM_RCOPTS 20
-#else
-#define NUM_RCOPTS 19
-#endif
+#define NUM_RCOPTS 21
/* Static stuff for the nanorc file */
rcoption rcopts[NUM_RCOPTS] = {
@@ -57,11 +53,7 @@
{"operatingdir", 0},
{"pico", PICO_MODE},
{"tabsize", 0},
-
-#ifndef DISABLE_WRAPJUSTIFY
{"fill", 0},
-#endif
-
{"speller", 0},
{"tempfile", TEMP_OPT},
{"view", VIEW_MODE},
@@ -71,7 +63,8 @@
{"multibuffer", MULTIBUFFER},
{"smooth", SMOOTHSCROLL},
{"keypad", ALT_KEYPAD},
- {"relative", RELATIVECHARS}
+ {"relative", RELATIVECHARS},
+ {"noconvert", NO_CONVERT}
};
static int errors = 0;
diff -urN nano-1.1.6-cvs/winio.c nano-1.1.6-cvs-fixed/winio.c
--- nano-1.1.6-cvs/winio.c Fri Jan 25 16:59:02 2002
+++ nano-1.1.6-cvs-fixed/winio.c Sun Feb 3 20:05:25 2002
@@ -1902,6 +1902,7 @@
"Adam Rogoyski",
"Rob Siemborski",
"Rocco Corsi",
+ "David Lawrence Ramsey",
"Ken Tyler",
"Sven Guckes",
"Florian König",
@@ -1916,7 +1917,6 @@
"Joshua Jensen",
"Ryan Krebs",
"Albert Chin",
- "David Lawrence Ramsey",
"",
specialthx,
"Plattsburgh State University",