aboutsummaryrefslogtreecommitdiff
path: root/texinfo/util/update-info
blob: 0d31fde4d27b40587ae8a70bb40f55175341b9f1 (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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
#!/bin/sh
# update-info -- update dir file from all extant info pages.
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, you can either send email to this
# program's maintainer or write to: The Free Software Foundation,
# Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
# 
# Author: rhawes@dmapub.dma.org.  Please report bugs to him.
# 
# run this program to install update-info
# ###SECTION 0### install script
# These constants set the version numbers for both files:
PROGRAM_VERSION="1.4"
PACKAGE_VERSION="4.0"

# ENVIRONMENT
if test -z "$TMPDIR"; then
	TMPDIR="/usr/tmp"
fi

TMP_SED="$TMPDIR/uss$$.info"
TMP_F_ADD_SECTION="$TMPDIR/ufa$$.info"
TMP_F_DELETE_INVALID="$TMPDIR/ufd$$.info"
TMP_F_INSERT_MISSING="$TMPDIR/ufi$$.info"
TMP_FILES="$TMP_SED $TMP_F_ADD_SECTION $TMP_F_DELETE_INVALID\
	$TMP_F_INSERT_MISSING"

trap 'rm -f $TMP_FILES' 0

# file boundaries
UPDATE_INFO="/^# _file: 'update-info'_/"
UPDATE_INFO_F="/^# _file: 'update-info.f'_/"

# @F_ADD_SECTION@
echo 'Item_Num=`expr "$Item_Num" + "1"`
echo "$1">>"$TMP_SECTIONS"
if test "$Item_Status"; then
	Item_Status=`echo "${Item_Status}
X"`
else
	Item_Status="X"
fi '>$TMP_F_ADD_SECTION

# @F_INSERT_MISSING@
echo 'if test -z "$Create_Node"; then
	rm -f ${Info_Node}.old
	cp $Info_Node ${Info_Node}.old
	echo "$BACKUP_MSG"
fi
echo "/$MENU_BEGIN/
+,$ d
r $TMP_MENU
w
q"|ed -s $Info_Node>/dev/null'>$TMP_F_INSERT_MISSING

# @F_DELETE_INVALID@
echo '
rm -f ${Info_Node}.old
cp $Info_Node ${Info_Node}.old
echo "$BACKUP_MSG"
echo "/$MENU_BEGIN/
+,$ d
w
q"|ed -s $Info_Node>/dev/null
sed -f "$TMP_SED" "$TMP_MENU">>"$Info_Node"'>$TMP_F_DELETE_INVALID

cat<<Sed_Script_EOF>$TMP_SED
s/@UPDATE_INFO_VERSION@/$PROGRAM_VERSION/g
s/@TEXINFO_VERSION@/$PACKAGE_VERSION/g
s/@SET_ITEM@/Item_Status=\`echo "\$Item_Status"|sed -e "\${1}s%^.*%\${2}%"\`/
/@F_ADD_SECTION@/r $TMP_F_ADD_SECTION
/@F_ADD_SECTION@/d
/@F_DELETE_INVALID@/r $TMP_F_DELETE_INVALID
/@F_DELETE_INVALID@/d
/@F_INSERT_MISSING@/r $TMP_F_INSERT_MISSING
/@F_INSERT_MISSING@/d
Sed_Script_EOF

sed -e "1,${UPDATE_INFO}d" -e "$UPDATE_INFO_F,\$d" -f $TMP_SED $0>update-info
sed -e "1,${UPDATE_INFO_F}d" -f $TMP_SED $0>update-info.f
chmod +x update-info update-info.f
echo "installed update-info, and update-info.f into `pwd`"
rm -f $TMP_FILES
exit

# _file: 'update-info'_
#!/bin/sh
#update-info (GNU texinfo @TEXINFO_VERSION@) @UPDATE_INFO_VERSION@
#Copyright (C) 1997 Free Software Foundation, Inc.
#update-info comes with NO WARRANTY, to the extent permitted by law.
#You may redistribute copies of update-info
#under the terms of the GNU General Public License.
#For more information about these matters, see the files named COPYING."
#Author: Richard L. Hawes

# ###SECTION 1### Constants
set -h 2>/dev/null
# ENVIRONMENT
if test -z "$TMPDIR"; then
	TMPDIR="/usr/tmp"
fi
if test -z "$LINES"; then
	LINES=24
fi
if test -z "$COLUMNS"; then
	COLUMNS=80
fi
if test -z "$EDITOR"; then
	EDITOR=vi
fi
if test -z "$LINENO"; then
	LINENO="0"
fi
# constants redefined by update-info.f
PROMPT1="(y=yes, Y=yes to all, n=no, N=No to all):"
FUNCTIONS=""
#
ARGUMENTS="$*"
DISPLAY_NUM=`expr "$LINES" - 4`
CONTROL_D="{Ctrl-D}"
DIR_SECTION="^INFO-DIR-SECTION"
ENTRY_END="^END-INFO-DIR-ENTRY"
ENTRY_START="^START-INFO-DIR-ENTRY"
MENU_BEGIN='^\*\([ 	]\)\{1,\}Menu:'
MENU_ITEM='^\* ([^ 	]).*:([ 	])+\('
SECTION_TITLE="^[A-Za-z0-9]"
MENU_FILTER1='s/^\*\([ 	]\)\{1,\}/* /'
MENU_FILTER2='s/\([ 	]\)\{1,\}$//g'
TMP_ITEM="${TMPDIR}/ui${$}.info"
TMP_LIST="${TMPDIR}/ul${$}.info"
TMP_MENU="${TMPDIR}/um${$}.info"
TMP_SECTIONS="${TMPDIR}/us${$}.info" # used only in Detect_Missing
TMP_SED="$TMP_SECTIONS" # used only in Detect_Invalid routines
TMP_FILE1="${TMPDIR}/ux${$}.info"
TMP_FILE2="${TMPDIR}/uy${$}.info"
TMP_COUNT="$TMP_FILE2"
TMP_FILE_LIST="$TMP_LIST $TMP_MENU $TMP_SECTIONS $TMP_FILE1 $TMP_FILE2\
	$TMP_ITEM"
TRY_HELP_MSG="Try --help for more information"
if zcat --version 2>/dev/null>/dev/null; then
	CAT_COMMAND="zcat -f"
else
	echo "$0:$LINENO: GNU zcat not found">&2
	CAT_COMMAND="cat"
fi

# ###SECTION 100### main program
#variables set by options
Create_Node=""
Debug=":"
Interactive=""
Load_Functions="y"
Mode=""
#
Inserts="0"
Inserts_Total="0"
Invalid="0"
Invalid_Total="0"
Changed=""

while test "$*"
	do
	case "$1" in
		-c)             Create_Node="y";;
		-ci|-ic)        Create_Node="y"; Interactive="y";;
		-cif|-cfi|-ifc|-icf|-fci|-fic) Create_Node="y"
				Interactive="y"; Load_Functions="";;
		--debug)	set -eux; Debug="set>&2";;
		-d|--delete)	Mode="Detect_Invalid";;
		-f)		Load_Functions="";;
		-i|--interactive) Interactive="y";;
		-fi|-if)	Load_Functions=""; Interactive="y";;
		-id|-di)	Mode="Detect_Invalid"; Interactive="y";;
		+i|+d|+f);;
		--version)
cat<<VersionEOF
update-info (GNU texinfo @TEXINFO_VERSION@) @UPDATE_INFO_VERSION@
Copyright (C) 1997 Free Software Foundation, Inc.
update-info comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of update-info
under the terms of the GNU General Public License.
For more information about these matters, see the files named COPYING.
Author: Richard L. Hawes
VersionEOF
		exit;;

		--help)
cat<<HelpEndOfFile
Usage:	update-info  [OPTION]... INFO_PATH/INFO_DIR_FILE

It detects and inserts missing menu items into the info node file.

Options:
-c			create a new info node
	--debug		print debug information to standard error path
-d,	--delete	delete invalid menu items (ignore missing menu items)
-f			do not load functions (file update-info.f)
	--help		print this help message and exit
-i,	--interactive	interactive mode prompts before inserting or removing
			menu items
	--version	print current version and exit
Backup of the info node has a '.old' suffix added.  This is a shell script.
Files: update-info.f -- contains functions (optional).
Environment Variables: COLUMNS, EDITOR, LINES, TMPDIR
Email bug reports to bug-texinfo@gnu.org.
HelpEndOfFile
		exit;;

		[-+]*)	echo "$0:$LINENO: \"$1\" is not a valid option">&2
			echo "$TRY_HELP_MSG">&2
			exit 2;;
		*) break;;
	esac
	shift
	done

if test "$#" -lt "1"; then
	echo "$0:$LINENO: Too few parameters">&2
	echo "$TRY_HELP_MSG">&2
	exit 2
elif test "$#" -gt "1"; then
	echo "$0:$LINENO: Too many parameters">&2
	echo "$TRY_HELP_MSG">&2
	exit 2
fi
Info_Path="$1"
Info_Node=`basename "$Info_Path"`
if echo "$Info_Node"|grep ".*dir$">/dev/null; then
	:
else
	echo "$0:$LINENO: $Info_Node is not a valid info node name">&2
	exit 2
fi
Info_Pathname=`dirname "$Info_Path"`
cd "$Info_Pathname"||exit

BACKUP_MSG="Backed up $Info_Node to ${Info_Node}.old."
HANGUP_MSG="Hang up on \"update-info $ARGUMENTS\""
INSERT_MSG="menu item(s) were inserted (not counting duplicates)."
INSERT_MSG2="total menu item(s) were inserted into `pwd`/$Info_Node"
DELETE_MSG="invalid menu item(s) were removed (not counting duplicates)."
DELETE_MSG2="total invalid menu item(s) were removed from `pwd`/$Info_Node"

if test "$Create_Node"; then
	if test "$Mode"; then
		echo "$0:$LINENO: ERROR: Illogical option combination: -d -c">&2
		echo "$TRY_HELP_MSG">&2
		exit 2
	fi
	if test -f "$Info_Node"; then
		rm -f ${Info_Node}.old
		mv "$Info_Node" "${Info_Node}.old"
		echo "$BACKUP_MSG"
	fi
	echo "Creating new Info Node: `pwd`/$Info_Node"
cat>$Info_Node<<NodeEndOfFile||exit

This is the file .../info/dir, which contains the topmost node of the
Info hierarchy.  The first time you invoke Info you start off
looking at that node, which is (dir)Top.

File: dir	Node: Top	This is the top of the INFO tree
  This (the Directory node) gives a menu of major topics.
  Typing "d" returns here, "q" exits, "?" lists all INFO commands, "h"
  gives a primer for first-timers, "mTexinfo<Return>" visits Texinfo topic,
  etc.
  Or click mouse button 2 on a menu item or cross reference to select it.
  --- PLEASE ADD DOCUMENTATION TO THIS TREE. (See INFO topic first.) ---

* Menu: The list of major topics begins on the next line.

NodeEndOfFile
else
	if test ! -f "$Info_Node"; then
		echo "$0:$LINENO: $Info_Node is irregular or nonexistant">&2
		exit 2
	elif test ! -r "$Info_Node"; then
		echo "$0:$LINENO: $Info_Node is not readable">&2
		exit 2
	elif test ! -w "$Info_Node"; then
		echo "$0:$LINENO: $Info_Node is not writeable">&2
		exit 2
	fi
fi

if test "$Load_Functions" -a "$Interactive" -a -z "$Mode"; then
	if FUNCTIONS_VERSION=`( update-info.f )`; then
		if test `echo "$FUNCTIONS_VERSION"\
		|cut -d' ' -f5` = "@UPDATE_INFO_VERSION@"; then
			echo "Loading functions..."
			. update-info.f
		else
			echo "$0:$LINENO: wrong version of update-info.f">&2
			echo "(functions were not loaded)">&2
		fi
	else
		echo "(functions were not loaded)">&2
	fi
fi


trap ' eval "$Debug"; rm -f $TMP_FILE_LIST; exit ' 0
if test "$Interactive"; then
	if test ! -t "1"; then
		echo "$0:$LINENO: Cannot run in interactive mode  "\
		"standard out is redirected">&2
		exit 2
	fi
	trap ' ' 2 3
else
	trap ' rm -f $TMP_FILE_LIST
	echo "$0:$LINENO: received INT signal.  All edits are canceled.">&2
	exit ' 2
	trap ' rm -f $TMP_FILE_LIST
	echo "$0:$LINENO: received QUIT signal.  All edits are canceled.">&2
	exit ' 3
fi
if test -z "$Mode"; then
	trap '
	if test "$Changed"; then
		{
		echo $HANGUP_MSG
		@F_INSERT_MISSING@
		Inserts_Total=`wc -c<"$TMP_COUNT"`
		echo $Inserts_Total $INSERT_MSG2
		}|mail "$LOGNAME"
	fi
	rm -f $TMP_FILE_LIST
	exit ' 1
else
	trap '
	if test "$Changed"; then
		{
		echo $HANGUP_MSG
		@F_DELETE_INVALID@
		Invalid_Total=`wc -l<"$TMP_SED"`
		echo $Invalid_Total $DELETE_MSG2
		}|mail $LOGNAME
	fi
	rm -f $TMP_FILE_LIST
	exit ' 1
fi

sed -e "1,/$MENU_BEGIN/d" -e "$MENU_FILTER1" -e "$MENU_FILTER2"<$Info_Node\
|tee $TMP_MENU\
|sed -n -e '/\* /{
s/).*$//g
s/\.gz$//
s/\.info$//
s/^.*(//p
}'|sort -u>$TMP_FILE1
ls -F|sed -e '/\/$/d' -e '/[-.][0-9]/d'\
	-e '/:$/d' -e '/^$/d' -e "/^${Info_Node}~\$/d"\
	-e "/^${Info_Node}\$/d" -e "/^${Info_Node}.old\$/d"\
	-e 's/\.gz$//' -e 's/\.info$//'|sort>$TMP_FILE2

if test -z "$Mode"; then
	#Detect Missing
	comm -13 $TMP_FILE1 $TMP_FILE2>$TMP_LIST
	cat</dev/null>$TMP_COUNT
	#get sections, initialize variables
	sed -n -e "/$SECTION_TITLE/p" "$TMP_MENU">"$TMP_SECTIONS"
	Item_Num=`wc -l<"$TMP_SECTIONS"|tr -d ' '`
	Item_Status=`echo\
	|awk "BEGIN{for(i=1;i<=${Item_Num};i++)printf(\"_\n\")}"`
	Item_Dir="$Item_Num"
	for Info_Name in `cat $TMP_LIST`
		do
		if test -r "$Info_Name"; then
			Info_File="$Info_Name"
		elif test -r "${Info_Name}.info"; then
			Info_File="${Info_Name}.info"
		elif test -r "${Info_Name}.gz"; then
			Info_File="${Info_Name}.gz"
		elif test -r "${Info_Name}.info.gz"; then
			Info_File="${Info_Name}.info.gz"
		else
			echo "$0:$LINENO: can't find info file for ${Info_Name}?">&2
		fi
		#generate menu item
		echo|tr -d '\012'>$TMP_FILE1
		eval $CAT_COMMAND "$Info_File"\
		|sed -n -e "/$DIR_SECTION/w $TMP_FILE1"\
		-e "/$ENTRY_START/,/$ENTRY_END/{
		$MENU_FILTER1
		p
		}"|awk "BEGIN{Mode=0}
		/^$/{if(Mode==1)exit}
		/^([ 	])+([^ 	])+/{if(Mode==1)print}
		/^[^ 	]/{if(Mode==1)exit}
		/${MENU_ITEM}${Info_Name}\)\./{if(Mode==0){Mode++
				print}
			else
				exit}">"$TMP_ITEM"
		if test ! -s "$TMP_ITEM"; then
			echo "* $Info_Name: ($Info_Name).">"$TMP_ITEM"
		fi
		Item_Status=`echo "$Item_Status"|sed -e '1,$s/^./_/'`
		if test -s "$TMP_FILE1"; then
			Item_Section=`sed -e "s/$DIR_SECTION[ 	]*//"\
			<$TMP_FILE1`
		else
			Item_Section=`echo "Miscellaneous"`
		fi
		Size=`echo "$Item_Section"|wc -l|tr -d ' '`
		# initialize variables, check for new sections
		Num1=1
		while test "$Num1" -le "$Size"
			do
			Item=`echo "$Item_Section"|sed -n -e "${Num1}p"`
			if Num=`grep -in "^$Item$" "$TMP_SECTIONS"`; then
				Num=`echo "$Num"|sed -e 's/:.*$//g'`
				##F#Set_Item
				set "$Num" "X"
				@SET_ITEM@
			else
				set "$Item"
				@F_ADD_SECTION@
			fi
			Num1=`expr "$Num1" + "1"`
			done
		if test "$Interactive"; then
			echo "$Item_Section"
			cat "$TMP_ITEM"
			echo "add menu item for $Info_File? "
			while true
				do
				echo "$PROMPT1"|tr -d '\012'
				read Answer
				case $Answer in
					y) break;;
					e)
					if test "$FUNCTIONS"; then
						Select_Sections
						break
					else
						echo "Can't edit.  "\
						"Functions are not loaded.">&2
					fi;;
					Y) Interactive=""; break;;
					n) continue 2;;
					N) break 2;;
					*) echo "\"$Answer\" "\
					"is an invalid response">&2;;
					esac
				done
		fi
		if echo "$Item_Status"|grep '^X'>/dev/null; then
			# edit $TMP_MENU

			Changed="y"
			(
			trap ' ' 1 2 3
			Tmp_Var=`echo "$Item_Status"|tr -d '\012'`
			Key=`awk -F':' ' FNR==1{ print $1}' $TMP_ITEM`
			# add new sections to 'dir' file
			if test "$Item_Num" -gt "$Item_Dir"; then
				if test "$Item_Dir" -ne "0"; then
					sed -e "1,${Item_Dir}d" -e 'i\

' "$TMP_SECTIONS">>"$TMP_MENU"
				else
					sed -e 'i\

' "$TMP_SECTIONS">>"$TMP_MENU"
				fi
			fi
			# awk determines the insertion points for each section
			awk -F":" "function Insert(Line){
			if(Mode==2){
				Mode=1;if(substr(\"$Tmp_Var\",Item++,1)==\"X\")
					print Line
				}
			}
			BEGIN{Mode=1;Item=1}
			/$SECTION_TITLE/{Insert(FNR-1);if(Mode>=1)Mode=2}
			/${MENU_ITEM}.*\)\./{if(\$1>Item_Name)Insert(FNR-1)}
			/^$/{Insert(FNR-1)}
			END{Insert(FNR)}" Item_Name="$Key" "$TMP_MENU"\
			|sort -nr|sed -e "s%\$% r $TMP_ITEM%"|sed -e '$a\
w
' -e '$a\
q
'|ed -s "$TMP_MENU"
			echo "$Item_Status"|tr -cd "X">>$TMP_COUNT
			)

			Inserts=`expr "$Inserts" + "1"`
			echo "$Info_File installed into section(s):"\
			|tr -d '\012'
			echo "$Item_Status"|awk '/X/{printf(" %d", FNR)}'
			echo
			Item_Dir="$Item_Num"
		else
			echo "$Info_File not installed (no section selected)"
		fi
		done
	# print summary
	trap ' ' 1 2 3
	if test "$Changed"; then
		@F_INSERT_MISSING@
		Inserts_Total=`wc -c<"$TMP_COUNT"|tr -d " "`
		if test "$Inserts" -ne "$Inserts_Total"; then
			echo "$Inserts $INSERT_MSG"
		fi
		echo "$Inserts_Total $INSERT_MSG2"
	fi
else
	# Detect Invalid
	cat</dev/null>"$TMP_SED"
	comm -23 $TMP_FILE1 $TMP_FILE2>$TMP_LIST
	for Info_Name in `cat $TMP_LIST`
		do
		if test "$Interactive"; then
			# display invalid menu item(s)
			awk "BEGIN{Mode=1}
			/^([ 	])+([^ 	])+/{if(Mode==2)print}
			/^$/{if(Mode==2)Mode=1}
			/$SECTION_TITLE/{Section=\$0}
			/^[^ 	]/{if(Mode==2)Mode=1}
			/${MENU_ITEM}${Info_Name}\)\./{if(Mode==1){Mode++
				print Section
				print}}" $TMP_MENU
			echo "delete menu item for $Info_Name? "
			while true
				do
				echo\
				"(y=yes, n=no, Y=yes to all, N=No to all):"\
				|tr -d '\012'
				read Answer
				case "$Answer" in
					y) break;;
					Y) Interactive=""; break;;
					n) continue 2;;
					N) break 2;;
					*) echo "\"$Answer\" "\
					"is an invalid reponse">&2;;
					esac
				done
		fi
		# remove menu item from $TMP_MENU
		Invalid=`expr "$Invalid" + "1"`
		Changed="y"
		(
		trap ' ' 1 2 3
		echo\
		"invalid menu item for $Info_Name removed from section(s):"\
		|tr -d '\012'
		awk "function Delete(Last){
		printf(\"%d,%dd\n\",First,Last-1)>>\"$TMP_SED\"}
		BEGIN{Mode=1;Section=0}
		/^$/{if(Mode==2){Delete(FNR);Mode=1}}
		/$SECTION_TITLE/{Section++}
		/^[^ 	]/{if(Mode==2){Delete(FNR);Mode=1}}
		/${MENU_ITEM}${Info_Name}\)\./{if(Mode==1){
			First=FNR;printf(\" %d\",Section);Mode=2}}
		END{if(Mode==2)Delete(FNR+1)}" $TMP_MENU
		echo
		)
		done

	# display a summary
	trap ' ' 1 2 3
	if test "$Changed"; then
		Invalid_Total=`wc -l<"$TMP_SED"|tr -d ' '`
		@F_DELETE_INVALID@
		if test "$Invalid" -ne "$Invalid_Total"; then
			echo "$Invalid $DELETE_MSG"
		fi
		echo "$Invalid_Total $DELETE_MSG2"
	fi
fi
if test -z "$Changed"; then
	echo "Nothing to do"
fi
rm -f $TMP_FILE_LIST
eval "$Debug"
exit 0
# _file: 'update-info.f'_
#update-info.f (GNU texinfo @TEXINFO_VERSION@) @UPDATE_INFO_VERSION@
#Copyright (C) 1997 Free Software Foundation, Inc.
#update-info comes with NO WARRANTY, to the extent permitted by law.
#You may redistribute copies of update-info
#under the terms of the GNU General Public License.
#For more information about these matters, see the files named COPYING."
#Author: Richard L. Hawes

# update-info.f functions for update-info

# ###SECTION 1### functions used to insert missing menu items

Set_Item (){
# set item status
@SET_ITEM@
}

Add_Section (){
# add a section
@F_ADD_SECTION@
}

# ###SECTION 2### functions for menu selection of sections

Print (){
# print a line without a linefeed
echo "$*"|tr -d '\012'
}

Get_Answer (){
# get an answer to question
_gs_Valid="$1"
_gs_Prompt="$2"
set -f
Answer=""
while test -z "$Answer"
	do
	Print "$_gs_Prompt"
	if read Answer; then
		:
	else
		Answer="$CONTROL_D"
		echo
	fi
	if expr "$Answer" : "[$_gs_Valid]$">/dev/null; then
		:
	else
		Print "\"$Answer\" is not a valid response! --">&2
		Answer=""
	fi
	done
set +f
}

Do_Previous (){
# go to previous screen
if test "$Previous"; then
	Next="$Top_Item"
	Top_Item="$Previous"
	if Previous=`expr "$Top_Item" - "$DISPLAY_NUM"`; then
		if test "$Previous" -le "0"; then
			Previous=""
		fi
	else
		Previous=""
	fi
elif test "$Next"; then
	Last_Page
else
	Print "There is no previous page. ">&2
fi
}

Do_Next (){
# process go to next
if test "$Next"; then
	Previous="$Top_Item"
	Top_Item="$Next"
	Set_Next
elif test "$Previous"; then
	Top_Item="1"
	Previous=""
	Set_Next
else
	Print "There is no next page. ">&2
fi
}

Do_Add_Section (){
# process add section command
echo
echo "Please enter the name of the new section:"
if read Answer; then
	Answer=`echo "$Answer"\
	|sed -e 's/^\([ 	]\)\{1,\}//g' -e "$MENU_FILTER2"`
	if test "$Answer"; then
		Add_Section "$Answer"
		Last_Page
		clear
	fi
else
	Answer=""
fi
if test -z "$Answer"; then
	clear
	Print "no section added. "
fi
}

Do_Edit (){
# process edit item command
if test -t "2"; then
	_de_Done=""
	cp "$TMP_ITEM" "$TMP_FILE1"
	while test -z "$_de_Done"
		do
		eval $EDITOR "$TMP_FILE1"
		clear
		_de_Done="t"
		if sed -n -e "$MENU_FILTER1" -e '1p' "$TMP_FILE1"\
		|egrep "${MENU_ITEM}${Info_Name}\)\.">/dev/null; then
			:
		else
			sed -n -e '1p' "$TMP_FILE1"
			echo "Pattern mismatch: `echo\
			"/${MENU_ITEM}${Info_Name}\)\./"\
			|tr -d "\011"`">&2
			echo
			_de_Done=""
		fi
		if sed -n -e '2,$p' "$TMP_FILE1"|grep '^[^ 	]'>&2; then
			echo "These lines must have leading spaces">&2
			echo
			_de_Done=""
		fi
		if test -z "$_de_Done"; then
			Get_Answer "yn" "Invalid entry, cancel edits? (y or n):"
			if test "y" = "$Answer"; then
				clear
				Print "Canceling edits -- invalid entry ">&2
				_de_Done="t"
			fi
		else
			sed -e "$MENU_FILTER1" -e "$MENU_FILTER2" -e '/^$/d'\
			<"$TMP_FILE1">"$TMP_ITEM"
		fi
		done
else
	Print "editor cannot run with error path redirected "
fi
}

Do_Number (){
# process number
_dn_Num="$1"
if test "$_dn_Num" -ge 1 -a "$_dn_Num" -le "$Item_Num"; then
	if test `echo "$Item_Status"|sed -n -e "${_dn_Num}p"` = "_"; then
		Set_Item "$_dn_Num" "X"
	else
		Set_Item "$_dn_Num" "_"
	fi
else
	Print "\"$_dn_Num\" is an invalid section number. ">&2
fi
}

Do_Help (){
# process menu help
echo
echo "\
Enter the following commands seperated
by spaces and terminated by<ENTER>:
# : (section number) toggle section
a : add a new section
e : edit item -- changes will not be
  accepted if you change the
  '(info_file_name).' or delete
  the key parts: '*' 'Menu Name' ':'
h : get this help screen
n : next page
p : previous page
q : quit and do not put into menu
s : save and put into menu"
Print "Press enter to continue:"
read junk
clear
}

Set_Next (){
# determine value of Next
Next=`expr "$DISPLAY_NUM" + "$Top_Item"`
if test "$Next" -gt "$Item_Num"; then
	Next=""
fi
}

Last_Page (){
# go to last page of menu
Top_Item=`echo|awk "BEGIN{printf(\"%d\",
int((${Item_Num}-1)/${DISPLAY_NUM})*${DISPLAY_NUM}+1)}"`
if test "$Top_Item" -gt "$DISPLAY_NUM"; then
	Previous=`expr "$Top_Item" '-' "$DISPLAY_NUM"`
