diff options
| author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2022-08-24 12:31:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-24 12:31:18 +0200 |
| commit | 87c48f3e4ddba13d9c014067e62568ba906cc410 (patch) | |
| tree | c99889ec0b9bbab2bc5ee14cd9046d0a122eb226 /samples/eol.lua | |
| parent | 95b7efa9da506ef968c1347edf3fc56370f0deed (diff) | |
| parent | 97d5194f302d3fb9fe27874d9b5f73004a208d01 (diff) | |
| download | luasocket-87c48f3e4ddba13d9c014067e62568ba906cc410.tar.gz luasocket-87c48f3e4ddba13d9c014067e62568ba906cc410.tar.bz2 luasocket-87c48f3e4ddba13d9c014067e62568ba906cc410.zip | |
Merge pull request #364 from lunarmodules/cleanup
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) | ||
