- Translation updates (see po/ChangeLog for details).
- configure.ac:
- 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
- General:
- Add a comment to nanorc.sample warning that an out-of-range
negative value for fill can make nano die complaining that
the screen is too small (which may not be immediately
- obvious. (DLR)
+ obvious). (DLR)
- There were some opendir() calls in files.c without
corresponding closedir() calls; add them. (DLR)
- Move align() and null_at() from nano.c to utils.c, and move
*/
char *real_dir_from_tilde(char *buf)
{
- char *dirtmp = NULL, *find_user = NULL;
+ char *dirtmp = NULL;
int i = 1;
struct passwd *userdata;
if (buf[0] == '~') {
if (buf[1] == 0 || buf[1] == '/') {
- if (getenv("HOME") != NULL) {
-
- free(dirtmp);
- dirtmp = charalloc(strlen(buf) + 2 + strlen(getenv("HOME")));
-
- sprintf(dirtmp, "%s%s", getenv("HOME"), &buf[1]);
-
- }
+ /* Determine home directory using getpwent(), don't rely on
+ $HOME */
+ uid_t euid = geteuid();
+ do {
+ userdata = getpwent();
+ } while (userdata != NULL && userdata->pw_uid != euid);
}
else {
+ char *find_user = NULL;
/* Figure how how much of the str we need to compare */
for (i = 1; buf[i] != '/' && buf[i] != 0; i++)
find_user = mallocstrcpy(find_user, &buf[1]);
find_user[i - 1] = '\0';
- for (userdata = getpwent(); userdata != NULL &&
- strcmp(userdata->pw_name, find_user);
- userdata = getpwent());
+ for (userdata = getpwent(); userdata != NULL &&
+ strcmp(userdata->pw_name, find_user);
+ userdata = getpwent());
free(find_user);
+ }
+ endpwent();
- if (userdata != NULL) { /* User found */
-
- free(dirtmp);
- dirtmp = charalloc(strlen(buf) + 2 + strlen(userdata->pw_dir));
- sprintf(dirtmp, "%s%s", userdata->pw_dir, &buf[i]);
-
- }
-
- endpwent();
+ if (userdata != NULL) { /* User found */
+ free(dirtmp);
+ dirtmp = charalloc(strlen(buf) + 2 + strlen(userdata->pw_dir));
+ sprintf(dirtmp, "%s%s", userdata->pw_dir, &buf[i]);
}
}
/* If the word starts with `~' and there is no slash in the word,
* then try completing this word as a username. */
- /* FIXME -- this check is broken! */
- if (*tmp == '~' && !strchr(tmp, '/'))
+ /* If the original string begins with a tilde, and the part
+ 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);
+ }
/* Try to match everything in the current working directory that
* matches. */
nano_reverse_msg = _("Search backwards");
nano_dos_msg = _("Write file out in DOS format");
nano_mac_msg = _("Write file out in Mac format");
-#ifndef NANO_SMALL
nano_backup_msg = _("Back up original file when saving");
-#endif
#ifdef HAVE_REGEX_H
nano_regexp_msg = _("Use regular expressions");
nano_bracket_msg = _("Find other bracket");
sc_init_one(&whereis_list, NANO_OTHERSEARCH_KEY, _("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);
#ifndef NANO_SMALL
return ISSET(NO_HELP) ? 2 : 0;
}
-#if defined(DISABLE_JUSTIFY) || defined(DISABLE_SPELLER) || \
- defined(DISABLE_HELP) || defined(NANO_SMALL)
+#if defined(DISABLE_JUSTIFY) || defined(DISABLE_SPELLER) || defined(DISABLE_HELP) || defined(NANO_SMALL)
void nano_disabled_msg(void)
{
statusbar(_("Sorry, support for this function has been disabled"));
placewewant = xplustabs();
- if (current->lineno >= editbot->lineno)
- edit_update(current, CENTER);
+ if (current->lineno >= editbot->lineno) {
+ /* 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 {
/* If we've jumped lines, refresh the old line. We can't just
use current->prev here, because we may have skipped over some
placewewant = xplustabs();
- if (current->lineno <= edittop->lineno)
- edit_update(current, CENTER);
+ if (current->lineno <= edittop->lineno) {
+ /* 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 {
/* If we've jumped lines, refresh the old line. We can't just
use current->prev here, because we may have skipped over some
int do_backspace(void)
{
+ int refresh = 0;
if (current_x > 0) {
assert(current_x <= strlen(current->data));
/* Let's get dangerous */
mark_beginx--;
#endif
do_left();
+#ifdef ENABLE_COLOR
+ refresh = 1;
+#endif
} else {
filestruct *previous;
const filestruct *tmp;
fprintf(stderr, _("After, data = \"%s\"\n"), current->data);
#endif
UNSET(KEEP_CUTBUFFER);
- edit_refresh();
+ refresh = 1;
}
totsize--;
set_modified();
+ if (refresh)
+ edit_refresh();
return 1;
}
int do_delete(void)
{
+ int refresh = 0;
+
/* blbf -> blank line before filebot (see below) */
int blbf = 0;
strlen(current->data) - current_x);
align(¤t->data);
-
+#ifdef ENABLE_COLOR
+ refresh = 1;
+#endif
} else if (current->next != NULL && (current->next != filebot || blbf)) {
/* We can delete the line before filebot only if it is blank: it
becomes the new magic line then. */
unlink_node(foo);
delete_node(foo);
renumber(current);
- /* Have to renumber before doing update_line(). */
- update_line(current, current_x);
totlines--;
+ refresh = 1;
} else
return 0;
totsize--;
set_modified();
UNSET(KEEP_CUTBUFFER);
- edit_refresh();
+ update_line(current, current_x);
+ if (refresh)
+ edit_refresh();
return 1;
}
return 1;
}
-#if !defined(DISABLE_WRAPPING) && !defined(NANO_SMALL) || \
- !defined(DISABLE_JUSTIFY)
+#if !defined(DISABLE_WRAPPING) && !defined(NANO_SMALL) || !defined(DISABLE_JUSTIFY)
/* The "indentation" of a line is the white-space between the quote part
* and the non-white-space of the line. */
size_t indent_length(const char *line) {
*front = ' ';
}
/* these tests are safe since line->data + skip is not a space */
- if (*front == ' ' && *(front-1) == ' ' && *(front-2) != '.' &&
- *(front-2) != '!' && *(front-2) != '?') {
+ if (*front == ' ' && *(front - 1) == ' ' && *(front - 2) != '.' &&
+ *(front - 2) != '!' && *(front - 2) != '?') {
/* Now *front is a space we want to remove. We do that by
* simply failing to assign it to *back */
if (!changes_allowed)
return 1;
/* 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. */
if (back != front) {
IFREG(const char *b_line, const regex_t *qreg)) {
/* Here is the assumption about a_quote: */
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);
}
#ifdef HAVE_REGEX_H
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);
if (rc) {
}
}
} else {
- /* this line is not part of a paragraph. Move down until we get
- * to a non "blank" line */
+ /* This line is not part of a paragraph. Move down until we get
+ * to a non "blank" line. */
do {
/* There is no next paragraph, so nothing to justify. */
if (current->next == NULL)
/* Minimum fill length (space available for text before wrapping occurs) */
#define MIN_FILL_LENGTH 10
-#endif /* !NANO_H */
+#endif /* !NANO_H */