[BACK]Return to apropos.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/Attic/apropos.c between version 1.10 and 1.13

version 1.10, 2011/11/09 22:05:56 version 1.13, 2011/11/14 10:07:06
Line 14 
Line 14 
  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF   * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.   * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */   */
   #ifdef HAVE_CONFIG_H
   #include "config.h"
   #endif
   
 #include <assert.h>  #include <assert.h>
 #include <getopt.h>  #include <getopt.h>
 #include <limits.h>  #include <limits.h>
Line 21 
Line 25 
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
   
 #include "apropos.h"  #include "apropos_db.h"
 #include "mandoc.h"  #include "mandoc.h"
   
 static  int      cmp(const void *, const void *);  static  int      cmp(const void *, const void *);
Line 33  static char *progname;
Line 37  static char *progname;
 int  int
 main(int argc, char *argv[])  main(int argc, char *argv[])
 {  {
         int              ch, cs;          int              ch;
           size_t           sz;
           char            *buf;
         struct opts      opts;          struct opts      opts;
         struct expr     *e;          struct expr     *e;
         extern int       optind;          extern int       optind;
Line 47  main(int argc, char *argv[])
Line 53  main(int argc, char *argv[])
         else          else
                 ++progname;                  ++progname;
   
         cs = 0;          while (-1 != (ch = getopt(argc, argv, "S:s:")))
   
         while (-1 != (ch = getopt(argc, argv, "S:s:I")))  
                 switch (ch) {                  switch (ch) {
                 case ('S'):                  case ('S'):
                         opts.arch = optarg;                          opts.arch = optarg;
Line 57  main(int argc, char *argv[])
Line 61  main(int argc, char *argv[])
                 case ('s'):                  case ('s'):
                         opts.cat = optarg;                          opts.cat = optarg;
                         break;                          break;
                 case ('I'):  
                         cs = 1;  
                         break;  
                 default:                  default:
                         usage();                          usage();
                         return(EXIT_FAILURE);                          return(EXIT_FAILURE);
Line 71  main(int argc, char *argv[])
Line 72  main(int argc, char *argv[])
         if (0 == argc)          if (0 == argc)
                 return(EXIT_SUCCESS);                  return(EXIT_SUCCESS);
   
         if (NULL == (e = exprcomp(cs, argv, argc))) {          /*
            * Collapse expressions into a single string.
            * First count up the contained strings, adding a space at the
            * end of each (plus nil-terminator).  Then merge.
            */
   
           for (sz = 0, ch = 0; ch < argc; ch++)
                   sz += strlen(argv[ch]) + 1;
   
           buf = mandoc_malloc(++sz);
   
           for (*buf = '\0', ch = 0; ch < argc; ch++) {
                   strlcat(buf, argv[ch], sz);
                   strlcat(buf, " ", sz);
           }
   
           buf[sz - 2] = '\0';
   
           if (NULL == (e = exprcomp(buf))) {
                 fprintf(stderr, "Bad expression\n");                  fprintf(stderr, "Bad expression\n");
                   free(buf);
                 return(EXIT_FAILURE);                  return(EXIT_FAILURE);
         }          }
   
           free(buf);
   
         /*          /*
          * Configure databases.           * Configure databases.

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.13

CVSweb