CVS code -
- General:
- Translation updates (see po/ChangeLog for details).
+ - Change uncast nrealloc()s assigned to char pointers/arrays to
+ charealloc()s, and cast all other nrealloc()s and all
+ nmalloc()s. (David Benbennick and DLR)
+- utils.c:
+ align()
+ - Tweak to avoid a potential problem when strp is non-NULL but
+ *strp is NULL. (David Benbennick)
+- winio.c:
+ nanogetstr()
+ - Fix problem with search history where a temporary string
+ added at the bottom of the history (but which was not in the
+ history) would not be preserved after scrolling down to the
+ blank bottom entry and then scrolling back up. (DLR)
+- configure.ac:
+ - Change the program used to detect a broken regexec() function
+ so that it works properly, using information found at
+ http://sources.redhat.com/ml/libc-hacker/2001-06/msg00015.html.
+ (DLR)
+- nanorc.sample:
+ - Revised comment explaining the non-escaping of quotes to cover
+ non-escaping of all shell-interpreted characters. (DLR)
+ - Fixes to the descriptions and examples in the comments, and
+ changes to some default values. (David Benbennick and DLR)
+ - Add regexes for Perl syntax. (Richard Smith, tweaked for
+ greater efficiency by David Benbennick)
+ - Add regexes for Java source syntax. (David Benbennick)
+ Regex for C++-style comments (colored the same way as C-style
+ comments) added by DLR.
- THANKS:
- Added Laurentiu Buzdugan, for Romanian.
- Added Geir Helland, for Norwegian Bokmål.
+- TODO:
+ - Move the items for nano 1.2 to the "Old Requests" section,
+ and mark color syntax highlighting as done. (David Benbennick)
- nano.1, nanorc.5:
- Formatting improvements by Jean-Philippe Guérard.
TODO file (? means the feature may be implemented, but not definitely)
-----------------------------------------------------------------------------
-For version 1.2:
-- Single line scroll up/down? [DONE]
-- Color syntax highlighting? (certainly seems like there's a demand for it.)
-- .nanorc [DONE]
-- Backup making (filename~)? [DONE]
-- Search (etc.) string history [DONE]
-- Implement Pico's -j and -g flags, as they are pretty easy to do. [DONE]
-- Make mouse support work with clicking on the shortcuts (-m). Must
- make global variable pointing to current shortcut list to determine what
- keystroke to ungetch(). [DONE].
-- Implement -o (chroot of sorts) [DONE]
-- Allow -r to take a negative argument, meaning right margin instead of
- left (allows resizing that way), formerly -W arg. [DONE]
-
For version 1.4:
- UTF-8 support.
- Support for Pico's paragraph searching ability.
- Spell check selected text only.
- Make "To line" (^W^T) and "Read from Command" (^R^X) re-enter their
parent menu when their keystroke is entered a second time (^W^T^T and
- (^R^X^X)(requires figuring out when to keep cursor pos and when not to).
+ (^R^X^X)(requires figuring out when to keep cursor pos and when not
+ to).
- Fix resetstatuspos global which we shouldn't have.
Old requests:
+For version 1.2:
+- Single line scroll up/down? [DONE]
+- Color syntax highlighting? (certainly seems like there's a demand for
+ it.) [DONE]
+- .nanorc [DONE]
+- Backup making (filename~)? [DONE]
+- Search (etc.) string history [DONE]
+- Implement Pico's -j and -g flags, as they are pretty easy to do.
+ [DONE]
+- Make mouse support work with clicking on the shortcuts (-m). Must
+ make global variable pointing to current shortcut list to determine
+ what keystroke to ungetch(). [DONE].
+- Implement -o (chroot of sorts) [DONE]
+- Allow -r to take a negative argument, meaning right margin instead of
+ left (allows resizing that way), formerly -W arg. [DONE]
+
For version 1.0:
- Implement Spelling [DONE]
- Implement Help [DONE]
AC_TRY_RUN([
#include <sys/types.h>
#include <regex.h>
-int main() { regex_t reg; size_t n; regmatch_t r; regcomp(®, ".", 0); regexec(®, "", n, &r, 0); return 0; }],
+int main () { regex_t reg; size_t n = 1; regmatch_t r; regcomp(®, "\\<", 0); regexec(®, "", n, &r, 0); regfree(®); return 0; }],
AC_MSG_RESULT(no),
- AC_MSG_RESULT(yes); AC_DEFINE(BROKEN_REGEXEC, 1, [Define this if your regexec() function segfaults when passed an empty string.])
+ AC_MSG_RESULT(yes); AC_DEFINE(BROKEN_REGEXEC, 1, [Define this if your regexec() function segfaults when passed an empty string under certain conditions.])
)
)
size_t buf_len = strlen(cutbuffer->data);
size_t cur_len = strlen(current->data);
- current->data = nrealloc(current->data, cur_len + buf_len + 1);
+ current->data = charealloc(current->data, cur_len + buf_len + 1);
memmove(current->data + current_x + buf_len,
current->data + current_x, cur_len - current_x + 1);
strncpy(current->data + current_x, cutbuffer->data, buf_len);
decrease it at all. We do free it at the end, though. */
if (i >= bufx - 1) {
bufx += 128;
- buf = nrealloc(buf, bufx);
+ buf = charealloc(buf, bufx);
}
buf[i] = input;
buf[i + 1] = '\0';
/* Create a new openfilestruct node. */
openfilestruct *make_new_opennode(openfilestruct *prevnode)
{
- openfilestruct *newnode = nmalloc(sizeof(openfilestruct));
+ openfilestruct *newnode = (openfilestruct *)nmalloc(sizeof(openfilestruct));
newnode->filename = NULL;
newnode->fileage = NULL;
align(&d_here);
if (strcmp(d_here, "/")) {
- d_here = nrealloc(d_here, strlen(d_here) + 2);
+ d_here = charealloc(d_here, strlen(d_here) + 2);
strcat(d_here, "/");
}
if (path_only) {
tmp = d_there[strlen(d_there) - 1];
if (tmp != '/') {
- d_there = nrealloc(d_there, strlen(d_there) + 2);
+ d_there = charealloc(d_there, strlen(d_there) + 2);
strcat(d_there, "/");
- d_there_file = nrealloc(d_there_file, strlen(d_there_file) + 2);
+ d_there_file = charealloc(d_there_file, strlen(d_there_file) + 2);
strcat(d_there_file, "/");
}
}
/* add a slash to d_there, unless it's "/", in which
case we don't need it */
if (strcmp(d_there, "/")) {
- d_there = nrealloc(d_there, strlen(d_there) + 2);
+ d_there = charealloc(d_there, strlen(d_there) + 2);
strcat(d_there, "/");
}
}
strcpy(full_tempdir, "/tmp/");
}
- full_tempdir = nrealloc(full_tempdir, strlen(full_tempdir) + 12);
+ full_tempdir = charealloc(full_tempdir, strlen(full_tempdir) + 12);
/* like tempnam(), use only the first 5 characters of the prefix */
strncat(full_tempdir, filename_prefix, 5);
struct passwd *userdata;
*num_matches = 0;
- matches = nmalloc(BUFSIZ * sizeof(char *));
+ matches = (char **)nmalloc(BUFSIZ * sizeof(char *));
strcat(buf, "*");
DIR *dir;
struct dirent *next;
- matches = nmalloc(BUFSIZ * sizeof(char *));
+ matches = (char **)nmalloc(BUFSIZ * sizeof(char *));
/* Stick a wildcard onto the buf, for later use */
strcat(buf, "*");
/* Make a local copy of the string -- up to the position of the
cursor */
- matchbuf = (char *)nmalloc((strlen(buf) + 2) * sizeof(char));
- memset(matchbuf, '\0', (strlen(buf) + 2));
+ matchbuf = charalloc(strlen(buf) + 2);
+ memset(matchbuf, '\0', strlen(buf) + 2);
strncpy(matchbuf, buf, place);
tmp = matchbuf;
break;
case 1:
- buf = nrealloc(buf, strlen(buf) + strlen(matches[0]) + 1);
+ buf = charealloc(buf, strlen(buf) + strlen(matches[0]) + 1);
if (buf[0] != '\0' && strstr(buf, "/") != NULL) {
for (tmp = buf + strlen(buf); *tmp != '/' && tmp != buf;
(i == num_matches || matches[i] != 0)) {
/* All the matches have the same character at pos+1,
so paste it into buf... */
- buf = nrealloc(buf, strlen(buf) + 2);
+ buf = charealloc(buf, strlen(buf) + 2);
strncat(buf, matches[0] + pos, 1);
*newplace += 1;
pos++;
rewinddir(dir);
*longest += 10;
- filelist = nmalloc(*numents * sizeof (char *));
+ filelist = (char **)nmalloc(*numents * sizeof (char *));
if (!strcmp(path, "/"))
path = "";
if (homenv != NULL) {
- nanohist = nrealloc(nanohist, strlen(homenv) + 15);
+ nanohist = charealloc(nanohist, strlen(homenv) + 15);
sprintf(nanohist, "%s/.nano_history", homenv);
} else {
userage = getpwuid(geteuid());
endpwent();
- nanohist = nrealloc(nanohist, strlen(userage->pw_dir) + 15);
+ nanohist = charealloc(nanohist, strlen(userage->pw_dir) + 15);
sprintf(nanohist, "%s/.nano_history", userage->pw_dir);
}
return;
if (homenv != NULL) {
- nanohist = nrealloc(nanohist, strlen(homenv) + 15);
+ nanohist = charealloc(nanohist, strlen(homenv) + 15);
sprintf(nanohist, "%s/.nano_history", homenv);
} else {
userage = getpwuid(geteuid());
endpwent();
- nanohist = nrealloc(nanohist, strlen(userage->pw_dir) + 15);
+ nanohist = charealloc(nanohist, strlen(userage->pw_dir) + 15);
sprintf(nanohist, "%s/.nano_history", userage->pw_dir);
}
chmod(nanohist, S_IRUSR | S_IWUSR);
/* write oldest first */
for (h = search_history.tail ; h->prev ; h = h->prev) {
- h->data = nrealloc(h->data, strlen(h->data) + 2);
+ h->data = charealloc(h->data, strlen(h->data) + 2);
strcat(h->data, "\n");
if (fputs(h->data, hist) == EOF) {
rcfile_msg(_("Unable to write ~/.nano_history file, %s"), strerror(errno));
goto come_from;
}
for (h = replace_history.tail ; h->prev ; h = h->prev) {
- h->data = nrealloc(h->data, strlen(h->data) + 2);
+ h->data = charealloc(h->data, strlen(h->data) + 2);
strcat(h->data, "\n");
if (fputs(h->data, hist) == EOF) {
rcfile_msg(_("Unable to write ~/.nano_history file, %s"), strerror(errno));
shortcut *s;
if (*shortcutage == NULL) {
- *shortcutage = nmalloc(sizeof(shortcut));
+ *shortcutage = (shortcut *)nmalloc(sizeof(shortcut));
s = *shortcutage;
} else {
for (s = *shortcutage; s->next != NULL; s = s->next)
;
- s->next = nmalloc(sizeof(shortcut));
+ s->next = (shortcut *)nmalloc(sizeof(shortcut));
s = s->next;
}
toggle *u;
if (toggles == NULL) {
- toggles = nmalloc(sizeof(toggle));
+ toggles = (toggle *)nmalloc(sizeof(toggle));
u = toggles;
} else {
for (u = toggles; u->next != NULL; u = u->next)
;
- u->next = nmalloc(sizeof(toggle));
+ u->next = (toggle *)nmalloc(sizeof(toggle));
u = u->next;
}
}
/* more dangerousness fun =) */
- current->data = nrealloc(current->data, current_len + 2);
+ current->data = charealloc(current->data, current_len + 2);
assert(current_x <= current_len);
memmove(¤t->data[current_x + 1],
¤t->data[current_x],
mark_beginbuf = previous;
}
#endif
- previous->data = nrealloc(previous->data,
+ previous->data = charealloc(previous->data,
current_x + strlen(current->data) + 1);
strcpy(previous->data + current_x, current->data);
filestruct *foo;
- current->data = nrealloc(current->data,
+ current->data = charealloc(current->data,
strlen(current->data) +
strlen(current->next->data) + 1);
strcat(current->data, current->next->data);
while ((bytesread = read(uniq_fd[0], read_buff_ptr, pipe_buff_size)) > 0) {
read_buff_read += bytesread;
read_buff_size += pipe_buff_size;
- read_buff = read_buff_ptr = nrealloc(read_buff, read_buff_size);
+ read_buff = read_buff_ptr = charealloc(read_buff, read_buff_size);
read_buff_ptr += read_buff_read;
}
/* Set up an argument list to pass the execvp function */
if (spellargs == NULL) {
- spellargs = nmalloc(arglen * sizeof(char *));
+ spellargs = (char **)nmalloc(arglen * sizeof(char *));
spellargs[0] = strtok(alt_speller, " ");
while ((ptr = strtok(NULL, " ")) != NULL) {
arglen++;
- spellargs = nrealloc(spellargs, arglen * sizeof(char *));
+ spellargs = (char **)nrealloc(spellargs, arglen * sizeof(char *));
spellargs[arglen - 3] = ptr;
}
spellargs[arglen - 1] = NULL;
fill = 0;
#endif
- hblank = nrealloc(hblank, COLS + 1);
+ hblank = charealloc(hblank, COLS + 1);
memset(hblank, ' ', COLS);
hblank[COLS] = '\0';
## Sample initialization file for GNU nano
-## Please note that you must have configured nano with
-## --enable-nanorc for this file to be read!
+## Please note that you must have configured nano with --enable-nanorc
+## for this file to be read! Also note that characters specially
+## interpreted by the shell should not be escaped here.
##
## To make sure a value is not enabled, use "unset <option>"
+##
+## For the options that take parameters, the default value is given.
+## Other options are unset by default.
## Use auto-indentation
# set autoindent
## Backup files to filename~
# set backup
-## Constantly update the cursor position
+## Constantly display the cursor position in the status bar.
# set const
## Use cut to end of line with ^K by default
# set cut
-## Use this value instead of the default
-## An out-of-range negative value can make nano die complaining that the
-## screen is too small
-## set fill -8
+## Set the line length for wrapping text and justifying paragraphs.
+## If fill is negative, the line length will be the screen width less
+## this number.
+##
+# set fill -8
+
+## Enable ~/.nano_history for saving and reading search/replace strings.
+# set historylog
## Use alternate keypad routines
# set keypad
-## Allow multiple file buffers (using ^R inserts into separate buffer)
+## Allow multiple file buffers (using ^R inserts into separate buffer).
## You must have configured with --enable-multibuffer or --enable-extra
-## for this to work
+## for this to work.
##
## set multibuffer
## Don't wrap text at all
# set nowrap
-## Set operating directory (chroot of sorts)
-# set operatingdir "~"
+## Set operating directory. nano will not read or write files outside
+## this directory and its subdirectories. Also, the current directory
+## is changed to here, so files are inserted from this dir. A blank
+## string means the operating directory feature is turned off.
+##
+# set operatingdir ""
## Preserve the XON and XOFF keys (^Q and ^S)
# set preserve
-## The email-quote string. This is a "regular expression" if your
-## system supports them, otherwise a literal string. Default
-# set quotestr "^([ \t]*[|>:}#])+" if you have regexps, otherwise
-# set quotestr "> ".
+## The email-quote string, used to justify email-quoted paragraphs.
+## This is an extended regular expression if your system supports them,
+## otherwise a literal string. Default:
+# set quotestr "^([ ]*[\|>:}#])+"
+## if you have regexps, otherwise:
+# set quotestr "> "
## You can get old nano quoted-justify behavior via:
# set quotestr "(> )+"
-## Do regular expression searches by default
+## Do extended regular expression searches by default
# set regexp
## Use smooth scrolling as the default
# set smooth
-## Use this spelling checker instead of the default one
-# set speller aspell
+## Use this spelling checker instead of the internal one. This option
+## does not properly have a default value.
+##
+# set speller "aspell -c"
## Allow nano to be suspended with ^Z
# set suspend
## Use this tab size instead of the default; it must be greater than 0
-# set tabsize 4
+# set tabsize 8
## Save automatically on exit, don't prompt
# set tempfile
# set view
## Color setup
-## Format:
+## Format:
## syntax "short description" ["filename regex" ...]
## color foreground,background "regex" ["regex"...]
##
-## Legal colors are: white, black, red, blue, green, yellow, magenta,
-## cyan. You may use the prefix "bright" to mean a stronger color
-## highlight.
+## Legal colors: white, black, red, blue, green, yellow, magenta, cyan.
+## You may use the prefix "bright" to mean a stronger color highlight.
##
## To use multi-line regexes use the start="regex" end="regex" format.
##
## If your system supports transparency, not specifying a background
## color will use a transparent color. If you don't want this, be sure
## to set the background color to black or white.
-
-# syntax "c-file" ".*\.c$" ".*\.h$"
+##
+# syntax "c-file" "\.(c|h)$"
# color red "\<[A-Z_]{2,}\>"
-# color green "\<float\>" "\<char\>" "\<int\>" "\<void\>"
-# color green "\<static\>" "\<const\>" "\<struct\>"
-# color brightyellow "\<if\>" "\<while\>" "\<do\>" "\<else\>" "\<case\>" "\<switch\>"
-# color brightcyan "#define" "#include" "#ifn*def" "#endif"
-# color brightcyan "#elif" "#else" "#if"
-
+# color green "\<(float|char|int|void|static|const|struct)\>"
+# color brightyellow "\<(if|while|do|else|case|switch)\>"
+# color brightcyan "^#( )*(define|include|ifn?def|endif|elif|else|if)"
+##
## You will in general want your comments and strings to come last,
## because syntax highlighting rules will be applied in the order they
-## are read in. Note that quotes in regexes should not be escaped (use "
-## instead of \").
-
-# color brightyellow "<[^= ]*>" ""(\\.|[^\"])*""
-
+## are read in.
+##
+# color brightyellow "<[^= ]*>" ""(\\.|[^\"])*""
+##
## This string is VERY resource intensive!!!
# color brightyellow start=""(\\.|[^\"])*\\( | )*$" end="^(\\.|[^\"])*""
-
+##
## And we want to have some nice comment highlighting too
# color brightblue "//.*"
# color brightblue start="/\*" end="\*/"
-
-## Here are some short examples for TeX files and HTML
+## Here is a short example for HTML
# syntax "HTML" "\.html$"
-#
# color blue start="<" end=">"
-# color red "&([^; ])*;"
-#
+# color red "&[^; ]*;"
+
+## Here is a short example for TeX files
# syntax "TeX" "\.tex$"
-#
-# color green "\\(.|([A-Za-z]*))"
-# color magenta "\{" "\}"
+# color green "\\.|\\[A-Za-z]*"
+# color magenta "[{}]"
# color blue "%.*"
-
-## For this you will probably want to set your editor to "nano -Y mutt"
+## Here is an example for quoted emails (under e.g. mutt)
# syntax "mutt"
# color green "^>.*"
-
-## Here is are examples for groff and for your .nanorc
-
-#syntax "groff" "\.ms$" "\.mm$" "\.me$" "\.tmac$" "^tmac." ".rof"
+## Here is an example for groff
+##
+# syntax "groff" "\.ms$" "\.mm$" "\.me$" "\.tmac$" "^tmac." ".rof"
## The argument of .nr or .ds
-#color cyan "^\.ds [^ ]*"
-#color cyan "^\.nr [^ ]*"
+# color cyan "^\.ds [^ ]*"
+# color cyan "^\.nr [^ ]*"
## Single character escapes
-#color brightmagenta "\\."
-## Highlight the argument of \f or \s in the same colour
-#color brightmagenta "\\f."
-#color brightmagenta "\\f\(.."
-#color brightmagenta "\\s(\+|\-)?[0-9]"
+# color brightmagenta "\\."
+## Highlight the argument of \f or \s in the same color
+# color brightmagenta "\\f."
+# color brightmagenta "\\f\(.."
+# color brightmagenta "\\s(\+|\-)?[0-9]"
## \n
-#color cyan "(\\|\\\\)n."
-#color cyan "(\\|\\\\)n\(.."
-#color cyan start="(\\|\\\\)n\[" end="]"
+# color cyan "(\\|\\\\)n."
+# color cyan "(\\|\\\\)n\(.."
+# color cyan start="(\\|\\\\)n\[" end="]"
## Requests
-#color brightgreen "^\. *[^ ]*"
+# color brightgreen "^\. *[^ ]*"
## Comments
-#color yellow "^\.\\\".*$"
+# color yellow "^\.\\\".*$"
## Strings
-#color green "(\\|\\\\)\*."
-#color green "(\\|\\\\)\*\(.."
-#color green start="(\\|\\\\)\*\[" end="]"
+# color green "(\\|\\\\)\*."
+# color green "(\\|\\\\)\*\(.."
+# color green start="(\\|\\\\)\*\[" end="]"
## Characters
-#color brightred "\\\(.."
-#color brightred start="\\\[" end="]"
+# color brightred "\\\(.."
+# color brightred start="\\\[" end="]"
## Macro arguments
-#color brightcyan "\\\\\$[1-9]"
-
-
-#syntax "nanorc" "[\.]*nanorc$"
-#color white "^ *(set|unset).*$"
-#color cyan "^ *(set|unset) (autoindent|backup|const|cut|fill|keypad|multibuffer|noconvert|nofollow|nohelp|nowrap|operatingdir|preserve|quotestr|regexp|smooth|speller|suspend|tabsize|tempfile|historylog|view)"
-#color brightwhite "^ *syntax [^ ]*"
-#color brightblue "^ *set\>" "^ *unset\>" "^ *syntax\>"
-#color white "^ *color\>.*"
-#color yellow "^ *color (bright)?(white|black|red|blue|green|yellow|magenta|cyan)\>"
-#color magenta "^ *color\>"
-#color green "^#.*$"
+# color brightcyan "\\\\\$[1-9]"
+
+## Here is an example for perl
+##
+# syntax "perl" "\.p[lm]$"
+# color red "\<(accept|alarm|atan2|bin(d|mode)|c(aller|h(dir|mod|op|own|root)|lose(dir)?|onnect|os|rypt)|d(bm(close|open)|efined|elete|ie|o|ump)|e(ach|of|val|x(ec|ists|it|p))|f(cntl|ileno|lock|ork)|get(c|login|peername|pgrp|ppid|priority|pwnam|(host|net|proto|serv)byname|pwuid|grgid|(host|net)byaddr|protobynumber|servbyport)|([gs]et|end)(pw|gr|host|net|proto|serv)ent|getsock(name|opt)|gmtime|goto|grep|hex|index|int|ioctl|join|keys|kill|last|length|link|listen|local(time)?|log|lstat|m|mkdir|msg(ctl|get|snd|rcv)|next|oct|open(dir)?|ord|pack|pipe|pop|printf?|push|q|qq|qx|rand|re(ad(dir|link)?|cv|do|name|quire|set|turn|verse|winddir)|rindex|rmdir|s|scalar|seek|seekdir|se(lect|mctl|mget|mop|nd|tpgrp|tpriority|tsockopt)|shift|shm(ctl|get|read|write)|shutdown|sin|sleep|socket(pair)?|sort|spli(ce|t)|sprintf|sqrt|srand|stat|study|substr|symlink|sys(call|read|tem|write)|tell(dir)?|time|tr|y|truncate|umask|un(def|link|pack|shift)|utime|values|vec|wait(pid)?|wantarray|warn|write)\>"
+# color magenta "\<(continue|else|elsif|do|for|foreach|if|unless|until|while|eq|ne|lt|gt|le|ge|cmp|x|my|sub|use|package|can|isa)\>"
+# color cyan start="[$@%]" end="( |\\W|-)"
+# color yellow "".*"|qq\|.*\|"
+# color white "[sm]/.*/"
+# color white start="(^use| = new)" end=";"
+# color green "#.*"
+# color yellow start="<< 'STOP'" end="STOP"
+
+## Here is an example for Java source
+##
+# syntax "Java source" "\.java$"
+# color green "\<(boolean|byte|char|double|float|int|long|new|short|this|transient|void)\>"
+# color red "\<(break|case|catch|continue|default|do|else|finally|for|if|return|switch|throw|try|while)\>"
+# color cyan "\<(abstract|class|extends|final|implements|import|instanceof|interface|native|package|private|protected|public|static|strictfp|super|synchronized|throws|volatile)\>"
+# color red ""[^\"]*""
+# color yellow "\<(true|false|null)\>"
+# color blue "//.*"
+# color blue start="/\*" end="\*/"
+# color brightblue start="/\*\*" end="\*/"
+# color brightgreen,brightgreen "[ ]+$"
+
+## Here is an example for your .nanorc
+##
+# syntax "nanorc" "[\.]*nanorc$"
+# color white "^ *(set|unset).*$"
+# color cyan "^ *(set|unset) (autoindent|backup|const|cut|fill|keypad|multibuffer|noconvert|nofollow|nohelp|nowrap|operatingdir|preserve|quotestr|regexp|smooth|speller|suspend|tabsize|tempfile|historylog|view)"
+# color brightwhite "^ *syntax [^ ]*"
+# color brightblue "^ *set\>" "^ *unset\>" "^ *syntax\>"
+# color white "^ *color\>.*"
+# color yellow "^ *color (bright)?(white|black|red|blue|green|yellow|magenta|cyan)\>"
+# color magenta "^ *color\>"
+# color green "^#.*$"
/* Rely on $HOME, fall back on getpwuid() */
if (homenv != NULL) {
- nanorc = nrealloc(nanorc, strlen(homenv) + 10);
+ nanorc = charealloc(nanorc, strlen(homenv) + 10);
sprintf(nanorc, "%s/.nanorc", homenv);
} else {
userage = getpwuid(euid);
rcfile_error(_("I can't find my home directory! Wah!"));
SET(NO_RCFILE);
} else {
- nanorc = nrealloc(nanorc, strlen(userage->pw_dir) + 9);
+ nanorc = charealloc(nanorc, strlen(userage->pw_dir) + 9);
sprintf(nanorc, "%s/.nanorc", userage->pw_dir);
}
{
historytype *a;
- a = nmalloc(sizeof(historytype));
+ a = (historytype *)nmalloc(sizeof(historytype));
a->next = h->next;
a->prev = h->next->prev;
h->next->prev = a;
/* Fix the memory allocation for a string. */
void align(char **strp)
{
- if (strp != NULL)
- *strp = nrealloc(*strp, strlen(*strp) + 1);
+ assert(strp != NULL);
+ if (*strp != NULL)
+ *strp = charealloc(*strp, strlen(*strp) + 1);
}
/* Null a string at a certain index and align it. */
/* Append a new magic-line to filebot. */
void new_magicline(void)
{
- filebot->next = nmalloc(sizeof(filestruct));
+ filebot->next = (filestruct *)nmalloc(sizeof(filestruct));
filebot->next->data = charalloc(1);
filebot->next->data[0] = '\0';
filebot->next->prev = filebot;
char *history = NULL;
char *currentbuf = NULL;
char *complete = NULL;
- int last_kbinput = 0, ret2cb = 0;
+ int last_kbinput = 0;
+
+ /* This variable is used in the search history code. use_cb == 0
+ means that we're using the existing history and ignoring
+ currentbuf. use_cb == 1 means that the entry in answer should be
+ moved to currentbuf or restored from currentbuf to answer.
+ use_cb == 2 means that the entry in currentbuf should be moved to
+ answer or restored from answer to currentbuf. */
+ int use_cb = 0;
#endif
xend = strlen(def);
do_upkey:
if (history_list != NULL) {
- /* If there's no previous temp holder, or if we already
- arrowed back down to it and (possibly edited it),
- update the holder */
- if (currentbuf == NULL || (ret2cb == 1 && strcmp(currentbuf, answer))) {
+ /* if currentbuf is NULL, or if use_cb is 1, currentbuf
+ isn't NULL, and currentbuf is different from answer,
+ it means that we're scrolling up at the top of the
+ search history, and we need to save the current
+ answer in currentbuf; do this and reset use_cb to
+ 0 */
+ if (currentbuf == NULL || (use_cb == 1 && strcmp(currentbuf, answer))) {
currentbuf = mallocstrcpy(currentbuf, answer);
- ret2cb = 0;
+ use_cb = 0;
}
- /* get older search from the history list */
- if ((history = get_history_older(history_list)) != NULL) {
+ /* if currentbuf isn't NULL, use_cb is 2, and currentbuf
+ is different from answer, it means that we're
+ scrolling up at the bottom of the search history, and
+ we need to make the string in currentbuf the current
+ answer; do this, blow away currentbuf since we don't
+ need it anymore, and reset use_cb to 0 */
+ if (currentbuf != NULL && use_cb == 2 && strcmp(currentbuf, answer)) {
+ answer = mallocstrcpy(answer, currentbuf);
+ free(currentbuf);
+ currentbuf = NULL;
+ xend = strlen(answer);
+ use_cb = 0;
+
+ /* else get older search from the history list and save
+ it in answer; if there is no older search, blank out
+ answer */
+ } else if ((history = get_history_older(history_list)) != NULL) {
answer = mallocstrcpy(answer, history);
xend = strlen(history);
} else {
#ifndef NANO_SMALL
do_downkey:
if (history_list != NULL) {
- /* get newer search from the history list */
+
+ /* get newer search from the history list and save it
+ in answer */
if ((history = get_history_newer(history_list)) != NULL) {
answer = mallocstrcpy(answer, history);
xend = strlen(history);
- /* else if we ran out of history, regurgitate the temporary
- buffer and blow away currentbuf */
- } else if (currentbuf != NULL) {
+ /* if there is no newer search, we're here */
+
+ /* if currentbuf isn't NULL and use_cb isn't 2, it means
+ that we're scrolling down at the bottom of the search
+ history and we need to make the string in currentbuf
+ the current answer; do this, blow away currentbuf
+ since we don't need it anymore, and set use_cb to
+ 1 */
+ } else if (currentbuf != NULL && use_cb != 2) {
answer = mallocstrcpy(answer, currentbuf);
free(currentbuf);
currentbuf = NULL;
xend = strlen(answer);
- ret2cb = 1;
- } else {
+ use_cb = 1;
+
+ /* otherwise, if currentbuf is NULL and use_cb isn't 2,
+ it means that we're scrolling down at the bottom of
+ the search history and the current answer needs to be
+ saved in currentbuf; do this, blank out answer, and
+ set use_cb to 2 */
+ } else if (use_cb != 2) {
+ currentbuf = mallocstrcpy(currentbuf, answer);
answer = mallocstrcpy(answer, "");
xend = 0;
+ use_cb = 2;
}
x = xend;
}
default:
if (kbinput < 32)
break;
- answer = nrealloc(answer, xend + 2);
+ answer = charealloc(answer, xend + 2);
memmove(answer + x + 1, answer + x, xend - x + 1);
xend++;
answer[x] = kbinput;