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

Diff for /src/usr.bin/cvs/rcs.c between version 1.253 and 1.254

version 1.253, 2008/02/28 21:55:48 version 1.254, 2008/03/01 20:03:56
Line 223 
Line 223 
   
 #define RCS_NERR   (sizeof(rcs_errstrs)/sizeof(rcs_errstrs[0]))  #define RCS_NERR   (sizeof(rcs_errstrs)/sizeof(rcs_errstrs[0]))
   
 int rcs_errno = RCS_ERR_NOERR;  
   
 static RCSNUM   *rcs_get_revision(const char *, RCSFILE *);  static RCSNUM   *rcs_get_revision(const char *, RCSFILE *);
 int             rcs_patch_lines(struct cvs_lines *, struct cvs_lines *,  int             rcs_patch_lines(struct cvs_lines *, struct cvs_lines *,
                     struct cvs_line **, struct rcs_delta *);                      struct cvs_line **, struct rcs_delta *);
Line 644 
Line 642 
   
         /* first look for duplication */          /* first look for duplication */
         TAILQ_FOREACH(ap, &(file->rf_access), ra_list) {          TAILQ_FOREACH(ap, &(file->rf_access), ra_list) {
                 if (strcmp(ap->ra_name, login) == 0) {                  if (strcmp(ap->ra_name, login) == 0)
                         rcs_errno = RCS_ERR_DUPENT;  
                         return (-1);                          return (-1);
                 }  
         }          }
   
         ap = xmalloc(sizeof(*ap));          ap = xmalloc(sizeof(*ap));
Line 675 
Line 671 
                 if (strcmp(ap->ra_name, login) == 0)                  if (strcmp(ap->ra_name, login) == 0)
                         break;                          break;
   
         if (ap == NULL) {          if (ap == NULL)
                 rcs_errno = RCS_ERR_NOENT;  
                 return (-1);                  return (-1);
         }  
   
         TAILQ_REMOVE(&(file->rf_access), ap, ra_list);          TAILQ_REMOVE(&(file->rf_access), ap, ra_list);
         xfree(ap->ra_name);          xfree(ap->ra_name);
