Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 854267 | Differences between
and this patch

Collapse All | Expand All

(-)mandoc-1.14.6.orig/configure (-1 / +1 lines)
Lines 430-436 Link Here
430
[ "${FATAL}" -eq 0 ] || exit 1
430
[ "${FATAL}" -eq 0 ] || exit 1
431
431
432
# --- LDADD ---
432
# --- LDADD ---
433
LDADD="${LDADD} ${LD_NANOSLEEP} ${LD_RECVMSG} ${LD_OHASH} -lz"
433
LDADD="${LDADD} ${LD_NANOSLEEP} ${LD_RECVMSG} ${LD_OHASH} -lbz2 -lz"
434
echo "selected LDADD=\"${LDADD}\"" 1>&2
434
echo "selected LDADD=\"${LDADD}\"" 1>&2
435
echo "selected LDADD=\"${LDADD}\"" 1>&3
435
echo "selected LDADD=\"${LDADD}\"" 1>&3
436
echo 1>&3
436
echo 1>&3
(-)mandoc-1.14.6.orig/lib.in (+1 lines)
Lines 33-38 Link Here
33
LINE("libbluetooth",	"Bluetooth Library (libbluetooth, \\-lbluetooth)")
33
LINE("libbluetooth",	"Bluetooth Library (libbluetooth, \\-lbluetooth)")
34
LINE("libbsdxml",	"eXpat XML parser library (libbsdxml, \\-lbsdxml)")
34
LINE("libbsdxml",	"eXpat XML parser library (libbsdxml, \\-lbsdxml)")
35
LINE("libbsm",		"Basic Security Module Library (libbsm, \\-lbsm)")
35
LINE("libbsm",		"Basic Security Module Library (libbsm, \\-lbsm)")
36
LINE("libbz2",		"Compression Library (libbz2, \\-lbzz)")
36
LINE("libc",		"Standard C\\~Library (libc, \\-lc)")
37
LINE("libc",		"Standard C\\~Library (libc, \\-lc)")
37
LINE("libc_r",		"Reentrant C\\~Library (libc_r, \\-lc_r)")
38
LINE("libc_r",		"Reentrant C\\~Library (libc_r, \\-lc_r)")
38
LINE("libcalendar",	"Calendar Arithmetic Library (libcalendar, \\-lcalendar)")
39
LINE("libcalendar",	"Calendar Arithmetic Library (libcalendar, \\-lcalendar)")
(-)mandoc-1.14.6.orig/main.c (-1 / +4 lines)
Lines 538-544 Link Here
538
					prio += 10; /* Wrong dir name. */
538
					prio += 10; /* Wrong dir name. */
