summaryrefslogtreecommitdiffstats
path: root/testing/mansh/mdocml-support.patch
blob: 3ee667549734dbb13b3d29771d14f0adc0c0c41d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
--- man.orig
+++ man.sh
@@ -88,45 +88,13 @@
 	decho "Using manual path: $MANPATH"
 }
 
-# Usage: check_cat catglob
-# Checks to see if a cat glob is available.
-check_cat() {
-	if exists "$1"; then
-		use_cat=yes
-		catpage=$found
-		setup_cattool $catpage
-		decho "    Found catpage $catpage"
-		return 0
-	else
-		return 1
-	fi
-}
-
 # Usage: check_man manglob catglob
 # Given 2 globs, figures out if the manglob is available, if so, check to
 # see if the catglob is also available and up to date.
 check_man() {
 	if exists "$1"; then
-		# We have a match, check for a cat page
 		manpage=$found
-		setup_cattool $manpage
 		decho "    Found manpage $manpage"
-
-		if [ -n "${use_width}" ]; then
-			# non-standard width
-			unset use_cat
-			decho "    Skipping catpage: non-standard page width"
-		elif exists "$2" && is_newer $found $manpage; then
-			# cat page found and is newer, use that
-			use_cat=yes
-			catpage=$found
-			setup_cattool $catpage
-			decho "    Using catpage $catpage"
-		else
-			# no cat page or is older
-			unset use_cat
-			decho "    Skipping catpage: not found or old"
-		fi
 		return 0
 	fi
 
@@ -167,13 +135,11 @@
 # Returns: true if something is matched and found.
 # Search the given path/section combo for a given page.
 find_file() {
-	local manroot catroot mann man0 catn cat0
+	local manroot mann man0
 
 	manroot="$1/man$2"
-	catroot="$1/cat$2"
 	if [ -n "$3" ]; then
 		manroot="$manroot/$3"
-		catroot="$catroot/$3"
 	fi
 
 	if [ ! -d "$manroot" ]; then
@@ -183,19 +149,13 @@
 
 	mann="$manroot/$4.$2*"
 	man0="$manroot/$4.0*"
-	catn="$catroot/$4.$2*"
-	cat0="$catroot/$4.0*"
 
 	# This is the behavior as seen by the original man utility.
 	# Let's not change that which doesn't seem broken.
-	if check_man "$mann" "$catn"; then
+	if check_man "$mann"; then
 		return 0
-	elif check_man "$man0" "$cat0"; then
+	elif check_man "$man0"; then
 		return 0
-	elif check_cat "$catn"; then
-		return 0
-	elif check_cat "$cat0"; then
-		return 0
 	fi
 
 	return 1
@@ -279,31 +239,13 @@
 # Usage: man_display_page
 # Display either the manpage or catpage depending on the use_cat variable
 man_display_page() {
-	local EQN NROFF PIC TBL TROFF REFER VGRIND
-	local IFS l nroff_dev pipeline preproc_arg tool
+	local NROFF
+	local IFS l pipeline preproc_arg tool
 
 	# We are called with IFS set to colon. This causes really weird
 	# things to happen for the variables that have spaces in them.
 	unset IFS
 
-	# If we are supposed to use a catpage and we aren't using troff(1)
-	# just zcat the catpage and we are done.
-	if [ -z "$tflag" -a -n "$use_cat" ]; then
-		if [ -n "$wflag" ]; then
-			echo "$catpage (source: $manpage)"
-			ret=0
-		else
-			if [ $debug -gt 0 ]; then
-				decho "Command: $cattool $catpage | $MANPAGER"
-				ret=0
-			else
-				eval "$cattool $catpage | $MANPAGER"
-				ret=$?
-			fi
-		fi
-		return
-	fi
-
 	# Okay, we are using the manpage, do we just need to output the
 	# name of the manpage?
 	if [ -n "$wflag" ]; then
@@ -312,88 +254,17 @@
 		return
 	fi
 
-	# So, we really do need to parse the manpage. First, figure out the
-	# device flag (-T) we have to pass to eqn(1) and groff(1). Then,
-	# setup the pipeline of commands based on the user's request.
+	NROFF="$NROFF -Tutf8"
 
-	# If the manpage is from a particular charset, we need to setup nroff
-	# to properly output for the correct device.
-	case "${manpage}" in
-	*.${man_charset}/*)
-		# I don't pretend to know this; I'm just copying from the
-		# previous version of man(1).
-		case "$man_charset" in
-		KOI8-R)		nroff_dev="koi8-r" ;;
-		ISO8859-1)	nroff_dev="latin1" ;;
-		ISO8859-15)	nroff_dev="latin1" ;;
-		UTF-8)		nroff_dev="utf8" ;;
-		*)		nroff_dev="ascii" ;;
-		esac
-
-		NROFF="$NROFF -T$nroff_dev"
-		EQN="$EQN -T$nroff_dev"
-
-		# Iff the manpage is from the locale and not just the charset,
-		# then we need to define the locale string.
-		case "${manpage}" in
-		*/${man_lang}_${man_country}.${man_charset}/*)
-			NROFF="$NROFF -dlocale=$man_lang.$man_charset"
-			;;
-		*/${man_lang}.${man_charset}/*)
-			NROFF="$NROFF -dlocale=$man_lang.$man_charset"
-			;;
-		esac
-
-		# Allow language specific calls to override the default
-		# set of utilities.
-		l=$(echo $man_lang | tr [:lower:] [:upper:])
-		for tool in EQN NROFF PIC TBL TROFF REFER VGRIND; do
-			eval "$tool=\${${tool}_$l:-\$$tool}"
-		done
-		;;
-	*)	NROFF="$NROFF -Tascii"
-		EQN="$EQN -Tascii"
-		;;
-	esac
-
-	if [ -z "$MANCOLOR" ]; then
-		NROFF="$NROFF -P-c"
-	fi
-
 	if [ -n "${use_width}" ]; then
-		NROFF="$NROFF -rLL=${use_width}n -rLT=${use_width}n"
+		NROFF="$NROFF -Owidth=${use_width}"
 	fi
 
-	if [ -n "$MANROFFSEQ" ]; then
-		set -- -$MANROFFSEQ
-		while getopts 'egprtv' preproc_arg; do
-			case "${preproc_arg}" in
-			e)	pipeline="$pipeline | $EQN" ;;
-			g)	;; # Ignore for compatability.
-			p)	pipeline="$pipeline | $PIC" ;;
-			r)	pipeline="$pipeline | $REFER" ;;
-			t)	pipeline="$pipeline | $TBL" ;;
-			v)	pipeline="$pipeline | $VGRIND" ;;
-			*)	usage ;;
-			esac
-		done
-		# Strip the leading " | " from the resulting pipeline.
-		pipeline="${pipeline#" | "}"
-	else
-		pipeline="$TBL"
-	fi
-
-	if [ -n "$tflag" ]; then
-		pipeline="$pipeline | $TROFF"
-	else
-		pipeline="$pipeline | $NROFF | $MANPAGER"
-	fi
-
 	if [ $debug -gt 0 ]; then
-		decho "Command: $cattool $manpage | $pipeline"
+		decho "Command: $NROFF $manpage | $MANPAGER"
 		ret=0
 	else
-		eval "$cattool $manpage | $pipeline"
+		eval "$NROFF $manpage | $MANPAGER"
 		ret=$?
 	fi
 }
@@ -408,9 +279,7 @@
 	case "$1" in
 	*/*)	if [ -f "$1" -a -r "$1" ]; then
 			decho "Found a usable page, displaying that"
-			unset use_cat
 			manpage="$1"
-			setup_cattool $manpage
 			if man_check_for_so $manpage $(dirname $manpage); then
 				found_page=yes
 				man_display_page
@@ -428,33 +297,6 @@
 				p=$path/$locpath
 				p=${p%/.} # Rid ourselves of the trailing /.
 
-				# Check if there is a MACHINE specific manpath.
-				if find_file $p $sect $MACHINE "$1"; then
-					if man_check_for_so $manpage $p; then
-						found_page=yes
-						man_display_page
-						if [ -n "$aflag" ]; then
-							continue 2
-						else
-							return
-						fi
-					fi
-				fi
-
-				# Check if there is a MACHINE_ARCH
-				# specific manpath.
-				if find_file $p $sect $MACHINE_ARCH "$1"; then
-					if man_check_for_so $manpage $p; then
-						found_page=yes
-						man_display_page
-						if [ -n "$aflag" ]; then
-							continue 2
-						else
-							return
-						fi
-					fi
-				fi
-
 				# Check plain old manpath.
 				if find_file $p $sect '' "$1"; then
 					if man_check_for_so $manpage $p; then
@@ -544,19 +386,6 @@
 # Usage: man_setup
 # Setup various trivial but essential variables.
 man_setup() {
-	# Setup machine and architecture variables.
-	if [ -n "$mflag" ]; then
-		MACHINE_ARCH=${mflag%%:*}
-		MACHINE=${mflag##*:}
-	fi
-	if [ -z "$MACHINE_ARCH" ]; then
-		MACHINE_ARCH=$($SYSCTL -n hw.machine_arch)
-	fi
-	if [ -z "$MACHINE" ]; then
-		MACHINE=$($SYSCTL -n hw.machine)
-	fi
-	decho "Using architecture: $MACHINE_ARCH:$MACHINE"
-
 	setup_pager
 
 	# Setup manual sections to search.
@@ -582,14 +411,6 @@
 			use_width=$MANWIDTH
 		fi
 		;;
-	[Tt][Tt][Yy])
-		if { sizes=$($STTY size 0>&3 2>/dev/null); } 3>&1; then
-			set -- $sizes
-			if [ $2 -gt 80 ]; then
-				use_width=$(($2-2))
-			fi
-		fi
-		;;
 	esac
 	if [ -n "$use_width" ]; then
 		decho "Using non-standard page width: ${use_width}"
@@ -601,38 +422,8 @@
 # Usage: man_setup_locale
 # Setup necessary locale variables.
 man_setup_locale() {
-	local lang_cc
 
 	locpaths='.'
-	man_charset='US-ASCII'
-
-	# Setup locale information.
-	if [ -n "$oflag" ]; then
-		decho 'Using non-localized manpages'
-	else
-		# Use the locale tool to give us the proper LC_CTYPE
-		eval $( $LOCALE )
-
-		case "$LC_CTYPE" in
-		C)		;;
-		POSIX)		;;
-		[a-z][a-z]_[A-Z][A-Z]\.*)
-				lang_cc="${LC_CTYPE%.*}"
-				man_lang="${LC_CTYPE%_*}"
-				man_country="${lang_cc#*_}"
-				man_charset="${LC_CTYPE#*.}"
-				locpaths="$LC_CTYPE"
-				locpaths="$locpaths:$man_lang.$man_charset"
-				if [ "$man_lang" != "en" ]; then
-					locpaths="$locpaths:en.$man_charset"
-				fi
-				locpaths="$locpaths:."
-				;;
-		*)		echo 'Unknown locale, assuming C' >&2
-				;;
-		esac
-	fi
-
 	decho "Using locale paths: $locpaths"
 }
 
