SCCS-vsn: usr.bin/mail/lex.c 5.18
SCCS-vsn: usr.bin/mail/cmd3.c 5.19
SCCS-vsn: usr.bin/mail/main.c 5.22
-static char sccsid[] = "@(#)cmd3.c 5.18 (Berkeley) %G%";
+static char sccsid[] = "@(#)cmd3.c 5.19 (Berkeley) %G%";
#endif /* not lint */
#include "rcv.h"
#endif /* not lint */
#include "rcv.h"
file(argv)
register char **argv;
{
file(argv)
register char **argv;
{
if (argv[0] == NOSTR) {
newfileinfo();
return 0;
}
if (argv[0] == NOSTR) {
newfileinfo();
return 0;
}
- if ((cp = expand(*argv)) == NOSTR)
- return 1;
- strcpy(prevfile, mailname);
- if (setfile(cp, **argv != '%') < 0)
+ if (setfile(*argv) < 0)
return 1;
announce();
return 0;
return 1;
announce();
return 0;
-static char sccsid[] = "@(#)lex.c 5.17 (Berkeley) %G%";
+static char sccsid[] = "@(#)lex.c 5.18 (Berkeley) %G%";
#endif /* not lint */
#include "rcv.h"
#endif /* not lint */
#include "rcv.h"
/*
* Set up editing on the given file name.
/*
* Set up editing on the given file name.
- * If isedit is true, we are considered to be editing the file,
- * otherwise we are reading our mail which has signficance for
- * mbox and so forth.
+ * If the first character of name is %, we are considered to be
+ * editing the file, otherwise we are reading our mail which has
+ * signficance for mbox and so forth.
char *name;
{
FILE *ibuf;
int i;
struct stat stb;
char *name;
{
FILE *ibuf;
int i;
struct stat stb;
+ char isedit = *name != '%';
+ char *who = name[1] ? name + 1 : myname;
static int shudclob;
extern char tempMesg[];
extern int errno;
static int shudclob;
extern char tempMesg[];
extern int errno;
+ if ((name = expand(name)) == NOSTR)
+ return -1;
+
if ((ibuf = fopen(name, "r")) == NULL) {
if ((ibuf = fopen(name, "r")) == NULL) {
+ if (!isedit && errno == ENOENT)
+ goto nomail;
perror(name);
return(-1);
}
perror(name);
return(-1);
}
}
shudclob = 1;
edit = isedit;
}
shudclob = 1;
edit = isedit;
+ strcpy(prevfile, mailname);
if (name != mailname)
strcpy(mailname, name);
mailsize = fsize(ibuf);
if (name != mailname)
strcpy(mailname, name);
mailsize = fsize(ibuf);
fclose(ibuf);
relsesigs();
sawcom = 0;
fclose(ibuf);
relsesigs();
sawcom = 0;
+ if (!edit && msgCount == 0) {
+nomail:
+ fprintf(stderr, "No mail for %s\n", who);
+ return -1;
+ }
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)main.c 5.21 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c 5.22 (Berkeley) %G%";
#endif /* not lint */
#include "rcv.h"
#endif /* not lint */
#include "rcv.h"
char *subject;
char *ef;
char nosrc = 0;
char *subject;
char *ef;
char nosrc = 0;
int hdrstop(), (*prevint)();
int sigchild();
extern int getopt(), optind, opterr;
int hdrstop(), (*prevint)();
int sigchild();
extern int getopt(), optind, opterr;
* Decide whether we are editing a mailbox or reading
* the system mailbox, and open up the right stuff.
*/
* Decide whether we are editing a mailbox or reading
* the system mailbox, and open up the right stuff.
*/
- if (ef != NOSTR)
- isedit++;
- else
- if ((ef = expand(ef)) == NOSTR || setfile(ef, isedit) < 0)
exit(1); /* error already reported */
exit(1); /* error already reported */
- if (!edit && msgCount == 0) {
- fprintf(stderr, "No mail for %s\n", myname);
- exit(1);
- }
if (setjmp(hdrjmp) == 0) {
extern char *version;
if (setjmp(hdrjmp) == 0) {
extern char *version;