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

Diff for /src/usr.bin/rcs/rcsprog.c between version 1.27 and 1.28

version 1.27, 2005/10/12 17:43:18 version 1.28, 2005/10/13 12:35:30
Line 45 
Line 45 
 const char rcs_version[] = "OpenCVS RCS version 3.6";  const char rcs_version[] = "OpenCVS RCS version 3.6";
 int verbose = 1;  int verbose = 1;
   
   int     rcs_optind;
   char    *rcs_optarg;
   
 struct rcs_prog {  struct rcs_prog {
         char    *prog_name;          char    *prog_name;
         int     (*prog_hdlr)(int, char **);          int     (*prog_hdlr)(int, char **);
Line 60 
Line 63 
 };  };
   
 int  int
   rcs_getopt(int argc, char **argv, const char *optstr)
   {
           char *a;
           const char *c;
           static int i = 1;
           int opt, hasargument, ret;
   
           hasargument = 0;
           rcs_optarg = NULL;
   
           if (i >= argc)
                   return (-1);
   
           a = argv[i++];
           if (*a++ != '-')
                   return (-1);
   
           ret = 0;
           opt = *a;
           for (c = optstr; *c != '\0'; c++) {
                   if (*c == opt) {
                           a++;
                           ret = opt;
   
                           if (*(c + 1) == ':') {
                                   if (*(c + 2) == ':') {
                                           if (*a != '\0')
                                                   hasargument = 1;
                                   } else {
                                           if (*a != '\0') {
                                                   hasargument = 1;
                                           } else {
                                                   ret = 1;
                                                   break;
                                           }
                                   }
                           }
   
                           if (hasargument == 1)
                                   rcs_optarg = a;
   
                           if (ret == opt)
                                   rcs_optind++;
                           break;
                   }
           }
   
           if (ret == 0)
                   cvs_log(LP_ERR, "unknown option -%c", opt);
           else if (ret == 1)
                   cvs_log(LP_ERR, "missing argument for option -%c", opt);
   
           return (ret);
   }
   
   int
 rcs_statfile(char *fname, char *out, size_t len)  rcs_statfile(char *fname, char *out, size_t len)
 {  {
         int l;          int l;
Line 108 
Line 167 
         int ret;          int ret;
   
         ret = -1;          ret = -1;
           rcs_optind = 1;
         cvs_strtab_init();          cvs_strtab_init();
         cvs_log_init(LD_STD, 0);          cvs_log_init(LD_STD, 0);
   
Line 154 
Line 214 
         flags = RCS_RDWR;          flags = RCS_RDWR;
         logstr = oldfile = alist = comment = elist = NULL;          logstr = oldfile = alist = comment = elist = NULL;
   
         while ((ch = getopt(argc, argv, "A:a:b::c:e::hik:Lm:MqUV")) != -1) {          while ((ch = rcs_getopt(argc, argv, "A:a:b::c:e::hik:Lm:MqUV")) != -1) {
                 switch (ch) {                  switch (ch) {
                 case 'A':                  case 'A':
                         oldfile = optarg;                          oldfile = rcs_optarg;
                         break;                          break;
                 case 'a':                  case 'a':
                         alist = optarg;                          alist = rcs_optarg;
                         break;                          break;
                 case 'c':                  case 'c':
                         comment = optarg;                          comment = rcs_optarg;
                         break;                          break;
                 case 'e':                  case 'e':
                         elist = optarg;                          elist = rcs_optarg;
                         break;                          break;
                 case 'h':                  case 'h':
                         (usage)();                          (usage)();
Line 175 
Line 235 
                         flags |= RCS_CREATE;                          flags |= RCS_CREATE;
                         break;                          break;
                 case 'k':                  case 'k':
                         kflag = rcs_kflag_get(optarg);                          kflag = rcs_kflag_get(rcs_optarg);
                         if (RCS_KWEXP_INVAL(kflag)) {                          if (RCS_KWEXP_INVAL(kflag)) {
                                 cvs_log(LP_ERR,                                  cvs_log(LP_ERR,
                                     "invalid keyword substitution mode `%s'",                                      "invalid keyword substitution mode `%s'",
                                     optarg);                                      rcs_optarg);
                                 exit(1);                                  exit(1);
                         }                          }
                         break;                          break;
Line 189 
Line 249 
                         lkmode = RCS_LOCK_STRICT;                          lkmode = RCS_LOCK_STRICT;
                         break;                          break;
                 case 'm':                  case 'm':
                         if ((logstr = strdup(optarg)) == NULL) {                          if ((logstr = strdup(rcs_optarg)) == NULL) {
                                 cvs_log(LP_ERRNO, "failed to copy logstring");                                  cvs_log(LP_ERRNO, "failed to copy logstring");
                                 exit(1);                                  exit(1);
                         }                          }
Line 214 
Line 274 
                 }                  }
         }          }
   
         argc -= optind;          argc -= rcs_optind;
         argv += optind;          argv += rcs_optind;
         if (argc == 0) {          if (argc == 0) {
                 cvs_log(LP_ERR, "no input file");                  cvs_log(LP_ERR, "no input file");
                 (usage)();                  (usage)();

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28