]> git.cameronkatri.com Git - mandoc.git/blobdiff - mdoc_argv.c
Scaling factor made floating point (as per groff.7) and, e.g., gnu/usr.bin/cvs/man...
[mandoc.git] / mdoc_argv.c
index 6e2c48b3cea630ed22ad0e83f3d1205e80d0c972..4a30cff0529d438df63e1bc7374834234ae86736 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: mdoc_argv.c,v 1.24 2009/08/20 09:07:24 kristaps Exp $ */
+/*     $Id: mdoc_argv.c,v 1.27 2009/10/07 14:52:35 kristaps Exp $ */
 /*
  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
  *
 /*
  * Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
  *
@@ -60,7 +60,7 @@ static        int mdoc_argvflags[MDOC_ARG_MAX] = {
        ARGV_NONE,      /* MDOC_Unfilled */
        ARGV_NONE,      /* MDOC_Literal */
        ARGV_NONE,      /* MDOC_File */
        ARGV_NONE,      /* MDOC_Unfilled */
        ARGV_NONE,      /* MDOC_Literal */
        ARGV_NONE,      /* MDOC_File */
-       ARGV_SINGLE,    /* MDOC_Offset */
+       ARGV_OPT_SINGLE, /* MDOC_Offset */
        ARGV_NONE,      /* MDOC_Bullet */
        ARGV_NONE,      /* MDOC_Dash */
        ARGV_NONE,      /* MDOC_Hyphen */
        ARGV_NONE,      /* MDOC_Bullet */
        ARGV_NONE,      /* MDOC_Dash */
        ARGV_NONE,      /* MDOC_Hyphen */
