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

Diff for /mandoc/Attic/mlg.c between version 1.1 and 1.2

version 1.1, 2008/12/03 14:39:59 version 1.2, 2008/12/03 19:21:58
Line 31 
Line 31 
   
 #define COLUMNS           72  #define COLUMNS           72
 #define INDENT            4  #define INDENT            4
 #define MAXINDENT         8  #define MAXINDENT         10
   
 enum    md_tok {  enum    md_tok {
         MD_TEXT,          MD_TEXT,
Line 53  struct md_mlg {
Line 53  struct md_mlg {
         void             *arg;          void             *arg;
         ml_begintag       begintag;          ml_begintag       begintag;
         ml_endtag         endtag;          ml_endtag         endtag;
           ml_begin          begin;
           ml_end            end;
         int               flags;          int               flags;
 #define ML_OVERRIDE_ONE  (1 << 0)  #define ML_OVERRIDE_ONE  (1 << 0)
 #define ML_OVERRIDE_ALL  (1 << 1)  #define ML_OVERRIDE_ALL  (1 << 1)
Line 68  static int   mlg_roffdata(void *, int, char *);
Line 70  static int   mlg_roffdata(void *, int, char *);
 static  int              mlg_roffout(void *, int);  static  int              mlg_roffout(void *, int);
 static  int              mlg_roffblkin(void *, int, int *, char **);  static  int              mlg_roffblkin(void *, int, int *, char **);
 static  int              mlg_roffblkout(void *, int);  static  int              mlg_roffblkout(void *, int);
 static  int              mlg_roffspecial(void *, int, int *, char **, char **);  static  int              mlg_roffspecial(void *, int, int *,
                                   char **, char **);
   static  int              mlg_roffblkheadin(void *, int, int *, char **);
   static  int              mlg_roffblkheadout(void *, int);
   static  int              mlg_roffblkbodyin(void *, int, int *, char **);
   static  int              mlg_roffblkbodyout(void *, int);
   
   static  int              mlg_beginblk(struct md_mlg *, enum md_ns, int,
                                   int *, char **);
   static  int              mlg_endblk(struct md_mlg *, enum md_ns, int);
 static  int              mlg_begintag(struct md_mlg *, enum md_ns,  static  int              mlg_begintag(struct md_mlg *, enum md_ns,
                                 int, int *, char **);                                  int, int *, char **);
 static  int              mlg_endtag(struct md_mlg *, enum md_ns, int);  static  int              mlg_endtag(struct md_mlg *, enum md_ns, int);
Line 84  extern size_t   strlcpy(char *, const char *, size_t);
Line 95  extern size_t   strlcpy(char *, const char *, size_t);
   
   
 static int  static int
   mlg_beginblk(struct md_mlg *p, enum md_ns ns, int tok,
                   int *argc, char **argv)
   {
           if (0 != p->pos) {
                   if ( ! mlg_newline(p))
                           return(0);
                   if ( ! mlg_indent(p))
                           return(0);
           } else if ( ! mlg_indent(p))
                   return(0);
   
           p->indent++;
           mlg_mode(p, MD_BLK_IN);
   
           if ( ! mlg_begintag(p, ns, tok, argc, argv))
                   return(0);
           return(mlg_newline(p));
   }
   
   
   static int
   mlg_endblk(struct md_mlg *p, enum md_ns ns, int tok)
   {
   
           p->indent--;
   
           if (0 != p->pos) {
                   if ( ! mlg_newline(p))
                           return(0);
                   if ( ! mlg_indent(p))
                           return(0);
           } else if ( ! mlg_indent(p))
                   return(0);
   
           mlg_mode(p, MD_BLK_OUT);
           if ( ! mlg_endtag(p, ns, tok))
                   return(0);
           return(mlg_newline(p));
   }
   
   
   static int
 mlg_begintag(struct md_mlg *p, enum md_ns ns, int tok,  mlg_begintag(struct md_mlg *p, enum md_ns ns, int tok,
                 int *argc, char **argv)                  int *argc, char **argv)
 {  {
Line 251  struct md_mlg *
Line 304  struct md_mlg *
 mlg_alloc(const struct md_args *args,  mlg_alloc(const struct md_args *args,
                 const struct md_rbuf *rbuf,                  const struct md_rbuf *rbuf,
                 struct md_mbuf *mbuf,                  struct md_mbuf *mbuf,
                 ml_begintag begintag, ml_endtag endtag)                  ml_begintag begintag, ml_endtag endtag,
                   ml_begin begin, ml_end end)
 {  {
         struct roffcb    cb;          struct roffcb    cb;
         struct md_mlg   *p;          struct md_mlg   *p;
Line 261  mlg_alloc(const struct md_args *args, 
Line 315  mlg_alloc(const struct md_args *args, 
         cb.roffin = mlg_roffin;          cb.roffin = mlg_roffin;
         cb.roffout = mlg_roffout;          cb.roffout = mlg_roffout;
         cb.roffblkin = mlg_roffblkin;          cb.roffblkin = mlg_roffblkin;
           cb.roffblkheadin = mlg_roffblkheadin;
           cb.roffblkheadout = mlg_roffblkheadout;
           cb.roffblkbodyin = mlg_roffblkbodyin;
           cb.roffblkbodyout = mlg_roffblkbodyout;
         cb.roffblkout = mlg_roffblkout;          cb.roffblkout = mlg_roffblkout;
         cb.roffspecial = mlg_roffspecial;          cb.roffspecial = mlg_roffspecial;
         cb.roffmsg = mlg_roffmsg;          cb.roffmsg = mlg_roffmsg;
Line 274  mlg_alloc(const struct md_args *args, 
Line 332  mlg_alloc(const struct md_args *args, 
         p->rbuf = rbuf;          p->rbuf = rbuf;
         p->begintag = begintag;          p->begintag = begintag;
         p->endtag = endtag;          p->endtag = endtag;
           p->begin = begin;
           p->end = end;
   
         if (NULL == (p->tree = roff_alloc(&cb, p))) {          if (NULL == (p->tree = roff_alloc(&cb, p))) {
                 free(p);                  free(p);
Line 293  mlg_roffhead(void *arg)
Line 353  mlg_roffhead(void *arg)
         p = (struct md_mlg *)arg;          p = (struct md_mlg *)arg;
   
         mlg_mode(p, MD_BLK_IN);          mlg_mode(p, MD_BLK_IN);
         if ( ! mlg_begintag(p, MD_NS_DEFAULT, -1, NULL, NULL))          if ( ! (*p->begin)(p->mbuf, p->args))
                 return(0);                  return(0);
   
         p->indent++;          p->indent++;
Line 313  mlg_rofftail(void *arg)
Line 373  mlg_rofftail(void *arg)
                 return(0);                  return(0);
   
         mlg_mode(p, MD_BLK_OUT);          mlg_mode(p, MD_BLK_OUT);
         if ( ! mlg_endtag(p, -1, MD_NS_DEFAULT))          if ( ! (*p->end)(p->mbuf, p->args))
                 return(0);                  return(0);
   
         return(mlg_newline(p));          return(mlg_newline(p));
Line 351  mlg_roffspecial(void *arg, int tok, int *argc, char **
Line 411  mlg_roffspecial(void *arg, int tok, int *argc, char **
 static int  static int
 mlg_roffblkin(void *arg, int tok, int *argc, char **argv)  mlg_roffblkin(void *arg, int tok, int *argc, char **argv)
 {  {
         struct md_mlg   *p;  
   
         assert(arg);          return(mlg_beginblk((struct md_mlg *)arg,
         p = (struct md_mlg *)arg;                                  MD_NS_BLOCK, tok, argc, argv));
   }
   
         if (0 != p->pos) {  
                 if ( ! mlg_newline(p))  
                         return(0);  
                 if ( ! mlg_indent(p))  
                         return(0);  
         } else if ( ! mlg_indent(p))  
                 return(0);  
   
         p->indent++;  static int
         mlg_mode(p, MD_BLK_IN);  mlg_roffblkout(void *arg, int tok)
   {
   
         if ( ! mlg_begintag(p, MD_NS_BLOCK, tok, argc, argv))          return(mlg_endblk((struct md_mlg *)arg, MD_NS_BLOCK, tok));
                 return(0);  
         return(mlg_newline(p));  
 }  }
   
   
 static int  static int
 mlg_roffblkout(void *arg, int tok)  mlg_roffblkbodyin(void *arg, int tok, int *argc, char **argv)
 {  {
         struct md_mlg   *p;  
   
         assert(arg);          return(mlg_beginblk((struct md_mlg *)arg,
         p = (struct md_mlg *)arg;                                  MD_NS_BODY, tok, argc, argv));
   }
   
         p->indent--;  
   
         if (0 != p->pos) {  static int
                 if ( ! mlg_newline(p))  mlg_roffblkbodyout(void *arg, int tok)
                         return(0);  {
                 if ( ! mlg_indent(p))  
                         return(0);  
         } else if ( ! mlg_indent(p))  
                 return(0);  
   
         mlg_mode(p, MD_BLK_OUT);          return(mlg_endblk((struct md_mlg *)arg, MD_NS_BODY, tok));
         if ( ! mlg_endtag(p, MD_NS_BLOCK, tok))  }
                 return(0);  
         return(mlg_newline(p));  
   static int
   mlg_roffblkheadin(void *arg, int tok, int *argc, char **argv)
   {
   
           return(mlg_beginblk((struct md_mlg *)arg,
                                   MD_NS_HEAD, tok, argc, argv));
   }
   
   
   static int
   mlg_roffblkheadout(void *arg, int tok)
   {
   
           return(mlg_endblk((struct md_mlg *)arg, MD_NS_HEAD, tok));
 }  }
   
   

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

CVSweb