From 4a41111d1e3424312016b280ea40198d29354825 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Sat, 24 Jun 2017 18:36:01 +0200 Subject: [PATCH] `analyse_structure` is not automatically called, if no info regarding a table could be found. --- analyze_structure.lua | 2 +- pretty.lua | 8 ++++---- test/test_analyze_structure.lua | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/analyze_structure.lua b/analyze_structure.lua index f215869..3311e0d 100644 --- a/analyze_structure.lua +++ b/analyze_structure.lua @@ -257,4 +257,4 @@ end -------------------------------------------------------------------------------- -return { analyze_structure, get_table_info } +return analyze_structure diff --git a/pretty.lua b/pretty.lua index 925c169..a45ebf2 100644 --- a/pretty.lua +++ b/pretty.lua @@ -2,7 +2,7 @@ -- Ensure loading library, if it exists, no matter where pretty.lua was loaded from. -- Load the library component -local format_number, format_function, analyze_structure, get_table_info, TABLE_TYPE +local format_number, format_function, analyze_structure, TABLE_TYPE do local thispath = ... and select('1', ...):match('.+%.') or '' local function import (name, ignore_failure) @@ -22,7 +22,6 @@ do -- Load other stuff analyze_structure = import 'analyze_structure' - analyze_structure, get_table_info = analyze_structure[1], analyze_structure[2] TABLE_TYPE = import 'table_type' end -- @@ -308,7 +307,9 @@ local function format_table (t, depth, l) assert(type(depth) == 'number' and type(l) == 'table') -- Do stuff - local table_info = l.info[t] or get_table_info(t) + if not l.info[t] then analyze_structure(t, l.options.max_depth-depth, l.info) end + local table_info = l.info[t] + assert(table_info) if l.options.recursion == 'marked' and table_info.marker then l[#l+1], l[#l+2], l[#l+3] = '<', table_info.marker, '>' @@ -462,7 +463,6 @@ setmetatable(StringBuilder, { -------------------------------------------------------------------------------- - local DEBUG_OPTIONS = { _all_function_info = true, _table_addr_comment = true } local KNOWN_OPTIONS = { diff --git a/test/test_analyze_structure.lua b/test/test_analyze_structure.lua index 4ac85ff..73aff59 100644 --- a/test/test_analyze_structure.lua +++ b/test/test_analyze_structure.lua @@ -1,7 +1,7 @@ local SUITE = require('TestSuite').new('analyze_structure') SUITE:setEnviroment { - analyze_structure = require('analyze_structure')[1], + analyze_structure = require('analyze_structure'), TABLE_TYPE = require('table_type') }