@@ -822,19 +613,6 @@
 	exit $rval
 }
 
-# Usage: setup_cattool page
-# Finds an appropriate decompressor based on extension
-setup_cattool() {
-	case "$1" in
-	*.bz)	cattool='/usr/bin/bzcat' ;;
-	*.bz2)	cattool='/usr/bin/bzcat' ;;
-	*.gz)	cattool='/usr/bin/zcat' ;;
-	*.lzma)	cattool='/usr/bin/lzcat' ;;
-	*.xz)	cattool='/usr/bin/xzcat' ;;
-	*)	cattool='/usr/bin/zcat -f' ;;
-	esac
-}
-
 # Usage: setup_pager
 # Correctly sets $MANPAGER
 setup_pager() {
@@ -932,22 +710,12 @@
 }
 
 # User's PATH setting decides on the groff-suite to pick up.
-EQN=eqn
-NROFF='groff -S -P-h -Wall -mtty-char -man'
-PIC=pic
-REFER=refer
-TBL=tbl
-TROFF='groff -S -man'
-VGRIND=vgrind
+NROFF='mandoc'
 
-LOCALE=/usr/bin/locale
-STTY=/bin/stty
-SYSCTL=/sbin/sysctl
-
 debug=0
 man_default_sections='1:1aout:8:2:3:n:4:5:6:7:9:l'
 man_default_path='/usr/share/man:/usr/share/openssl/man:/usr/local/man'
-cattool='/usr/bin/zcat -f'
+cattool=/bin/cat
 
 config_global='/etc/man.conf'