]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - man/make_sed.sh
ncurses 6.3 - patch 20220326
[ncurses.git] / man / make_sed.sh
index 766801d551a8b0e980c7dfbfab834c4295ab3521..0b794f86b0e83e29dcdf31c15fb1b4cfd4943dae 100755 (executable)
@@ -1,7 +1,8 @@
 #!/bin/sh
-# $Id: make_sed.sh,v 1.7 2003/10/25 20:33:16 tom Exp $
+# $Id: make_sed.sh,v 1.14 2022/02/05 20:38:54 tom Exp $
 ##############################################################################
-# Copyright (c) 1998,2003 Free Software Foundation, Inc.                     #
+# Copyright 2020-2021,2022 Thomas E. Dickey                                  #
+# Copyright 1998-2005,2017 Free Software Foundation, Inc.                    #
 #                                                                            #
 # Permission is hereby granted, free of charge, to any person obtaining a    #
 # copy of this software and associated documentation files (the "Software"), #
@@ -28,7 +29,7 @@
 # authorization.                                                             #
 ##############################################################################
 #
-# Author: Thomas E. Dickey 1997
+# Author: Thomas E. Dickey 1997-2005
 #
 # Construct a sed-script to perform renaming within man-pages.  Originally
 # written in much simpler form, this one accounts for the common cases of
@@ -45,7 +46,8 @@ UPPER=upper$$
 SCRIPT=script$$
 RESULT=result$$
 rm -f $UPPER $SCRIPT $RESULT
-trap "rm -f $COL.* $INPUT $UPPER $SCRIPT $RESULT" 0 1 2 5 15
+trap "rm -f $COL.* $INPUT $UPPER $SCRIPT $RESULT; exit 1" 1 2 3 15
+trap "rm -f $COL.* $INPUT $UPPER $SCRIPT $RESULT" 0
 fgrep -v \# $1 | \
 sed    -e 's/[ ][      ]*/     /g' >$INPUT
 
@@ -57,13 +59,13 @@ done
 for F in 2 4
 do
        tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ <$COL.$F >$UPPER
-       mv $UPPER $COL.$F 
+       mv $UPPER $COL.$F
 done
 paste $COL.* | \
 sed    -e 's/^/s\/\\</' \
        -e 's/$/\//' >$UPPER
 
-# Do the TH lines
+echo "# Do the TH lines" >>$RESULT
 sed    -e 's/\//\/TH /' \
        -e 's/  / /' \
        -e 's/  / ""\/TH /' \
@@ -71,13 +73,19 @@ sed -e 's/\//\/TH /' \
        -e 's/\/$/ ""\//' \
        $UPPER >>$RESULT
 
-# Do the embedded references
+echo "# Do the embedded references" >>$RESULT
 sed    -e 's/</<fB/' \
-       -e 's/  /\\\\fR(/' \
+       -e 's/  /\\\\fP(/' \
        -e 's/  /)\/fB/' \
-       -e 's/  /\\\\fR(/' \
+       -e 's/  /\\\\fP(/' \
        -e 's/\/$/)\//' \
        $UPPER >>$RESULT
 
+echo "# Do the \fBxxx\fP references in the .NAME section" >>$RESULT
+sed    -e 's/\\</^\\\\fB/' \
+       -e 's/  [^      ]*      /\\\\f[RP] -\/\\\\fB/' \
+       -e 's/  .*$/\\\\fP -\//' \
+       $UPPER >>$RESULT
+
 # Finally, send the result to standard output
 cat $RESULT