Commit d865da10 authored by Chris Allegretta's avatar Chris Allegretta
Browse files

DLR's latest and greatest

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1256 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
parent d793cc18
Showing with 88 additions and 48 deletions
+88 -48
...@@ -3,6 +3,27 @@ CVS code - ...@@ -3,6 +3,27 @@ CVS code -
- Translation updates (see po/ChangeLog for details). - Translation updates (see po/ChangeLog for details).
- configure.ac: - configure.ac:
- Added pt_BR to ALL_LINGUAS (Jordi). - Added pt_BR to ALL_LINGUAS (Jordi).
- files.c:
real_dir_from_tilde()
- Rework to use getpwent() exclusively and end reliance on
$HOME. Adapted from equivalent code in do_rcfile(). (DLR)
input_tab()
- Most likely fixed the check marked with FIXME, so that tab
completion works properly when we're trying to tab-complete a
username and the string already contains data. (DLR)
- nano.c:
do_next_word(), do_prev_word()
- If we're on the last/first line of the file, don't center the
screen; Pico doesn't in the former case. (DLR)
do_backspace()
- Rework to call edit_refresh() regardless of the value of
current_x if ENABLE_COLOR is defined, so that multiple-line
color regexes are properly updated onscreen as they are in
do_delete(). (DLR)
do_delete()
- Rework to only call edit_refresh() unconditionally if
ENABLE_COLOR is defined; if it isn't, and we're not deleting
the end of the line, only call update_line(). (DLR)
GNU nano 1.1.10 - 07/25/2002 GNU nano 1.1.10 - 07/25/2002
- General: - General:
...@@ -72,7 +93,7 @@ GNU nano 1.1.10 - 07/25/2002 ...@@ -72,7 +93,7 @@ GNU nano 1.1.10 - 07/25/2002
- Add a comment to nanorc.sample warning that an out-of-range - Add a comment to nanorc.sample warning that an out-of-range
negative value for fill can make nano die complaining that negative value for fill can make nano die complaining that
the screen is too small (which may not be immediately the screen is too small (which may not be immediately
obvious. (DLR) obvious). (DLR)
- There were some opendir() calls in files.c without - There were some opendir() calls in files.c without
corresponding closedir() calls; add them. (DLR) corresponding closedir() calls; add them. (DLR)
- Move align() and null_at() from nano.c to utils.c, and move - Move align() and null_at() from nano.c to utils.c, and move
......
...@@ -1899,7 +1899,7 @@ int do_writeout_void(void) ...@@ -1899,7 +1899,7 @@ int do_writeout_void(void)
*/ */
char *real_dir_from_tilde(char *buf) char *real_dir_from_tilde(char *buf)
{ {
char *dirtmp = NULL, *find_user = NULL; char *dirtmp = NULL;
int i = 1; int i = 1;
struct passwd *userdata; struct passwd *userdata;
...@@ -1908,16 +1908,15 @@ char *real_dir_from_tilde(char *buf) ...@@ -1908,16 +1908,15 @@ char *real_dir_from_tilde(char *buf)
if (buf[0] == '~') { if (buf[0] == '~') {
if (buf[1] == 0 || buf[1] == '/') { if (buf[1] == 0 || buf[1] == '/') {
if (getenv("HOME") != NULL) { /* Determine home directory using getpwent(), don't rely on
$HOME */
free(dirtmp); uid_t euid = geteuid();
dirtmp = charalloc(strlen(buf) + 2 + strlen(getenv("HOME"))); do {
userdata = getpwent();
sprintf(dirtmp, "%s%s", getenv("HOME"), &buf[1]); } while (userdata != NULL && userdata->pw_uid != euid);
}
} }
else { else {
char *find_user = NULL;
/* Figure how how much of the str we need to compare */ /* Figure how how much of the str we need to compare */
for (i = 1; buf[i] != '/' && buf[i] != 0; i++) for (i = 1; buf[i] != '/' && buf[i] != 0; i++)
...@@ -1926,21 +1925,18 @@ char *real_dir_from_tilde(char *buf) ...@@ -1926,21 +1925,18 @@ char *real_dir_from_tilde(char *buf)
find_user = mallocstrcpy(find_user, &buf[1]); find_user = mallocstrcpy(find_user, &buf[1]);
find_user[i - 1] = '\0'; find_user[i - 1] = '\0';
for (userdata = getpwent(); userdata != NULL && for (userdata = getpwent(); userdata != NULL &&
strcmp(userdata->pw_name, find_user); strcmp(userdata->pw_name, find_user);
userdata = getpwent()); userdata = getpwent());
free(find_user); free(find_user);
}
endpwent();
if (userdata != NULL) { /* User found */ if (userdata != NULL) { /* User found */
free(dirtmp);
free(dirtmp); dirtmp = charalloc(strlen(buf) + 2 + strlen(userdata->pw_dir));
dirtmp = charalloc(strlen(buf) + 2 + strlen(userdata->pw_dir)); sprintf(dirtmp, "%s%s", userdata->pw_dir, &buf[i]);
sprintf(dirtmp, "%s%s", userdata->pw_dir, &buf[i]);
}
endpwent();
} }
} }
...@@ -2189,9 +2185,15 @@ char *input_tab(char *buf, int place, int *lastwastab, int *newplace, int *list) ...@@ -2189,9 +2185,15 @@ char *input_tab(char *buf, int place, int *lastwastab, int *newplace, int *list)
/* If the word starts with `~' and there is no slash in the word, /* If the word starts with `~' and there is no slash in the word,
* then try completing this word as a username. */ * then try completing this word as a username. */
/* FIXME -- this check is broken! */ /* If the original string begins with a tilde, and the part
if (*tmp == '~' && !strchr(tmp, '/')) we're trying to tab-complete doesn't contain a slash, copy
the part we're tab-completing into buf, so tab completion
will result in buf's containing only the tab-completed
username. */
if (buf[0] == '~' && !strchr(tmp, '/')) {
buf = mallocstrcpy(buf, tmp);
matches = username_tab_completion(tmp, &num_matches); matches = username_tab_completion(tmp, &num_matches);
}
/* Try to match everything in the current working directory that /* Try to match everything in the current working directory that
* matches. */ * matches. */
......
...@@ -378,9 +378,7 @@ void shortcut_init(int unjustify) ...@@ -378,9 +378,7 @@ void shortcut_init(int unjustify)
nano_reverse_msg = _("Search backwards"); nano_reverse_msg = _("Search backwards");
nano_dos_msg = _("Write file out in DOS format"); nano_dos_msg = _("Write file out in DOS format");
nano_mac_msg = _("Write file out in Mac format"); nano_mac_msg = _("Write file out in Mac format");
#ifndef NANO_SMALL
nano_backup_msg = _("Back up original file when saving"); nano_backup_msg = _("Back up original file when saving");
#endif
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
nano_regexp_msg = _("Use regular expressions"); nano_regexp_msg = _("Use regular expressions");
nano_bracket_msg = _("Find other bracket"); nano_bracket_msg = _("Find other bracket");
...@@ -589,7 +587,7 @@ void shortcut_init(int unjustify) ...@@ -589,7 +587,7 @@ void shortcut_init(int unjustify)
sc_init_one(&whereis_list, NANO_OTHERSEARCH_KEY, _("Replace"), sc_init_one(&whereis_list, NANO_OTHERSEARCH_KEY, _("Replace"),
IFHELP(nano_replace_msg, 0), 0, 0, VIEW, do_replace); IFHELP(nano_replace_msg, 0), 0, 0, VIEW, do_replace);
sc_init_one(&whereis_list, NANO_FROMSEARCHTOGOTO_KEY, _("Go To Line"), sc_init_one(&whereis_list, NANO_FROMSEARCHTOGOTO_KEY, _("Go To Line"),
IFHELP(nano_goto_msg, 0), 0, 0, VIEW, do_gotoline_void); IFHELP(nano_goto_msg, 0), 0, 0, VIEW, do_gotoline_void);
#ifndef NANO_SMALL #ifndef NANO_SMALL
......
...@@ -529,8 +529,7 @@ int no_help(void) ...@@ -529,8 +529,7 @@ int no_help(void)
return ISSET(NO_HELP) ? 2 : 0; return ISSET(NO_HELP) ? 2 : 0;
} }
#if defined(DISABLE_JUSTIFY) || defined(DISABLE_SPELLER) || \ #if defined(DISABLE_JUSTIFY) || defined(DISABLE_SPELLER) || defined(DISABLE_HELP) || defined(NANO_SMALL)
defined(DISABLE_HELP) || defined(NANO_SMALL)
void nano_disabled_msg(void) void nano_disabled_msg(void)
{ {
statusbar(_("Sorry, support for this function has been disabled")); statusbar(_("Sorry, support for this function has been disabled"));
...@@ -691,8 +690,13 @@ int do_next_word(void) ...@@ -691,8 +690,13 @@ int do_next_word(void)
placewewant = xplustabs(); placewewant = xplustabs();
if (current->lineno >= editbot->lineno) if (current->lineno >= editbot->lineno) {
edit_update(current, CENTER); /* If we're on the last line, don't center the screen. */
if (current->lineno == filebot->lineno)
edit_refresh();
else
edit_update(current, CENTER);
}
else { else {
/* If we've jumped lines, refresh the old line. We can't just /* If we've jumped lines, refresh the old line. We can't just
use current->prev here, because we may have skipped over some use current->prev here, because we may have skipped over some
...@@ -746,8 +750,13 @@ int do_prev_word(void) ...@@ -746,8 +750,13 @@ int do_prev_word(void)
placewewant = xplustabs(); placewewant = xplustabs();
if (current->lineno <= edittop->lineno) if (current->lineno <= edittop->lineno) {
edit_update(current, CENTER); /* If we're on the first line, don't center the screen. */
if (current->lineno == fileage->lineno)
edit_refresh();
else
edit_update(current, CENTER);
}
else { else {
/* If we've jumped lines, refresh the old line. We can't just /* If we've jumped lines, refresh the old line. We can't just
use current->prev here, because we may have skipped over some use current->prev here, because we may have skipped over some
...@@ -980,6 +989,7 @@ void do_early_abort(void) ...@@ -980,6 +989,7 @@ void do_early_abort(void)
int do_backspace(void) int do_backspace(void)
{ {
int refresh = 0;
if (current_x > 0) { if (current_x > 0) {
assert(current_x <= strlen(current->data)); assert(current_x <= strlen(current->data));
/* Let's get dangerous */ /* Let's get dangerous */
...@@ -994,6 +1004,9 @@ int do_backspace(void) ...@@ -994,6 +1004,9 @@ int do_backspace(void)
mark_beginx--; mark_beginx--;
#endif #endif
do_left(); do_left();
#ifdef ENABLE_COLOR
refresh = 1;
#endif
} else { } else {
filestruct *previous; filestruct *previous;
const filestruct *tmp; const filestruct *tmp;
...@@ -1046,16 +1059,20 @@ int do_backspace(void) ...@@ -1046,16 +1059,20 @@ int do_backspace(void)
fprintf(stderr, _("After, data = \"%s\"\n"), current->data); fprintf(stderr, _("After, data = \"%s\"\n"), current->data);
#endif #endif
UNSET(KEEP_CUTBUFFER); UNSET(KEEP_CUTBUFFER);
edit_refresh(); refresh = 1;
} }
totsize--; totsize--;
set_modified(); set_modified();
if (refresh)
edit_refresh();
return 1; return 1;
} }
int do_delete(void) int do_delete(void)
{ {
int refresh = 0;
/* blbf -> blank line before filebot (see below) */ /* blbf -> blank line before filebot (see below) */
int blbf = 0; int blbf = 0;
...@@ -1070,7 +1087,9 @@ int do_delete(void) ...@@ -1070,7 +1087,9 @@ int do_delete(void)
strlen(current->data) - current_x); strlen(current->data) - current_x);
align(&current->data); align(&current->data);
#ifdef ENABLE_COLOR
refresh = 1;
#endif
} else if (current->next != NULL && (current->next != filebot || blbf)) { } else if (current->next != NULL && (current->next != filebot || blbf)) {
/* We can delete the line before filebot only if it is blank: it /* We can delete the line before filebot only if it is blank: it
becomes the new magic line then. */ becomes the new magic line then. */
...@@ -1091,16 +1110,17 @@ int do_delete(void) ...@@ -1091,16 +1110,17 @@ int do_delete(void)
unlink_node(foo); unlink_node(foo);
delete_node(foo); delete_node(foo);
renumber(current); renumber(current);
/* Have to renumber before doing update_line(). */
update_line(current, current_x);
totlines--; totlines--;
refresh = 1;
} else } else
return 0; return 0;
totsize--; totsize--;
set_modified(); set_modified();
UNSET(KEEP_CUTBUFFER); UNSET(KEEP_CUTBUFFER);
edit_refresh(); update_line(current, current_x);
if (refresh)
edit_refresh();
return 1; return 1;
} }
...@@ -1925,8 +1945,7 @@ int do_tab(void) ...@@ -1925,8 +1945,7 @@ int do_tab(void)
return 1; return 1;
} }
#if !defined(DISABLE_WRAPPING) && !defined(NANO_SMALL) || \ #if !defined(DISABLE_WRAPPING) && !defined(NANO_SMALL) || !defined(DISABLE_JUSTIFY)
!defined(DISABLE_JUSTIFY)
/* The "indentation" of a line is the white-space between the quote part /* The "indentation" of a line is the white-space between the quote part
* and the non-white-space of the line. */ * and the non-white-space of the line. */
size_t indent_length(const char *line) { size_t indent_length(const char *line) {
...@@ -1974,8 +1993,8 @@ static int justify_format(int changes_allowed, filestruct *line, ...@@ -1974,8 +1993,8 @@ static int justify_format(int changes_allowed, filestruct *line,
*front = ' '; *front = ' ';
} }
/* these tests are safe since line->data + skip is not a space */ /* these tests are safe since line->data + skip is not a space */
if (*front == ' ' && *(front-1) == ' ' && *(front-2) != '.' && if (*front == ' ' && *(front - 1) == ' ' && *(front - 2) != '.' &&
*(front-2) != '!' && *(front-2) != '?') { *(front - 2) != '!' && *(front - 2) != '?') {
/* Now *front is a space we want to remove. We do that by /* Now *front is a space we want to remove. We do that by
* simply failing to assign it to *back */ * simply failing to assign it to *back */
if (!changes_allowed) if (!changes_allowed)
...@@ -2001,7 +2020,7 @@ static int justify_format(int changes_allowed, filestruct *line, ...@@ -2001,7 +2020,7 @@ static int justify_format(int changes_allowed, filestruct *line,
return 1; return 1;
/* This assert merely documents a fact about the loop above. */ /* This assert merely documents a fact about the loop above. */
assert(changes_allowed || back==front); assert(changes_allowed || back == front);
/* Now back is the new end of line->data. */ /* Now back is the new end of line->data. */
if (back != front) { if (back != front) {
...@@ -2057,7 +2076,7 @@ static int quotes_match(const char *a_line, size_t a_quote, ...@@ -2057,7 +2076,7 @@ static int quotes_match(const char *a_line, size_t a_quote,
IFREG(const char *b_line, const regex_t *qreg)) { IFREG(const char *b_line, const regex_t *qreg)) {
/* Here is the assumption about a_quote: */ /* Here is the assumption about a_quote: */
assert(a_quote == quote_length(IFREG(a_line, qreg))); assert(a_quote == quote_length(IFREG(a_line, qreg)));
return a_quote==quote_length(IFREG(b_line, qreg)) && return a_quote == quote_length(IFREG(b_line, qreg)) &&
!strncmp(a_line, b_line, a_quote); !strncmp(a_line, b_line, a_quote);
} }
...@@ -2222,7 +2241,7 @@ int do_justify(void) { ...@@ -2222,7 +2241,7 @@ int do_justify(void) {
#ifdef HAVE_REGEX_H #ifdef HAVE_REGEX_H
regex_t qreg; /* qreg is the compiled quotation regexp. regex_t qreg; /* qreg is the compiled quotation regexp.
* We no longer care about quotestr */ * We no longer care about quotestr. */
int rc = regcomp(&qreg, quotestr, REG_EXTENDED); int rc = regcomp(&qreg, quotestr, REG_EXTENDED);
if (rc) { if (rc) {
...@@ -2270,8 +2289,8 @@ int do_justify(void) { ...@@ -2270,8 +2289,8 @@ int do_justify(void) {
} }
} }
} else { } else {
/* this line is not part of a paragraph. Move down until we get /* This line is not part of a paragraph. Move down until we get
* to a non "blank" line */ * to a non "blank" line. */
do { do {
/* There is no next paragraph, so nothing to justify. */ /* There is no next paragraph, so nothing to justify. */
if (current->next == NULL) if (current->next == NULL)
......
...@@ -374,4 +374,4 @@ typedef enum { ...@@ -374,4 +374,4 @@ typedef enum {
/* Minimum fill length (space available for text before wrapping occurs) */ /* Minimum fill length (space available for text before wrapping occurs) */
#define MIN_FILL_LENGTH 10 #define MIN_FILL_LENGTH 10
#endif /* !NANO_H */ #endif /* !NANO_H */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment