From 304107c793e7da2ff7480477d42c382918153f90 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Sat, 5 Nov 2016 16:35:32 +0000 Subject: don't skip names that match the beginning of the file name; joint work with bcook@ --- regress/usr.bin/mandoc/db/mlinks/mlinks.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'regress') diff --git a/regress/usr.bin/mandoc/db/mlinks/mlinks.c b/regress/usr.bin/mandoc/db/mlinks/mlinks.c index f3e56fe10e0..9fa0543042d 100644 --- a/regress/usr.bin/mandoc/db/mlinks/mlinks.c +++ b/regress/usr.bin/mandoc/db/mlinks/mlinks.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mlinks.c,v 1.1 2016/11/04 19:57:27 schwarze Exp $ */ +/* $OpenBSD: mlinks.c,v 1.2 2016/11/05 16:35:31 schwarze Exp $ */ /* * Copyright (c) 2016 Ingo Schwarze * @@ -33,7 +33,7 @@ main(int argc, char *argv[]) const char *np; /* Names of the page. */ const char *fp; /* Primary filename of the page. */ const char *ep; /* Filname extension including the dot. */ - size_t nlen; + size_t flen, nlen; int32_t i, npages; if (argc != 2) @@ -67,6 +67,7 @@ main(int argc, char *argv[]) ep = strrchr(fp, '/'); if (ep != NULL) fp = ep + 1; + flen = ep - fp; ep = strrchr(fp, '.'); if (ep == NULL) @@ -79,7 +80,7 @@ main(int argc, char *argv[]) /* Skip the primary filename. */ nlen = strlen(np); - if (strncmp(fp, np, nlen) == 0) { + if (nlen == flen && strncmp(fp, np, nlen) == 0) { np = strchr(np, '\0') + 1; continue; } -- cgit v1.2.3