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