David Benbennick's minor fixes, plus one of mine
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1275 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
605165e292
commit
e21adfa181
30
ChangeLog
30
ChangeLog
|
@ -15,6 +15,15 @@ CVS code -
|
|||
some functions around to put similar functions closer
|
||||
together (for this, rename clear_bottombars() to
|
||||
blank_bottombars()). (DLR; suggested by David Benbennick)
|
||||
- More changes of char *'s to const char *'s when possible.
|
||||
(David Benbennick)
|
||||
- Fix various minor memory leaks in files.c. (David Benbennick)
|
||||
- Fix minor problems with the operating directory code: set the
|
||||
operating directory properly if it's specified only in a
|
||||
nanorc file, and handle an operating directory of "/"
|
||||
properly. New function init_operating_dir() to handle
|
||||
setting it both on the command line and in the nanorc file.
|
||||
(David Benbennick)
|
||||
- configure.ac:
|
||||
- Added pt_BR to ALL_LINGUAS (Jordi).
|
||||
- Changed --enable-color warning to be slightly less severe.
|
||||
|
@ -28,10 +37,9 @@ CVS code -
|
|||
- Disallow multibuffer toggling at the "Insert File" prompt if
|
||||
we're in both view and multibuffer mode, so as to keep proper
|
||||
integration between the two, and make sure the toggle
|
||||
actually works all the time otherwise. Also, use
|
||||
NANO_LOAD_KEY as an alias for TOGGLE_LOAD_KEY, so
|
||||
--enable-tiny and --enable-multibuffer can be used together
|
||||
again. (DLR)
|
||||
actually works all the time otherwise. Also, make sure
|
||||
TOGGLE_LOAD_KEY isn't referenced when NANO_SMALL and
|
||||
ENABLE_MULTIBUFFER are both defined. (DLR)
|
||||
open_prevfile_void(), open_nextfile_void()
|
||||
- Return the return values of open_prevfile() and
|
||||
open_nextfile(), respectively, instead of (incorrectly)
|
||||
|
@ -45,9 +53,9 @@ CVS code -
|
|||
username and the string already contains data. (DLR)
|
||||
- global.c:
|
||||
shortcut_init()
|
||||
- Use NANO_LOAD_KEY as an alias for TOGGLE_LOAD_KEY, so
|
||||
--enable-tiny and --enable-multibuffer can be used together
|
||||
again. (DLR)
|
||||
- Disable the new multibuffer toggle at the file insertion
|
||||
prompt when NANO_SMALL and ENABLE_MULTIBUFFER are both
|
||||
defined. (DLR)
|
||||
thanks_for_all_the_fish()
|
||||
- Make sure the reference to help_text is #ifdefed out when
|
||||
--disable-help is used. (DLR)
|
||||
|
@ -92,7 +100,9 @@ CVS code -
|
|||
Benbennick)
|
||||
do_justify()
|
||||
- Fix cosmetic problems caused when justifying on the
|
||||
magicline. (David Benbennick)
|
||||
magicline, and a minor problem where the cursor would
|
||||
sometimes be moved to the wrong line after justification.
|
||||
(David Benbennick)
|
||||
main()
|
||||
- When searching through the main shortcut list looking for a
|
||||
shortcut key, stop searching after finding one; this avoids a
|
||||
|
@ -104,6 +114,10 @@ CVS code -
|
|||
- nanorc.sample:
|
||||
- Fix the c-file regex for all caps words to be extended regex
|
||||
format ({} instead of \{\}) (found by DLR).
|
||||
- utils.c:
|
||||
charalloc()
|
||||
- Switch from using calloc() to using malloc(). (David
|
||||
Benbennick)
|
||||
- faq.html:
|
||||
- Typo fix. (DLR)
|
||||
- TODO:
|
||||
|
|
12
global.c
12
global.c
|
@ -153,10 +153,10 @@ regex_t syntaxfile_regexp; /* Global to store compiled search regexp */
|
|||
regmatch_t synfilematches[1]; /* Match positions for parenthetical */
|
||||
#endif /* ENABLE_COLOR */
|
||||
|
||||
|
||||
int length_of_list(const shortcut *s)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
for (; s != NULL; s = s->next)
|
||||
i++;
|
||||
return i;
|
||||
|
@ -304,7 +304,7 @@ void free_shortcutage(shortcut **shortcutage)
|
|||
void shortcut_init(int unjustify)
|
||||
{
|
||||
#ifndef DISABLE_HELP
|
||||
char *nano_help_msg = "", *nano_writeout_msg = "", *nano_exit_msg =
|
||||
const char *nano_help_msg = "", *nano_writeout_msg = "", *nano_exit_msg =
|
||||
"", *nano_goto_msg = "", *nano_justify_msg =
|
||||
"", *nano_replace_msg = "", *nano_insert_msg =
|
||||
"", *nano_whereis_msg = "", *nano_prevpage_msg =
|
||||
|
@ -325,11 +325,11 @@ void shortcut_init(int unjustify)
|
|||
"", *nano_backup_msg = "";
|
||||
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
char *nano_openprev_msg = "", *nano_opennext_msg =
|
||||
const char *nano_openprev_msg = "", *nano_opennext_msg =
|
||||
"", *nano_multibuffer_msg = "";
|
||||
#endif
|
||||
#ifdef HAVE_REGEX_H
|
||||
char *nano_regexp_msg = "", *nano_bracket_msg = "";
|
||||
const char *nano_regexp_msg = "", *nano_bracket_msg = "";
|
||||
#endif
|
||||
|
||||
nano_help_msg = _("Invoke the help menu");
|
||||
|
@ -725,10 +725,10 @@ void shortcut_init(int unjustify)
|
|||
#ifndef NANO_SMALL
|
||||
sc_init_one(&insertfile_list, NANO_EXTCMD_KEY, _("Execute Command"),
|
||||
IFHELP(nano_execute_msg, 0), 0, 0, NOVIEW, 0);
|
||||
#endif
|
||||
#ifdef ENABLE_MULTIBUFFER
|
||||
sc_init_one(&insertfile_list, NANO_LOAD_KEY, _("New Buffer"),
|
||||
sc_init_one(&insertfile_list, TOGGLE_LOAD_KEY, _("New Buffer"),
|
||||
IFHELP(nano_multibuffer_msg, 0), 0, 0, NOVIEW, 0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
free_shortcutage(&spell_list);
|
||||
|
|
57
nano.c
57
nano.c
|
@ -2177,7 +2177,7 @@ int do_justify(void)
|
|||
* 2) the line above it is not part of a paragraph, or
|
||||
* 3) the line above it does not have precisely the same quote
|
||||
* part, or
|
||||
* 4) the indentation of this line is not a subset of the
|
||||
* 4) the indentation of this line is not an initial substring of the
|
||||
* indentation of the previous line, or
|
||||
* 5) this line has no quote part and some indentation, and
|
||||
* AUTOINDENT is not set.
|
||||
|
@ -2250,29 +2250,28 @@ int do_justify(void)
|
|||
current_x = 0;
|
||||
if (current->data[quote_len + indent_len] != '\0') {
|
||||
/* This line is part of a paragraph. So we must search back to
|
||||
* the first line of this paragraph. */
|
||||
if (quote_len > 0 || indent_len == 0
|
||||
#ifndef NANO_SMALL
|
||||
|| ISSET(AUTOINDENT)
|
||||
#endif
|
||||
) {
|
||||
/* We don't justify indented paragraphs unless AUTOINDENT is
|
||||
* turned on. See 5) above. */
|
||||
while (current->prev && quotes_match(current->data,
|
||||
* the first line of this paragraph. First we check items 1) and
|
||||
* 3) above. */
|
||||
while (current->prev && quotes_match(current->data,
|
||||
quote_len, IFREG(current->prev->data, &qreg))) {
|
||||
/* indentation length of the previous line */
|
||||
size_t temp_id_len =
|
||||
size_t temp_id_len =
|
||||
indent_length(current->prev->data + quote_len);
|
||||
/* The indentation length of the previous line. */
|
||||
|
||||
if (!indents_match(current->prev->data + quote_len,
|
||||
temp_id_len, current->data + quote_len,
|
||||
indent_len) ||
|
||||
current->prev->data[quote_len + temp_id_len] == '\0')
|
||||
break;
|
||||
indent_len = temp_id_len;
|
||||
current = current->prev;
|
||||
current_y--;
|
||||
}
|
||||
/* Is this line the beginning of a paragraph, according to
|
||||
items 2), 5), or 4) above? If so, stop. */
|
||||
if (current->prev->data[quote_len + temp_id_len] == '\0' ||
|
||||
(quote_len == 0 && indent_len > 0
|
||||
#ifndef NANO_SMALL
|
||||
&& !ISSET(AUTOINDENT)
|
||||
#endif
|
||||
) ||
|
||||
!indents_match(current->prev->data + quote_len,
|
||||
temp_id_len, current->data + quote_len, indent_len))
|
||||
break;
|
||||
indent_len = temp_id_len;
|
||||
current = current->prev;
|
||||
current_y--;
|
||||
}
|
||||
} else {
|
||||
/* This line is not part of a paragraph. Move down until we get
|
||||
|
@ -2646,15 +2645,13 @@ void signal_init(void)
|
|||
#endif /* _POSIX_VDISABLE */
|
||||
|
||||
if (!ISSET(SUSPEND)) {
|
||||
|
||||
/* Insane! */
|
||||
/* Insane! */
|
||||
#ifdef _POSIX_VDISABLE
|
||||
term.c_cc[VSUSP] = _POSIX_VDISABLE;
|
||||
#else
|
||||
act.sa_handler = SIG_IGN;
|
||||
sigaction(SIGTSTP, &act, NULL);
|
||||
#endif
|
||||
|
||||
} else {
|
||||
/* If we don't do this, it seems other stuff interrupts the
|
||||
suspend handler! Try using nano with mutt without this
|
||||
|
@ -3091,12 +3088,6 @@ int main(int argc, char *argv[])
|
|||
#ifndef DISABLE_OPERATINGDIR
|
||||
case 'o':
|
||||
operating_dir = mallocstrcpy(operating_dir, optarg);
|
||||
|
||||
/* make sure we're inside the operating directory */
|
||||
if (check_operating_dir(".", 0) && chdir(operating_dir) == -1) {
|
||||
free(operating_dir);
|
||||
operating_dir = NULL;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case 'p':
|
||||
|
@ -3150,6 +3141,12 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
/* Set up the operating directory. This entails chdir()ing there, so
|
||||
that file reads and writes will be based there. */
|
||||
init_operating_dir();
|
||||
#endif
|
||||
|
||||
/* Clear the filename we'll be using */
|
||||
filename = charalloc(1);
|
||||
filename[0] = '\0';
|
||||
|
|
3
nano.h
3
nano.h
|
@ -137,7 +137,7 @@ typedef struct toggle {
|
|||
|
||||
#ifdef ENABLE_NANORC
|
||||
typedef struct rcoption {
|
||||
char *name;
|
||||
const char *name;
|
||||
int flag;
|
||||
} rcoption;
|
||||
#endif /* ENABLE_NANORC */
|
||||
|
@ -326,7 +326,6 @@ know what you're doing */
|
|||
#define NANO_TOFILES_KEY NANO_CONTROL_T
|
||||
#define NANO_APPEND_KEY NANO_ALT_A
|
||||
#define NANO_PREPEND_KEY NANO_ALT_P
|
||||
#define NANO_LOAD_KEY NANO_ALT_F
|
||||
#define NANO_OPENPREV_KEY NANO_ALT_LCARAT
|
||||
#define NANO_OPENNEXT_KEY NANO_ALT_RCARAT
|
||||
#define NANO_OPENPREV_ALTKEY NANO_ALT_COMMA
|
||||
|
|
22
proto.h
22
proto.h
|
@ -126,7 +126,6 @@ int do_uncut_text(void);
|
|||
void load_file(int update);
|
||||
void new_file(void);
|
||||
filestruct *read_line(char *buf, filestruct *prev, int *line1ins, int len);
|
||||
int write_file(char *name, int tmpfile, int append, int nonamechange);
|
||||
int read_file(FILE *f, const char *filename, int quiet);
|
||||
int open_file(const char *filename, int insert, int quiet);
|
||||
char *get_next_filename(const char *name);
|
||||
|
@ -147,20 +146,21 @@ int open_nextfile_void(void);
|
|||
int close_open_file(void);
|
||||
#endif
|
||||
#if !defined(DISABLE_SPELLER) || !defined(DISABLE_OPERATINGDIR)
|
||||
char *get_full_path(char *origpath);
|
||||
char *get_full_path(const char *origpath);
|
||||
#endif
|
||||
#ifndef DISABLE_SPELLER
|
||||
char *check_writable_directory(char *path);
|
||||
char *check_writable_directory(const char *path);
|
||||
char *safe_tempnam(const char *dirname, const char *filename_prefix);
|
||||
#endif
|
||||
#ifndef DISABLE_OPERATINGDIR
|
||||
int check_operating_dir(char *currpath, int allow_tabcomp);
|
||||
void init_operating_dir(void);
|
||||
int check_operating_dir(const char *currpath, int allow_tabcomp);
|
||||
#endif
|
||||
int write_file(char *name, int tmp, int append, int nonamechange);
|
||||
int do_writeout(char *path, int exiting, int append);
|
||||
int write_file(const char *name, int tmp, int append, int nonamechange);
|
||||
int do_writeout(const char *path, int exiting, int append);
|
||||
int do_writeout_void(void);
|
||||
#ifndef DISABLE_TABCOMP
|
||||
char *real_dir_from_tilde(char *buf);
|
||||
char *real_dir_from_tilde(const char *buf);
|
||||
#endif
|
||||
int append_slash_if_dir(char *buf, int *lastwastab, int *place);
|
||||
char **username_tab_completion(char *buf, int *num_matches);
|
||||
|
@ -170,11 +170,11 @@ char *input_tab(char *buf, int place, int *lastwastab, int *newplace, int *list)
|
|||
struct stat filestat(const char *path);
|
||||
int diralphasort(const void *va, const void *vb);
|
||||
void free_charptrarray(char **array, int len);
|
||||
char *tail(char *foo);
|
||||
const char *tail(const char *foo);
|
||||
void striponedir(char *foo);
|
||||
char **browser_init(char *path, int *longest, int *numents);
|
||||
char *do_browser(char *inpath);
|
||||
char *do_browse_from(char *inpath);
|
||||
char **browser_init(const char *path, int *longest, int *numents);
|
||||
char *do_browser(const char *inpath);
|
||||
char *do_browse_from(const char *inpath);
|
||||
#endif
|
||||
|
||||
/* Public functions in global.c */
|
||||
|
|
9
rcfile.c
9
rcfile.c
|
@ -19,6 +19,8 @@
|
|||
* *
|
||||
**************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
@ -30,7 +32,6 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <assert.h>
|
||||
#include "config.h"
|
||||
#include "proto.h"
|
||||
#include "nano.h"
|
||||
|
||||
|
@ -43,7 +44,7 @@
|
|||
#define _(string) (string)
|
||||
#endif
|
||||
|
||||
static rcoption rcopts[] = {
|
||||
const static rcoption rcopts[] = {
|
||||
#ifndef NANO_SMALL
|
||||
{"autoindent", AUTOINDENT},
|
||||
{"backup", BACKUP_FILE},
|
||||
|
@ -90,7 +91,7 @@ static rcoption rcopts[] = {
|
|||
{"tabsize", 0},
|
||||
{"tempfile", TEMP_OPT},
|
||||
{"view", VIEW_MODE},
|
||||
{"", 0}
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
static int errors = 0;
|
||||
|
@ -483,7 +484,7 @@ void parse_rcfile(FILE *rcstream)
|
|||
/* We don't care if ptr == NULL, as it should if using proper syntax */
|
||||
|
||||
if (set != 0) {
|
||||
for (i = 0; rcopts[i].name != ""; i++) {
|
||||
for (i = 0; rcopts[i].name != NULL; i++) {
|
||||
if (!strcasecmp(option, rcopts[i].name)) {
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, _("parse_rcfile: Parsing option %s\n"),
|
||||
|
|
2
search.c
2
search.c
|
@ -820,7 +820,7 @@ void do_gotopos(int line, int pos_x, int pos_y, int pos_placewewant)
|
|||
int do_find_bracket(void)
|
||||
{
|
||||
char ch_under_cursor, wanted_ch;
|
||||
char *pos, *brackets = "([{<>}])";
|
||||
const char *pos, *brackets = "([{<>}])";
|
||||
char regexp_pat[] = "[ ]";
|
||||
int offset, have_past_editbuff = 0, flagsave, current_x_save, count = 1;
|
||||
filestruct *current_save;
|
||||
|
|
11
utils.c
11
utils.c
|
@ -19,13 +19,14 @@
|
|||
* *
|
||||
**************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#include "config.h"
|
||||
#include "proto.h"
|
||||
#include "nano.h"
|
||||
|
||||
|
@ -221,12 +222,10 @@ void *nmalloc(size_t howmuch)
|
|||
the transition cost of moving to the appropriate function. */
|
||||
char *charalloc(size_t howmuch)
|
||||
{
|
||||
char *r;
|
||||
char *r = (char *)malloc(howmuch * sizeof(char));
|
||||
|
||||
/* Panic save? */
|
||||
|
||||
if (!(r = (char *)calloc(howmuch, sizeof (char))))
|
||||
die(_("nano: calloc: out of memory!"));
|
||||
if (r == NULL)
|
||||
die(_("nano: malloc: out of memory!"));
|
||||
|
||||
return r;
|
||||
}
|
||||
|
|
9
winio.c
9
winio.c
|
@ -19,13 +19,14 @@
|
|||
* *
|
||||
**************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#include <assert.h>
|
||||
#include "config.h"
|
||||
#include "proto.h"
|
||||
#include "nano.h"
|
||||
|
||||
|
@ -1804,10 +1805,10 @@ void do_credits(void)
|
|||
{
|
||||
int i, j = 0, k, place = 0, start_x;
|
||||
|
||||
char *what;
|
||||
char *xlcredits[XLCREDIT_LEN];
|
||||
const char *what;
|
||||
const char *xlcredits[XLCREDIT_LEN];
|
||||
|
||||
char *credits[CREDIT_LEN] = {
|
||||
const char *credits[CREDIT_LEN] = {
|
||||
"0", /* "The nano text editor" */
|
||||
"1", /* "version" */
|
||||
VERSION,
|
||||
|
|
Loading…
Reference in New Issue