Line 694 
Line 688 
  *   *
  * Add a symbol to the list of symbols for the RCS file <rfp>.  The new symbol   * Add a symbol to the list of symbols for the RCS file <rfp>.  The new symbol
  * is named <sym> and is bound to the RCS revision <snum>.   * is named <sym> and is bound to the RCS revision <snum>.
  * Returns 0 on success, or -1 on failure.  
  */   */
 int  int
 rcs_sym_add(RCSFILE *rfp, const char *sym, RCSNUM *snum)  rcs_sym_add(RCSFILE *rfp, const char *sym, RCSNUM *snum)
 {  {
         struct rcs_sym *symp;          struct rcs_sym *symp;
   
         if (!rcs_sym_check(sym)) {          if (!rcs_sym_check(sym))
                 rcs_errno = RCS_ERR_BADSYM;  
                 return (-1);                  return (-1);
         }  
   
         /* first look for duplication */          /* first look for duplication */
         TAILQ_FOREACH(symp, &(rfp->rf_symbols), rs_list) {          TAILQ_FOREACH(symp, &(rfp->rf_symbols), rs_list) {
                 if (strcmp(symp->rs_name, sym) == 0) {                  if (strcmp(symp->rs_name, sym) == 0)
                         rcs_errno = RCS_ERR_DUPENT;                          return (1);
                         return (-1);  
                 }  
         }          }
   
         symp = xmalloc(sizeof(*symp));          symp = xmalloc(sizeof(*symp));
Line 739 
Line 728 
 {  {
         struct rcs_sym *symp;          struct rcs_sym *symp;
   
         if (!rcs_sym_check(sym)) {          if (!rcs_sym_check(sym))
                 rcs_errno = RCS_ERR_BADSYM;  
                 return (-1);                  return (-1);
         }  
   
         TAILQ_FOREACH(symp, &(file->rf_symbols), rs_list)          TAILQ_FOREACH(symp, &(file->rf_symbols), rs_list)
                 if (strcmp(symp->rs_name, sym) == 0)                  if (strcmp(symp->rs_name, sym) == 0)
                         break;                          break;
   
         if (symp == NULL) {          if (symp == NULL)
                 rcs_errno = RCS_ERR_NOENT;  
                 return (-1);                  return (-1);
         }  
   
         TAILQ_REMOVE(&(file->rf_symbols), symp, rs_list);          TAILQ_REMOVE(&(file->rf_symbols), symp, rs_list);
         xfree(symp->rs_name);          xfree(symp->rs_name);
Line 796 
Line 781 
         RCSNUM *num;          RCSNUM *num;
         struct rcs_sym *symp;          struct rcs_sym *symp;
   
         if (!rcs_sym_check(sym)) {          if (!rcs_sym_check(sym))
                 rcs_errno = RCS_ERR_BADSYM;  
                 return (NULL);                  return (NULL);
         }  
   
         if (!strcmp(sym, RCS_HEAD_BRANCH)) {          if (!strcmp(sym, RCS_HEAD_BRANCH)) {
                 num = rcsnum_alloc();                  num = rcsnum_alloc();
Line 812 
Line 795 
                 if (strcmp(symp->rs_name, sym) == 0)                  if (strcmp(symp->rs_name, sym) == 0)
                         break;                          break;
   
         if (symp == NULL) {          if (symp != NULL) {
                 rcs_errno = RCS_ERR_NOENT;  
         } else {  
                 num = rcsnum_alloc();                  num = rcsnum_alloc();
                 rcsnum_cpy(symp->rs_num, num, 0);                  rcsnum_cpy(symp->rs_num, num, 0);
         }          }
Line 897 
Line 878 
         /* first look for duplication */          /* first look for duplication */
         TAILQ_FOREACH(lkp, &(file->rf_locks), rl_list) {          TAILQ_FOREACH(lkp, &(file->rf_locks), rl_list) {
                 if (strcmp(lkp->rl_name, user) == 0 &&                  if (strcmp(lkp->rl_name, user) == 0 &&
                     rcsnum_cmp(rev, lkp->rl_num, 0) == 0) {                      rcsnum_cmp(rev, lkp->rl_num, 0) == 0)
                         rcs_errno = RCS_ERR_DUPENT;  
                         return (-1);                          return (-1);
                 }  
         }          }
   
         lkp = xmalloc(sizeof(*lkp));          lkp = xmalloc(sizeof(*lkp));
Line 933 
Line 912 
                         break;                          break;
         }          }
   
         if (lkp == NULL) {          if (lkp == NULL)
                 rcs_errno = RCS_ERR_NOENT;  
                 return (-1);                  return (-1);
         }  
   
         TAILQ_REMOVE(&(file->rf_locks), lkp, rl_list);          TAILQ_REMOVE(&(file->rf_locks), lkp, rl_list);
         rcsnum_free(lkp->rl_num);          rcsnum_free(lkp->rl_num);
Line 988 
Line 965 
         int i;          int i;
         const char *sp;          const char *sp;
   
         if ((sp = strrchr(filename, '.')) == NULL) {          if ((sp = strrchr(filename, '.')) == NULL)
                 rcs_errno = RCS_ERR_NOENT;  
                 return (NULL);                  return (NULL);
         }  
         sp++;          sp++;
   
         for (i = 0; i < (int)NB_COMTYPES; i++)          for (i = 0; i < (int)NB_COMTYPES; i++)
Line 1219 
Line 1194 
                         rev = rcsnum_inc(rf->rf_head);                          rev = rcsnum_inc(rf->rf_head);
                 }                  }
         } else {          } else {
                 if ((rdp = rcs_findrev(rf, rev)) != NULL) {                  if ((rdp = rcs_findrev(rf, rev)) != NULL)
                         rcs_errno = RCS_ERR_DUPENT;  
                         return (-1);                          return (-1);
                 }  
         }          }
   
         if ((pw = getpwuid(getuid())) == NULL)          if ((pw = getpwuid(getuid())) == NULL)
