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

Diff for /mandoc/Attic/mdoc_action.c between version 1.58 and 1.59

version 1.58, 2010/05/15 16:24:38 version 1.59, 2010/05/17 22:11:42
Line 28 
Line 28 
 #include <string.h>  #include <string.h>
 #include <time.h>  #include <time.h>
   
   #include "mandoc.h"
 #include "libmdoc.h"  #include "libmdoc.h"
 #include "libmandoc.h"  #include "libmandoc.h"
   
Line 269  concat(struct mdoc *m, char *p, const struct mdoc_node
Line 270  concat(struct mdoc *m, char *p, const struct mdoc_node
         p[0] = '\0';          p[0] = '\0';
         for ( ; n; n = n->next) {          for ( ; n; n = n->next) {
                 assert(MDOC_TEXT == n->type);                  assert(MDOC_TEXT == n->type);
                 if (strlcat(p, n->string, sz) >= sz)                  /*
                         return(mdoc_nerr(m, n, ETOOLONG));                   * XXX: yes, these can technically be resized, but it's
                    * highly unlikely that we're going to get here, so let
                    * it slip for now.
                    */
                   if (strlcat(p, n->string, sz) >= sz) {
                           mdoc_nmsg(m, n, MANDOCERR_MEM);
                           return(0);
                   }
                 if (NULL == n->next)                  if (NULL == n->next)
                         continue;                          continue;
                 if (strlcat(p, " ", sz) >= sz)                  if (strlcat(p, " ", sz) >= sz) {
                         return(mdoc_nerr(m, n, ETOOLONG));                          mdoc_nmsg(m, n, MANDOCERR_MEM);
                           return(0);
                   }
         }          }
   
         return(1);          return(1);
Line 288  concat(struct mdoc *m, char *p, const struct mdoc_node
Line 298  concat(struct mdoc *m, char *p, const struct mdoc_node
 static int  static int
 post_std(POST_ARGS)  post_std(POST_ARGS)
 {  {
         struct mdoc_node        *nn;          struct mdoc_node *nn;
   
         if (n->child)          if (n->child)
                 return(1);                  return(1);
           if (NULL == m->meta.name)
                   return(1);
   
         nn = n;          nn = n;
         m->next = MDOC_NEXT_CHILD;          m->next = MDOC_NEXT_CHILD;
         assert(m->meta.name);  
         if ( ! mdoc_word_alloc(m, n->line, n->pos, m->meta.name))          if ( ! mdoc_word_alloc(m, n->line, n->pos, m->meta.name))
                 return(0);                  return(0);
         m->last = nn;          m->last = nn;
Line 453  post_sh(POST_ARGS)
Line 465  post_sh(POST_ARGS)
                         break;                          break;
                 if (*m->meta.msec == '9')                  if (*m->meta.msec == '9')
                         break;                          break;
                 return(mdoc_nwarn(m, n, EWRONGMSEC));                  return(mdoc_nmsg(m, n, MANDOCERR_SECMSEC));
         default:          default:
                 break;                  break;
         }          }
Line 517  post_dt(POST_ARGS)
Line 529  post_dt(POST_ARGS)
         if (cp) {          if (cp) {
                 m->meta.vol = mandoc_strdup(cp);                  m->meta.vol = mandoc_strdup(cp);
                 m->meta.msec = mandoc_strdup(nn->string);                  m->meta.msec = mandoc_strdup(nn->string);
         } else if (mdoc_nwarn(m, n, EBADMSEC)) {          } else if (mdoc_nmsg(m, n, MANDOCERR_BADMSEC)) {
                 m->meta.vol = mandoc_strdup(nn->string);                  m->meta.vol = mandoc_strdup(nn->string);
                 m->meta.msec = mandoc_strdup(nn->string);                  m->meta.msec = mandoc_strdup(nn->string);
         } else          } else
Line 574  post_os(POST_ARGS)
Line 586  post_os(POST_ARGS)
         if ( ! concat(m, buf, n->child, BUFSIZ))          if ( ! concat(m, buf, n->child, BUFSIZ))
                 return(0);                  return(0);
   
           /* XXX: yes, these can all be dynamically-adjusted buffers, but
            * it's really not worth the extra hackery.
            */
   
         if ('\0' == buf[0]) {          if ('\0' == buf[0]) {
 #ifdef OSNAME  #ifdef OSNAME
                 if (strlcat(buf, OSNAME, BUFSIZ) >= BUFSIZ)                  if (strlcat(buf, OSNAME, BUFSIZ) >= BUFSIZ) {
                         return(mdoc_nerr(m, n, EUTSNAME));                          mdoc_nmsg(m, n, MANDOCERR_MEM);
                           return(0);
                   }
 #else /*!OSNAME */  #else /*!OSNAME */
                 if (-1 == uname(&utsname))                  if (-1 == uname(&utsname))
                         return(mdoc_nerr(m, n, EUTSNAME));                          return(mdoc_nmsg(m, n, MANDOCERR_UTSNAME));
                 if (strlcat(buf, utsname.sysname, BUFSIZ) >= BUFSIZ)  
                         return(mdoc_nerr(m, n, ETOOLONG));                  if (strlcat(buf, utsname.sysname, BUFSIZ) >= BUFSIZ) {
                 if (strlcat(buf, " ", 64) >= BUFSIZ)                          mdoc_nmsg(m, n, MANDOCERR_MEM);
                         return(mdoc_nerr(m, n, ETOOLONG));                          return(0);
                 if (strlcat(buf, utsname.release, BUFSIZ) >= BUFSIZ)                  }
                         return(mdoc_nerr(m, n, ETOOLONG));                  if (strlcat(buf, " ", 64) >= BUFSIZ) {
                           mdoc_nmsg(m, n, MANDOCERR_MEM);
                           return(0);
                   }
                   if (strlcat(buf, utsname.release, BUFSIZ) >= BUFSIZ) {
                           mdoc_nmsg(m, n, MANDOCERR_MEM);
                           return(0);
                   }
 #endif /*!OSNAME*/  #endif /*!OSNAME*/
         }          }
   
Line 621  post_bl_tagwidth(POST_ARGS)
Line 646  post_bl_tagwidth(POST_ARGS)
                 if (MDOC_TEXT != nn->type) {                  if (MDOC_TEXT != nn->type) {
                         sz = mdoc_macro2len(nn->tok);                          sz = mdoc_macro2len(nn->tok);
                         if (sz == 0) {                          if (sz == 0) {
                                 if ( ! mdoc_nwarn(m, n, ENOWIDTH))                                  if ( ! mdoc_nmsg(m, n, MANDOCERR_NOWIDTHARG))
                                         return(0);                                          return(0);
                                 sz = 10;                                  sz = 10;
                         }                          }
Line 684  post_bl_width(POST_ARGS)
Line 709  post_bl_width(POST_ARGS)
          */           */
   
         if (0 == strcmp(p, "Ds"))          if (0 == strcmp(p, "Ds"))
                 /* XXX: make into a macro. */  
                 width = 6;                  width = 6;
         else if (MDOC_MAX == (tok = mdoc_hash_find(p)))          else if (MDOC_MAX == (tok = mdoc_hash_find(p)))
                 return(1);                  return(1);
         else if (0 == (width = mdoc_macro2len(tok)))          else if (0 == (width = mdoc_macro2len(tok)))
                 return(mdoc_nwarn(m, n, ENOWIDTH));                  return(mdoc_nmsg(m, n, MANDOCERR_BADWIDTH));
   
         /* The value already exists: free and reallocate it. */          /* The value already exists: free and reallocate it. */
   
Line 848  post_dd(POST_ARGS)
Line 872  post_dd(POST_ARGS)
                 (MTIME_MDOCDATE | MTIME_CANONICAL, buf);                  (MTIME_MDOCDATE | MTIME_CANONICAL, buf);
   
         if (0 == m->meta.date) {          if (0 == m->meta.date) {
                 if ( ! mdoc_nwarn(m, n, EBADDATE))                  if ( ! mdoc_nmsg(m, n, MANDOCERR_BADDATE))
                         return(0);                          return(0);
                 m->meta.date = time(NULL);                  m->meta.date = time(NULL);
         }          }

Legend:
Removed from v.1.58  
changed lines
  Added in v.1.59

CVSweb