aboutsummaryrefslogtreecommitdiffstats
path: root/awklib/eg/lib
diff options
context:
space:
mode:
authorJuergen Kahrs <Juergen.Kahrs@googlemail.com>2013-12-23 18:26:45 +0100
committerJuergen Kahrs <Juergen.Kahrs@googlemail.com>2013-12-23 18:26:45 +0100
commitee9707cc44eea3ca64cb71666ac3e8ed26a3bb7f (patch)
tree3945f1b3afd64a7147582611f21b7f5e59891e41 /awklib/eg/lib
parent0ac63db595a009d1f07dba8246e52710348b0798 (diff)
parentc66f7da30bb5635957b6e68c1e1db7e77e7b4174 (diff)
downloadegawk-ee9707cc44eea3ca64cb71666ac3e8ed26a3bb7f.tar.gz
egawk-ee9707cc44eea3ca64cb71666ac3e8ed26a3bb7f.tar.bz2
egawk-ee9707cc44eea3ca64cb71666ac3e8ed26a3bb7f.zip
Merge remote-tracking branch 'origin/master' into cmake
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
+}