head 1.1; branch 1.1.1; access; symbols netbsd-11-0-RC4:1.1.1.1 netbsd-11-0-RC3:1.1.1.1 netbsd-11-0-RC2:1.1.1.1 netbsd-11-0-RC1:1.1.1.1 perseant-exfatfs-base-20250801:1.1.1.1 netbsd-11:1.1.1.1.0.30 netbsd-11-base:1.1.1.1 netbsd-10-1-RELEASE:1.1.1.1 perseant-exfatfs-base-20240630:1.1.1.1 perseant-exfatfs:1.1.1.1.0.28 perseant-exfatfs-base:1.1.1.1 netbsd-8-3-RELEASE:1.1.1.1 netbsd-9-4-RELEASE:1.1.1.1 netbsd-10-0-RELEASE:1.1.1.1 netbsd-10-0-RC6:1.1.1.1 netbsd-10-0-RC5:1.1.1.1 netbsd-10-0-RC4:1.1.1.1 netbsd-10-0-RC3:1.1.1.1 netbsd-10-0-RC2:1.1.1.1 netbsd-10-0-RC1:1.1.1.1 netbsd-10:1.1.1.1.0.26 netbsd-10-base:1.1.1.1 netbsd-9-3-RELEASE:1.1.1.1 cjep_sun2x-base1:1.1.1.1 cjep_sun2x:1.1.1.1.0.24 cjep_sun2x-base:1.1.1.1 cjep_staticlib_x-base1:1.1.1.1 netbsd-9-2-RELEASE:1.1.1.1 cjep_staticlib_x:1.1.1.1.0.22 cjep_staticlib_x-base:1.1.1.1 netbsd-9-1-RELEASE:1.1.1.1 phil-wifi-20200421:1.1.1.1 phil-wifi-20200411:1.1.1.1 is-mlppp:1.1.1.1.0.20 is-mlppp-base:1.1.1.1 phil-wifi-20200406:1.1.1.1 netbsd-8-2-RELEASE:1.1.1.1 netbsd-9-0-RELEASE:1.1.1.1 netbsd-9-0-RC2:1.1.1.1 netbsd-9-0-RC1:1.1.1.1 phil-wifi-20191119:1.1.1.1 netbsd-9:1.1.1.1.0.18 netbsd-9-base:1.1.1.1 phil-wifi-20190609:1.1.1.1 netbsd-8-1-RELEASE:1.1.1.1 netbsd-8-1-RC1:1.1.1.1 pgoyette-compat-merge-20190127:1.1.1.1 pgoyette-compat-20190127:1.1.1.1 pgoyette-compat-20190118:1.1.1.1 pgoyette-compat-1226:1.1.1.1 pgoyette-compat-1126:1.1.1.1 pgoyette-compat-1020:1.1.1.1 pgoyette-compat-0930:1.1.1.1 pgoyette-compat-0906:1.1.1.1 pgoyette-compat-0728:1.1.1.1 netbsd-8-0-RELEASE:1.1.1.1 phil-wifi:1.1.1.1.0.16 phil-wifi-base:1.1.1.1 pgoyette-compat-0625:1.1.1.1 netbsd-8-0-RC2:1.1.1.1 pgoyette-compat-0521:1.1.1.1 pgoyette-compat-0502:1.1.1.1 pgoyette-compat-0422:1.1.1.1 netbsd-8-0-RC1:1.1.1.1 pgoyette-compat-0415:1.1.1.1 pgoyette-compat-0407:1.1.1.1 pgoyette-compat-0330:1.1.1.1 pgoyette-compat-0322:1.1.1.1 pgoyette-compat-0315:1.1.1.1 pgoyette-compat:1.1.1.1.0.14 pgoyette-compat-base:1.1.1.1 matt-nb8-mediatek:1.1.1.1.0.12 matt-nb8-mediatek-base:1.1.1.1 perseant-stdc-iso10646:1.1.1.1.0.10 perseant-stdc-iso10646-base:1.1.1.1 netbsd-8:1.1.1.1.0.8 netbsd-8-base:1.1.1.1 prg-localcount2-base3:1.1.1.1 prg-localcount2-base2:1.1.1.1 prg-localcount2-base1:1.1.1.1 prg-localcount2:1.1.1.1.0.6 prg-localcount2-base:1.1.1.1 pgoyette-localcount-20170426:1.1.1.1 bouyer-socketcan-base1:1.1.1.1 pgoyette-localcount-20170320:1.1.1.1 bouyer-socketcan:1.1.1.1.0.4 bouyer-socketcan-base:1.1.1.1 pgoyette-localcount-20170107:1.1.1.1 pgoyette-localcount-20161104:1.1.1.1 localcount-20160914:1.1.1.1 pgoyette-localcount-20160806:1.1.1.1 pgoyette-localcount-20160726:1.1.1.1 pgoyette-localcount:1.1.1.1.0.2 pgoyette-localcount-base:1.1.1.1 texinfo-4-8a:1.1.1.1 FSF:1.1.1; locks; strict; comment @# @; 1.1 date 2016.01.14.00.11.29; author christos; state Exp; branches 1.1.1.1; next ; commitid 9dronS78TckhBPQy; 1.1.1.1 date 2016.01.14.00.11.29; author christos; state Exp; branches; next ; commitid 9dronS78TckhBPQy; desc @@ 1.1 log @Initial revision @ text @#! /usr/local/bin/gawk -f # fixref.awk --- fix xrefs in texinfo documents # Copyright, 1991, Arnold David Robbins, arnold@@skeeve.atl.ga.us # Copyright, 1998, Arnold David Robbins, arnold@@gnu.org # FIXREF 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 of the License, or # (at your option) any later version. # # FIXREF 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, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA # Updated: Jul 21 1992 --- change unknown # Updated: Jul 18 1997 --- bug fix # usage: gawk -f fixref.awk input-file > output-file # or if you have #!: fixref.awk input-file > output-file # Limitations: # 1. no more than one cross reference on a line # 2. cross references may not cross a newline BEGIN \ { # we make two passes over the file. To do that we artificially # tweak the argument vector to do a variable assignment if (ARGC != 2) { printf("usage: %s texinfo-file\n", ARGV[0]) > "/dev/stderr" exit 1 } ARGV[2] = "pass=2" ARGV[3] = ARGV[1] ARGC = 4 # examine paragraphs RS = "" heading = "@@(chapter|appendix|unnumbered|(appendix(sec|subsec|subsubsec))|section|subsection|subsubsection|unnumberedsec|heading|top)" pass = 1 # put space between paragraphs on output ORS = "\n\n" } pass == 1 && NF == 0 { next } # pass == 1 && /@@node/ \ # bug fix 7/18/96 pass == 1 && /^@@node/ \ { lname = name = "" n = split($0, lines, "\n") for (i = 1; i <= n; i++) { if (lines[i] ~ ("^" heading)) { sub(heading, "", lines[i]) sub(/^[ \t]*/, "", lines[i]) lname = lines[i] # printf "long name is '%s'\n", lines[i] } else if (lines[i] ~ /@@node/) { sub(/@@node[ \t]*/, "", lines[i]) sub(/[ \t]*,.*$/, "", lines[i]) name = lines[i] # printf "node name is '%s'\n", lines[i] } } if (name && lname) names[name] = lname else if (lname) printf("node name for %s missing!\n", lname) > "/dev/stderr" else printf("long name for %s missing!\n", name) > "/dev/stderr" if (name ~ /:/) printf("node `%s' contains a `:'\n", name) > "/dev/stderr" if (lname) { if (lname ~ /:/) printf("name `%s' contains a `:'\n", lname) > "/dev/stderr" else if (lname ~ /,/) { printf("name `%s' contains a `,'\n", lname) > "/dev/stderr" gsub(/,/, " ", lname) names[name] = lname # added 7/18/97 } } } pass == 2 && /@@(x|px)?ref{/ \ { # split the paragraph into lines # write them out one by one after fixing them n = split($0, lines, "\n") for (i = 1; i <= n; i++) if (lines[i] ~ /@@(x|px)?ref{/) { res = updateref(lines[i]) printf "%s\n", res } else printf "%s\n", lines[i] printf "\n" # avoid ORS next } function updateref(orig, refkind, line) { line = orig # work on a copy # find the beginning of the reference match(line, "@@(x|px)?ref{") refkind = substr(line, RSTART, RLENGTH) # pull out just the node name sub(/.*ref{/, "", line) sub(/}.*$/, "", line) sub(/,.*/, "", line) # debugging # printf("found ref to node '%s'\n", line) > "/dev/stderr" # If the node name and the section name are the same # we don't want to bother doing this. if (! (line in names)) # sanity checking printf("no long name for %s\n", line) > "/dev/stderr" else if (names[line] != line && names[line] !~ /[:,]/) { # build up new ref newref = refkind line ", ," names[line] "}" pat = refkind line "[^}]*}" sub(pat, newref, orig) } return orig } pass == 2 { print } @ 1.1.1.1 log @import texinfo-4.8a @ text @@