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

Diff for /mandoc/Attic/dummy.c between version 1.4 and 1.6

version 1.4, 2008/11/24 18:32:39 version 1.6, 2008/11/25 16:49:57
Line 25 
Line 25 
 #include "libmdocml.h"  #include "libmdocml.h"
 #include "private.h"  #include "private.h"
   
   #ifdef  __linux__
   #define strlcat         strncat
   #endif
   
 static roffin           in[ROFF_MAX];  static  int             md_dummy_blk_in(int);
 static roffout          out[ROFF_MAX];  static  int             md_dummy_blk_out(int);
 static roffblkin        blkin[ROFF_MAX];  static  int             md_dummy_text_in(int, int *, char **);
 static roffblkout       blkout[ROFF_MAX];  static  int             md_dummy_text_out(int);
   
 static int              md_dummy_blk_in(int);  static  void            dbg_prologue(const char *);
 static int              md_dummy_blk_out(int);  static  void            dbg_epilogue(void);
 static int              md_dummy_text_in(int, int *, char **);  
 static int              md_dummy_text_out(int);  
   
 static void             dbg_indent(void);  static  int             dbg_lvl = 0;
   static  char            dbg_line[72];
   
 static int              dbg_lvl = 0;  
   
 struct  md_dummy {  struct  md_dummy {
         struct rofftree *tree;          struct rofftree *tree;
 };  };
   
   
 static void  static void
 dbg_indent(void)  dbg_prologue(const char *p)
 {  {
         char            buf[128];          int              i;
         int             i;  
   
         *buf = 0;          (void)snprintf(dbg_line, sizeof(dbg_line) - 1, "%6s", p);
         assert(dbg_lvl >= 0);          (void)strlcat(dbg_line, ": ", sizeof(dbg_line) - 1);
           /* LINTED */
         for (i = 0; i < dbg_lvl; i++)          for (i = 0; i < dbg_lvl; i++)
                 (void)strncat(buf, "  ", sizeof(buf) - 1);                  (void)strlcat(dbg_line, "    ", sizeof(dbg_line) - 1);
   }
   
         (void)printf("%s", buf);  
   static void
   dbg_epilogue(void)
   {
   
           assert(0 != dbg_line[0]);
           (void)printf("%s\n", dbg_line);
 }  }
   
   
Line 64  static int
Line 70  static int
 md_dummy_blk_in(int tok)  md_dummy_blk_in(int tok)
 {  {
   
         dbg_indent();          dbg_prologue("blk");
         (void)printf("+++blk\n");          (void)strlcat(dbg_line, toknames[tok], sizeof(dbg_line) - 1);
           dbg_epilogue();
   
         dbg_lvl++;          dbg_lvl++;
         return(1);          return(1);
 }  }
Line 75  static int
Line 83  static int
 md_dummy_blk_out(int tok)  md_dummy_blk_out(int tok)
 {  {
   
         assert(dbg_lvl > 0);  
         dbg_lvl--;          dbg_lvl--;
         dbg_indent();  
         (void)printf("---blk\n");  
         return(1);          return(1);
 }  }
   
   
   /* ARGSUSED */
 static int  static int
 md_dummy_text_in(int tok, int *argcp, char **argvp)  md_dummy_text_in(int tok, int *argcp, char **argvp)
 {  {
   
         dbg_indent();          dbg_prologue("text");
         (void)printf("in: text\n");          (void)strlcat(dbg_line, toknames[tok], sizeof(dbg_line) - 1);
           (void)strlcat(dbg_line, " ", sizeof(dbg_line) - 1);
           while (ROFF_ARGMAX != *argcp) {
                   (void)strlcat(dbg_line, "[", sizeof(dbg_line) - 1);
                   (void)strlcat(dbg_line, tokargnames[*argcp],
                                   sizeof(dbg_line) - 1);
                   if (*argvp) {
                           (void)strlcat(dbg_line, " [",
                                           sizeof(dbg_line) - 1);
                           (void)strlcat(dbg_line, *argvp,
                                           sizeof(dbg_line) - 1);
                           (void)strlcat(dbg_line, "]",
                                           sizeof(dbg_line) - 1);
                   }
                   (void)strlcat(dbg_line, "]", sizeof(dbg_line) - 1);
                   argcp++;
                   argvp++;
           }
           dbg_epilogue();
         return(1);          return(1);
 }  }
   
Line 97  static int
Line 121  static int
 md_dummy_text_out(int tok)  md_dummy_text_out(int tok)
 {  {
   
         dbg_indent();  
         (void)printf("out: text\n");  
         return(1);          return(1);
 }  }
   
Line 132  md_init_dummy(const struct md_args *args,
Line 154  md_init_dummy(const struct md_args *args,
                 struct md_mbuf *mbuf, const struct md_rbuf *rbuf)                  struct md_mbuf *mbuf, const struct md_rbuf *rbuf)
 {  {
         struct md_dummy *p;          struct md_dummy *p;
         int              i;  
   
         for (i = 0; i < ROFF_MAX; i++) {  
                 in[i] = md_dummy_text_in;  
                 out[i] = md_dummy_text_out;  
                 blkin[i] = md_dummy_blk_in;  
                 blkout[i] = md_dummy_blk_out;  
         }  
   
         if (NULL == (p = malloc(sizeof(struct md_dummy)))) {          if (NULL == (p = malloc(sizeof(struct md_dummy)))) {
                 warn("malloc");                  warn("malloc");
                 return(NULL);                  return(NULL);
         }          }
   
         p->tree = roff_alloc          p->tree = roff_alloc(args, mbuf, rbuf,
                 (args, mbuf, rbuf, in, out, blkin, blkout);                          md_dummy_text_in, md_dummy_text_out,
                           md_dummy_blk_in, md_dummy_blk_out);
   
         if (NULL == p->tree) {          if (NULL == p->tree) {
                 free(p);                  free(p);

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.6

CVSweb