[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nano-devel] minor fixes for 1.1.10-cvs
From: |
David Lawrence Ramsey |
Subject: |
[Nano-devel] minor fixes for 1.1.10-cvs |
Date: |
Fri, 26 Jul 2002 05:08:21 -0700 (PDT) |
The attached patch fixes a few minor problems in
1.1.10-cvs.
* while rcfile.c:do_rcfile() no longer relies on $HOME to
obtain the user's home directory,
files.c:real_dir_from_tilde() still does; I've adapted the
do_rcfile() code to get the effective user id to it, and
removed some redundant code that cropped up as a result of
that
* do_backspace now calls edit_refresh() unconditionally if
we're using color, which is needed so that changes to a
multiple-line color regex made by backspacing show up all at
once as they do when the cnages are made by deleting
* do_delete() now (only) calls edit_refresh()
unconditionally if we'rwe using color; if not, it just calls
update_line() if we're not deleting the end of the line, and
update_line() and edit_refresh() if we are; this matches
do_backspace()'s new behavior, since its call to do_left()
before edit_refresh() indirectly calls update_line()
These seem to work so far, afaict, but I'll keep testing
just in case. The patch is also online at:
http://pooka_regent.tripod.com/patches/nano/nanomisc4-patch.txt
_____________________________________________________________
Sluggy.Net: The Sluggy Freelance Community!
_____________________________________________________________
Promote your group and strengthen ties to your members with address@hidden by
Everyone.net http://www.everyone.net/?btn=tag
diff -urN nano-1.1.10-cvs/ChangeLog nano-1.1.10-cvs-fixed/ChangeLog
--- nano-1.1.10-cvs/ChangeLog 2002-07-25 18:27:50.000000000 -0400
+++ nano-1.1.10-cvs-fixed/ChangeLog 2002-07-25 21:34:22.000000000 -0400
@@ -1,4 +1,18 @@
CVS code -
+- files.c:
+ real_dir_from_tilde()
+ - Rework to use getpwent() exclusively and end reliance on
+ $HOME. Adapted from equivalent code in do_rcfile(). (DLR)
+- nano.c:
+ 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
diff -urN nano-1.1.10-cvs/files.c nano-1.1.10-cvs-fixed/files.c
--- nano-1.1.10-cvs/files.c 2002-07-23 21:02:26.000000000 -0400
+++ nano-1.1.10-cvs-fixed/files.c 2002-07-25 21:32:46.000000000 -0400
@@ -1899,7 +1899,7 @@
*/
char *real_dir_from_tilde(char *buf)
{
- char *dirtmp = NULL, *find_user = NULL;
+ char *dirtmp = NULL;
int i = 1;
struct passwd *userdata;
@@ -1908,16 +1908,16 @@
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);
+ endpwent();
}
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++)
@@ -1926,21 +1926,18 @@
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());
+ endpwent();
free(find_user);
+ }
- 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]);
}
}
diff -urN nano-1.1.10-cvs/nano.c nano-1.1.10-cvs-fixed/nano.c
--- nano-1.1.10-cvs/nano.c 2002-07-23 21:02:26.000000000 -0400
+++ nano-1.1.10-cvs-fixed/nano.c 2002-07-25 21:32:46.000000000 -0400
@@ -980,6 +980,7 @@
int do_backspace(void)
{
+ int refresh = 0;
if (current_x > 0) {
assert(current_x <= strlen(current->data));
/* Let's get dangerous */
@@ -994,6 +995,9 @@
mark_beginx--;
#endif
do_left();
+#ifdef ENABLE_COLOR
+ refresh = 1;
+#endif
} else {
filestruct *previous;
const filestruct *tmp;
@@ -1046,16 +1050,20 @@
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;
@@ -1070,7 +1078,9 @@
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. */
@@ -1091,16 +1101,17 @@
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;
}
diff -urN nano-1.1.10-cvs/nano.h nano-1.1.10-cvs-fixed/nano.h
--- nano-1.1.10-cvs/nano.h 2002-07-22 20:33:08.000000000 -0400
+++ nano-1.1.10-cvs-fixed/nano.h 2002-07-25 21:36:16.000000000 -0400
@@ -374,4 +374,4 @@
/* Minimum fill length (space available for text before wrapping occurs) */
#define MIN_FILL_LENGTH 10
-#endif /* !NANO_H */
+#endif /* !NANO_H */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Nano-devel] minor fixes for 1.1.10-cvs,
David Lawrence Ramsey <=