]> git.cameronkatri.com Git - mandoc.git/blobdiff - mdoc_action.c
Replacement of `Lb' in mdoc_action.c.
[mandoc.git] / mdoc_action.c
index 176dd19548a12ace760a299039b20c9c280bc721..dcb938e5f04ce08f1d0410961579b88d7343fefc 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: mdoc_action.c,v 1.25 2009/07/12 20:24:24 kristaps Exp $ */
+/*     $Id: mdoc_action.c,v 1.27 2009/07/12 20:50:08 kristaps Exp $ */
 /*
  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
  *
@@ -41,11 +41,13 @@ static      int       post_bl_width(POST_ARGS);
 static int       post_dd(POST_ARGS);
 static int       post_display(POST_ARGS);
 static int       post_dt(POST_ARGS);
+static int       post_lb(POST_ARGS);
 static int       post_lk(POST_ARGS);
 static int       post_nm(POST_ARGS);
 static int       post_os(POST_ARGS);
 static int       post_prol(POST_ARGS);
 static int       post_sh(POST_ARGS);
+static int       post_st(POST_ARGS);
 static int       post_std(POST_ARGS);
 
 static int       pre_bd(PRE_ARGS);
@@ -89,7 +91,7 @@ const struct actions mdoc_actions[MDOC_MAX] = {
        { NULL, NULL }, /* Ot */
        { NULL, NULL }, /* Pa */
        { NULL, post_std }, /* Rv */
-       { NULL, NULL }, /* St */
+       { NULL, post_st }, /* St */
        { NULL, NULL }, /* Va */
        { NULL, NULL }, /* Vt */ 
        { NULL, NULL }, /* Xr */
@@ -158,7 +160,7 @@ const       struct actions mdoc_actions[MDOC_MAX] = {
        { NULL, NULL }, /* Hf */
        { NULL, NULL }, /* Fr */
        { NULL, NULL }, /* Ud */
-       { NULL, NULL }, /* Lb */
+       { NULL, post_lb }, /* Lb */
        { NULL, NULL }, /* Lp */
        { NULL, post_lk }, /* Lk */
        { NULL, NULL }, /* Mt */
@@ -289,6 +291,52 @@ post_nm(POST_ARGS)
 }
 
 
+static int
+post_lb(POST_ARGS)
+{
+       const char      *p;
+       char            *buf;
+       size_t           sz;
+
+       assert(MDOC_TEXT == m->last->child->type);
+       p = mdoc_a2lib(m->last->child->string);
+       if (NULL == p) {
+               sz = strlen(m->last->child->string) +
+                       2 + strlen("\\(lqlibrary\\(rq");
+               buf = malloc(sz);
+               if (NULL == buf)
+                       return(mdoc_nerr(m, m->last, EMALLOC));
+               (void)snprintf(buf, sz, "library \\(lq%s\\(rq", 
+                               m->last->child->string);
+               free(m->last->child->string);
+               m->last->child->string = buf;
+               return(1);
+       }
+
+       free(m->last->child->string);
+       m->last->child->string = strdup(p);
+       if (NULL == m->last->child->string)
+               return(mdoc_nerr(m, m->last, EMALLOC));
+       return(1);
+}
+
+
+static int
+post_st(POST_ARGS)
+{
+       const char      *p;
+
+       assert(MDOC_TEXT == m->last->child->type);
+       p = mdoc_a2st(m->last->child->string);
+       assert(p);
+       free(m->last->child->string);
+       m->last->child->string = strdup(p);
+       if (NULL == m->last->child->string)
+               return(mdoc_nerr(m, m->last, EMALLOC));
+       return(1);
+}
+
+
 static int
 post_at(POST_ARGS)
 {