else
	Previous=""
fi
Set_Next
}

Select_Sections (){
# prompt user for which sections
set -f
Top_Item="1"
Previous=""
Set_Next
clear
echo "Default sections are selected."
Done=""
while test -z "$Done"
	do
	awk "FNR==1{printf(\"%s\n\", substr(\$0,1,${COLUMNS}))}" $TMP_ITEM
	Tmp_Var=`echo "$Item_Status"|tr -d '\012'`
	awk "BEGIN{Max=$Top_Item+$DISPLAY_NUM}
	FNR>=$Top_Item{if(FNR>=Max)exit
	printf(\"%2d:%s %s\n\",FNR,substr(\"$Tmp_Var\",FNR,1),
	substr(\$0,1,${COLUMNS}-5))}" "$TMP_SECTIONS"
	echo "Enter 1-${Item_Num}, add, edit, help,"
	if test "$Previous" -o "$Next"; then
		Print "next, previous, "
	fi
	Print "quit, save :"
	read Command_List||Command_List="$CONTROL_D"
	Command_List=`echo "$Command_List"\
	|tr '\011' ' '|tr ' ' '\012'|sed -e "/^$/d"`
	clear
	if test -z "$Command_List"; then
		Help="y"
	else
		Help=""
	fi
	while test "$Command_List"
		do
		Command=`echo "$Command_List"|sed -n -e '1p'`
		Command_List=`echo "$Command_List"|sed -e '1d'`
		case "$Command" in
			[0-9]|[0-9][0-9]) Do_Number "$Command";;
			n*)	Do_Next;;
			p*)	Do_Previous;;
			a*)	Do_Add_Section;;
			e*)	Do_Edit; break;;
			h*)	Help="y";;
			s*)	Done="s"; break;;
			q*)	Done="q"
			Item_Status=`echo "$Item_Status"|sed -e '1,$s/^./_/'`
			break;;
			*) Print "$Command is not a valid command. ">&2
			Help="y";;
		esac
		done
	if test "$Help"; then
		Do_Help
	fi
	echo
	done
set +f
# if new sections added, remove unused ones
if test "$Item_Num" -gt "$Item_Dir"; then
	Tmp_Var=`echo "$Item_Status"|awk "FNR>$Item_Dir{
	if(\\$0==\"_\")printf(\"%d\n\", FNR)}"`
	if test "$Tmp_Var"; then
		Tmp_Var1=`echo "$Tmp_Var"|sed -e 's/$/d/'`
		sed -e "$Tmp_Var1" "$TMP_SECTIONS">$TMP_FILE1
		cp $TMP_FILE1 "$TMP_SECTIONS"
		Item_Status=`echo "$Item_Status"|sed -e "$Tmp_Var1"`
		Tmp_Var=""
		Tmp_Var1=""
		Item_Num=`wc -l<"$TMP_SECTIONS"|tr -d ' '`
	fi
fi
}

# ###SECTION 100### Constants that redefine
PROMPT1="(y=yes, e=edit, Y=yes to all, n=no, N=No to all):"
FUNCTIONS="y"
#
echo "update-info.f (GNU texinfo @TEXINFO_VERSION@) @UPDATE_INFO_VERSION@"