Skip to content

Commit

Permalink
Add Ctrl-Q documentation for getline #202
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Aug 26, 2023
1 parent 5933710 commit 37c2f32
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Makesurefile
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
@depends_on document_processed @args 'I18N-Functions.html'
@depends_on std.awk_exit
@depends_on std.awk_printf
@depends_on std.awk_getline

@goal std.awk
@doc 'generates std.awk file used for documentation (Ctrl-Q)'
Expand Down Expand Up @@ -173,3 +174,8 @@
@goal std.awk_printf @private
awk -v Stmt=printf -f gen_std.awk

@goal std.awk_getline @private
@depends_on document_downloaded @args 'Getline.html'
@depends_on document_downloaded @args 'Getline-Summary.html'
awk -v Stmt=getline -f gen_std.awk

11 changes: 10 additions & 1 deletion gen_std.awk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ BEGIN {
Doc=""
Base="https://www.gnu.org/software/gawk/manual/html_node/"

if ("printf" == Stmt) { closeItem(); exit }
if ("getline" == Stmt || "printf" == Stmt) { closeItem(); exit }
}

{ sub(/<\/pre><pre class="example">/,"") } # unsplit code blocks
Expand Down Expand Up @@ -91,6 +91,15 @@ function closeItem() {
appendPartOfFileToDoc2("temp/Control-Letters.html")
appendDocLine("<br>")
appendPartOfFileToDoc2("temp/Format-Modifiers.html")
} else if (Stmt=="getline") {
appendDocLine("<dt><code>getline</code></dt>")
appendDocLine("<br>")
appendPartOfFileToDoc("temp/Getline.html",
"<p>The .+ command returns 1",
"<p>If .+ indicates that the I/O")
appendPartOfFileToDoc("temp/Getline-Summary.html",
"<table",
"<div")
} else if (Name=="strftime") {
appendDocLine("<br>")
appendDocLine("<h3>Format-Control Letters</h3>")
Expand Down
22 changes: 22 additions & 0 deletions src/main/resources/std.awk
Original file line number Diff line number Diff line change
Expand Up @@ -3015,3 +3015,25 @@ function stmt::exit() {}
# </p>
#
function stmt::printf() {}

# <dt><code>getline</code></dt>
# <br>
# <p>The <code class="code">getline</code> command returns 1 if it finds a record and 0 if
# it encounters the end of the file. If there is some error in getting
# a record, such as a file that cannot be opened, then <code class="code">getline</code>
# returns &minus;1. In this case, <code class="command">gawk</code> sets the variable
# <code class="code">ERRNO</code> to a string describing the error that occurred.
# </p>
# <table class="multitable">
# <thead><tr><th width="33%">Variant</th><th width="38%">Effect</th><th width="27%"><code class="command">awk</code> / <code class="command">gawk</code></th></tr></thead>
# <tbody><tr><td width="33%"><code class="code">getline</code></td><td width="38%">Sets <code class="code">$0</code>, <code class="code">NF</code>, <code class="code">FNR</code>, <code class="code">NR</code>, and <code class="code">RT</code></td><td width="27%"><code class="command">awk</code></td></tr>
# <tr><td width="33%"><code class="code">getline</code> <var class="var">var</var></td><td width="38%">Sets <var class="var">var</var>, <code class="code">FNR</code>, <code class="code">NR</code>, and <code class="code">RT</code></td><td width="27%"><code class="command">awk</code></td></tr>
# <tr><td width="33%"><code class="code">getline &lt;</code> <var class="var">file</var></td><td width="38%">Sets <code class="code">$0</code>, <code class="code">NF</code>, and <code class="code">RT</code></td><td width="27%"><code class="command">awk</code></td></tr>
# <tr><td width="33%"><code class="code">getline <var class="var">var</var> &lt; <var class="var">file</var></code></td><td width="38%">Sets <var class="var">var</var> and <code class="code">RT</code></td><td width="27%"><code class="command">awk</code></td></tr>
# <tr><td width="33%"><var class="var">command</var> <code class="code">| getline</code></td><td width="38%">Sets <code class="code">$0</code>, <code class="code">NF</code>, and <code class="code">RT</code></td><td width="27%"><code class="command">awk</code></td></tr>
# <tr><td width="33%"><var class="var">command</var> <code class="code">| getline</code> <var class="var">var</var></td><td width="38%">Sets <var class="var">var</var> and <code class="code">RT</code></td><td width="27%"><code class="command">awk</code></td></tr>
# <tr><td width="33%"><var class="var">command</var> <code class="code">|&amp; getline</code></td><td width="38%">Sets <code class="code">$0</code>, <code class="code">NF</code>, and <code class="code">RT</code></td><td width="27%"><code class="command">gawk</code></td></tr>
# <tr><td width="33%"><var class="var">command</var> <code class="code">|&amp; getline</code> <var class="var">var</var></td><td width="38%">Sets <var class="var">var</var> and <code class="code">RT</code></td><td width="27%"><code class="command">gawk</code></td></tr>
# </tbody>
# </table>
function stmt::getline() {}

0 comments on commit 37c2f32

Please sign in to comment.