summaryrefslogtreecommitdiff
path: root/awklib/eg
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2010-07-16 13:22:00 +0300
committerArnold D. Robbins <arnold@skeeve.com>2010-07-16 13:22:00 +0300
commit6cc7d587a710606d3fe52222707739c7cc1b8651 (patch)
tree2b6360852d8f966bd83eeb6efd8af90f8e9b83f9 /awklib/eg
parente888f1834b88270590b7e04d64c03c75863e4565 (diff)
downloadgawk-6cc7d587a710606d3fe52222707739c7cc1b8651.tar.gz
Move to gawk-3.1.3.gawk-3.1.3
Diffstat (limited to 'awklib/eg')
-rw-r--r--awklib/eg/lib/grcat.c2
-rw-r--r--awklib/eg/lib/zerofile.awk19
-rw-r--r--awklib/eg/network/coreserv.awk4
-rw-r--r--awklib/eg/network/eliza.awk4
-rw-r--r--awklib/eg/network/protbase.awk2
-rw-r--r--awklib/eg/network/remconf.awk2
-rw-r--r--awklib/eg/network/statist.awk4
-rw-r--r--awklib/eg/network/stoxpred.awk22
8 files changed, 39 insertions, 20 deletions
diff --git a/awklib/eg/lib/grcat.c b/awklib/eg/lib/grcat.c
index c022dc7e..83567142 100644
--- a/awklib/eg/lib/grcat.c
+++ b/awklib/eg/lib/grcat.c
@@ -12,7 +12,7 @@
#if HAVE_CONFIG_H
#include <config.h>
#endif
-
+
#if defined (STDC_HEADERS)
#include <stdlib.h>
#endif
diff --git a/awklib/eg/lib/zerofile.awk b/awklib/eg/lib/zerofile.awk
new file mode 100644
index 00000000..01926fdd
--- /dev/null
+++ b/awklib/eg/lib/zerofile.awk
@@ -0,0 +1,19 @@
+# zerofile.awk --- library file to process empty input files
+#
+# Arnold Robbins, arnold@gnu.org, Public Domain
+# June 2003
+
+BEGIN { Argind = 0 }
+
+ARGIND > Argind + 1 {
+ for (Argind++; Argind < ARGIND; Argind++)
+ zerofile(ARGV[Argind], Argind)
+}
+
+ARGIND != Argind { Argind = ARGIND }
+
+END {
+ if (ARGIND > Argind)
+ for (Argind++; Argind <= ARGIND; Argind++)
+ zerofile(ARGV[Argind], Argind)
+}
diff --git a/awklib/eg/network/coreserv.awk b/awklib/eg/network/coreserv.awk
index e9e61710..348568e0 100644
--- a/awklib/eg/network/coreserv.awk
+++ b/awklib/eg/network/coreserv.awk
@@ -46,7 +46,7 @@ BEGIN {
print "Content-length:", len |& HttpService
print ORS Prompt |& HttpService
# ignore all the header lines
- while ((HttpService |& getline) > 0)
+ while ((HttpService |& getline) > 0)
continue
# stop talking to this client
close(HttpService)
@@ -75,7 +75,7 @@ function CGI_setup( method, uri, version, i)
PARAM[i] = _CGI_decode(PARAM[i])
j = index(PARAM[i], "=")
GETARG[substr(PARAM[i], 1, j-1)] = \
- substr(PARAM[i], j+1)
+ substr(PARAM[i], j+1)
}
} else { # there is no "?", no need for splitting PARAMs
split(uri, MENU, "[/:]")
diff --git a/awklib/eg/network/eliza.awk b/awklib/eg/network/eliza.awk
index 2e022b41..75e353a7 100644
--- a/awklib/eg/network/eliza.awk
+++ b/awklib/eg/network/eliza.awk
@@ -72,7 +72,7 @@ function ElizaSays(YouSay) {
if (w == "-") { # no keyword, take old subject
w = wold
subj = subjold
- } else { # find subject
+ } else { # find subject
subj = substr(q, index(q, w) + length(w)+1)
wold = w
subjold = subj # remember keyword and subject
@@ -228,7 +228,7 @@ function SetUpEliza() {
r[117] = "WHAT'S ABOUT ME ?"
r[118] = "WHY DO YOU ALWAYS BRING UP MY NAME ?"
# table for looking up answers that
- # fit to a certain keyword
+ # fit to a certain keyword
k["CAN YOU"] = "1 2 3"
k["CAN I"] = "4 5"
k["YOU ARE"] =\
diff --git a/awklib/eg/network/protbase.awk b/awklib/eg/network/protbase.awk
index 16199e45..f4a911c9 100644
--- a/awklib/eg/network/protbase.awk
+++ b/awklib/eg/network/protbase.awk
@@ -4,7 +4,7 @@ END {
BLASTService = "/inet/tcp/0/www.ncbi.nlm.nih.gov/80"
printf "POST /cgi-bin/BLAST/nph-blast_report HTTP/1.0\n" |& BLASTService
printf "Content-Length: " length(request) "\n\n" |& BLASTService
- printf request |& BLASTService
+ printf request |& BLASTService
while ((BLASTService |& getline) > 0)
print $0
close(BLASTService)
diff --git a/awklib/eg/network/remconf.awk b/awklib/eg/network/remconf.awk
index f4f21e1a..ef922265 100644
--- a/awklib/eg/network/remconf.awk
+++ b/awklib/eg/network/remconf.awk
@@ -35,7 +35,7 @@ function HandleGET() {
config[GETARG["Param"]] = GETARG["Value"]
Document = (GETARG["Param"] " = " GETARG["Value"] ".")
} else {
- Document = "Parameter <b>" GETARG["Param"] "</b> is invalid."
+ Document = "Parameter <b>" GETARG["Param"] "</b> is invalid."
}
} else {
Document = "<FORM method=GET><h4>Change one parameter</h4>\
diff --git a/awklib/eg/network/statist.awk b/awklib/eg/network/statist.awk
index 8a583940..a4fc55cf 100644
--- a/awklib/eg/network/statist.awk
+++ b/awklib/eg/network/statist.awk
@@ -73,9 +73,9 @@ function HandleGET() {
<TD><input type=text name=v2 value=" v2 " size=8></TD>\
<TD>2. Count </TD>
<TD><input type=text name=n2 value=" n2 " size=8></TD>\
- </TR> <input type=submit value=\"Compute\">\
+ </TR> <input type=submit value=\"Compute\">\
</TABLE></FORM><BR>"
- } else if (MENU[2] ~ "Image") {
+ } else if (MENU[2] ~ "Image") {
Reason = "OK" ORS "Content-type: image/png"
#Reason = "OK" ORS "Content-type: application/x-postscript"
#Reason = "OK" ORS "Content-type: image/gif"
diff --git a/awklib/eg/network/stoxpred.awk b/awklib/eg/network/stoxpred.awk
index 5cdc2a8d..62744c14 100644
--- a/awklib/eg/network/stoxpred.awk
+++ b/awklib/eg/network/stoxpred.awk
@@ -38,15 +38,15 @@ function Prediction() {
for (stock = 1; stock <= StockCount; stock++) {
if (data[1, stock] > data[2, stock]) {
predict[stock] = "up"
- } else if (data[1, stock] < data[2, stock]) {
- predict[stock] = "down"
+ } else if (data[1, stock] < data[2, stock]) {
+ predict[stock] = "down"
} else {
predict[stock] = "neutral"
}
if ((data[1, stock] > data[2, stock]) && (data[2, stock] > data[3, stock]))
hot[stock] = 1
if ((data[1, stock] < data[2, stock]) && (data[2, stock] < data[3, stock]))
- avoid[stock] = 1
+ avoid[stock] = 1
}
# Do a plausibility check: how many predictions proved correct?
for (s = 1; s <= StockCount; s++) {
@@ -57,20 +57,20 @@ function Prediction() {
DownCount++
} else {
NeutralCount++
- }
+ }
if (((data[d, s] > data[d+1, s]) && (data[d+1, s] > data[d+2, s])) ||
((data[d, s] < data[d+1, s]) && (data[d+1, s] < data[d+2, s])) ||
((data[d, s] == data[d+1, s]) && (data[d+1, s] == data[d+2, s])))
CorrectCount++
- }
- }
+ }
+ }
}
function Report() {
# Generate report
report = "\nThis is your daily "
report = report "stock market report for "strftime("%A, %B %d, %Y")".\n"
report = report "Here are the predictions for today:\n\n"
- for (stock = 1; stock <= StockCount; stock++)
+ for (stock = 1; stock <= StockCount; stock++)
report = report "\t" name[stock] "\t" predict[stock] "\n"
for (stock in hot) {
if (HotCount++ == 0)
@@ -83,7 +83,7 @@ function Report() {
report = report "\nThe stock shares to avoid today are these:\n\n"
report = report "\t" name[stock] "\t\thttp://biz.yahoo.com/n/" \
tolower(substr(name[stock], 1, 1)) "/" tolower(name[stock]) ".html\n"
- }
+ }
report = report "\nThis sums up to " HotCount+0 " winners and " AvoidCount+0
report = report " losers. When using this kind\nof prediction scheme for"
report = report " the 12 months which lie behind us,\nwe get " UpCount
@@ -97,8 +97,8 @@ function Report() {
report = report "market, this report is, of course, complete nonsense.\n"
report = report "If you are stupid enough to believe these predictions\n"
report = report "you should visit a doctor who can treat your ailment."
-}
-function SendMail() {
+}
+function SendMail() {
# send report to customers
customer["uncle.scrooge@ducktown.gov"] = "Uncle Scrooge"
customer["more@utopia.org" ] = "Sir Thomas More"
@@ -113,4 +113,4 @@ function SendMail() {
print report "\n.\n" | MailPipe
close(MailPipe)
}
-}
+}