Annotation of mandoc/strings.c, Revision 1.23
1.23 ! kristaps 1: /* $Id: strings.c,v 1.22 2009/02/27 10:55:16 kristaps Exp $ */
1.1 kristaps 2: /*
3: * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
4: *
5: * Permission to use, copy, modify, and distribute this software for any
6: * purpose with or without fee is hereby granted, provided that the
7: * above copyright notice and this permission notice appear in all
8: * copies.
9: *
10: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11: * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12: * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13: * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14: * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15: * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16: * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17: * PERFORMANCE OF THIS SOFTWARE.
18: */
19: #include <assert.h>
20: #include <ctype.h>
21: #include <stdlib.h>
22: #include <stdio.h>
1.2 kristaps 23: #include <string.h>
1.15 kristaps 24: #ifndef __OpenBSD__
1.4 kristaps 25: #include <time.h>
26: #endif
1.1 kristaps 27:
1.14 kristaps 28: /*
29: * Convert scalars to and from string format.
30: */
31:
1.1 kristaps 32: #include "private.h"
33:
1.4 kristaps 34: #ifdef __linux__
35: extern char *strptime(const char *, const char *, struct tm *);
36: #endif
37:
1.16 kristaps 38:
39: size_t
40: mdoc_isescape(const char *p)
41: {
42: size_t c;
43:
44: if ('\\' != *p++)
45: return(0);
46:
47: switch (*p) {
48: case ('\\'):
49: /* FALLTHROUGH */
50: case ('\''):
51: /* FALLTHROUGH */
52: case ('`'):
53: /* FALLTHROUGH */
54: case ('-'):
55: /* FALLTHROUGH */
56: case (' '):
57: /* FALLTHROUGH */
1.17 kristaps 58: case ('&'):
59: /* FALLTHROUGH */
1.16 kristaps 60: case ('.'):
61: /* FALLTHROUGH */
62: case ('e'):
63: return(2);
1.21 kristaps 64: case ('*'):
65: if (0 == *++p || ! isgraph((int)*p))
66: return(0);
67: switch (*p) {
68: case ('('):
69: if (0 == *++p || ! isgraph((int)*p))
70: return(0);
71: return(4);
72: default:
73: break;
74: }
75: return(3);
1.16 kristaps 76: case ('('):
1.19 kristaps 77: if (0 == *++p || ! isgraph((int)*p))
1.16 kristaps 78: return(0);
1.19 kristaps 79: if (0 == *++p || ! isgraph((int)*p))
1.16 kristaps 80: return(0);
81: return(4);
82: case ('['):
83: break;
84: default:
85: return(0);
86: }
87:
88: for (c = 3, p++; *p && ']' != *p; p++, c++)
1.19 kristaps 89: if ( ! isgraph((int)*p))
1.16 kristaps 90: break;
91:
92: return(*p == ']' ? c : 0);
93: }
94:
95:
1.1 kristaps 96: int
1.3 kristaps 97: mdoc_iscdelim(char p)
1.1 kristaps 98: {
99:
1.3 kristaps 100: switch (p) {
1.1 kristaps 101: case('.'):
102: /* FALLTHROUGH */
103: case(','):
104: /* FALLTHROUGH */
105: case(';'):
106: /* FALLTHROUGH */
107: case(':'):
108: /* FALLTHROUGH */
109: case('?'):
110: /* FALLTHROUGH */
111: case('!'):
112: /* FALLTHROUGH */
113: case('('):
114: /* FALLTHROUGH */
115: case(')'):
116: /* FALLTHROUGH */
117: case('['):
118: /* FALLTHROUGH */
119: case(']'):
120: /* FALLTHROUGH */
1.7 kristaps 121: case('{'):
122: /* FALLTHROUGH */
1.1 kristaps 123: case('}'):
124: return(1);
125: default:
126: break;
127: }
128:
129: return(0);
130: }
131:
1.2 kristaps 132:
1.3 kristaps 133: int
134: mdoc_isdelim(const char *p)
135: {
136:
137: if (0 == *p)
138: return(0);
139: if (0 != *(p + 1))
140: return(0);
141: return(mdoc_iscdelim(*p));
142: }
143:
144:
1.2 kristaps 145: enum mdoc_sec
1.9 kristaps 146: mdoc_atosec(const char *p)
1.2 kristaps 147: {
148:
1.9 kristaps 149: assert(p);
150: if (0 == strcmp(p, "NAME"))
1.2 kristaps 151: return(SEC_NAME);
1.9 kristaps 152: else if (0 == strcmp(p, "RETURN VALUES"))
153: return(SEC_RETURN_VALUES);
154: else if (0 == strcmp(p, "SEE ALSO"))
155: return(SEC_SEE_ALSO);
156: else if (0 == strcmp(p, "SYNOPSIS"))
1.2 kristaps 157: return(SEC_SYNOPSIS);
1.9 kristaps 158: else if (0 == strcmp(p, "DESCRIPTION"))
1.2 kristaps 159: return(SEC_DESCRIPTION);
1.9 kristaps 160: else if (0 == strcmp(p, "ENVIRONMENT"))
1.2 kristaps 161: return(SEC_ENVIRONMENT);
1.9 kristaps 162: else if (0 == strcmp(p, "FILES"))
1.2 kristaps 163: return(SEC_FILES);
1.9 kristaps 164: else if (0 == strcmp(p, "EXAMPLES"))
1.2 kristaps 165: return(SEC_EXAMPLES);
1.9 kristaps 166: else if (0 == strcmp(p, "DIAGNOSTICS"))
1.2 kristaps 167: return(SEC_DIAGNOSTICS);
1.9 kristaps 168: else if (0 == strcmp(p, "ERRORS"))
1.2 kristaps 169: return(SEC_ERRORS);
1.9 kristaps 170: else if (0 == strcmp(p, "STANDARDS"))
1.2 kristaps 171: return(SEC_STANDARDS);
1.9 kristaps 172: else if (0 == strcmp(p, "HISTORY"))
1.2 kristaps 173: return(SEC_HISTORY);
1.9 kristaps 174: else if (0 == strcmp(p, "AUTHORS"))
1.2 kristaps 175: return(SEC_AUTHORS);
1.9 kristaps 176: else if (0 == strcmp(p, "CAVEATS"))
1.2 kristaps 177: return(SEC_CAVEATS);
1.9 kristaps 178: else if (0 == strcmp(p, "BUGS"))
1.2 kristaps 179: return(SEC_BUGS);
180:
181: return(SEC_CUSTOM);
182: }
183:
184:
185: time_t
186: mdoc_atotime(const char *p)
187: {
188: struct tm tm;
1.11 kristaps 189: char *pp;
1.2 kristaps 190:
1.5 kristaps 191: (void)memset(&tm, 0, sizeof(struct tm));
192:
1.11 kristaps 193: if (xstrcmp(p, "$Mdocdate$"))
194: return(time(NULL));
195: if ((pp = strptime(p, "$Mdocdate: %b %d %Y $", &tm)) && 0 == *pp)
1.2 kristaps 196: return(mktime(&tm));
1.11 kristaps 197: /* XXX - this matches "June 1999", which is wrong. */
198: if ((pp = strptime(p, "%b %d %Y", &tm)) && 0 == *pp)
199: return(mktime(&tm));
200: if ((pp = strptime(p, "%b %d, %Y", &tm)) && 0 == *pp)
1.2 kristaps 201: return(mktime(&tm));
202:
203: return(0);
204: }
205:
206:
207: enum mdoc_msec
208: mdoc_atomsec(const char *p)
209: {
210:
211: if (0 == strcmp(p, "1"))
212: return(MSEC_1);
213: else if (0 == strcmp(p, "2"))
214: return(MSEC_2);
215: else if (0 == strcmp(p, "3"))
216: return(MSEC_3);
217: else if (0 == strcmp(p, "3f"))
218: return(MSEC_3f);
219: else if (0 == strcmp(p, "3p"))
220: return(MSEC_3p);
221: else if (0 == strcmp(p, "4"))
222: return(MSEC_4);
223: else if (0 == strcmp(p, "5"))
224: return(MSEC_5);
225: else if (0 == strcmp(p, "6"))
226: return(MSEC_6);
227: else if (0 == strcmp(p, "7"))
228: return(MSEC_7);
229: else if (0 == strcmp(p, "8"))
230: return(MSEC_8);
231: else if (0 == strcmp(p, "9"))
232: return(MSEC_9);
233: else if (0 == strcmp(p, "X11"))
234: return(MSEC_X11);
235: else if (0 == strcmp(p, "X11R6"))
236: return(MSEC_X11R6);
237: else if (0 == strcmp(p, "local"))
238: return(MSEC_local);
239: else if (0 == strcmp(p, "n"))
240: return(MSEC_n);
241: else if (0 == strcmp(p, "unass"))
242: return(MSEC_unass);
243: else if (0 == strcmp(p, "draft"))
244: return(MSEC_draft);
245: else if (0 == strcmp(p, "paper"))
246: return(MSEC_paper);
247:
248: return(MSEC_DEFAULT);
249: }
250:
251:
252: enum mdoc_vol
253: mdoc_atovol(const char *p)
254: {
255:
256: if (0 == strcmp(p, "AMD"))
257: return(VOL_AMD);
258: else if (0 == strcmp(p, "IND"))
259: return(VOL_IND);
260: else if (0 == strcmp(p, "KM"))
261: return(VOL_KM);
262: else if (0 == strcmp(p, "LOCAL"))
263: return(VOL_LOCAL);
264: else if (0 == strcmp(p, "PRM"))
265: return(VOL_PRM);
266: else if (0 == strcmp(p, "PS1"))
267: return(VOL_PS1);
268: else if (0 == strcmp(p, "SMM"))
269: return(VOL_SMM);
270: else if (0 == strcmp(p, "URM"))
271: return(VOL_URM);
272: else if (0 == strcmp(p, "USD"))
273: return(VOL_USD);
274:
275: return(VOL_DEFAULT);
276: }
277:
278:
279: enum mdoc_arch
280: mdoc_atoarch(const char *p)
281: {
282:
283: if (0 == strcmp(p, "alpha"))
284: return(ARCH_alpha);
285: else if (0 == strcmp(p, "amd64"))
286: return(ARCH_amd64);
287: else if (0 == strcmp(p, "amiga"))
288: return(ARCH_amiga);
289: else if (0 == strcmp(p, "arc"))
290: return(ARCH_arc);
1.8 kristaps 291: else if (0 == strcmp(p, "arm"))
292: return(ARCH_arm);
1.2 kristaps 293: else if (0 == strcmp(p, "armish"))
294: return(ARCH_armish);
295: else if (0 == strcmp(p, "aviion"))
296: return(ARCH_aviion);
297: else if (0 == strcmp(p, "hp300"))
298: return(ARCH_hp300);
299: else if (0 == strcmp(p, "hppa"))
300: return(ARCH_hppa);
301: else if (0 == strcmp(p, "hppa64"))
302: return(ARCH_hppa64);
303: else if (0 == strcmp(p, "i386"))
304: return(ARCH_i386);
305: else if (0 == strcmp(p, "landisk"))
306: return(ARCH_landisk);
307: else if (0 == strcmp(p, "luna88k"))
308: return(ARCH_luna88k);
309: else if (0 == strcmp(p, "mac68k"))
310: return(ARCH_mac68k);
311: else if (0 == strcmp(p, "macppc"))
312: return(ARCH_macppc);
313: else if (0 == strcmp(p, "mvme68k"))
314: return(ARCH_mvme68k);
315: else if (0 == strcmp(p, "mvme88k"))
316: return(ARCH_mvme88k);
317: else if (0 == strcmp(p, "mvmeppc"))
318: return(ARCH_mvmeppc);
319: else if (0 == strcmp(p, "pmax"))
320: return(ARCH_pmax);
321: else if (0 == strcmp(p, "sgi"))
322: return(ARCH_sgi);
323: else if (0 == strcmp(p, "socppc"))
324: return(ARCH_socppc);
325: else if (0 == strcmp(p, "sparc"))
326: return(ARCH_sparc);
327: else if (0 == strcmp(p, "sparc64"))
328: return(ARCH_sparc64);
329: else if (0 == strcmp(p, "sun3"))
330: return(ARCH_sun3);
331: else if (0 == strcmp(p, "vax"))
332: return(ARCH_vax);
333: else if (0 == strcmp(p, "zaurus"))
334: return(ARCH_zaurus);
335:
336: return(ARCH_DEFAULT);
337: }
1.4 kristaps 338:
339:
340: enum mdoc_att
341: mdoc_atoatt(const char *p)
342: {
343:
344: assert(p);
345: if (0 == strcmp(p, "v1"))
346: return(ATT_v1);
347: else if (0 == strcmp(p, "v2"))
348: return(ATT_v2);
349: else if (0 == strcmp(p, "v3"))
350: return(ATT_v3);
351: else if (0 == strcmp(p, "v4"))
352: return(ATT_v4);
353: else if (0 == strcmp(p, "v5"))
354: return(ATT_v5);
355: else if (0 == strcmp(p, "v6"))
356: return(ATT_v6);
357: else if (0 == strcmp(p, "v7"))
358: return(ATT_v7);
359: else if (0 == strcmp(p, "32v"))
360: return(ATT_32v);
1.23 ! kristaps 361: else if (0 == strcmp(p, "V"))
! 362: return(ATT_V);
1.4 kristaps 363: else if (0 == strcmp(p, "V.1"))
364: return(ATT_V1);
365: else if (0 == strcmp(p, "V.2"))
366: return(ATT_V2);
367: else if (0 == strcmp(p, "V.3"))
368: return(ATT_V3);
369: else if (0 == strcmp(p, "V.4"))
370: return(ATT_V4);
371:
372: return(ATT_DEFAULT);
373: }
1.6 kristaps 374:
375:
376: char *
377: mdoc_type2a(enum mdoc_type type)
378: {
379: switch (type) {
380: case (MDOC_ROOT):
381: return("root");
382: case (MDOC_BLOCK):
383: return("block");
384: case (MDOC_HEAD):
385: return("block-head");
386: case (MDOC_BODY):
387: return("block-body");
388: case (MDOC_TAIL):
389: return("block-tail");
390: case (MDOC_ELEM):
391: return("elem");
392: case (MDOC_TEXT):
393: return("text");
394: default:
395: break;
396: }
397:
398: abort();
399: /* NOTREACHED */
400: }
1.12 kristaps 401:
402:
1.13 kristaps 403: const char *
1.12 kristaps 404: mdoc_arch2a(enum mdoc_arch arch)
405: {
406:
407: switch (arch) {
408: case (ARCH_alpha):
409: return("Alpha");
410: case (ARCH_amd64):
411: return("AMD64");
412: case (ARCH_amiga):
413: return("Amiga");
414: case (ARCH_arc):
415: return("ARC");
416: case (ARCH_arm):
417: return("ARM");
418: case (ARCH_armish):
419: return("ARMISH");
420: case (ARCH_aviion):
1.20 kristaps 421: return("AViiON");
1.12 kristaps 422: case (ARCH_hp300):
423: return("HP300");
424: case (ARCH_hppa):
425: return("HPPA");
426: case (ARCH_hppa64):
427: return("HPPA64");
428: case (ARCH_i386):
429: return("i386");
430: case (ARCH_landisk):
431: return("LANDISK");
432: case (ARCH_luna88k):
433: return("Luna88k");
434: case (ARCH_mac68k):
435: return("Mac68k");
436: case (ARCH_macppc):
437: return("MacPPC");
438: case (ARCH_mvme68k):
439: return("MVME68k");
440: case (ARCH_mvme88k):
441: return("MVME88k");
442: case (ARCH_mvmeppc):
443: return("MVMEPPC");
444: case (ARCH_pmax):
445: return("PMAX");
446: case (ARCH_sgi):
447: return("SGI");
448: case (ARCH_socppc):
449: return("SOCPPC");
450: case (ARCH_sparc):
451: return("SPARC");
452: case (ARCH_sparc64):
453: return("SPARC64");
454: case (ARCH_sun3):
455: return("Sun3");
456: case (ARCH_vax):
457: return("VAX");
458: case (ARCH_zaurus):
459: return("Zaurus");
460: case (ARCH_DEFAULT):
461: return(NULL);
462: default:
463: break;
464: }
465:
466: abort();
467: /* NOTREACHED */
468: }
469:
470:
1.13 kristaps 471: const char *
1.12 kristaps 472: mdoc_vol2a(enum mdoc_vol vol)
473: {
474:
475: switch (vol) {
476: case (VOL_AMD):
1.22 kristaps 477: return("Ancestral Manual Documents");
1.12 kristaps 478: case (VOL_IND):
1.22 kristaps 479: return("Manual Master Index");
1.12 kristaps 480: case (VOL_KM):
1.22 kristaps 481: return("Kernel Manual");
1.12 kristaps 482: case (VOL_LOCAL):
1.22 kristaps 483: return("Local Manual");
1.12 kristaps 484: case (VOL_PRM):
1.22 kristaps 485: return("Programmer's Manual");
1.12 kristaps 486: case (VOL_PS1):
1.22 kristaps 487: return("Programmer's Supplementary Documents");
1.12 kristaps 488: case (VOL_SMM):
1.22 kristaps 489: return("System Manager's Manual");
1.12 kristaps 490: case (VOL_URM):
1.22 kristaps 491: return("Reference Manual");
1.12 kristaps 492: case (VOL_USD):
1.22 kristaps 493: return("User's Supplementary Documents");
1.12 kristaps 494: case (VOL_DEFAULT):
495: return(NULL);
496: default:
497: break;
498: }
499:
500: abort();
501: /* NOTREACHED */
502: }
503:
504:
1.13 kristaps 505: const char *
1.12 kristaps 506: mdoc_msec2a(enum mdoc_msec msec)
507: {
508:
509: switch (msec) {
510: case(MSEC_1):
511: return("1");
512: case(MSEC_2):
513: return("2");
514: case(MSEC_3):
515: return("3");
516: case(MSEC_3f):
517: return("3f");
518: case(MSEC_3p):
519: return("3p");
520: case(MSEC_4):
521: return("4");
522: case(MSEC_5):
523: return("5");
524: case(MSEC_6):
525: return("6");
526: case(MSEC_7):
527: return("7");
528: case(MSEC_8):
529: return("8");
530: case(MSEC_9):
531: return("9");
532: case(MSEC_X11):
533: return("X11");
534: case(MSEC_X11R6):
535: return("X11R6");
536: case(MSEC_local):
537: return("local");
538: case(MSEC_n):
539: return("n");
540: case(MSEC_unass):
541: /* FALLTHROUGH */
542: case(MSEC_draft):
543: return("draft");
544: case(MSEC_paper):
545: return("paper");
546: case(MSEC_DEFAULT):
547: return(NULL);
548: default:
549: break;
550: }
551:
552: abort();
553: /* NOTREACHED */
554: }
555:
1.18 kristaps 556:
557: const char *
558: mdoc_st2a(int c)
559: {
560: char *p;
561:
562: switch (c) {
563: case(MDOC_p1003_1_88):
564: p = "IEEE Std 1003.1-1988 (\\(lqPOSIX\\(rq)";
565: break;
566: case(MDOC_p1003_1_90):
567: p = "IEEE Std 1003.1-1990 (\\(lqPOSIX\\(rq)";
568: break;
569: case(MDOC_p1003_1_96):
570: p = "ISO/IEC 9945-1:1996 (\\(lqPOSIX\\(rq)";
571: break;
572: case(MDOC_p1003_1_2001):
573: p = "IEEE Std 1003.1-2001 (\\(lqPOSIX\\(rq)";
574: break;
575: case(MDOC_p1003_1_2004):
576: p = "IEEE Std 1003.1-2004 (\\(lqPOSIX\\(rq)";
577: break;
578: case(MDOC_p1003_1):
579: p = "IEEE Std 1003.1 (\\(lqPOSIX\\(rq)";
580: break;
581: case(MDOC_p1003_1b):
582: p = "IEEE Std 1003.1b (\\(lqPOSIX\\(rq)";
583: break;
584: case(MDOC_p1003_1b_93):
585: p = "IEEE Std 1003.1b-1993 (\\(lqPOSIX\\(rq)";
586: break;
587: case(MDOC_p1003_1c_95):
588: p = "IEEE Std 1003.1c-1995 (\\(lqPOSIX\\(rq)";
589: break;
590: case(MDOC_p1003_1g_2000):
591: p = "IEEE Std 1003.1g-2000 (\\(lqPOSIX\\(rq)";
592: break;
593: case(MDOC_p1003_2_92):
594: p = "IEEE Std 1003.2-1992 (\\(lqPOSIX.2\\(rq)";
595: break;
596: case(MDOC_p1387_2_95):
597: p = "IEEE Std 1387.2-1995 (\\(lqPOSIX.7.2\\(rq)";
598: break;
599: case(MDOC_p1003_2):
600: p = "IEEE Std 1003.2 (\\(lqPOSIX.2\\(rq)";
601: break;
602: case(MDOC_p1387_2):
603: p = "IEEE Std 1387.2 (\\(lqPOSIX.7.2\\(rq)";
604: break;
605: case(MDOC_isoC_90):
606: p = "ISO/IEC 9899:1990 (\\(lqISO C90\\(rq)";
607: break;
608: case(MDOC_isoC_amd1):
609: p = "ISO/IEC 9899/AMD1:1995 (\\(lqISO C90\\(rq)";
610: break;
611: case(MDOC_isoC_tcor1):
612: p = "ISO/IEC 9899/TCOR1:1994 (\\(lqISO C90\\(rq)";
613: break;
614: case(MDOC_isoC_tcor2):
615: p = "ISO/IEC 9899/TCOR2:1995 (\\(lqISO C90\\(rq)";
616: break;
617: case(MDOC_isoC_99):
618: p = "ISO/IEC 9899:1999 (\\(lqISO C99\\(rq)";
619: break;
620: case(MDOC_ansiC):
621: p = "ANSI X3.159-1989 (\\(lqANSI C\\(rq)";
622: break;
623: case(MDOC_ansiC_89):
624: p = "ANSI X3.159-1989 (\\(lqANSI C\\(rq)";
625: break;
626: case(MDOC_ansiC_99):
627: p = "ANSI/ISO/IEC 9899-1999 (\\(lqANSI C99\\(rq)";
628: break;
629: case(MDOC_ieee754):
630: p = "IEEE Std 754-1985";
631: break;
632: case(MDOC_iso8802_3):
633: p = "ISO 8802-3: 1989";
634: break;
635: case(MDOC_xpg3):
636: p = "X/Open Portability Guide Issue 3 "
637: "(\\(lqXPG3\\(rq)";
638: break;
639: case(MDOC_xpg4):
640: p = "X/Open Portability Guide Issue 4 "
641: "(\\(lqXPG4\\(rq)";
642: break;
643: case(MDOC_xpg4_2):
644: p = "X/Open Portability Guide Issue 4.2 "
645: "(\\(lqXPG4.2\\(rq)";
646: break;
647: case(MDOC_xpg4_3):
648: p = "X/Open Portability Guide Issue 4.3 "
649: "(\\(lqXPG4.3\\(rq)";
650: break;
651: case(MDOC_xbd5):
652: p = "X/Open System Interface Definitions Issue 5 "
653: "(\\(lqXBD5\\(rq)";
654: break;
655: case(MDOC_xcu5):
656: p = "X/Open Commands and Utilities Issue 5 "
657: "(\\(lqXCU5\\(rq)";
658: break;
659: case(MDOC_xsh5):
660: p = "X/Open System Interfaces and Headers Issue 5 "
661: "(\\(lqXSH5\\(rq)";
662: break;
663: case(MDOC_xns5):
664: p = "X/Open Networking Services Issue 5 "
665: "(\\(lqXNS5\\(rq)";
666: break;
667: case(MDOC_xns5_2d2_0):
668: p = "X/Open Networking Services Issue 5.2 Draft 2.0 "
669: "(\\(lqXNS5.2D2.0\\(rq)";
670: break;
671: case(MDOC_xcurses4_2):
672: p = "X/Open Curses Issue 4 Version 2 "
673: "(\\(lqXCURSES4.2\\(rq)";
674: break;
675: case(MDOC_susv2):
676: p = "Version 2 of the Single UNIX Specification";
677: break;
678: case(MDOC_susv3):
679: p = "Version 3 of the Single UNIX Specification";
680: break;
681: case(MDOC_svid4):
682: p = "System V Interface Definition, Fourth Edition "
683: "(\\(lqSVID4\\(rq)";
684: break;
685: default:
686: p = NULL;
687: break;
688: }
689:
690: return(p);
691: }
692:
693:
694: const char *
695: mdoc_att2a(enum mdoc_att c)
696: {
697: char *p;
698:
699: switch (c) {
700: case(ATT_v1):
701: p = "Version 1 AT&T UNIX";
702: break;
703: case(ATT_v2):
704: p = "Version 2 AT&T UNIX";
705: break;
706: case(ATT_v3):
707: p = "Version 3 AT&T UNIX";
708: break;
709: case(ATT_v4):
710: p = "Version 4 AT&T UNIX";
711: break;
712: case(ATT_v5):
713: p = "Version 5 AT&T UNIX";
714: break;
715: case(ATT_v6):
716: p = "Version 6 AT&T UNIX";
717: break;
718: case(ATT_v7):
719: p = "Version 7 AT&T UNIX";
720: break;
721: case(ATT_32v):
722: p = "Version 32V AT&T UNIX";
723: break;
1.23 ! kristaps 724: case(ATT_V):
! 725: p = "AT&T System V UNIX";
! 726: break;
1.18 kristaps 727: case(ATT_V1):
728: p = "AT&T System V.1 UNIX";
729: break;
730: case(ATT_V2):
731: p = "AT&T System V.2 UNIX";
732: break;
733: case(ATT_V3):
734: p = "AT&T System V.3 UNIX";
735: break;
736: case(ATT_V4):
737: p = "AT&T System V.4 UNIX";
738: break;
739: default:
740: p = "AT&T UNIX";
741: break;
742: }
743:
744: return(p);
745: }
1.20 kristaps 746:
747:
748: size_t
749: mdoc_macro2len(int macro)
750: {
751:
752: switch (macro) {
753: case(MDOC_Ad):
754: return(12);
755: case(MDOC_Ao):
756: return(12);
757: case(MDOC_An):
758: return(12);
759: case(MDOC_Aq):
760: return(12);
761: case(MDOC_Ar):
762: return(12);
763: case(MDOC_Bo):
764: return(12);
765: case(MDOC_Bq):
766: return(12);
767: case(MDOC_Cd):
768: return(12);
769: case(MDOC_Cm):
770: return(10);
771: case(MDOC_Do):
772: return(10);
773: case(MDOC_Dq):
774: return(12);
775: case(MDOC_Dv):
776: return(12);
777: case(MDOC_Eo):
778: return(12);
779: case(MDOC_Em):
780: return(10);
781: case(MDOC_Er):
782: return(12);
783: case(MDOC_Ev):
784: return(15);
785: case(MDOC_Fa):
786: return(12);
787: case(MDOC_Fl):
788: return(10);
789: case(MDOC_Fo):
790: return(16);
791: case(MDOC_Fn):
792: return(16);
793: case(MDOC_Ic):
794: return(10);
795: case(MDOC_Li):
796: return(16);
797: case(MDOC_Ms):
798: return(6);
799: case(MDOC_Nm):
800: return(10);
801: case(MDOC_No):
802: return(12);
803: case(MDOC_Oo):
804: return(10);
805: case(MDOC_Op):
806: return(14);
807: case(MDOC_Pa):
808: return(32);
809: case(MDOC_Pf):
810: return(12);
811: case(MDOC_Po):
812: return(12);
813: case(MDOC_Pq):
814: return(12);
815: case(MDOC_Ql):
816: return(16);
817: case(MDOC_Qo):
818: return(12);
819: case(MDOC_So):
820: return(12);
821: case(MDOC_Sq):
822: return(12);
823: case(MDOC_Sy):
824: return(6);
825: case(MDOC_Sx):
826: return(16);
827: case(MDOC_Tn):
828: return(10);
829: case(MDOC_Va):
830: return(12);
831: case(MDOC_Vt):
832: return(12);
833: case(MDOC_Xr):
834: return(10);
835: default:
836: break;
837: };
838: return(0);
839: }
CVSweb