From 7294a1bc728a0697499676e96f2fb716f62b3964 Mon Sep 17 00:00:00 2001 From: Geoff Leyland Date: Thu, 5 Dec 2013 15:01:41 +1300 Subject: [PATCH] fix up accidental global variables. Thanks on Ashwyn Hirschi --- lua/csv.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/csv.lua b/lua/csv.lua index fb143a4..98830a8 100644 --- a/lua/csv.lua +++ b/lua/csv.lua @@ -74,7 +74,7 @@ end -- what to do with them. Mostly this is about checking we've got the columns -- we need and writing a nice complaint if we haven't. local function build_column_index_map(header, column_name_map) - column_index_map = {} + local column_index_map = {} -- Match the columns in the file to the columns in the name map local found = {} @@ -126,6 +126,7 @@ local function transform_field(value, index, map, filename, line, column) local field = map[index] if field then if field.transform then + local ok ok, value = pcall(field.transform, value) if not ok then error(("%s:%d:%d: Couldn't read field '%s': %s"): @@ -221,6 +222,7 @@ local function separated_values_iterator(file, parameters) local field_start_line = line local field_start_column = anchor_pos - line_start + 1 local field_end, sep_end, this_sep + local tidy -- If the field is quoted, go find the other quote if sub(1, 1) == '"' then