539
				if (search.sec != NULL) {
539
				if (search.sec != NULL) {
540
					ep = strchr(sec, '\0');
540
					ep = strchr(sec, '\0');
541
					if (ep - sec > 3 &&
541
					if (ep - sec > 4 &&
542
					    strncmp(ep - 4, ".bz2", 4) == 0)
543
						ep -= 4;
544
					else if (ep - sec > 3 &&
542
					    strncmp(ep - 3, ".gz", 3) == 0)
545
					    strncmp(ep - 3, ".gz", 3) == 0)
543
						ep -= 3;
546
						ep -= 3;
544
					if ((size_t)(ep - sec) < ssz + 3 ||
547
					if ((size_t)(ep - sec) < ssz + 3 ||
(-)mandoc-1.14.6.orig/mandocdb.c (-6 / +23 lines)
Lines 70-75 Link Here
70
	OP_TEST /* change no databases, report potential problems */
70
	OP_TEST /* change no databases, report potential problems */
71
};
71
};
72
72
73
enum compressor {
74
	compressor_none,
75
	compressor_bzip2,
76
	compressor_gzip
77
};
78
73
struct	str {
79
struct	str {
74
	const struct mpage *mpage; /* if set, the owning parse */
80
	const struct mpage *mpage; /* if set, the owning parse */
75
	uint64_t	 mask; /* bitmask in sequence */
81
	uint64_t	 mask; /* bitmask in sequence */
Lines 102-108 Link Here
102
	char		*fsec;    /* section from file name suffix */
108
	char		*fsec;    /* section from file name suffix */
103
	struct mlink	*next;    /* singly linked list */
109
	struct mlink	*next;    /* singly linked list */
104
	struct mpage	*mpage;   /* parent */
110
	struct mpage	*mpage;   /* parent */
105
	int		 gzip;	  /* filename has a .gz suffix */
111
	enum compressor compressor; /* filename has a compressor suffix */
106
	enum form	 dform;   /* format from directory */
112
	enum form	 dform;   /* format from directory */
107
	enum form	 fform;   /* format from file name suffix */
113
	enum form	 fform;   /* format from file name suffix */
108
};
114
};
Lines 580-586 Link Here
580
	FTS		*f;
586
	FTS		*f;
581
	FTSENT		*ff;
587
	FTSENT		*ff;
582
	struct mlink	*mlink;
588
	struct mlink	*mlink;
583
	int		 gzip;
589
	enum compressor	 compressor;
584
	enum form	 dform;
590
	enum form	 dform;
585
	char		*dsec, *arch, *fsec, *cp;
591
	char		*dsec, *arch, *fsec, *cp;
586
	const char	*path;
592
	const char	*path;
Lines 645-657 Link Here
645
					say(path, "Extraneous file");
651
					say(path, "Extraneous file");
646
				continue;
652
				continue;
647
			}
653
			}
648
			gzip = 0;
654
			compressor = 0;
649
			fsec = NULL;
655
			fsec = NULL;
650
			while (fsec == NULL) {
656
			while (fsec == NULL) {
651
				fsec = strrchr(ff->fts_name, '.');
657
				fsec = strrchr(ff->fts_name, '.');
652
				if (fsec == NULL || strcmp(fsec+1, "gz"))
658
				if (fsec == NULL)
659
					break;
660
				if (!strcmp(fsec+1, "bz2"))
661
					compressor = compressor_bzip2;
662
				else if (!strcmp(fsec+1, "gz"))
663
					compressor = compressor_gzip;
664
				else
653
					break;
665
					break;
654
				gzip = 1;
655
				*fsec = '\0';
666
				*fsec = '\0';
656
				fsec = NULL;
667
				fsec = NULL;
657
			}
668
			}
Lines 697-703 Link Here
697
			mlink->arch = arch;
708
			mlink->arch = arch;
698
			mlink->name = ff->fts_name;
709
			mlink->name = ff->fts_name;
699
			mlink->fsec = fsec;
710
			mlink->fsec = fsec;
700
			mlink->gzip = gzip;
711
			mlink->compressor = compressor;
701
			mlink_add(mlink, ff->fts_statp);
712
			mlink_add(mlink, ff->fts_statp);
702
			continue;
713
			continue;
703
714
Lines 1209-1214 Link Here
1209
			mlink_dest = ohash_find(&mlinks,
1220
			mlink_dest = ohash_find(&mlinks,
1210
			    ohash_qlookup(&mlinks, meta->sodest));
1221
			    ohash_qlookup(&mlinks, meta->sodest));
