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

Diff for /texi2mdoc/main.c between version 1.54 and 1.55

version 1.54, 2015/02/28 13:16:44 version 1.55, 2015/03/01 00:25:07
Line 26 
Line 26 
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include <time.h>  
 #include <unistd.h>  #include <unistd.h>
   
 #include "extern.h"  #include "extern.h"
Line 1553  dosection(struct texi *p, enum texicmd cmd, size_t *po
Line 1552  dosection(struct texi *p, enum texicmd cmd, size_t *po
         int              sec;          int              sec;
   
         switch (cmd) {          switch (cmd) {
           case (TEXICMD_TOP):
                   sec = 0;
                   break;
         case (TEXICMD_APPENDIX):          case (TEXICMD_APPENDIX):
         case (TEXICMD_CHAPTER):          case (TEXICMD_CHAPTER):
         case (TEXICMD_TOP):  
         case (TEXICMD_UNNUMBERED):          case (TEXICMD_UNNUMBERED):
                 sec = sectioner(p, 0);                  sec = sectioner(p, 0);
                 break;                  break;
Line 1574  dosection(struct texi *p, enum texicmd cmd, size_t *po
Line 1575  dosection(struct texi *p, enum texicmd cmd, size_t *po
         else if (p->literal)          else if (p->literal)
                 texierr(p, "\"%s\" in a literal scope!?", sects[sec]);                  texierr(p, "\"%s\" in a literal scope!?", sects[sec]);
   
           if (0 == sec && NULL != p->chapters) {
                   teximdocclose(p, 0);
                   teximdocopen(p);
           }
   
         teximacroopen(p, sects[sec]);          teximacroopen(p, sects[sec]);
         parseeoln(p, pos);          parseeoln(p, pos);
         teximacroclose(p);          teximacroclose(p);
Line 1581  dosection(struct texi *p, enum texicmd cmd, size_t *po
Line 1587  dosection(struct texi *p, enum texicmd cmd, size_t *po
 }  }
   
 static void  static void
   dotop(struct texi *p, enum texicmd cmd, size_t *pos)
   {
   
           if (--p->ign)
                   texierr(p, "@top command while ignoring");
   
           if (NULL == p->chapters)
                   teximdocopen(p);
           dosection(p, cmd, pos);
   }
   
   static void
 dosp(struct texi *p, enum texicmd cmd, size_t *pos)  dosp(struct texi *p, enum texicmd cmd, size_t *pos)
 {  {
   
Line 1593  dosp(struct texi *p, enum texicmd cmd, size_t *pos)
Line 1611  dosp(struct texi *p, enum texicmd cmd, size_t *pos)
 }  }
   
 static void  static void
 dotop(struct texi *p, enum texicmd cmd, size_t *pos)  
 {  
         const char      *cp;  
         time_t           t;  
         char             date[32];  
   
         if (--p->ign)  
                 texierr(p, "@top command while ignoring");  
   
         /*  
          * Here we print our standard mdoc(7) prologue.  
          * We use the title set with @settitle for the `Nd' description  
          * and the source document filename (the first one as invoked on  
          * the command line) for the title.  
          * The date is set to the current date.  
          */  
         t = time(NULL);  
         strftime(date, sizeof(date), "%F", localtime(&t));  
   
         teximacroopen(p, "Dd");  
         texiputchars(p, date);  
         teximacroclose(p);  
         teximacroopen(p, "Dt");  
         for (cp = p->title; '\0' != *cp; cp++)  
                 texiputchar(p, toupper((unsigned int)*cp));  
         texiputchars(p, " 7");  
         teximacroclose(p);  
         teximacro(p, "Os");  
         teximacro(p, "Sh NAME");  
         teximacroopen(p, "Nm");  
         for (cp = p->title; '\0' != *cp; cp++)  
                 texiputchar(p, *cp);  
         teximacroclose(p);  
         teximacroopen(p, "Nd");  
         if (NULL != p->subtitle)  
                 for (cp = p->subtitle; '\0' != *cp; cp++)  
                         texiputchar(p, *cp);  
         else  
                 texiputchars(p, "Unknown description");  
         teximacroclose(p);  
         p->seenvs = 1;  
         dosection(p, cmd, pos);  
 }  
   
 static void  
 doitem(struct texi *p, enum texicmd cmd, size_t *pos)  doitem(struct texi *p, enum texicmd cmd, size_t *pos)
 {  {
   
Line 1885  main(int argc, char *argv[])
Line 1858  main(int argc, char *argv[])
   
         memset(&texi, 0, sizeof(struct texi));          memset(&texi, 0, sizeof(struct texi));
         texi.ign = 1;          texi.ign = 1;
           texi.outfile = stdout;
         Idir = NULL;          Idir = NULL;
   
         while (-1 != (c = getopt(argc, argv, "I:")))          while (-1 != (c = getopt(argc, argv, "C:I:")))
                 switch (c) {                  switch (c) {
                   case ('C'):
                           texi.chapters = optarg;
                           break;
                 case ('I'):                  case ('I'):
                         Idir = optarg;                          Idir = optarg;
                         break;                          break;
Line 1924  main(int argc, char *argv[])
Line 1901  main(int argc, char *argv[])
         texiexit(&texi);          texiexit(&texi);
         return(EXIT_FAILURE);          return(EXIT_FAILURE);
 usage:  usage:
         fprintf(stderr, "usage: %s [-Idirs] [file]\n", progname);          fprintf(stderr, "usage: %s [-Cdir] [-Idirs] [file]\n", progname);
         return(EXIT_FAILURE);          return(EXIT_FAILURE);
 }  }

Legend:
Removed from v.1.54  
changed lines
  Added in v.1.55

CVSweb