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

Diff for /mandoc/mdoc.c between version 1.154 and 1.161

version 1.154, 2010/07/01 22:56:17 version 1.161, 2010/08/07 20:57:33
Line 1 
Line 1 
 /*      $Id$ */  /*      $Id$ */
 /*  /*
  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@bsd.lv>   * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
    * Copyright (c) 2010 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 21 
Line 22 
 #include <sys/types.h>  #include <sys/types.h>
   
 #include <assert.h>  #include <assert.h>
 #include <ctype.h>  
 #include <stdarg.h>  #include <stdarg.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
Line 29 
Line 29 
 #include <time.h>  #include <time.h>
   
 #include "mandoc.h"  #include "mandoc.h"
 #include "regs.h"  
 #include "libmdoc.h"  #include "libmdoc.h"
 #include "libmandoc.h"  #include "libmandoc.h"
   
Line 514  mdoc_word_alloc(struct mdoc *m, int line, int pos, con
Line 513  mdoc_word_alloc(struct mdoc *m, int line, int pos, con
 }  }
   
   
 /* FIXME: put in mdoc_node_delete(). */  static void
 void  
 mdoc_node_free(struct mdoc_node *p)  mdoc_node_free(struct mdoc_node *p)
 {  {
   
           /*
            * XXX: if these end up being problematic in terms of memory
            * management and dereferencing freed blocks, then make them
            * into reference-counted double-pointers.
            */
   
         if (MDOC_Bd == p->tok && MDOC_BLOCK == p->type)          if (MDOC_Bd == p->tok && MDOC_BLOCK == p->type)
                 if (p->data.Bd)                  if (p->data.Bd)
                         free(p->data.Bd);                          free(p->data.Bd);
         if (MDOC_Bl == p->tok && MDOC_BLOCK == p->type)          if (MDOC_Bl == p->tok && MDOC_BLOCK == p->type)
                 if (p->data.Bl)                  if (p->data.Bl)
                         free(p->data.Bl);                          free(p->data.Bl);
           if (MDOC_Bf == p->tok && MDOC_HEAD == p->type)
                   if (p->data.Bf)
                           free(p->data.Bf);
   
         if (p->string)          if (p->string)
                 free(p->string);                  free(p->string);
Line 713  mdoc_ptext(struct mdoc *m, int line, char *buf, int of
Line 720  mdoc_ptext(struct mdoc *m, int line, char *buf, int of
   
         assert(buf < end);          assert(buf < end);
   
         if (mandoc_eos(buf+offs, (size_t)(end-buf-offs)))          if (mandoc_eos(buf+offs, (size_t)(end-buf-offs), 0))
                 m->last->flags |= MDOC_EOS;                  m->last->flags |= MDOC_EOS;
   
         return(1);          return(1);
Line 739  macrowarn(struct mdoc *m, int ln, const char *buf, int
Line 746  macrowarn(struct mdoc *m, int ln, const char *buf, int
  * Parse a macro line, that is, a line beginning with the control   * Parse a macro line, that is, a line beginning with the control
  * character.   * character.
  */   */
 int  static int
 mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs)  mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs)
 {  {
         enum mdoct        tok;          enum mdoct        tok;
Line 756  mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off
Line 763  mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off
   
         i = offs;          i = offs;
   
         /* Accept whitespace after the initial control char. */          /* Accept tabs/whitespace after the initial control char. */
   
         if (' ' == buf[i]) {          if (' ' == buf[i] || '\t' == buf[i]) {
                 i++;                  i++;
                 while (buf[i] && ' ' == buf[i])                  while (buf[i] && (' ' == buf[i] || '\t' == buf[i]))
                         i++;                          i++;
                 if ('\0' == buf[i])                  if ('\0' == buf[i])
                         return(1);                          return(1);
Line 768  mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off
Line 775  mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off
   
         sv = i;          sv = i;
   
         /* Copy the first word into a nil-terminated buffer. */          /*
            * Copy the first word into a nil-terminated buffer.  Stop
            * copying when a tab, space, or eoln is encountered.
            */
   
         for (j = 0; j < 4; j++, i++) {          for (j = 0; j < 4; j++, i++)
                 if ('\0' == (mac[j] = buf[i]))                  if ('\0' == (mac[j] = buf[i]))
                         break;                          break;
                 else if (' ' == buf[i])                  else if (' ' == buf[i] || '\t' == buf[i])
                         break;                          break;
   
                 /* Check for invalid characters. */  
   
                 if (isgraph((u_char)buf[i]))  
                         continue;  
                 if ( ! mdoc_pmsg(m, ln, i, MANDOCERR_BADCHAR))  
                         return(0);  
                 i--;  
         }  
   
         mac[j] = '\0';          mac[j] = '\0';
   
         if (j == 4 || j < 2) {          if (j == 4 || j < 2) {
Line 799  mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off
Line 800  mdoc_pmacro(struct mdoc *m, int ln, char *buf, int off
                 return(1);                  return(1);
         }          }
   
         /* The macro is sane.  Jump to the next word. */          /* Disregard the first trailing tab, if applicable. */
   
           if ('\t' == buf[i])
                   i++;
   
           /* Jump to the next non-whitespace word. */
   
         while (buf[i] && ' ' == buf[i])          while (buf[i] && ' ' == buf[i])
                 i++;                  i++;

Legend:
Removed from v.1.154  
changed lines
  Added in v.1.161

CVSweb