From 7894b155119acc6c95649016ce23684128195c58 Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Tue, 25 Sep 2012 13:11:21 +0100 Subject: [PATCH] Tidy up debug support. 1. Make "-d" switch passed to reader.lua enable all debugging 2. Enable debugging for now (development stage) to preserve the current behaviour. But for the production release I advise to: a) disable it by not passing "-d" and b) redirect standard output (not just standard error) of reader.lua to crash.log in kpdf.sh 3. Comment out debug printf()s in pdf.c Conflicts: reader.lua --- launchpad/kpdf.sh | 2 +- pdf.c | 12 ++++++------ reader.lua | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/launchpad/kpdf.sh b/launchpad/kpdf.sh index c1f81c700..173e5f7e4 100755 --- a/launchpad/kpdf.sh +++ b/launchpad/kpdf.sh @@ -22,7 +22,7 @@ fi killall -stop cvm # finally call reader -./reader.lua "$1" 2> /mnt/us/kindlepdfviewer/crash.log || cat /mnt/us/kindlepdfviewer/crash.log +./reader.lua -d "$1" 2> /mnt/us/kindlepdfviewer/crash.log || cat /mnt/us/kindlepdfviewer/crash.log # unmount system fonts if grep /mnt/us/kindlepdfviewer/fonts/host /proc/mounts; then diff --git a/pdf.c b/pdf.c index 0de2150d9..780b33dd7 100644 --- a/pdf.c +++ b/pdf.c @@ -78,7 +78,7 @@ static void resetMsize(){ static void showMsize(){ char buf[15],buf2[15],buf3[15],buf4[15]; - printf("§§§ now: %s was: %s - min: %s - max: %s\n",readable_fs(msize,buf),readable_fs(msize_iniz,buf2),readable_fs(msize_min,buf3),readable_fs(msize_max,buf4)); + //printf("§§§ now: %s was: %s - min: %s - max: %s\n",readable_fs(msize,buf),readable_fs(msize_iniz,buf2),readable_fs(msize_min,buf3),readable_fs(msize_max,buf4)); resetMsize(); } @@ -89,7 +89,7 @@ static void log_size(char *funcName){ msize_min = msize; if(1==0 && abs(msize-msize_prev)>msize_prev*LOG_TRESHOLD_PERC){ char buf[15],buf2[15]; - printf("§§§ %s - total: %s (was %s)\n",funcName, readable_fs(msize,buf),readable_fs(msize_prev,buf2)); + //printf("§§§ %s - total: %s (was %s)\n",funcName, readable_fs(msize,buf),readable_fs(msize_prev,buf2)); msize_prev = msize; } } @@ -133,7 +133,7 @@ my_realloc_default(void *opaque, void *old, unsigned int size) } else { struct header * h = ((struct header *)old) - 1; if (h -> magic != MAGIC) { // Not allocated by my_malloc_default - printf("§§§ warn: not allocated by my_malloc_default, new size: %i\n",size); + //printf("§§§ warn: not allocated by my_malloc_default, new size: %i\n",size); newp = realloc(old,size); } else { // malloc + free is_realloc = 1; @@ -166,7 +166,7 @@ static int openDocument(lua_State *L) { char *filename = strdup(luaL_checkstring(L, 1)); int cache_size = luaL_optint(L, 2, 64 << 20); // 64 MB limit default char buf[15]; - printf("## cache_size: %s\n",readable_fs(cache_size,buf)); + //printf("## cache_size: %s\n",readable_fs(cache_size,buf)); PdfDocument *doc = (PdfDocument*) lua_newuserdata(L, sizeof(PdfDocument)); @@ -567,13 +567,13 @@ static int drawPage(lua_State *L) { } static int getCacheSize(lua_State *L) { - printf("## mupdf getCacheSize = %zu\n", msize); + //printf("## mupdf getCacheSize = %zu\n", msize); lua_pushnumber(L, msize); return 1; } static int cleanCache(lua_State *L) { - printf("## mupdf cleanCache NOP\n"); + //printf("## mupdf cleanCache NOP\n"); return 0; } diff --git a/reader.lua b/reader.lua index f0f17c16d..8e9e627b2 100755 --- a/reader.lua +++ b/reader.lua @@ -67,7 +67,7 @@ longopts = { goto = "g", gamma = "G", debug = "d", - help = "h" + help = "h", } function showusage()