webmcp
annotate framework/env/format/file_path_element.lua @ 562:328f120924a2
Removed if-clause when initializing file descriptor set to avoid compiler warning for mondelefant_conn_try_wait
author | jbe |
---|---|
date | Fri Feb 05 15:51:39 2021 +0100 (2021-02-05) |
parents | a9fea293b2d6 |
children |
rev | line source |
---|---|
jbe@471 | 1 --[[-- |
jbe@471 | 2 text = -- a string |
jbe@471 | 3 format.file_path_element( |
jbe@471 | 4 value, -- part of an encoded file path, see encode.file_path_element(...) |
jbe@471 | 5 options -- options as supported by format.string(...) |
jbe@471 | 6 ) |
jbe@471 | 7 |
jbe@471 | 8 Undoes the encoding done by encode.file_path_element(...) and additionally formats the resulting string using the options available for format.string(...). |
jbe@471 | 9 |
jbe@471 | 10 --]]-- |
jbe@471 | 11 |
jbe@471 | 12 function format.file_path_element(value, options) |
jbe@471 | 13 local options = options or {} |
jbe@471 | 14 if value == nil then |
jbe@471 | 15 return options.nil_as or "" |
jbe@471 | 16 else |
jbe@471 | 17 return format.string( |
jbe@471 | 18 string.gsub( |
jbe@471 | 19 tostring(value), |
jbe@471 | 20 "%%(%x%x)", |
jbe@471 | 21 function (hexcode) |
jbe@471 | 22 return string.char(tonumber("0x" .. hexcode)) |
jbe@471 | 23 end |
jbe@471 | 24 ), |
jbe@471 | 25 options |
jbe@471 | 26 ) |
jbe@471 | 27 end |
jbe@471 | 28 end |