diff options
author | Caleb Maclennan <caleb@alerque.com> | 2023-11-10 09:12:04 +0300 |
---|---|---|
committer | Caleb Maclennan <caleb@alerque.com> | 2023-11-10 09:12:04 +0300 |
commit | 5c4fc93d5f4137bf4c22ddf1a048c907a4a26727 (patch) | |
tree | a9a68e1f6a9c3bfe2b64fa1c3a4098865b7d3b5d /samples/eol.lua | |
parent | ccef3bc4e2aa6ee5b997a80aabb58f4ff0b0e98f (diff) | |
parent | 43a97b7f0053313b43906371dbdc226271e6c8ab (diff) | |
download | luasocket-hjelmeland-patch-1.tar.gz luasocket-hjelmeland-patch-1.tar.bz2 luasocket-hjelmeland-patch-1.zip |
Merge branch 'master' into hjelmeland-patch-1hjelmeland-patch-1
Diffstat (limited to 'samples/eol.lua')
-rw-r--r-- | samples/eol.lua | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/samples/eol.lua b/samples/eol.lua new file mode 100644 index 0000000..eeaf0ce --- /dev/null +++ b/samples/eol.lua | |||
@@ -0,0 +1,13 @@ | |||
1 | ----------------------------------------------------------------------------- | ||
2 | -- Little program to adjust end of line markers. | ||
3 | -- LuaSocket sample files | ||
4 | -- Author: Diego Nehab | ||
5 | ----------------------------------------------------------------------------- | ||
6 | local mime = require("mime") | ||
7 | local ltn12 = require("ltn12") | ||
8 | local marker = '\n' | ||
9 | if arg and arg[1] == '-d' then marker = '\r\n' end | ||
10 | local filter = mime.normalize(marker) | ||
11 | local source = ltn12.source.chain(ltn12.source.file(io.stdin), filter) | ||
12 | local sink = ltn12.sink.file(io.stdout) | ||
13 | ltn12.pump.all(source, sink) | ||