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

Diff for /mandoc/mandocdb.c between version 1.94 and 1.95

version 1.94, 2014/01/02 20:24:39 version 1.95, 2014/01/02 22:19:41
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2011, 2012, 2013 Ingo Schwarze <schwarze@openbsd.org>   * Copyright (c) 2011, 2012, 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
  *   *
  * Permission to use, copy, modify, and distribute this software for any   * Permission to use, copy, modify, and distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above   * purpose with or without fee is hereby granted, provided that the above
Line 176  static int    use_all; /* use all found files */
Line 176  static int    use_all; /* use all found files */
 static  int              nodb; /* no database changes */  static  int              nodb; /* no database changes */
 static  int              verb; /* print what we're doing */  static  int              verb; /* print what we're doing */
 static  int              warnings; /* warn about crap */  static  int              warnings; /* warn about crap */
   static  int              write_utf8; /* write UTF-8 output; else ASCII */
 static  int              exitcode; /* to be returned by main */  static  int              exitcode; /* to be returned by main */
 static  enum op          op; /* operational mode */  static  enum op          op; /* operational mode */
 static  char             basedir[PATH_MAX]; /* current base directory */  static  char             basedir[PATH_MAX]; /* current base directory */
Line 351  main(int argc, char *argv[])
Line 352  main(int argc, char *argv[])
         path_arg = NULL;          path_arg = NULL;
         op = OP_DEFAULT;          op = OP_DEFAULT;
   
         while (-1 != (ch = getopt(argc, argv, "aC:d:ntu:vW")))          while (-1 != (ch = getopt(argc, argv, "aC:d:nT:tu:vW")))
                 switch (ch) {                  switch (ch) {
                 case ('a'):                  case ('a'):
                         use_all = 1;                          use_all = 1;
Line 369  main(int argc, char *argv[])
Line 370  main(int argc, char *argv[])
                 case ('n'):                  case ('n'):
                         nodb = 1;                          nodb = 1;
                         break;                          break;
                   case ('T'):
                           if (strcmp(optarg, "utf8")) {
                                   fprintf(stderr, "-T%s: Unsupported "
                                       "output format\n", optarg);
                                   goto usage;
                           }
                           write_utf8 = 1;
                           break;
                 case ('t'):                  case ('t'):
                         CHECKOP(op, ch);                          CHECKOP(op, ch);
                         dup2(STDOUT_FILENO, STDERR_FILENO);                          dup2(STDOUT_FILENO, STDERR_FILENO);
Line 490  out:
Line 499  out:
         ohash_delete(&mlinks);          ohash_delete(&mlinks);
         return(exitcode);          return(exitcode);
 usage:  usage:
         fprintf(stderr, "usage: %s [-anvW] [-C file]\n"          fprintf(stderr, "usage: %s [-anvW] [-C file] [-Tutf8]\n"
                         "       %s [-anvW] dir ...\n"                          "       %s [-anvW] [-Tutf8] dir ...\n"
                         "       %s [-nvW] -d dir [file ...]\n"                          "       %s [-nvW] [-Tutf8] -d dir [file ...]\n"
                         "       %s [-nvW] -u dir [file ...]\n"                          "       %s [-nvW] -u dir [file ...]\n"
                         "       %s -t file ...\n",                          "       %s -t file ...\n",
                        progname, progname, progname,                         progname, progname, progname,
Line 1722  utf8key(struct mchars *mc, struct str *key)
Line 1731  utf8key(struct mchars *mc, struct str *key)
                  * Parse the escape sequence and see if it's a                   * Parse the escape sequence and see if it's a
                  * predefined character or special character.                   * predefined character or special character.
                  */                   */
   
                 esc = mandoc_escape                  esc = mandoc_escape
                         ((const char **)&val, &seq, &len);                          ((const char **)&val, &seq, &len);
                 if (ESCAPE_ERROR == esc)                  if (ESCAPE_ERROR == esc)
                         break;                          break;
   
                 if (ESCAPE_SPECIAL != esc)                  if (ESCAPE_SPECIAL != esc)
                         continue;                          continue;
                 if (0 == (u = mchars_spec2cp(mc, seq, len)))  
                         continue;  
   
                 /*                  /*
                  * If we have a Unicode codepoint, try to convert that                   * Render the special character
                  * to a UTF-8 byte string.                   * as either UTF-8 or ASCII.
                  */                   */
                 cpp = utfbuf;  
                 if (0 == (sz = utf8(u, utfbuf)))  
                         continue;  
   
                   if (write_utf8) {
                           if (0 == (u = mchars_spec2cp(mc, seq, len)))
                                   continue;
                           cpp = utfbuf;
                           if (0 == (sz = utf8(u, utfbuf)))
                                   continue;
                           sz = strlen(cpp);
                   } else {
                           cpp = mchars_spec2str(mc, seq, len, &sz);
                           if (NULL == cpp)
                                   continue;
                           if (ASCII_NBRSP == *cpp) {
                                   cpp = " ";
                                   sz = 1;
                           }
                   }
   
                 /* Copy the rendered glyph into the stream. */                  /* Copy the rendered glyph into the stream. */
   
                 sz = strlen(cpp);  
                 bsz += sz;                  bsz += sz;
   
                 buf = mandoc_realloc(buf, bsz);                  buf = mandoc_realloc(buf, bsz);
   
                 memcpy(&buf[pos], cpp, sz);                  memcpy(&buf[pos], cpp, sz);
                 pos += sz;                  pos += sz;
         }          }

Legend:
Removed from v.1.94  
changed lines
  Added in v.1.95

CVSweb