[BACK]Return to lex.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mail

Diff for /src/usr.bin/mail/lex.c between version 1.25 and 1.26

version 1.25, 2001/11/20 20:50:00 version 1.26, 2001/11/21 15:26:39
Line 36 
Line 36 
   
 #ifndef lint  #ifndef lint
 #if 0  #if 0
 static char sccsid[] = "@(#)lex.c       8.2 (Berkeley) 4/20/95";  static const char sccsid[] = "@(#)lex.c 8.2 (Berkeley) 4/20/95";
 #else  #else
 static char rcsid[] = "$OpenBSD$";  static const char rcsid[] = "$OpenBSD$";
 #endif  #endif
 #endif /* not lint */  #endif /* not lint */
   
Line 64 
Line 64 
  * signficance for mbox and so forth.   * signficance for mbox and so forth.
  */   */
 int  int
 setfile(name)  setfile(char *name)
         char *name;  
 {  {
         FILE *ibuf;          FILE *ibuf;
         int i, fd;          int i, fd;
Line 114 
Line 113 
          * while we are reading the new file, else we will ruin           * while we are reading the new file, else we will ruin
          * the message[] data structure.           * the message[] data structure.
          */           */
   
         holdsigs();          holdsigs();
         if (shudclob)          if (shudclob)
                 quit();                  quit();
Line 123 
Line 121 
          * Copy the messages into /tmp           * Copy the messages into /tmp
          * and set pointers.           * and set pointers.
          */           */
   
         readonly = 0;          readonly = 0;
         if ((i = open(name, 1)) < 0)          if ((i = open(name, O_WRONLY, 0)) < 0)
                 readonly++;                  readonly++;
         else          else
                 (void)close(i);                  (void)close(i);
Line 136 
Line 133 
         shudclob = 1;          shudclob = 1;
         edit = isedit;          edit = isedit;
         strcpy(prevfile, mailname);          strcpy(prevfile, mailname);
         if (name != mailname) {          if (name != mailname)
                 strncpy(mailname, name, sizeof(mailname) - 1);                  strlcpy(mailname, name, sizeof(mailname));
                 mailname[sizeof(mailname) - 1] = '\0';  
         }  
         mailsize = fsize(ibuf);          mailsize = fsize(ibuf);
         (void)snprintf(tempname, sizeof(tempname),          (void)snprintf(tempname, sizeof(tempname),
             "%s/mail.RxXXXXXXXXXX", tmpdir);              "%s/mail.RxXXXXXXXXXX", tmpdir);
Line 175 
Line 170 
  * started reading mail.   * started reading mail.
  */   */
 int  int
 incfile()  incfile(void)
 {  {
         int newsize;          int newsize;
         int omsgCount = msgCount;          int omsgCount = msgCount;
Line 216 
Line 211 
  * print no prompt.   * print no prompt.
  */   */
 void  void
 commands()  commands(void)
 {  {
         int n, sig, *sigp;          int n, sig, *sigp;
         int eofloop = 0;          int eofloop = 0;
Line 301 
Line 296 
  * Contxt is non-zero if called while composing mail.   * Contxt is non-zero if called while composing mail.
  */   */
 int  int
 execute(linebuf, contxt)  execute(char *linebuf, int contxt)
         char linebuf[];  
         int contxt;  
 {  {
         char word[LINESIZE];          char word[LINESIZE];
         char *arglist[MAXARGC];          char *arglist[MAXARGC];
Line 321 
Line 314 
          * Handle ! escapes differently to get the correct           * Handle ! escapes differently to get the correct
          * lexical conventions.           * lexical conventions.
          */           */
   
         for (cp = linebuf; isspace(*cp); cp++)          for (cp = linebuf; isspace(*cp); cp++)
                 ;                  ;
         if (*cp == '!') {          if (*cp == '!') {
Line 344 
Line 336 
          * however, we ignore blank lines to eliminate           * however, we ignore blank lines to eliminate
          * confusion.           * confusion.
          */           */
   
         if (sourcing && *word == '\0')          if (sourcing && *word == '\0')
                 return(0);                  return(0);
         com = lex(word);          com = lex(word);
         if (com == NONE) {          if (com == NULL) {
                 printf("Unknown command: \"%s\"\n", word);                  printf("Unknown command: \"%s\"\n", word);
                 goto out;                  goto out;
         }          }
Line 357 
Line 348 
          * See if we should execute the command -- if a conditional           * See if we should execute the command -- if a conditional
          * we always execute it, otherwise, check the state of cond.           * we always execute it, otherwise, check the state of cond.
          */           */
   
         if ((com->c_argtype & F) == 0)          if ((com->c_argtype & F) == 0)
                 if ((cond == CRCV && !rcvmode) || (cond == CSEND && rcvmode))                  if ((cond == CRCV && !rcvmode) || (cond == CSEND && rcvmode))
                         return(0);                          return(0);
Line 368 
Line 358 
          * If we are sourcing an interactive command, it's           * If we are sourcing an interactive command, it's
          * an error.           * an error.
          */           */
   
         if (!rcvmode && (com->c_argtype & M) == 0) {          if (!rcvmode && (com->c_argtype & M) == 0) {
                 printf("May not execute \"%s\" while sending\n",                  printf("May not execute \"%s\" while sending\n",
                     com->c_name);                      com->c_name);
Line 547 
Line 536 
  * lists to message list functions.   * lists to message list functions.
  */   */
 void  void
 setmsize(sz)  setmsize(int sz)
         int sz;  
 {  {
   
         if (msgvec != 0)          if (msgvec != 0)
Line 562 
Line 550 
  */   */
   
 const struct cmd *  const struct cmd *
 lex(word)  lex(char *word)
         char word[];  
 {  {
         extern const struct cmd cmdtab[];          extern const struct cmd cmdtab[];
         const struct cmd *cp;          const struct cmd *cp;
Line 573 
Line 560 
         for (cp = &cmdtab[0]; cp->c_name != NULL; cp++)          for (cp = &cmdtab[0]; cp->c_name != NULL; cp++)
                 if (isprefix(word, cp->c_name))                  if (isprefix(word, cp->c_name))
                         return(cp);                          return(cp);
         return(NONE);          return(NULL);
 }  }
   
 /*  /*
Line 581 
Line 568 
  * Return true if yep.   * Return true if yep.
  */   */
 int  int
 isprefix(as1, as2)  isprefix(char *as1, char *as2)
         char *as1, *as2;  
 {  {
         char *s1, *s2;          char *s1, *s2;
   
Line 601 
Line 587 
  * Close all open files except 0, 1, 2, and the temporary.   * Close all open files except 0, 1, 2, and the temporary.
  * Also, unstack all source files.   * Also, unstack all source files.
  */   */
   
 int     inithdr;                        /* am printing startup headers */  int     inithdr;                        /* am printing startup headers */
   
 void  void
 dointr()  dointr(void)
 {  {
   
         noreset = 0;          noreset = 0;
Line 629 
Line 614 
  * give the message count, and print a header listing.   * give the message count, and print a header listing.
  */   */
 void  void
 announce()  announce(void)
 {  {
         int vec[2], mdot;          int vec[2], mdot;
   
Line 649 
Line 634 
  * Return a likely place to set dot.   * Return a likely place to set dot.
  */   */
 int  int
 newfileinfo(omsgCount)  newfileinfo(int omsgCount)
         int omsgCount;  
 {  {
         struct message *mp;          struct message *mp;
         int u, n, mdot, d, s;          int u, n, mdot, d, s;
Line 680 
Line 664 
         }          }
         ename = mailname;          ename = mailname;
         if (getfold(fname, sizeof(fname)) >= 0) {          if (getfold(fname, sizeof(fname)) >= 0) {
                 strncat(fname, "/", sizeof(fname) - strlen(fname) - 1);                  strlcat(fname, "/", sizeof(fname));
                 if (strncmp(fname, mailname, strlen(fname)) == 0) {                  if (strncmp(fname, mailname, strlen(fname)) == 0) {
                         (void)snprintf(zname, sizeof(zname), "+%s",                          (void)snprintf(zname, sizeof(zname), "+%s",
                             mailname + strlen(fname));                              mailname + strlen(fname));
Line 709 
Line 693 
 /*  /*
  * Print the current version number.   * Print the current version number.
  */   */
   
 /*ARGSUSED*/  /*ARGSUSED*/
 int  int
 pversion(v)  pversion(void *v)
         void *v;  
 {  {
         extern char *version;          extern const char version[];
   
         printf("Version %s\n", version);          printf("Version %s\n", version);
         return(0);          return(0);
Line 725 
Line 707 
  * Load a file of user definitions.   * Load a file of user definitions.
  */   */
 void  void
 load(name)  load(char *name)
         char *name;  
 {  {
         FILE *in, *oldin;          FILE *in, *oldin;
   

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.26