@@ -74,7 +74,7 @@ static        int mdoc_argvflags[MDOC_ARG_MAX] = {
        ARGV_MULTI,     /* MDOC_Column */
        ARGV_SINGLE,    /* MDOC_Width */
        ARGV_NONE,      /* MDOC_Compact */
        ARGV_MULTI,     /* MDOC_Column */
        ARGV_SINGLE,    /* MDOC_Width */
        ARGV_NONE,      /* MDOC_Compact */
-       ARGV_OPT_SINGLE, /* MDOC_Std */
+       ARGV_NONE,      /* MDOC_Std */
        ARGV_NONE,      /* MDOC_Filled */
        ARGV_NONE,      /* MDOC_Words */
        ARGV_NONE,      /* MDOC_Emphasis */
        ARGV_NONE,      /* MDOC_Filled */
        ARGV_NONE,      /* MDOC_Words */
        ARGV_NONE,      /* MDOC_Emphasis */
@@ -309,9 +309,13 @@ mdoc_argv_free(struct mdoc_arg *p)
        for (i = 0; i < (int)p->argc; i++) {
                if (0 == p->argv[i].sz)
                        continue;
        for (i = 0; i < (int)p->argc; i++) {
                if (0 == p->argv[i].sz)
                        continue;
+               if (NULL == p->argv[i].value)
+                       continue;
+
                /* LINTED */
                for (j = 0; j < (int)p->argv[i].sz; j++) 
                /* LINTED */
                for (j = 0; j < (int)p->argv[i].sz; j++) 
-                       free(p->argv[i].value[j]);
+                       if (p->argv[i].value[j])
+                               free(p->argv[i].value[j]);
 
                free(p->argv[i].value);
        }
 
                free(p->argv[i].value);
        }
@@ -553,7 +557,7 @@ args(struct mdoc *m, int line, int *pos,
 
 
 static int
 
 
 static int
-argv_a2arg(int tok, const char *argv)
+argv_a2arg(int tok, const char *p)
 {
 
        /*
 {
 
        /*
@@ -566,80 +570,80 @@ argv_a2arg(int tok, const char *argv)
 
        switch (tok) {
        case (MDOC_An):
 
        switch (tok) {
        case (MDOC_An):
-               if (0 == strcmp(argv, "split"))
+               if (0 == strcmp(p, "split"))
                        return(MDOC_Split);
                        return(MDOC_Split);
-               else if (0 == strcmp(argv, "nosplit"))
+               else if (0 == strcmp(p, "nosplit"))
                        return(MDOC_Nosplit);
                break;
 
        case (MDOC_Bd):
                        return(MDOC_Nosplit);
                break;
 
        case (MDOC_Bd):
-               if (0 == strcmp(argv, "ragged"))
+               if (0 == strcmp(p, "ragged"))
                        return(MDOC_Ragged);
                        return(MDOC_Ragged);
-               else if (0 == strcmp(argv, "unfilled"))
+               else if (0 == strcmp(p, "unfilled"))
                        return(MDOC_Unfilled);
                        return(MDOC_Unfilled);
-               else if (0 == strcmp(argv, "filled"))
+               else if (0 == strcmp(p, "filled"))
                        return(MDOC_Filled);
                        return(MDOC_Filled);
-               else if (0 == strcmp(argv, "literal"))
+               else if (0 == strcmp(p, "literal"))
                        return(MDOC_Literal);
                        return(MDOC_Literal);
-               else if (0 == strcmp(argv, "file"))
+               else if (0 == strcmp(p, "file"))
                        return(MDOC_File);
                        return(MDOC_File);
-               else if (0 == strcmp(argv, "offset"))
+               else if (0 == strcmp(p, "offset"))
                        return(MDOC_Offset);
                        return(MDOC_Offset);
-               else if (0 == strcmp(argv, "compact"))
+               else if (0 == strcmp(p, "compact"))
                        return(MDOC_Compact);
                break;
 
        case (MDOC_Bf):
                        return(MDOC_Compact);
                break;
 
        case (MDOC_Bf):
-               if (0 == strcmp(argv, "emphasis"))
+               if (0 == strcmp(p, "emphasis"))
                        return(MDOC_Emphasis);
                        return(MDOC_Emphasis);
-               else if (0 == strcmp(argv, "literal"))
+               else if (0 == strcmp(p, "literal"))
                        return(MDOC_Literal);
                        return(MDOC_Literal);
-               else if (0 == strcmp(argv, "symbolic"))
+               else if (0 == strcmp(p, "symbolic"))
                        return(MDOC_Symbolic);
                break;
 
        case (MDOC_Bk):
                        return(MDOC_Symbolic);
                break;
 
        case (MDOC_Bk):
-               if (0 == strcmp(argv, "words"))
+               if (0 == strcmp(p, "words"))
                        return(MDOC_Words);
                break;
 
        case (MDOC_Bl):
                        return(MDOC_Words);
                break;
 
        case (MDOC_Bl):
-               if (0 == strcmp(argv, "bullet"))
+               if (0 == strcmp(p, "bullet"))
                        return(MDOC_Bullet);
                        return(MDOC_Bullet);
-               else if (0 == strcmp(argv, "dash"))
+               else if (0 == strcmp(p, "dash"))
                        return(MDOC_Dash);
                        return(MDOC_Dash);
-               else if (0 == strcmp(argv, "hyphen"))
+               else if (0 == strcmp(p, "hyphen"))
                        return(MDOC_Hyphen);
                        return(MDOC_Hyphen);
-               else if (0 == strcmp(argv, "item"))
+               else if (0 == strcmp(p, "item"))
                        return(MDOC_Item);
                        return(MDOC_Item);
-               else if (0 == strcmp(argv, "enum"))
+               else if (0 == strcmp(p, "enum"))
                        return(MDOC_Enum);
                        return(MDOC_Enum);
-               else if (0 == strcmp(argv, "tag"))
+               else if (0 == strcmp(p, "tag"))
                        return(MDOC_Tag);
                        return(MDOC_Tag);
-               else if (0 == strcmp(argv, "diag"))
+               else if (0 == strcmp(p, "diag"))
                        return(MDOC_Diag);
                        return(MDOC_Diag);
-               else if (0 == strcmp(argv, "hang"))
+               else if (0 == strcmp(p, "hang"))
                        return(MDOC_Hang);
                        return(MDOC_Hang);
-               else if (0 == strcmp(argv, "ohang"))
+               else if (0 == strcmp(p, "ohang"))
                        return(MDOC_Ohang);
                        return(MDOC_Ohang);
-               else if (0 == strcmp(argv, "inset"))
+               else if (0 == strcmp(p, "inset"))
                        return(MDOC_Inset);
                        return(MDOC_Inset);
-               else if (0 == strcmp(argv, "column"))
+               else if (0 == strcmp(p, "column"))
                        return(MDOC_Column);
                        return(MDOC_Column);
-               else if (0 == strcmp(argv, "width"))
+               else if (0 == strcmp(p, "width"))
                        return(MDOC_Width);
                        return(MDOC_Width);
-               else if (0 == strcmp(argv, "offset"))
+               else if (0 == strcmp(p, "offset"))
                        return(MDOC_Offset);
                        return(MDOC_Offset);
-               else if (0 == strcmp(argv, "compact"))
+               else if (0 == strcmp(p, "compact"))
                        return(MDOC_Compact);
                        return(MDOC_Compact);
-               else if (0 == strcmp(argv, "nested"))
+               else if (0 == strcmp(p, "nested"))
                        return(MDOC_Nested);
                break;
        
        case (MDOC_Rv):
                /* FALLTHROUGH */
        case (MDOC_Ex):
                        return(MDOC_Nested);
                break;
        
        case (MDOC_Rv):
                /* FALLTHROUGH */
        case (MDOC_Ex):
-               if (0 == strcmp(argv, "std"))
+               if (0 == strcmp(p, "std"))
                        return(MDOC_Std);
                break;
        default:
                        return(MDOC_Std);
                break;
        default: