function readline() { if (use_zcat || use_bzcat || use_lzcat) { result = (pipe_cmd | getline); if (result < 0) { print "Pipe error: " pipe_cmd " " ERRNO > "/dev/stderr"; } } else { result = (getline < filename); if (result < 0) { print "Read file error: " filename " " ERRNO > "/dev/stderr"; } } return result; } function closeline() { if (use_zcat || use_bzcat || use_lzcat) { return close(pipe_cmd); } else { return close(filename); } } function do_one() { insh = 0; thisjoin = 1; done = 0; entire_line = ""; if (verbose) { print "adding " filename > "/dev/stderr" } use_zcat = match(filename,"\\.Z$") || match(filename,"\\.z$") || match(filename,"\\.gz$"); if (!use_zcat) use_bzcat = match(filename,"\\.bz2"); if(!use_bzcat) use_lzcat = match(filename,"\\.lzma"); if (use_zcat || use_bzcat || use_lzcat ) { filename_no_gz = substr(filename, 0, RSTART - 1); } else { filename_no_gz = filename; } match(filename_no_gz, "/[^/]+$"); progname = substr(filename, RSTART + 1, RLENGTH - 1); if (match(progname, "\\." section "[A-Za-z]+")) { actual_section = substr(progname, RSTART + 1, RLENGTH - 1); } else { actual_section = section; } sub(/\..*/, "", progname); if (use_zcat || use_bzcat || use_lzcat) { if (use_zcat) { pipe_cmd = "zcat \"" filename "\""; } else if (use_bzcat) { pipe_cmd = "bzcat \"" filename "\""; } else { pipe_cmd = "lzcat \"" filename "\""; } # try to avoid suspicious stuff if (filename ~ /[;&|`$(]/) { print "ignored strange file name " filename " in " curdir > "/dev/stderr"; return; } } while (!done && readline() > 0) { gsub(/.\b/, ""); if (($1 ~ /^\.[Ss][Hh]/ && ($2 ~ /[Nn][Aa][Mm][Ee]/ || $2 ~ /^JM?NO/ || $2 ~ /^NAVN/ || $2 ~ /^NUME/ || \ $2 ~ /^BEZEICHNUNG/ || $2 ~ /^NOMBRE/ || $2 ~ /^NIMI/ || $2 ~ /^NOM/ || $2 ~ /^IME/ || $2 ~ /^N[?E]V/ || \ $2 ~ /^NAMA/ || $2 ~ /^????/ || $2 ~ /^????/ || $2 ~ /^????/ || $2 ~ /^NAZWA/ || $2 ~ /^????????/ || \ $2 ~ /^????/ || $2 ~ /^?W??/ || $2 ~ /^NOME/ || $2 ~ /^NAAM/ || $2 ~ /^???/)) || \ (pages == "cat" && $1 ~ /^NAME/)) { if (!insh) { insh = 1; } else { done = 1; } } else if (insh) { if ($1 ~ /^\.[Ss][HhYS]/ || (pages == "cat" && ($1 ~ /^S[yYeE]/ || $1 ~ /^DESCRIPTION/ || $1 ~ /^COMMAND/ || $1 ~ /^OVERVIEW/ || \ $1 ~ /^STRUCTURES/ || $1 ~ /^INTRODUCTION/ || \ $0 ~ /^[^ ]/))) { # end insh for Synopsis, Syntax, but also for # DESCRIPTION (e.g., XFree86.1x), # COMMAND (e.g., xspread.1) # OVERVIEW (e.g., TclCommandWriting.3) # STRUCTURES (e.g., XEvent.3x) # INTRODUCTION (e.g., TclX.n) # and anything at all that begins in Column 1, so # is probably a section header. done = 1; } else { if ($0 ~ progname"-") { # Fix old cat pages sub(progname"-", progname" - "); } if ($0 ~ /[^ \\]-$/) { sub(/-$/, ""); # Handle Hyphenations nextjoin = 1; } else if ($0 ~ /\\c$/) { sub(/\\c$/, ""); # Handle Continuations nextjoin = 1; } else nextjoin = 0; sub(/^.[IB] /, ""); # Kill bold and italics sub(/^.BI /, ""); # sub(/^.SM /, ""); # Kill small sub(/^.Nm /, ""); # Kill bold sub(/^.Tn /, ""); # Kill normal sub(/^.Li /, ""); # Kill .Li sub(/^.Dq /, ""); # Kill .Dq sub(/^.Nd */, "- "); # Convert .Nd to dash sub(/\\\".*/, ""); # Trim pending comments sub(/ *$/, ""); # Trim pending spaces sub(/^\.$/, ""); # Kill blank comments sub(/^'.*/, ""); # Kill .... .... ....