[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nmh-commits] CVS: nmh/uip Makefile.in,1.15,1.16 flist.c,1.4,1.5 folder.
From: |
Jon Steinhart <address@hidden> |
Subject: |
[Nmh-commits] CVS: nmh/uip Makefile.in,1.15,1.16 flist.c,1.4,1.5 folder.c,1.4,1.5 install-mh.c,1.4,1.5 rmf.c,1.5,1.6 |
Date: |
Mon, 18 Nov 2002 13:25:10 -0500 |
Update of /cvsroot/nmh/nmh/uip
In directory subversions:/tmp/cvs-serv2504/uip
Modified Files:
Makefile.in flist.c folder.c install-mh.c rmf.c
Log Message:
The file README-ATTACHMENTS was removed - it has been moved to the docs
subdirectory. I thought that this had already been done but I guess not.
It's unrelated to the rest of these changes.
The remainder of these changes affect the way that nmh is installed. Nmh
has historically prompted the user for installation when any nmh command
is invoked if it doesn't think that it's installed. This is a problem for
programs that want to, for example, interact with nmh programs via pipes.
These changes alter this behavior. Now, when an nmh program thinks that
nmh isn't installed, it tells the user to run install-mh to install it.
A -check option has been added to install-mh that allows the existence of
an installation to be silently checked and indicated via the exit status.
The bulk of this change is in sbr/read_context.c. In the process of making
these changes, I noticed a fair amount of useless code that I removed. In
particular:
1. The program started with a test for whether or not defpath had already
been set. This could only happen if context_read() was called more
than once, which it isn't. This check also existed and was removed
from the following places:
sbr/context_del.c
sbr/context_find.c
sbr/context_replace.c
sbr/seq_read.c
sbr/seq_save.c
uip/flist.c
uip/folder.c
uip/rmf.c
2. A similar test for mypath was removed. No need to test it since it
doesn't happen. I'm just not a believer that
a = 1;
if (a != 1)
error();
is a good way to write code!
3. I removed the code makes a copy of the $HOME environment variable as
returned by getenv(). It's never changed, so it doesn't need copying.
4. I removed code that copied the pw_dir member of the passwd structure
returned by getpwuid() if $HOME isn't set. Yes, the returned structure
is static, but since the function is never called again the returned
values stay valid and don't need copying.
5. I removed the test for a NULL pw_dir member in the passwd structure
returned by getpwuid() since that never happens.
6. I removed code that removed a trailing / from mypath if mypath is more
than one character long. Unnecessary as // is interpreted as / anyway.
mypath never shows up in an error message, so nobody will ever see it.
Besides, this code didn't handle the case of multiple trailing slashes.
7. I removed code that replaced the MH environment variable contents with
an absolute path if it was a relative one. I'm a bit nervous about this
one, only testing will tell. Any nmh program that's invoked will use
the same context_read() code to convert a relative path to an absolute
one anyway. And there's no guarantee (or discussion) of this feature
in any of the documentation.
8. Althout context_read() tested the MH environment variable, install-mh
didn't. This means that the behavior was not consistent between
install-mh and all other nmh programs. I changed install-mh to be
consistent with context_read().
9. install-mh has been installed in the lib directory, not bin. So a
user would be unlikely to find it when prompted to run it. The
installation has been changed to add a link from bin to lib.
Index: Makefile.in
===================================================================
RCS file: /cvsroot/nmh/nmh/uip/Makefile.in,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** Makefile.in 9 Jan 2001 06:40:12 -0000 1.15
--- Makefile.in 18 Nov 2002 18:25:02 -0000 1.16
***************
*** 252,256 ****
# install everything
! install: install-cmds install-lcmds install-misc install-scmds
# install commands
--- 252,256 ----
# install everything
! install: install-cmds install-misc install-lcmds install-scmds
# install commands
***************
*** 271,274 ****
--- 271,275 ----
$(LN) $(bindir)/show $(bindir)/prev
$(LN) $(bindir)/show $(bindir)/next
+ $(LN) $(libdir)/install-mh $(bindir)/install-mh
# install misc support binaries
Index: flist.c
===================================================================
RCS file: /cvsroot/nmh/nmh/uip/flist.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** flist.c 4 Feb 2000 20:28:23 -0000 1.4
--- flist.c 18 Nov 2002 18:25:02 -0000 1.5
***************
*** 698,705 ****
register struct node *np;
- /* sanity check - check that context has been read */
- if (defpath == NULL)
- adios (NULL, "oops, context hasn't been read yet");
-
snprintf (atrcur, sizeof(atrcur), "atr-%s-", current);
atrlen = strlen (atrcur);
--- 698,701 ----
Index: folder.c
===================================================================
RCS file: /cvsroot/nmh/nmh/uip/folder.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** folder.c 2 Jul 2002 22:09:14 -0000 1.4
--- folder.c 18 Nov 2002 18:25:02 -0000 1.5
***************
*** 819,826 ****
register struct node *np;
- /* sanity check - check that context has been read */
- if (defpath == NULL)
- adios (NULL, "oops, context hasn't been read yet");
-
snprintf (atrcur, sizeof(atrcur), "atr-%s-", current);
atrlen = strlen (atrcur);
--- 819,822 ----
Index: install-mh.c
===================================================================
RCS file: /cvsroot/nmh/nmh/uip/install-mh.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** install-mh.c 2 Jul 2002 22:09:14 -0000 1.4
--- install-mh.c 18 Nov 2002 18:25:02 -0000 1.5
***************
*** 1,3 ****
-
/*
* install-mh.c -- initialize the nmh environment of a new user
--- 1,2 ----
***************
*** 10,15 ****
*/
! #include <h/mh.h>
! #include <pwd.h>
static struct swit switches[] = {
--- 9,14 ----
*/
! #include <h/mh.h> /* mh internals */
! #include <pwd.h> /* structure for getpwuid()
results */
static struct swit switches[] = {
***************
*** 20,35 ****
#define HELPSW 2
{ "help", 0 },
{ NULL, 0 }
};
- static char *message[] = {
- "Prior to using nmh, it is necessary to have a file in your login",
- "directory (%s) named %s which contains information",
- "to direct certain nmh operations. The only item which is required",
- "is the path to use for all nmh folder operations. The suggested nmh",
- "path for you is %s/Mail...",
- NULL
- };
-
/*
* static prototypes
--- 19,27 ----
#define HELPSW 2
{ "help", 0 },
+ #define CHECKSW 3
+ { "check", 1 },
{ NULL, 0 }
};
/*
* static prototypes
***************
*** 41,46 ****
main (int argc, char **argv)
{
! int i, autof = 0;
! char *cp, *path, buf[BUFSIZ];
char *dp, **arguments, **argp;
struct node *np;
--- 33,38 ----
main (int argc, char **argv)
{
! int autof = 0;
! char *cp, *pathname, buf[BUFSIZ];
char *dp, **arguments, **argp;
struct node *np;
***************
*** 48,51 ****
--- 40,44 ----
struct stat st;
FILE *in, *out;
+ int check;
#ifdef LOCALE
***************
*** 56,59 ****
--- 49,54 ----
argp = arguments;
+ check = 0;
+
while ((dp = *argp++)) {
if (*dp == '-') {
***************
*** 76,79 ****
--- 71,78 ----
autof++;
continue;
+
+ case CHECKSW:
+ check = 1;
+ continue;
}
} else {
***************
*** 82,117 ****
}
! /* straight from context_read ... */
! if (mypath == NULL) {
! if ((mypath = getenv ("HOME"))) {
! mypath = getcpy (mypath);
! } else {
! if ((pw = getpwuid (getuid ())) == NULL
! || pw->pw_dir == NULL
! || *pw->pw_dir == 0)
! adios (NULL, "no HOME envariable");
! else
! mypath = getcpy (pw->pw_dir);
! }
! if ((cp = mypath + strlen (mypath) - 1) > mypath && *cp == '/')
! *cp = 0;
}
! defpath = concat (mypath, "/", mh_profile, NULL);
if (stat (defpath, &st) != NOTOK) {
! if (autof)
adios (NULL, "invocation error");
else
! adios (NULL,
! "You already have an nmh profile, use an editor to modify
it");
}
if (!autof && gans ("Do you want help? ", anoyes)) {
! putchar ('\n');
! for (i = 0; message[i]; i++) {
! printf (message[i], mypath, mh_profile);
! putchar ('\n');
! }
! putchar ('\n');
}
--- 81,136 ----
}
! /*
! * Find user's home directory. Try the HOME environment variable
first,
! * the home directory field in the password file if that's not
found.
! */
!
! if ((mypath = getenv("HOME")) == (char *)0) {
! if ((pw = getpwuid(getuid())) == (struct passwd *)0 || *pw->pw_dir ==
'\0')
! adios(NULL, "cannot determine your home directory");
! else
! mypath = pw->pw_dir;
}
!
! /*
! * Find the user's profile. Check for the existence of an MH
environment
! * variable first with non-empty contents. Convert any relative
path name
! * found there to an absolute one. Look for the profile in the
user's home
! * directory if the MH environment variable isn't set.
! */
!
! if ((cp = getenv("MH")) && *cp != '\0')
! defpath = path(cp, TFILE);
! else
! defpath = concat(mypath, "/", mh_profile, NULL);
!
! /*
! * Check for the existence of the profile file. It's an error if
it exists and
! * this isn't an installation check. An installation check fails
if it does not
! * exist, succeeds if it does.
! */
if (stat (defpath, &st) != NOTOK) {
! if (check)
! done(0);
!
! else if (autof)
adios (NULL, "invocation error");
else
! adios (NULL, "You already have an nmh profile, use an editor to
modify it");
! }
! else if (check) {
! done(1);
}
if (!autof && gans ("Do you want help? ", anoyes)) {
! (void)printf(
! "\n"
! "Prior to using nmh, it is necessary to have a file in your login\n"
! "directory (%s) named %s which contains information\n"
! "to direct certain nmh operations. The only item which is required\n"
! "is the path to use for all nmh folder operations. The suggested
nmh\n"
! "path for you is %s/Mail...\n"
! "\n", mypath, mh_profile, mypath);
}
***************
*** 122,126 ****
cp, "\".\nDo you want to use it for nmh? ", NULL);
if (gans (cp, anoyes))
! path = "Mail";
else
goto query;
--- 141,145 ----
cp, "\".\nDo you want to use it for nmh? ", NULL);
if (gans (cp, anoyes))
! pathname = "Mail";
else
goto query;
***************
*** 135,139 ****
mypath, "/", "Mail\"? ", NULL);
if (autof || gans (cp, anoyes))
! path = "Mail";
else {
query:
--- 154,158 ----
mypath, "/", "Mail\"? ", NULL);
if (autof || gans (cp, anoyes))
! pathname = "Mail";
else {
query:
***************
*** 141,148 ****
anoyes)) {
printf ("What is the path? %s/", mypath);
! path = geta ();
} else {
printf ("What is the whole path? /");
! path = concat ("/", geta (), NULL);
}
}
--- 160,167 ----
anoyes)) {
printf ("What is the path? %s/", mypath);
! pathname = geta ();
} else {
printf ("What is the whole path? /");
! pathname = concat ("/", geta (), NULL);
}
}
***************
*** 150,158 ****
chdir (mypath);
! if (chdir (path) == NOTOK) {
! cp = concat ("\"", path, "\" doesn't exist; Create it? ", NULL);
if (autof || gans (cp, anoyes))
! if (makedir (path) == 0)
! adios (NULL, "unable to create %s", path);
} else {
printf ("[Using existing directory]\n");
--- 169,177 ----
chdir (mypath);
! if (chdir (pathname) == NOTOK) {
! cp = concat ("\"", pathname, "\" doesn't exist; Create it? ", NULL);
if (autof || gans (cp, anoyes))
! if (makedir (pathname) == 0)
! adios (NULL, "unable to create %s", pathname);
} else {
printf ("[Using existing directory]\n");
***************
*** 166,170 ****
np = m_defs;
np->n_name = getcpy ("Path");
! np->n_field = getcpy (path);
np->n_context = 0;
np->n_next = NULL;
--- 185,189 ----
np = m_defs;
np->n_name = getcpy ("Path");
! np->n_field = getcpy (pathname);
np->n_context = 0;
np->n_next = NULL;
Index: rmf.c
===================================================================
RCS file: /cvsroot/nmh/nmh/uip/rmf.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -r1.5 -r1.6
*** rmf.c 23 Aug 2002 20:37:01 -0000 1.5
--- rmf.c 18 Nov 2002 18:25:02 -0000 1.6
***************
*** 224,231 ****
register struct node *np, *pp;
- /* sanity check - check that context has been read */
- if (defpath == NULL)
- adios (NULL, "oops, context hasn't been read yet");
-
alen = strlen ("atr-");
plen = strlen (cp = m_mailpath (folder)) + 1;
--- 224,227 ----
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Nmh-commits] CVS: nmh/uip Makefile.in,1.15,1.16 flist.c,1.4,1.5 folder.c,1.4,1.5 install-mh.c,1.4,1.5 rmf.c,1.5,1.6,
Jon Steinhart <address@hidden> <=
- Prev by Date:
[Nmh-commits] CVS: nmh/man install-mh.man,1.5,1.6 nmh.man,1.5,1.6
- Next by Date:
[Nmh-commits] CVS: nmh/sbr context_del.c,1.2,1.3 context_find.c,1.2,1.3 context_read.c,1.2,1.3 context_replace.c,1.2,1.3 seq_read.c,1.2,1.3 seq_save.c,1.2,1.3
- Previous by thread:
[Nmh-commits] CVS: nmh/man install-mh.man,1.5,1.6 nmh.man,1.5,1.6
- Next by thread:
[Nmh-commits] CVS: nmh/sbr context_del.c,1.2,1.3 context_find.c,1.2,1.3 context_read.c,1.2,1.3 context_replace.c,1.2,1.3 seq_read.c,1.2,1.3 seq_save.c,1.2,1.3
- Index(es):