beautiful: remove tabulations in key/value parsing

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Matteo Landi 2008-08-18 16:57:48 +02:00 committed by Julien Danjou
parent ffd981a645
commit 6049eaec3f
1 changed files with 5 additions and 3 deletions

View File

@ -28,13 +28,15 @@ local function split_line(line)
local split_val = line:find('=') local split_val = line:find('=')
if split_val and line:sub(1, 1) ~= '#' and line:sub(1, 2) ~= '--' then if split_val and line:sub(1, 1) ~= '#' and line:sub(1, 2) ~= '--' then
-- Remove spaces in key and extra spaces before value -- Remove spaces and tabulations in key
local key = line:sub(1, split_val - 1):gsub(' ', ''):gsub('\t', '')
-- and extra spaces and tabulations before value
local value = line:sub(split_val + 1, -1) local value = line:sub(split_val + 1, -1)
while value:sub(1, 1) == ' ' do while value:sub(1, 1) == ' ' or value:sub(1, 1) == '\t' do
value = value:sub(2, -1) value = value:sub(2, -1)
end end
return line:sub(1, split_val - 1):gsub(' ', ''), value return key, value
end end
end end