]>
git.cameronkatri.com Git - mandoc.git/blob - literals.c
1 /* $Id: literals.c,v 1.7 2008/12/10 10:43:57 kristaps Exp $ */
3 * Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
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
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.
25 #define ROFF_ATTname_V1 "v1"
26 #define ROFF_ATTname_V2 "v2"
27 #define ROFF_ATTname_V3 "v3"
28 #define ROFF_ATTname_V6 "v6"
29 #define ROFF_ATTname_V7 "v7"
30 #define ROFF_ATTname_32V "32v"
31 #define ROFF_ATTname_V_1 "V.1"
32 #define ROFF_ATTname_V_4 "V.4"
34 #define ROFFSecname_NAME "NAME"
35 #define ROFFSecname_SYNOP "SYNOPSIS"
36 #define ROFFSecname_DESC "DESCRIPTION"
37 #define ROFFSecname_ENV "ENVIRONMENT"
38 #define ROFFSecname_FILES "FILES"
39 #define ROFFSecname_EX "EXAMPLES"
40 #define ROFFSecname_DIAG "DIAGNOSTICS"
41 #define ROFFSecname_ERRS "ERRORS"
42 #define ROFFSecname_STAND "STANDARDS"
43 #define ROFFSecname_HIST "HISTORY"
44 #define ROFFSecname_AUTH "AUTHORS"
45 #define ROFFSecname_CAVEATS "CAVEATS"
46 #define ROFFSecname_BUGS "BUGS"
47 #define ROFFSecname_RETVAL "RETURN VALUES"
48 #define ROFFSecname_RETVAL1 "RETURN"
49 #define ROFFSecname_RETVAL2 "VALUES"
50 #define ROFFSecname_SEEALSO "SEE ALSO"
51 #define ROFFSecname_SEEALSO1 "SEE"
52 #define ROFFSecname_SEEALSO2 "ALSO"
54 #define ROFF_MSECname_1 "1"
55 #define ROFF_MSECname_2 "2"
56 #define ROFF_MSECname_3 "3"
57 #define ROFF_MSECname_3p "3p"
58 #define ROFF_MSECname_4 "4"
59 #define ROFF_MSECname_5 "5"
60 #define ROFF_MSECname_6 "6"
61 #define ROFF_MSECname_7 "7"
62 #define ROFF_MSECname_8 "8"
63 #define ROFF_MSECname_9 "9"
64 #define ROFF_MSECname_UNASS "unass"
65 #define ROFF_MSECname_DRAFT "draft"
66 #define ROFF_MSECname_PAPER "paper"
68 #define ROFF_VOLname_AMD "AMD"
69 #define ROFF_VOLname_IND "IND"
70 #define ROFF_VOLname_KM "KM"
71 #define ROFF_VOLname_LOCAL "LOCAL"
72 #define ROFF_VOLname_PRM "PRM"
73 #define ROFF_VOLname_PS1 "PS1"
74 #define ROFF_VOLname_SMM "SMM"
75 #define ROFF_VOLname_URM "URM"
76 #define ROFF_VOLname_USD "USD"
77 #define ROFF_ARCHname_ALPHA "alpha"
78 #define ROFF_ARCHname_AMD64 "amd64"
79 #define ROFF_ARCHname_AMIGA "amiga"
80 #define ROFF_ARCHname_ARC "arc"
81 #define ROFF_ARCHname_ARMISH "armish"
82 #define ROFF_ARCHname_AVIION "aviion"
83 #define ROFF_ARCHname_HP300 "hp300"
84 #define ROFF_ARCHname_HPPA "hppa"
85 #define ROFF_ARCHname_HPPA64 "hppa64"
86 #define ROFF_ARCHname_I386 "i386"
87 #define ROFF_ARCHname_LANDISK "landisk"
88 #define ROFF_ARCHname_LUNA88K "luna88k"
89 #define ROFF_ARCHname_MAC68K "mac68k"
90 #define ROFF_ARCHname_MACPPC "macppc"
91 #define ROFF_ARCHname_MVME68K "mvme68k"
92 #define ROFF_ARCHname_MVME88K "mvme88k"
93 #define ROFF_ARCHname_MVMEPPC "mvmeppc"
94 #define ROFF_ARCHname_PMAX "pmax"
95 #define ROFF_ARCHname_SGI "sgi"
96 #define ROFF_ARCHname_SPARC "sparc"
97 #define ROFF_ARCHname_SPARC64 "sparc64"
98 #define ROFF_ARCHname_SUN3 "sun3"
99 #define ROFF_ARCHname_VAX "vax"
100 #define ROFF_ARCHname_ZAURUS "zaurus"
103 roff_sec(const char **p
)
107 if (NULL
!= *(p
+ 1)) {
108 if (NULL
!= *(p
+ 2))
109 return(ROFFSec_OTHER
);
110 if (0 == strcmp(*p
, ROFFSecname_RETVAL1
) &&
111 0 == strcmp(*(p
+ 1), ROFFSecname_RETVAL2
))
112 return(ROFFSec_RETVAL
);
113 if (0 == strcmp(*p
, ROFFSecname_SEEALSO1
) &&
114 0 == strcmp(*(p
+ 1), ROFFSecname_SEEALSO2
))
115 return(ROFFSec_SEEALSO
);
116 return(ROFFSec_OTHER
);
119 if (0 == strcmp(*p
, ROFFSecname_NAME
))
120 return(ROFFSec_NAME
);
121 else if (0 == strcmp(*p
, ROFFSecname_SYNOP
))
122 return(ROFFSec_SYNOP
);
123 else if (0 == strcmp(*p
, ROFFSecname_DESC
))
124 return(ROFFSec_DESC
);
125 else if (0 == strcmp(*p
, ROFFSecname_ENV
))
127 else if (0 == strcmp(*p
, ROFFSecname_FILES
))
128 return(ROFFSec_FILES
);
129 else if (0 == strcmp(*p
, ROFFSecname_EX
))
131 else if (0 == strcmp(*p
, ROFFSecname_DIAG
))
132 return(ROFFSec_DIAG
);
133 else if (0 == strcmp(*p
, ROFFSecname_ERRS
))
134 return(ROFFSec_ERRS
);
135 else if (0 == strcmp(*p
, ROFFSecname_STAND
))
136 return(ROFFSec_STAND
);
137 else if (0 == strcmp(*p
, ROFFSecname_HIST
))
138 return(ROFFSec_HIST
);
139 else if (0 == strcmp(*p
, ROFFSecname_AUTH
))
140 return(ROFFSec_AUTH
);
141 else if (0 == strcmp(*p
, ROFFSecname_CAVEATS
))
142 return(ROFFSec_CAVEATS
);
143 else if (0 == strcmp(*p
, ROFFSecname_BUGS
))
144 return(ROFFSec_BUGS
);
145 else if (0 == strcmp(*p
, ROFFSecname_RETVAL
))
146 return(ROFFSec_RETVAL
);
147 else if (0 == strcmp(*p
, ROFFSecname_SEEALSO
))
148 return(ROFFSec_SEEALSO
);
150 return(ROFFSec_OTHER
);
155 roff_msec(const char *p
)
159 if (0 == strcmp(p
, ROFF_MSECname_1
))
161 else if (0 == strcmp(p
, ROFF_MSECname_2
))
163 else if (0 == strcmp(p
, ROFF_MSECname_3
))
165 else if (0 == strcmp(p
, ROFF_MSECname_3p
))
166 return(ROFF_MSEC_3p
);
167 else if (0 == strcmp(p
, ROFF_MSECname_4
))
169 else if (0 == strcmp(p
, ROFF_MSECname_5
))
171 else if (0 == strcmp(p
, ROFF_MSECname_6
))
173 else if (0 == strcmp(p
, ROFF_MSECname_7
))
175 else if (0 == strcmp(p
, ROFF_MSECname_8
))
177 else if (0 == strcmp(p
, ROFF_MSECname_9
))
179 else if (0 == strcmp(p
, ROFF_MSECname_UNASS
))
180 return(ROFF_MSEC_UNASS
);
181 else if (0 == strcmp(p
, ROFF_MSECname_DRAFT
))
182 return(ROFF_MSEC_DRAFT
);
183 else if (0 == strcmp(p
, ROFF_MSECname_PAPER
))
184 return(ROFF_MSEC_PAPER
);
186 return(ROFF_MSEC_MAX
);
191 roff_msecname(enum roffmsec sec
)
196 return(ROFF_MSECname_1
);
198 return(ROFF_MSECname_2
);
200 return(ROFF_MSECname_3
);
202 return(ROFF_MSECname_3p
);
204 return(ROFF_MSECname_4
);
206 return(ROFF_MSECname_5
);
208 return(ROFF_MSECname_6
);
210 return(ROFF_MSECname_7
);
212 return(ROFF_MSECname_8
);
214 return(ROFF_MSECname_9
);
215 case(ROFF_MSEC_UNASS
):
216 return(ROFF_MSECname_UNASS
);
217 case(ROFF_MSEC_DRAFT
):
218 return(ROFF_MSECname_DRAFT
);
219 case(ROFF_MSEC_PAPER
):
220 return(ROFF_MSECname_PAPER
);
231 roff_fmtstring(int tok
)
236 return ("The %s utility exits 0 on success, and "
237 ">0 if an error occurs.");
239 return ("The %s() function returns the value 0 if "
240 "successful; otherwise the value -1 "
241 "is returned and the global variable "
242 "errno is set to indicate the error.");
244 return("#include \\*(Lt%s\\*(Gt");
255 roff_literal(int tok
, const int *argc
,
256 const char **argv
, const char **morep
)
261 assert(NULL
== *argv
);
262 assert(ROFF_ARGMAX
== *argc
);
266 switch (roff_att(*morep
)) {
268 return("Version 1 AT&T UNIX");
270 return("Version 2 AT&T UNIX");
272 return("Version 3 AT&T UNIX");
274 return("Version 6 AT&T UNIX");
276 return("Version 7 AT&T UNIX");
278 return("Version 32v AT&T UNIX");
280 return("AT&T System V.1 UNIX");
282 return("AT&T System V.4 UNIX");
291 assert(ROFF_ARGMAX
!= *argc
);
292 assert(NULL
== *argv
);
294 case(ROFF_p1003_1_88
):
295 return("IEEE Std 1003.1-1988 "
296 "(\\*(LqPOSIX\\*(Rq)");
297 case(ROFF_p1003_1_90
):
298 return("IEEE Std 1003.1-1990 "
299 "(\\*(LqPOSIX\\*(Rq)");
300 case(ROFF_p1003_1_96
):
301 return("ISO/IEC 9945-1:1996 "
302 "(\\*(LqPOSIX\\*(Rq)");
303 case(ROFF_p1003_1_2001
):
304 return("IEEE Std 1003.1-2001 "
305 "(\\*(LqPOSIX\\*(Rq)");
306 case(ROFF_p1003_1_2004
):
307 return("IEEE Std 1003.1-2004 "
308 "(\\*(LqPOSIX\\*(Rq)");
310 return("IEEE Std 1003.1 "
311 "(\\*(LqPOSIX\\*(Rq)");
313 return("IEEE Std 1003.1b "
314 "(\\*(LqPOSIX\\*(Rq)");
315 case(ROFF_p1003_1b_93
):
316 return("IEEE Std 1003.1b-1993 "
317 "(\\*(LqPOSIX\\*(Rq)");
318 case(ROFF_p1003_1c_95
):
319 return("IEEE Std 1003.1c-1995 "
320 "(\\*(LqPOSIX\\*(Rq)");
321 case(ROFF_p1003_1g_2000
):
322 return("IEEE Std 1003.1g-2000 "
323 "(\\*(LqPOSIX\\*(Rq)");
324 case(ROFF_p1003_2_92
):
325 return("IEEE Std 1003.2-1992 "
326 "(\\*(LqPOSIX.2\\*(Rq)");
327 case(ROFF_p1387_2_95
):
328 return("IEEE Std 1387.2-1995 "
329 "(\\*(LqPOSIX.7.2\\*(Rq)");
331 return("IEEE Std 1003.2 "
332 "(\\*(LqPOSIX.2\\*(Rq)");
334 return("IEEE Std 1387.2 "
335 "(\\*(LqPOSIX.7.2\\*(Rq)");
337 return("ISO/IEC 9899:1990 "
338 "(\\*(LqISO C90\\*(Rq)");
339 case(ROFF_isoC_amd1
):
340 return("ISO/IEC 9899/AMD1:1995 "
341 "(\\*(LqISO C90\\*(Rq)");
342 case(ROFF_isoC_tcor1
):
343 return("ISO/IEC 9899/TCOR1:1994 "
344 "(\\*(LqISO C90\\*(Rq)");
345 case(ROFF_isoC_tcor2
):
346 return("ISO/IEC 9899/TCOR2:1995 "
347 "(\\*(LqISO C90\\*(Rq)");
349 return("ISO/IEC 9899:1999 "
350 "(\\*(LqISO C99\\*(Rq)");
352 return("ANSI X3.159-1989 "
353 "(\\*(LqANSI C\\*(Rq)");
355 return("ANSI X3.159-1989 "
356 "(\\*(LqANSI C\\*(Rq)");
358 return("ANSI/ISO/IEC 9899-1999 "
359 "(\\*(LqANSI C99\\*(Rq)");
361 return("IEEE Std 754-1985");
362 case(ROFF_iso8802_3
):
363 return("ISO 8802-3: 1989");
365 return("X/Open Portability Guide Issue 3 "
366 "(\\*(LqXPG3\\*(Rq)");
368 return("X/Open Portability Guide Issue 4 "
369 "(\\*(LqXPG4\\*(Rq)");
371 return("X/Open Portability Guide Issue 4.2 "
372 "(\\*(LqXPG4.2\\*(Rq)");
374 return("X/Open Portability Guide Issue 4.3 "
375 "(\\*(LqXPG4.3\\*(Rq)");
377 return("X/Open System Interface Definitions "
378 "Issue 5 (\\*(LqXBD5\\*(Rq)");
380 return("X/Open Commands and Utilities Issue 5 "
381 "(\\*(LqXCU5\\*(Rq)");
383 return("X/Open System Interfaces and Headers "
384 "Issue 5 (\\*(LqXSH5\\*(Rq)");
386 return("X/Open Networking Services Issue 5 "
387 "(\\*(LqXNS5\\*(Rq)");
388 case(ROFF_xns5_2d2_0
):
389 return("X/Open Networking Services "
390 "Issue 5.2 Draft 2.0 "
391 "(\\*(LqXNS5.2D2.0\\*(Rq)");
392 case(ROFF_xcurses4_2
):
393 return("X/Open Curses Issue 4 Version 2 "
394 "(\\*(LqXCURSES4.2\\*(Rq)");
396 return("Version 2 of the Single "
397 "UNIX Specification");
399 return("Version 3 of the Single "
400 "UNIX Specification");
402 return("System V Interface Definition, Fourth "
403 "Edition (\\*(LqSVID4\\*(Rq)");
411 return("is currently in beta test.");
413 return("currently under development.");
425 return("BSDI BSD/OS");
436 roff_att(const char *p
)
440 if (0 == strcmp(p
, ROFF_ATTname_V1
))
442 else if (0 == strcmp(p
, ROFF_ATTname_V2
))
444 else if (0 == strcmp(p
, ROFF_ATTname_V3
))
446 else if (0 == strcmp(p
, ROFF_ATTname_V6
))
448 else if (0 == strcmp(p
, ROFF_ATTname_V7
))
450 else if (0 == strcmp(p
, ROFF_ATTname_32V
))
451 return(ROFF_ATT_32V
);
452 else if (0 == strcmp(p
, ROFF_ATTname_V_1
))
453 return(ROFF_ATT_V_1
);
454 else if (0 == strcmp(p
, ROFF_ATTname_V_4
))
455 return(ROFF_ATT_V_4
);
457 return(ROFF_ATT_MAX
);
462 roff_vol(const char *p
)
465 if (0 == strcmp(p
, ROFF_VOLname_AMD
))
466 return(ROFF_VOL_AMD
);
467 else if (0 == strcmp(p
, ROFF_VOLname_IND
))
468 return(ROFF_VOL_IND
);
469 else if (0 == strcmp(p
, ROFF_VOLname_KM
))
471 else if (0 == strcmp(p
, ROFF_VOLname_LOCAL
))
472 return(ROFF_VOL_LOCAL
);
473 else if (0 == strcmp(p
, ROFF_VOLname_PRM
))
474 return(ROFF_VOL_PRM
);
475 else if (0 == strcmp(p
, ROFF_VOLname_PS1
))
476 return(ROFF_VOL_PS1
);
477 else if (0 == strcmp(p
, ROFF_VOLname_SMM
))
478 return(ROFF_VOL_SMM
);
479 else if (0 == strcmp(p
, ROFF_VOLname_URM
))
480 return(ROFF_VOL_URM
);
481 else if (0 == strcmp(p
, ROFF_VOLname_USD
))
482 return(ROFF_VOL_USD
);
483 else if (0 == strcmp(p
, ROFF_ARCHname_ALPHA
))
484 return(ROFF_ARCH_ALPHA
);
485 else if (0 == strcmp(p
, ROFF_ARCHname_AMD64
))
486 return(ROFF_ARCH_AMD64
);
487 else if (0 == strcmp(p
, ROFF_ARCHname_AMIGA
))
488 return(ROFF_ARCH_AMIGA
);
489 else if (0 == strcmp(p
, ROFF_ARCHname_ARC
))
490 return(ROFF_ARCH_ARC
);
491 else if (0 == strcmp(p
, ROFF_ARCHname_ARMISH
))
492 return(ROFF_ARCH_ARMISH
);
493 else if (0 == strcmp(p
, ROFF_ARCHname_AVIION
))
494 return(ROFF_ARCH_AVIION
);
495 else if (0 == strcmp(p
, ROFF_ARCHname_HP300
))
496 return(ROFF_ARCH_HP300
);
497 else if (0 == strcmp(p
, ROFF_ARCHname_HPPA
))
498 return(ROFF_ARCH_HPPA
);
499 else if (0 == strcmp(p
, ROFF_ARCHname_HPPA64
))
500 return(ROFF_ARCH_HPPA64
);
501 else if (0 == strcmp(p
, ROFF_ARCHname_I386
))
502 return(ROFF_ARCH_I386
);
503 else if (0 == strcmp(p
, ROFF_ARCHname_LANDISK
))
504 return(ROFF_ARCH_LANDISK
);
505 else if (0 == strcmp(p
, ROFF_ARCHname_LUNA88K
))
506 return(ROFF_ARCH_LUNA88K
);
507 else if (0 == strcmp(p
, ROFF_ARCHname_MAC68K
))
508 return(ROFF_ARCH_MAC68K
);
509 else if (0 == strcmp(p
, ROFF_ARCHname_MACPPC
))
510 return(ROFF_ARCH_MACPPC
);
511 else if (0 == strcmp(p
, ROFF_ARCHname_MVME68K
))
512 return(ROFF_ARCH_MVME68K
);
513 else if (0 == strcmp(p
, ROFF_ARCHname_MVME88K
))
514 return(ROFF_ARCH_MVME88K
);
515 else if (0 == strcmp(p
, ROFF_ARCHname_MVMEPPC
))
516 return(ROFF_ARCH_MVMEPPC
);
517 else if (0 == strcmp(p
, ROFF_ARCHname_PMAX
))
518 return(ROFF_ARCH_PMAX
);
519 else if (0 == strcmp(p
, ROFF_ARCHname_SGI
))
520 return(ROFF_ARCH_SGI
);
521 else if (0 == strcmp(p
, ROFF_ARCHname_SPARC
))
522 return(ROFF_ARCH_SPARC
);
523 else if (0 == strcmp(p
, ROFF_ARCHname_SPARC64
))
524 return(ROFF_ARCH_SPARC64
);
525 else if (0 == strcmp(p
, ROFF_ARCHname_SUN3
))
526 return(ROFF_ARCH_SUN3
);
527 else if (0 == strcmp(p
, ROFF_ARCHname_VAX
))
528 return(ROFF_ARCH_VAX
);
529 else if (0 == strcmp(p
, ROFF_ARCHname_ZAURUS
))
530 return(ROFF_ARCH_ZAURUS
);
532 return(ROFF_VOL_MAX
);