From e1f8b604a09410823f6129dd43e4e8a80963eca1 Mon Sep 17 00:00:00 2001 From: funshine Date: Tue, 24 Mar 2015 23:21:40 +0800 Subject: [PATCH] fix init_data detect flash api --- app/platform/flash_api.c | 2 +- examples/fragment.lua | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/platform/flash_api.c b/app/platform/flash_api.c index 97c6f20c..a96619e9 100644 --- a/app/platform/flash_api.c +++ b/app/platform/flash_api.c @@ -321,7 +321,7 @@ bool flash_init_data_written(void) // FLASH SEC - 4 uint32_t data[2] ICACHE_STORE_ATTR; #if defined(FLASH_SAFE_API) - if (SPI_FLASH_RESULT_OK == flash_safe_read((flash_rom_get_sec_num() - 4) * SPI_FLASH_SEC_SIZE, (uint32 *)data, sizeof(data))) + if (SPI_FLASH_RESULT_OK == flash_safe_read((flash_safe_get_sec_num() - 4) * SPI_FLASH_SEC_SIZE, (uint32 *)data, sizeof(data))) #else if (SPI_FLASH_RESULT_OK == spi_flash_read((flash_rom_get_sec_num() - 4) * SPI_FLASH_SEC_SIZE, (uint32 *)data, sizeof(data))) #endif // defined(FLASH_SAFE_API) diff --git a/examples/fragment.lua b/examples/fragment.lua index 67aa2c37..d3d0f7da 100644 --- a/examples/fragment.lua +++ b/examples/fragment.lua @@ -381,3 +381,18 @@ function TestDNSLeak() tmr.alarm(1, 3000, 0, function() print("hack socket close, MEM: "..node.heap()) c:close() end) -- socket timeout hack print("MEM: "..node.heap()) end + +v="abc%0D%0Adef" +print(string.gsub(v, "%%(%x%x)", function(x) return string.char(tonumber(x, 16)) end)) + +function ex(x) string.find("abc%0Ddef","bc") return 's' end +string.gsub("abc%0Ddef", "%%(%x%x)", ex) + +function ex(x) string.char(35) return 's' end +string.gsub("abc%0Ddef", "%%(%x%x)", ex) print("hello") + +function ex(x) string.lower('Ab') return 's' end +string.gsub("abc%0Ddef", "%%(%x%x)", ex) print("hello") + +v="abc%0D%0Adef" +pcall(function() print(string.gsub(v, "%%(%x%x)", function(x) return string.char(tonumber(x, 16)) end)) end) \ No newline at end of file