Line 1301 
Line 1274 
                 rev = rf->rf_head;                  rev = rf->rf_head;
   
         /* do we actually have that revision? */          /* do we actually have that revision? */
         if ((rdp = rcs_findrev(rf, rev)) == NULL) {          if ((rdp = rcs_findrev(rf, rev)) == NULL)
                 rcs_errno = RCS_ERR_NOENT;  
                 return (-1);                  return (-1);
         }  
   
         /*          /*
          * This is confusing, the previous delta is next in the TAILQ list.           * This is confusing, the previous delta is next in the TAILQ list.
Line 1683 
Line 1654 
         for (;;) {          for (;;) {
                 tok = rcs_gettok(rfp);                  tok = rcs_gettok(rfp);
                 if (tok == RCS_TOK_ERR) {                  if (tok == RCS_TOK_ERR) {
                         rcs_errno = RCS_ERR_PARSE;  
                         cvs_log(LP_ERR, "parse error in RCS admin section");                          cvs_log(LP_ERR, "parse error in RCS admin section");
                         goto fail;                          goto fail;
                 } else if (tok == RCS_TOK_NUM || tok == RCS_TOK_DESC) {                  } else if (tok == RCS_TOK_NUM || tok == RCS_TOK_DESC) {
Line 1702 
Line 1672 
                                 rk = &(rcs_keys[i]);                                  rk = &(rcs_keys[i]);
   
                 if (hmask & (1 << tok)) {                  if (hmask & (1 << tok)) {
                         rcs_errno = RCS_ERR_PARSE;  
                         cvs_log(LP_ERR, "duplicate RCS key");                          cvs_log(LP_ERR, "duplicate RCS key");
                         goto fail;                          goto fail;
                 }                  }
Line 1717 
Line 1686 
                         if (ntok == RCS_TOK_SCOLON)                          if (ntok == RCS_TOK_SCOLON)
                                 break;                                  break;
                         if (ntok != rk->rk_val) {                          if (ntok != rk->rk_val) {
                                 rcs_errno = RCS_ERR_PARSE;  
                                 cvs_log(LP_ERR,                                  cvs_log(LP_ERR,
                                     "invalid value type for RCS key `%s'",                                      "invalid value type for RCS key `%s'",
                                     rk->rk_str);                                      rk->rk_str);
Line 1743 
Line 1711 
                         /* now get the expected semi-colon */                          /* now get the expected semi-colon */
                         ntok = rcs_gettok(rfp);                          ntok = rcs_gettok(rfp);
                         if (ntok != RCS_TOK_SCOLON) {                          if (ntok != RCS_TOK_SCOLON) {
                                 rcs_errno = RCS_ERR_PARSE;  
                                 cvs_log(LP_ERR,                                  cvs_log(LP_ERR,
                                     "missing semi-colon after RCS `%s' key",                                      "missing semi-colon after RCS `%s' key",
                                     rk->rk_str);                                      rk->rk_str);
Line 1763 
Line 1730 
                                 goto fail;                                  goto fail;
                         break;                          break;
                 default:                  default:
                         rcs_errno = RCS_ERR_PARSE;  
                         cvs_log(LP_ERR,                          cvs_log(LP_ERR,
                             "unexpected token `%s' in RCS admin section",                              "unexpected token `%s' in RCS admin section",
                             RCS_TOKSTR(rfp));                              RCS_TOKSTR(rfp));
Line 1798 
Line 1764 
                 rcs_pushtok(rfp, RCS_TOKSTR(rfp), tok);                  rcs_pushtok(rfp, RCS_TOKSTR(rfp), tok);
                 return (0);                  return (0);
         } else if (tok != RCS_TOK_NUM) {          } else if (tok != RCS_TOK_NUM) {
                 rcs_errno = RCS_ERR_PARSE;  
                 cvs_log(LP_ERR, "unexpected token `%s' at start of delta",                  cvs_log(LP_ERR, "unexpected token `%s' at start of delta",
                     RCS_TOKSTR(rfp));                      RCS_TOKSTR(rfp));
                 return (-1);                  return (-1);
Line 1820 
Line 1785 
         for (;;) {          for (;;) {
                 tok = rcs_gettok(rfp);                  tok = rcs_gettok(rfp);
                 if (tok == RCS_TOK_ERR) {                  if (tok == RCS_TOK_ERR) {
                         rcs_errno = RCS_ERR_PARSE;  
                         cvs_log(LP_ERR, "parse error in RCS delta section");                          cvs_log(LP_ERR, "parse error in RCS delta section");
                         rcs_freedelta(rdp);                          rcs_freedelta(rdp);
                         return (-1);                          return (-1);
Line 1836 
Line 1800 
                                 rk = &(rcs_keys[i]);                                  rk = &(rcs_keys[i]);
   
                 if (hmask & (1 << tok)) {                  if (hmask & (1 << tok)) {
                         rcs_errno = RCS_ERR_PARSE;  
                         cvs_log(LP_ERR, "duplicate RCS key");                          cvs_log(LP_ERR, "duplicate RCS key");
                         rcs_freedelta(rdp);                          rcs_freedelta(rdp);
                         return (-1);                          return (-1);
Line 1853 
Line 1816 
                                 if (rk->rk_flags & RCS_VOPT)                                  if (rk->rk_flags & RCS_VOPT)
                                         break;                                          break;
                                 else {                                  else {
                                         rcs_errno = RCS_ERR_PARSE;  
                                         cvs_log(LP_ERR, "missing mandatory "                                          cvs_log(LP_ERR, "missing mandatory "
                                             "value to RCS key `%s'",                                              "value to RCS key `%s'",
                                             rk->rk_str);                                              rk->rk_str);
Line 1863 
Line 1825 
                         }                          }
   
                         if (ntok != rk->rk_val) {                          if (ntok != rk->rk_val) {
                                 rcs_errno = RCS_ERR_PARSE;  
                                 cvs_log(LP_ERR,                                  cvs_log(LP_ERR,
                                     "invalid value type for RCS key `%s'",                                      "invalid value type for RCS key `%s'",
                                     rk->rk_str);                                      rk->rk_str);
Line 1877 
Line 1838 
                         /* now get the expected semi-colon */                          /* now get the expected semi-colon */
                         ntok = rcs_gettok(rfp);                          ntok = rcs_gettok(rfp);
                         if (ntok != RCS_TOK_SCOLON) {                          if (ntok != RCS_TOK_SCOLON) {
                                 rcs_errno = RCS_ERR_PARSE;  
                                 cvs_log(LP_ERR,                                  cvs_log(LP_ERR,
                                     "missing semi-colon after RCS `%s' key",                                      "missing semi-colon after RCS `%s' key",
                                     rk->rk_str);                                      rk->rk_str);
Line 1893 
Line 1853 
                                         return (-1);                                          return (-1);
                                 }                                  }
                                 if (datenum->rn_len != 6) {                                  if (datenum->rn_len != 6) {
                                         rcs_errno = RCS_ERR_PARSE;  
                                         cvs_log(LP_ERR,                                          cvs_log(LP_ERR,
                                             "RCS date specification has %s "                                              "RCS date specification has %s "
                                             "fields",                                              "fields",
Line 1930 
Line 1889 
                         }                          }
                         break;                          break;
                 default:                  default:
                         rcs_errno = RCS_ERR_PARSE;  
                         cvs_log(LP_ERR, "unexpected token `%s' in RCS delta",                          cvs_log(LP_ERR, "unexpected token `%s' in RCS delta",
                             RCS_TOKSTR(rfp));                              RCS_TOKSTR(rfp));
                         rcs_freedelta(rdp);                          rcs_freedelta(rdp);
Line 1967 
Line 1925 
                 return (0);                  return (0);
   
         if (tok != RCS_TOK_NUM) {          if (tok != RCS_TOK_NUM) {
                 rcs_errno = RCS_ERR_PARSE;  
                 cvs_log(LP_ERR,                  cvs_log(LP_ERR,
                     "unexpected token `%s' at start of RCS delta text",                      "unexpected token `%s' at start of RCS delta text",
                     RCS_TOKSTR(rfp));                      RCS_TOKSTR(rfp));
Line 1991 
Line 1948 
   
         tok = rcs_gettok(rfp);          tok = rcs_gettok(rfp);
         if (tok != RCS_TOK_LOG) {          if (tok != RCS_TOK_LOG) {
                 rcs_errno = RCS_ERR_PARSE;  
                 cvs_log(LP_ERR, "unexpected token `%s' where RCS log expected",                  cvs_log(LP_ERR, "unexpected token `%s' where RCS log expected",
                     RCS_TOKSTR(rfp));                      RCS_TOKSTR(rfp));
                 return (-1);                  return (-1);
Line 1999 
Line 1955 
   
         tok = rcs_gettok(rfp);          tok = rcs_gettok(rfp);
         if (tok != RCS_TOK_STRING) {          if (tok != RCS_TOK_STRING) {
                 rcs_errno = RCS_ERR_PARSE;  
                 cvs_log(LP_ERR, "unexpected token `%s' where RCS log expected",                  cvs_log(LP_ERR, "unexpected token `%s' where RCS log expected",
                     RCS_TOKSTR(rfp));                      RCS_TOKSTR(rfp));
                 return (-1);                  return (-1);
Line 2007 
Line 1962 
         rdp->rd_log = xstrdup(RCS_TOKSTR(rfp));          rdp->rd_log = xstrdup(RCS_TOKSTR(rfp));
         tok = rcs_gettok(rfp);          tok = rcs_gettok(rfp);
         if (tok != RCS_TOK_TEXT) {          if (tok != RCS_TOK_TEXT) {
                 rcs_errno = RCS_ERR_PARSE;  
                 cvs_log(LP_ERR, "unexpected token `%s' where RCS text expected",                  cvs_log(LP_ERR, "unexpected token `%s' where RCS text expected",
                     RCS_TOKSTR(rfp));                      RCS_TOKSTR(rfp));
                 return (-1);                  return (-1);
Line 2015 
Line 1969 
   
         tok = rcs_gettok(rfp);          tok = rcs_gettok(rfp);
         if (tok != RCS_TOK_STRING) {          if (tok != RCS_TOK_STRING) {
                 rcs_errno = RCS_ERR_PARSE;  
                 cvs_log(LP_ERR, "unexpected token `%s' where RCS text expected",                  cvs_log(LP_ERR, "unexpected token `%s' where RCS text expected",
                     RCS_TOKSTR(rfp));                      RCS_TOKSTR(rfp));
                 return (-1);                  return (-1);
Line 2047 
Line 2000 
   
         while ((type = rcs_gettok(rfp)) != RCS_TOK_SCOLON) {          while ((type = rcs_gettok(rfp)) != RCS_TOK_SCOLON) {
                 if (type != RCS_TOK_ID) {                  if (type != RCS_TOK_ID) {
                         rcs_errno = RCS_ERR_PARSE;  
                         cvs_log(LP_ERR, "unexpected token `%s' in access list",                          cvs_log(LP_ERR, "unexpected token `%s' in access list",
                             RCS_TOKSTR(rfp));                              RCS_TOKSTR(rfp));
                         return (-1);                          return (-1);
Line 2078 
Line 2030 
                         break;                          break;
   
                 if (type != RCS_TOK_ID) {                  if (type != RCS_TOK_ID) {
                         rcs_errno = RCS_ERR_PARSE;  
                         cvs_log(LP_ERR, "unexpected token `%s' in symbol list",                          cvs_log(LP_ERR, "unexpected token `%s' in symbol list",
                             RCS_TOKSTR(rfp));                              RCS_TOKSTR(rfp));
                         return (-1);                          return (-1);
Line 2090 
Line 2041 
   
                 type = rcs_gettok(rfp);                  type = rcs_gettok(rfp);
                 if (type != RCS_TOK_COLON) {                  if (type != RCS_TOK_COLON) {
                         rcs_errno = RCS_ERR_PARSE;  
                         cvs_log(LP_ERR, "unexpected token `%s' in symbol list",                          cvs_log(LP_ERR, "unexpected token `%s' in symbol list",
                             RCS_TOKSTR(rfp));                              RCS_TOKSTR(rfp));
                         rcsnum_free(symp->rs_num);                          rcsnum_free(symp->rs_num);
Line 2101 
Line 2051 
   
                 type = rcs_gettok(rfp);                  type = rcs_gettok(rfp);
                 if (type != RCS_TOK_NUM) {                  if (type != RCS_TOK_NUM) {
                         rcs_errno = RCS_ERR_PARSE;  
                         cvs_log(LP_ERR, "unexpected token `%s' in symbol list",                          cvs_log(LP_ERR, "unexpected token `%s' in symbol list",
                             RCS_TOKSTR(rfp));                              RCS_TOKSTR(rfp));
                         rcsnum_free(symp->rs_num);                          rcsnum_free(symp->rs_num);
Line 2143 
Line 2092 
                         break;                          break;
   
                 if (type != RCS_TOK_ID) {                  if (type != RCS_TOK_ID) {
                         rcs_errno = RCS_ERR_PARSE;  
                         cvs_log(LP_ERR, "unexpected token `%s' in lock list",                          cvs_log(LP_ERR, "unexpected token `%s' in lock list",
                             RCS_TOKSTR(rfp));                              RCS_TOKSTR(rfp));
                         return (-1);                          return (-1);
Line 2155 
Line 2103 
   
                 type = rcs_gettok(rfp);                  type = rcs_gettok(rfp);
                 if (type != RCS_TOK_COLON) {                  if (type != RCS_TOK_COLON) {
                         rcs_errno = RCS_ERR_PARSE;  
                         cvs_log(LP_ERR, "unexpected token `%s' in symbol list",                          cvs_log(LP_ERR, "unexpected token `%s' in symbol list",
                             RCS_TOKSTR(rfp));                              RCS_TOKSTR(rfp));
                         rcsnum_free(lkp->rl_num);                          rcsnum_free(lkp->rl_num);
Line 2166 
Line 2113 
   
                 type = rcs_gettok(rfp);                  type = rcs_gettok(rfp);
                 if (type != RCS_TOK_NUM) {                  if (type != RCS_TOK_NUM) {
                         rcs_errno = RCS_ERR_PARSE;  
                         cvs_log(LP_ERR, "unexpected token `%s' in symbol list",                          cvs_log(LP_ERR, "unexpected token `%s' in symbol list",
                             RCS_TOKSTR(rfp));                              RCS_TOKSTR(rfp));
                         rcsnum_free(lkp->rl_num);                          rcsnum_free(lkp->rl_num);
Line 2196 
Line 2142 
   
                 type = rcs_gettok(rfp);                  type = rcs_gettok(rfp);
                 if (type != RCS_TOK_SCOLON) {                  if (type != RCS_TOK_SCOLON) {
                         rcs_errno = RCS_ERR_PARSE;  
                         cvs_log(LP_ERR,                          cvs_log(LP_ERR,
                             "missing semi-colon after `strict' keyword");                              "missing semi-colon after `strict' keyword");
                         return (-1);                          return (-1);
Line 2224 
Line 2169 
                         break;                          break;
   
                 if (type != RCS_TOK_NUM) {                  if (type != RCS_TOK_NUM) {
                         rcs_errno = RCS_ERR_PARSE;  
                         cvs_log(LP_ERR,                          cvs_log(LP_ERR,
                             "unexpected token `%s' in list of branches",                              "unexpected token `%s' in list of branches",
                             RCS_TOKSTR(rfp));                              RCS_TOKSTR(rfp));

Legend:
Removed from v.1.253  
changed lines
  Added in v.1.254