diff options
| author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2022-03-23 16:05:11 +0100 |
|---|---|---|
| committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2022-03-29 13:33:00 +0200 |
| commit | 86de838eb5ed49711be8d62e01255cc2ccd3342e (patch) | |
| tree | 13665628395e9247bf378737ca2cfa140a96a3c2 /samples/eol.lua | |
| parent | 7187be8b76452aa968726180af24deaaa545431d (diff) | |
| download | luasocket-86de838eb5ed49711be8d62e01255cc2ccd3342e.tar.gz luasocket-86de838eb5ed49711be8d62e01255cc2ccd3342e.tar.bz2 luasocket-86de838eb5ed49711be8d62e01255cc2ccd3342e.zip | |
cleanup; move ./etc into ./samples and mark 'unsupported'
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) | ||