1211
			if (mlink_dest == NULL) {
1222
			if (mlink_dest == NULL) {
1223
				mandoc_asprintf(&cp, "%s.bz2", meta->sodest);
1224
				mlink_dest = ohash_find(&mlinks,
1225
				    ohash_qlookup(&mlinks, cp));
1226
				free(cp);
1227
			}
1228
			if (mlink_dest == NULL) {
1212
				mandoc_asprintf(&cp, "%s.gz", meta->sodest);
1229
				mandoc_asprintf(&cp, "%s.gz", meta->sodest);
1213
				mlink_dest = ohash_find(&mlinks,
1230
				mlink_dest = ohash_find(&mlinks,
1214
				    ohash_qlookup(&mlinks, cp));
1231
				    ohash_qlookup(&mlinks, cp));
(-)mandoc-1.14.6.orig/mandoc.h (+1 lines)
Lines 261-266 Link Here
261
261
262
	MANDOCERR_SYSERR, /* ===== start of system errors ===== */
262
	MANDOCERR_SYSERR, /* ===== start of system errors ===== */
263
263
264
	MANDOCERR_BZREADOPEN,
264
	MANDOCERR_DUP,
265
	MANDOCERR_DUP,
265
	MANDOCERR_EXEC,
266
	MANDOCERR_EXEC,
266
	MANDOCERR_FDOPEN,
267
	MANDOCERR_FDOPEN,
(-)mandoc-1.14.6.orig/read.c (-27 / +77 lines)
Lines 38-43 Link Here
38
#include <string.h>
38
#include <string.h>
39
#include <unistd.h>
39
#include <unistd.h>
40
#include <zlib.h>
40
#include <zlib.h>
41
#include <bzlib.h>
41
42
42
#include "mandoc_aux.h"
43
#include "mandoc_aux.h"
43
#include "mandoc.h"
44
#include "mandoc.h"
Lines 51-56 Link Here
51
52
52
#define	REPARSE_LIMIT	1000
53
#define	REPARSE_LIMIT	1000
53
54
55
enum compressor { compressor_none, compressor_gzip, compressor_bzip2 };
56
54
struct	mparse {
57
struct	mparse {
55
	struct roff	 *roff; /* roff parser (!NULL) */
58
	struct roff	 *roff; /* roff parser (!NULL) */
56
	struct roff_man	 *man; /* man parser */
59
	struct roff_man	 *man; /* man parser */
Lines 59-65 Link Here
59
	struct buf	 *loop; /* open .while request line */
62
	struct buf	 *loop; /* open .while request line */
60
	const char	 *os_s; /* default operating system */
63
	const char	 *os_s; /* default operating system */
61
	int		  options; /* parser options */
64
	int		  options; /* parser options */
62
	int		  gzip; /* current input file is gzipped */
65
	enum compressor   compressor; /* current input file is compressed */
63
	int		  filenc; /* encoding of the current file */
66
	int		  filenc; /* encoding of the current file */
64
	int		  reparse_count; /* finite interp. stack */
67
	int		  reparse_count; /* finite interp. stack */
65
	int		  line; /* line number in the file */
68
	int		  line; /* line number in the file */
Lines 435-444 Link Here
435
read_whole_file(struct mparse *curp, int fd, struct buf *fb, int *with_mmap)
438
read_whole_file(struct mparse *curp, int fd, struct buf *fb, int *with_mmap)
436
{
439
{
437
	struct stat	 st;
440
	struct stat	 st;
441
	BZFILE		*bz;
438
	gzFile		 gz;
442
	gzFile		 gz;
439
	size_t		 off;
443
	size_t		 off;
440
	ssize_t		 ssz;
444
	ssize_t		 ssz;
441
	int		 gzerrnum, retval;
445
	int		 bzerrnum = 0, gzerrnum = 0, retval;
442
446
443
	if (fstat(fd, &st) == -1) {
447
	if (fstat(fd, &st) == -1) {
444
		mandoc_msg(MANDOCERR_FSTAT, 0, 0, "%s", strerror(errno));
448
		mandoc_msg(MANDOCERR_FSTAT, 0, 0, "%s", strerror(errno));
Lines 452-458 Link Here
452
	 * concerned that this is going to tank any machines.
456
	 * concerned that this is going to tank any machines.
453
	 */
457
	 */
454
458
455
	if (curp->gzip == 0 && S_ISREG(st.st_mode)) {
459
	if (curp->compressor == 0 && S_ISREG(st.st_mode)) {
456
		if (st.st_size > 0x7fffffff) {
460
		if (st.st_size > 0x7fffffff) {
457
			mandoc_msg(MANDOCERR_TOOLARGE, 0, 0, NULL);
461
			mandoc_msg(MANDOCERR_TOOLARGE, 0, 0, NULL);
458
			return -1;
462
			return -1;
Lines 464-470 Link Here
464
			return 0;
468
			return 0;
465
	}
469
	}
466
470
467
	if (curp->gzip) {
471
	if (curp->compressor) {
468
		/*
472
		/*
469
		 * Duplicating the file descriptor is required
473
		 * Duplicating the file descriptor is required
470
		 * because we will have to call gzclose(3)
474
		 * because we will have to call gzclose(3)
Lines 477-490 Link Here
477
			    "%s", strerror(errno));
481
			    "%s", strerror(errno));
478
			return -1;
482
			return -1;
479
		}
483
		}
484
	}
485
486
	bz = NULL;
487
	gz = NULL;
488
	switch (curp->compressor) {
489
	case compressor_none:
490
		break;
491
	case compressor_bzip2:
492
		{
493
			FILE *fp = fdopen(fd, "rb");
494
			if (!fp) {
495
				close(fd);
496
				return -1;
497
			}
498
			if ((bz = BZ2_bzReadOpen(&bzerrnum, fp, 0, 0, NULL, 0)) == NULL) {
499
				mandoc_msg(MANDOCERR_BZREADOPEN, 0, 0,
500
				    "%s", strerror(errno));
501
				close(fd);
502
				return -1;
503
			}
504
		}
505
		break;
506
	case compressor_gzip:
480
		if ((gz = gzdopen(fd, "rb")) == NULL) {
507
		if ((gz = gzdopen(fd, "rb")) == NULL) {
481
			mandoc_msg(MANDOCERR_GZDOPEN, 0, 0,
508
			mandoc_msg(MANDOCERR_GZDOPEN, 0, 0,
482
			    "%s", strerror(errno));
509
			    "%s", strerror(errno));
483
			close(fd);
510
			close(fd);
484
			return -1;
511
			return -1;
485
		}
512
		}
486
	} else
513
		break;
487
		gz = NULL;
514
	}
488
515
489
	/*
516
	/*
490
	 * If this isn't a regular file (like, say, stdin), then we must
517
	 * If this isn't a regular file (like, say, stdin), then we must
Lines 504-511 Link Here
504
			}
531
			}
505
			resize_buf(fb, 65536);
532
			resize_buf(fb, 65536);
506
		}
533
		}
507
		ssz = curp->gzip ?
534
		ssz = bz ? BZ2_bzRead(&bzerrnum, bz, fb->buf + (int)off, fb->sz - off) :
508
		    gzread(gz, fb->buf + (int)off, fb->sz - off) :
535
		    gz ? gzread(gz, fb->buf + (int)off, fb->sz - off) :
509
		    read(fd, fb->buf + (int)off, fb->sz - off);
536
		    read(fd, fb->buf + (int)off, fb->sz - off);
510
		if (ssz == 0) {
537
		if (ssz == 0) {
511
			fb->sz = off;
538
			fb->sz = off;
Lines 513-529 Link Here
513
			break;
540
			break;
514
		}
541
		}
515
		if (ssz == -1) {
542
		if (ssz == -1) {
516
			if (curp->gzip)
543
			if (gz)
517
				(void)gzerror(gz, &gzerrnum);
544
				(void)gzerror(gz, &gzerrnum);
545
			// BZ2_bzerror is the only way to get an error string,
546
			// yet it accepts a BZFILE* and writes to bzerrnum.
518
			mandoc_msg(MANDOCERR_READ, 0, 0, "%s",
547
			mandoc_msg(MANDOCERR_READ, 0, 0, "%s",
519
			    curp->gzip && gzerrnum != Z_ERRNO ?
548
			    bz && bzerrnum < 0 ? BZ2_bzerror(bz, &bzerrnum) :
520
			    zError(gzerrnum) : strerror(errno));
549
			    gz && gzerrnum != Z_ERRNO ? zError(gzerrnum) :
550
			    strerror(errno));
521
			break;
551
			break;
522
		}
552
		}
523
		off += (size_t)ssz;
553
		off += (size_t)ssz;
524
	}
554
	}
525
555
526
	if (curp->gzip && (gzerrnum = gzclose(gz)) != Z_OK)
556
	if (bz)
557
		BZ2_bzclose(bz);
558
	else if (gz && (gzerrnum = gzclose(gz)) != Z_OK)
527
		mandoc_msg(MANDOCERR_GZCLOSE, 0, 0, "%s",
559
		mandoc_msg(MANDOCERR_GZCLOSE, 0, 0, "%s",
528
		    gzerrnum == Z_ERRNO ? strerror(errno) :
560
		    gzerrnum == Z_ERRNO ? strerror(errno) :
529
		    zError(gzerrnum));
561
		    zError(gzerrnum));
Lines 627-633 Link Here
627
	int		  fd, save_errno;
659
	int		  fd, save_errno;
628
660
629
	cp = strrchr(file, '.');
661
	cp = strrchr(file, '.');
630
	curp->gzip = (cp != NULL && ! strcmp(cp + 1, "gz"));
662
	if (cp) {
663
		if (!strcmp(cp+1, "gz"))
664
			curp->compressor = compressor_gzip;
665
		else if (!strcmp(cp+1, "bz2"))
666
			curp->compressor = compressor_bzip2;
667
	}
631
668
632
	/* First try to use the filename as it is. */
669
	/* First try to use the filename as it is. */
633
670
Lines 635-657 Link Here
635
		return fd;
672
		return fd;
636
673
637
	/*
674
	/*
638
	 * If that doesn't work and the filename doesn't
675
	 * If that doesn't work and the filename doesn't already
639
	 * already  end in .gz, try appending .gz.
676
	 * end in a compressor extension, try them all.
640
	 */
677
	 */
641
678
642
	if ( ! curp->gzip) {
679
	if (curp->compressor) {
643
		save_errno = errno;
680
		/* Already ends in a compressor extension. */
644
		mandoc_asprintf(&cp, "%s.gz", file);
681
		return -1;
645
		fd = open(cp, O_RDONLY);
682
	}
646
		free(cp);
683
647
		errno = save_errno;
684
	save_errno = errno;
648
		if (fd != -1) {
685
	mandoc_asprintf(&cp, "%s.bz2", file);
649
			curp->gzip = 1;
686
	fd = open(cp, O_RDONLY);
650
			return fd;
687
	free(cp);
651
		}
688
	errno = save_errno;
689
	if (fd != -1) {
690
		curp->compressor = compressor_bzip2;
691
		return fd;
692
	}
693
694
	save_errno = errno;
695
	mandoc_asprintf(&cp, "%s.gz", file);
696
	fd = open(cp, O_RDONLY);
697
	free(cp);
698
	errno = save_errno;
699
	if (fd != -1) {
700
		curp->compressor = compressor_gzip;
701
		return fd;
652
	}
702
	}
653
703
654
	/* Neither worked, give up. */
704
	/* Nothing worked, give up. */
655
705
656
	return -1;
706
	return -1;
657
}
707
}
Lines 692-698 Link Here
692
	roff_man_reset(curp->man);
742
	roff_man_reset(curp->man);
693
	free_buf_list(curp->secondary);
743
	free_buf_list(curp->secondary);
694
	curp->secondary = NULL;
744
	curp->secondary = NULL;
695
	curp->gzip = 0;
745
	curp->compressor = 0;
696
	tag_alloc();
746
	tag_alloc();
697
}
747
}
698
748

Return to bug 854267