=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mandoc/mandocdb.c,v retrieving revision 1.50 retrieving revision 1.51 diff -c -r1.50 -r1.51 *** src/usr.bin/mandoc/mandocdb.c 2014/01/02 18:51:51 1.50 --- src/usr.bin/mandoc/mandocdb.c 2014/01/02 20:24:35 1.51 *************** *** 1,4 **** ! /* $Id: mandocdb.c,v 1.50 2014/01/02 18:51:51 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2011, 2012, 2013 Ingo Schwarze --- 1,4 ---- ! /* $Id: mandocdb.c,v 1.51 2014/01/02 20:24:35 schwarze Exp $ */ /* * Copyright (c) 2011, 2012 Kristaps Dzonsons * Copyright (c) 2011, 2012, 2013 Ingo Schwarze *************** *** 514,521 **** FTSENT *ff; struct mlink *mlink; int dform; ! char *fsec; ! const char *dsec, *arch, *cp, *path; const char *argv[2]; argv[0] = "."; --- 514,521 ---- FTSENT *ff; struct mlink *mlink; int dform; ! char *dsec, *arch, *fsec, *cp; ! const char *path; const char *argv[2]; argv[0] = "."; *************** *** 580,595 **** continue; } else fsec[-1] = '\0'; mlink = mandoc_calloc(1, sizeof(struct mlink)); strlcpy(mlink->file, path, sizeof(mlink->file)); mlink->dform = dform; ! if (NULL != dsec) ! mlink->dsec = mandoc_strdup(dsec); ! if (NULL != arch) ! mlink->arch = mandoc_strdup(arch); ! mlink->name = mandoc_strdup(ff->fts_name); ! if (NULL != fsec) ! mlink->fsec = mandoc_strdup(fsec); mlink_add(mlink, ff->fts_statp); continue; } else if (FTS_D != ff->fts_info && --- 580,593 ---- continue; } else fsec[-1] = '\0'; + mlink = mandoc_calloc(1, sizeof(struct mlink)); strlcpy(mlink->file, path, sizeof(mlink->file)); mlink->dform = dform; ! mlink->dsec = dsec; ! mlink->arch = arch; ! mlink->name = ff->fts_name; ! mlink->fsec = fsec; mlink_add(mlink, ff->fts_statp); continue; } else if (FTS_D != ff->fts_info && *************** *** 609,616 **** * Try to infer this from the name. * If we're not in use_all, enforce it. */ - dsec = NULL; - dform = FORM_NONE; cp = ff->fts_name; if (FTS_DP == ff->fts_info) break; --- 607,612 ---- *************** *** 621,626 **** --- 617,625 ---- } else if (0 == strncmp(cp, "cat", 3)) { dform = FORM_CAT; dsec = cp + 3; + } else { + dform = FORM_NONE; + dsec = NULL; } if (NULL != dsec || use_all) *************** *** 635,643 **** * Possibly our architecture. * If we're descending, keep tabs on it. */ - arch = NULL; if (FTS_DP != ff->fts_info && NULL != dsec) arch = ff->fts_name; break; default: if (FTS_DP == ff->fts_info || use_all) --- 634,643 ---- * Possibly our architecture. * If we're descending, keep tabs on it. */ if (FTS_DP != ff->fts_info && NULL != dsec) arch = ff->fts_name; + else + arch = NULL; break; default: if (FTS_DP == ff->fts_info || use_all) *************** *** 711,726 **** *p++ = '\0'; if (0 == strncmp(start, "man", 3)) { mlink->dform = FORM_SRC; ! mlink->dsec = mandoc_strdup(start + 3); } else if (0 == strncmp(start, "cat", 3)) { mlink->dform = FORM_CAT; ! mlink->dsec = mandoc_strdup(start + 3); } start = p; if (NULL != mlink->dsec && NULL != (p = strchr(start, '/'))) { *p++ = '\0'; ! mlink->arch = mandoc_strdup(start); start = p; } } --- 711,726 ---- *p++ = '\0'; if (0 == strncmp(start, "man", 3)) { mlink->dform = FORM_SRC; ! mlink->dsec = start + 3; } else if (0 == strncmp(start, "cat", 3)) { mlink->dform = FORM_CAT; ! mlink->dsec = start + 3; } start = p; if (NULL != mlink->dsec && NULL != (p = strchr(start, '/'))) { *p++ = '\0'; ! mlink->arch = start; start = p; } } *************** *** 735,741 **** if ('.' == *p) { *p++ = '\0'; ! mlink->fsec = mandoc_strdup(p); } /* --- 735,741 ---- if ('.' == *p) { *p++ = '\0'; ! mlink->fsec = p; } /* *************** *** 747,754 **** mlink->name = p + 1; *p = '\0'; } - mlink->name = mandoc_strdup(mlink->name); - mlink_add(mlink, &st); } --- 747,752 ---- *************** *** 761,774 **** assert(NULL != mlink->file); ! if (NULL == mlink->dsec) ! mlink->dsec = mandoc_strdup(""); ! if (NULL == mlink->arch) ! mlink->arch = mandoc_strdup(""); ! if (NULL == mlink->name) ! mlink->name = mandoc_strdup(""); ! if (NULL == mlink->fsec) ! mlink->fsec = mandoc_strdup(""); if ('0' == *mlink->fsec) { free(mlink->fsec); --- 759,768 ---- assert(NULL != mlink->file); ! mlink->dsec = mandoc_strdup(mlink->dsec ? mlink->dsec : ""); ! mlink->arch = mandoc_strdup(mlink->arch ? mlink->arch : ""); ! mlink->name = mandoc_strdup(mlink->name ? mlink->name : ""); ! mlink->fsec = mandoc_strdup(mlink->fsec ? mlink->fsec : ""); if ('0' == *mlink->fsec) { free(mlink->fsec);