| @@ -1,33 +1,33 @@ | | | @@ -1,33 +1,33 @@ |
1 | /* $NetBSD: makemandb.c,v 1.26 2015/03/02 13:51:24 joerg Exp $ */ | | 1 | /* $NetBSD: makemandb.c,v 1.27 2015/03/04 02:02:15 christos Exp $ */ |
2 | /* | | 2 | /* |
3 | * Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com> | | 3 | * Copyright (c) 2011 Abhinav Upadhyay <er.abhinav.upadhyay@gmail.com> |
4 | * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> | | 4 | * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv> |
5 | * | | 5 | * |
6 | * Permission to use, copy, modify, and distribute this software for any | | 6 | * Permission to use, copy, modify, and distribute this software for any |
7 | * purpose with or without fee is hereby granted, provided that the above | | 7 | * purpose with or without fee is hereby granted, provided that the above |
8 | * copyright notice and this permission notice appear in all copies. | | 8 | * copyright notice and this permission notice appear in all copies. |
9 | * | | 9 | * |
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | | 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | | 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | | 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | | 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | | 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | | 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | | 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
17 | */ | | 17 | */ |
18 | | | 18 | |
19 | #include <sys/cdefs.h> | | 19 | #include <sys/cdefs.h> |
20 | __RCSID("$NetBSD: makemandb.c,v 1.26 2015/03/02 13:51:24 joerg Exp $"); | | 20 | __RCSID("$NetBSD: makemandb.c,v 1.27 2015/03/04 02:02:15 christos Exp $"); |
21 | | | 21 | |
22 | #include <sys/stat.h> | | 22 | #include <sys/stat.h> |
23 | #include <sys/types.h> | | 23 | #include <sys/types.h> |
24 | | | 24 | |
25 | #include <assert.h> | | 25 | #include <assert.h> |
26 | #include <ctype.h> | | 26 | #include <ctype.h> |
27 | #include <dirent.h> | | 27 | #include <dirent.h> |
28 | #include <err.h> | | 28 | #include <err.h> |
29 | #include <archive.h> | | 29 | #include <archive.h> |
30 | #include <libgen.h> | | 30 | #include <libgen.h> |
31 | #include <md5.h> | | 31 | #include <md5.h> |
32 | #include <stdio.h> | | 32 | #include <stdio.h> |
33 | #include <stdlib.h> | | 33 | #include <stdlib.h> |
| @@ -980,32 +980,31 @@ pmdoc_Nd(const struct mdoc_node *n, mand | | | @@ -980,32 +980,31 @@ pmdoc_Nd(const struct mdoc_node *n, mand |
980 | char *buf = NULL; | | 980 | char *buf = NULL; |
981 | char *temp; | | 981 | char *temp; |
982 | char *nd_text; | | 982 | char *nd_text; |
983 | | | 983 | |
984 | if (n == NULL || n->tok == MDOC_MAX) | | 984 | if (n == NULL || n->tok == MDOC_MAX) |
985 | return; | | 985 | return; |
986 | | | 986 | |
987 | if (n->type == MDOC_TEXT) { | | 987 | if (n->type == MDOC_TEXT) { |
988 | if (rec->xr_found && n->next) { | | 988 | if (rec->xr_found && n->next) { |
989 | /* | | 989 | /* |
990 | * An Xr macro was seen previously, so parse this | | 990 | * An Xr macro was seen previously, so parse this |
991 | * and the next node. | | 991 | * and the next node. |
992 | */ | | 992 | */ |
993 | temp = estrdup(n->string); | | 993 | temp = n->string; |
994 | n = n->next; | | 994 | n = n->next; |
995 | easprintf(&buf, "%s(%s)", temp, n->string); | | 995 | easprintf(&buf, "%s(%s)", temp, n->string); |
996 | concat(&rec->name_desc, buf); | | 996 | concat(&rec->name_desc, buf); |
997 | free(buf); | | 997 | free(buf); |
998 | free(temp); | | | |
999 | } else { | | 998 | } else { |
1000 | nd_text = estrdup(n->string); | | 999 | nd_text = estrdup(n->string); |
1001 | replace_hyph(nd_text); | | 1000 | replace_hyph(nd_text); |
1002 | concat(&rec->name_desc, nd_text); | | 1001 | concat(&rec->name_desc, nd_text); |
1003 | free(nd_text); | | 1002 | free(nd_text); |
1004 | } | | 1003 | } |
1005 | rec->xr_found = 0; | | 1004 | rec->xr_found = 0; |
1006 | } else if (mdocs[n->tok] == pmdoc_Xr) { | | 1005 | } else if (mdocs[n->tok] == pmdoc_Xr) { |
1007 | /* Remember that we have encountered an Xr macro */ | | 1006 | /* Remember that we have encountered an Xr macro */ |
1008 | rec->xr_found = 1; | | 1007 | rec->xr_found = 1; |
1009 | } | | 1008 | } |
1010 | | | 1009 | |
1011 | if (n->child) | | 1010 | if (n->child) |
| @@ -1042,33 +1041,28 @@ pmdoc_macro_handler(const struct mdoc_no | | | @@ -1042,33 +1041,28 @@ pmdoc_macro_handler(const struct mdoc_no |
1042 | while (n->type != MDOC_TEXT && n->next) | | 1041 | while (n->type != MDOC_TEXT && n->next) |
1043 | n = n->next; | | 1042 | n = n->next; |
1044 | | | 1043 | |
1045 | if (n && n->type != MDOC_TEXT) | | 1044 | if (n && n->type != MDOC_TEXT) |
1046 | return; | | 1045 | return; |
1047 | sn = n; | | 1046 | sn = n; |
1048 | if (n->next) | | 1047 | if (n->next) |
1049 | n = n->next; | | 1048 | n = n->next; |
1050 | | | 1049 | |
1051 | while (n->type != MDOC_TEXT && n->next) | | 1050 | while (n->type != MDOC_TEXT && n->next) |
1052 | n = n->next; | | 1051 | n = n->next; |
1053 | | | 1052 | |
1054 | if (n && n->type == MDOC_TEXT) { | | 1053 | if (n && n->type == MDOC_TEXT) { |
1055 | size_t len = strlen(sn->string); | | 1054 | char *buf; |
1056 | char *buf = emalloc(len + 4); | | 1055 | easprintf(&buf, "%s(%s)", sn->string, n->string); |
1057 | memcpy(buf, sn->string, len); | | | |
1058 | buf[len] = '('; | | | |
1059 | buf[len + 1] = n->string[0]; | | | |
1060 | buf[len + 2] = ')'; | | | |
1061 | buf[len + 3] = 0; | | | |
1062 | mdoc_parse_section(n->sec, buf, rec); | | 1056 | mdoc_parse_section(n->sec, buf, rec); |
1063 | free(buf); | | 1057 | free(buf); |
1064 | } | | 1058 | } |
1065 | | | 1059 | |
1066 | break; | | 1060 | break; |
1067 | | | 1061 | |
1068 | /* Parse the .Pp macro to add a new line */ | | 1062 | /* Parse the .Pp macro to add a new line */ |
1069 | case MDOC_Pp: | | 1063 | case MDOC_Pp: |
1070 | if (n->type == MDOC_TEXT) | | 1064 | if (n->type == MDOC_TEXT) |
1071 | mdoc_parse_section(n->sec, "\n", rec); | | 1065 | mdoc_parse_section(n->sec, "\n", rec); |
1072 | break; | | 1066 | break; |
1073 | default: | | 1067 | default: |
1074 | break; | | 1068 | break; |