From 3a7ac1e04361e12ddfcbf344e9e1db82fb88157b Mon Sep 17 00:00:00 2001 From: Diego Nehab Date: Wed, 21 Jan 2004 01:09:50 +0000 Subject: [PATCH] Changed the naming convention of the mime module. Looks beautiful. --- TODO | 3 ++ etc/get.lua | 20 +++----- luasocket.vcproj | 2 +- src/mime.c | 80 ++++++++++++++++++------------ src/mime.lua | 92 ++++++++++++++++------------------ test/httptest.lua | 124 ++++++++++++++++++++++++++++++++++++++++++---- test/mimetest.lua | 30 +++++------ 7 files changed, 234 insertions(+), 117 deletions(-) diff --git a/TODO b/TODO index 260d9bf..b24f9e5 100644 --- a/TODO +++ b/TODO @@ -19,6 +19,9 @@ tests checar garbage collection check for interrupts +trust character constants in mime.c? noooooo. +smtp.lua needs stuff filter + new option.c module to put all options (TCP and UDP share...)? testar os options! add _tostring methods! diff --git a/etc/get.lua b/etc/get.lua index 9f29a51..d6760b8 100644 --- a/etc/get.lua +++ b/etc/get.lua @@ -19,7 +19,7 @@ function nicetime(s) end end end - if l == "s" then return string.format("%2.0f%s", s, l) + if l == "s" then return string.format("%5.0f%s", s, l) else return string.format("%5.2f%s", s, l) end end @@ -42,20 +42,16 @@ function nicesize(b) end -- returns a string with the current state of the download +local remaining_s = "%s received, %s/s throughput, %2.0f%% done, %s remaining" +local elapsed_s = "%s received, %s/s throughput, %s elapsed " function gauge(got, delta, size) local rate = got / delta if size and size >= 1 then - return string.format("%s received, %s/s throughput, " .. - "%.0f%% done, %s remaining", - nicesize(got), - nicesize(rate), - 100*got/size, - nicetime((size-got)/rate)) + return string.format(remaining_s, nicesize(got), nicesize(rate), + 100*got/size, nicetime((size-got)/rate)) else - return string.format("%s received, %s/s throughput, %s elapsed", - nicesize(got), - nicesize(rate), - nicetime(delta)) + return string.format(elapsed_s, nicesize(got), + nicesize(rate), nicetime(delta)) end end @@ -78,7 +74,7 @@ function stats(size) return chunk else -- close up - io.stderr:write("\n") + io.stderr:write("\r", gauge(got, delta), "\n") return "" end end diff --git a/luasocket.vcproj b/luasocket.vcproj index 5a74880..f6ae497 100644 --- a/luasocket.vcproj +++ b/luasocket.vcproj @@ -70,7 +70,7 @@