aboutsummaryrefslogtreecommitdiffstats
path: root/awklib/eg/lib
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2014-01-12 20:42:08 +0200
committerArnold D. Robbins <arnold@skeeve.com>2014-01-12 20:42:08 +0200
commit624d70844fe63068132adb7c66ea3f8a231e56a7 (patch)
tree79781e2b0e24b5e478804001c83fcde64602f502 /awklib/eg/lib
parentda83b6857bf0a67b15fc75d31a0b6802ac9baffe (diff)
parentf934f2192779db0091d1706d97d1fd43cb26dc9a (diff)
downloadegawk-624d70844fe63068132adb7c66ea3f8a231e56a7.tar.gz
egawk-624d70844fe63068132adb7c66ea3f8a231e56a7.tar.bz2
egawk-624d70844fe63068132adb7c66ea3f8a231e56a7.zip
Merge branch 'master' into comment
Diffstat (limited to 'awklib/eg/lib')
-rw-r--r--awklib/eg/lib/getopt.awk2
-rw-r--r--awklib/eg/lib/readfile.awk15
2 files changed, 16 insertions, 1 deletions
diff --git a/awklib/eg/lib/getopt.awk b/awklib/eg/lib/getopt.awk
index 0b81aa09..4283a7e1 100644
--- a/awklib/eg/lib/getopt.awk
+++ b/awklib/eg/lib/getopt.awk
@@ -17,7 +17,7 @@
# <c> a character representing the current option
# Private Data:
-# _opti -- index in multi-flag option, e.g., -abc
+# _opti -- index in multiflag option, e.g., -abc
function getopt(argc, argv, options, thisopt, i)
{
if (length(options) == 0) # no options given
diff --git a/awklib/eg/lib/readfile.awk b/awklib/eg/lib/readfile.awk
new file mode 100644
index 00000000..9137b26d
--- /dev/null
+++ b/awklib/eg/lib/readfile.awk
@@ -0,0 +1,15 @@
+# readfile.awk --- read an entire file at once
+#
+# Original idea by Denis Shirokov, cosmogen@gmail.com, April 2013
+#
+
+function readfile(file, tmp, save_rs)
+{
+ save_rs = RS
+ RS = "^$"
+ getline tmp < file
+ close(file)
+ RS = save_rs
+
+ return tmp
+}