From: Ian Jackson Date: Sun, 7 Jun 2009 15:45:22 +0000 (+0100) Subject: progress printing and bugfixing and build system improvements X-Git-Tag: 1.9.2~153 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.db-test.git;a=commitdiff_plain;h=09e8b6a8735c8cd1f7f3ffbabc1a05f0a8f8ca75 progress printing and bugfixing and build system improvements --- diff --git a/pctb/Makefile b/pctb/Makefile index 7d1d6ef..2265cec 100644 --- a/pctb/Makefile +++ b/pctb/Makefile @@ -1,7 +1,14 @@ -CFLAGS += -Wall -Wwrite-strings -Wpointer-arith -Wmissing-prototypes \ - -Wstrict-prototypes -Werror -g +OPTIMISE= -O2 +WERROR= -Werror +WARNINGS= -Wall -Wwrite-strings -Wpointer-arith -Wmissing-prototypes \ + -Wstrict-prototypes -Wno-format-zero-length +DEBUG=-g -all: convert x-manip-window +CFLAGS += $(WARNINGS) $(WERROR) $(OPTIMISE) $(DEBUG) + +TARGETS= convert x-manip-window + +all: $(TARGETS) CONVERT_OBJS= convert.o ocr.o pages.o structure.o @@ -9,3 +16,6 @@ convert: $(CONVERT_OBJS) -lnetpbm -lXtst -lX11 $(CONVERT_OBJS): ocr.h convert.h structure.h x-manip-window: -lXtst -lX11 + +clean: + rm -f $(TARGETS) *.o core core.* diff --git a/pctb/charset-15.txt b/pctb/charset-15.txt index d12325b..f89f60f 100644 --- a/pctb/charset-15.txt +++ b/pctb/charset-15.txt @@ -138,6 +138,15 @@ ff8 410 3e0 +Lower +E +ff8 +888 +888 +888 +888 +808 + Lower F ff8 @@ -628,6 +637,18 @@ y 0 0 +Lower +yt +60 +180 +2600 +1800 +600 +180 +60 +7f0 +820 + Lower yw 60 @@ -666,6 +687,24 @@ A 600 800 +Upper +Av +800 +600 +380 +260 +218 +260 +380 +600 +820 +c0 +700 +800 +700 +c0 +20 + Upper B ff8 @@ -826,6 +865,17 @@ ff8 88 70 +Upper +Q +3e0 +410 +808 +808 +808 +1410 +23e0 +2000 + Upper R ff8 diff --git a/pctb/convert.c b/pctb/convert.c index cd9c652..8b12f3a 100644 --- a/pctb/convert.c +++ b/pctb/convert.c @@ -90,6 +90,7 @@ int main(int argc, char **argv) { DEFINE_VWRAPPERF(, progress) DEFINE_VWRAPPERF(, progress_log) DEFINE_VWRAPPERF(, progress_spinner) +DEFINE_VWRAPPERF(, warning) static int last_progress_len; @@ -137,3 +138,10 @@ void vprogress_log(const char *fmt, va_list al) { putc('\n',stderr); fflush(stderr); } + +void vwarning(const char *fmt, va_list al) { + progress(""); + fputs("warning: ",stderr); + vfprintf(stderr,fmt,al); + fflush(stderr); +} diff --git a/pctb/convert.h b/pctb/convert.h index d396269..cb2bf77 100644 --- a/pctb/convert.h +++ b/pctb/convert.h @@ -22,14 +22,19 @@ void analyse(void); extern FILE *screenshots_file; -void vprogress(const char *fmt, va_list); -void progress(const char *fmt, ...); +#define FMT(f,a) __attribute__((format(printf,f,a))) -void vprogress_log(const char *fmt, va_list); -void progress_log(const char *fmt, ...); +void vwarning(const char *fmt, va_list) FMT(1,0); +void warning(const char *fmt, ...) FMT(1,2); -void vprogress_spinner(const char *fmt, va_list); -void progress_spinner(const char *fmt, ...); +void vprogress(const char *fmt, va_list) FMT(1,0); +void progress(const char *fmt, ...) FMT(1,2); + +void vprogress_log(const char *fmt, va_list) FMT(1,0); +void progress_log(const char *fmt, ...) FMT(1,2); + +void vprogress_spinner(const char *fmt, va_list) FMT(1,0); +void progress_spinner(const char *fmt, ...) FMT(1,2); /*----- from pages.c -----*/ diff --git a/pctb/pages.c b/pctb/pages.c index fbf3317..ffd0ba6 100644 --- a/pctb/pages.c +++ b/pctb/pages.c @@ -61,6 +61,58 @@ static void sync_after_input(void) { last_input= timestamp(); } +static void translate_coords_toroot(int wx, int wy, int *rx, int *ry) { + int r; + Window dummy; + r= XTranslateCoordinates(disp, id,attr.root, wx,wy, rx,ry, &dummy); + eassert(r); +} + +static void check_client_window_all_on_screen(void) { + int r; + int rxpos, rypos; + unsigned rwidth, rheight; + Window dummy; + unsigned bd, depth; + + r= XGetGeometry(disp,attr.root, &dummy, &rxpos,&rypos, + &rwidth, &rheight, + &bd,&depth); + + translate_coords_toroot(0,0, &rxpos,&rypos); + eassert(rxpos>=0 && rypos>=0); + + translate_coords_toroot(wwidth-1,wheight-1, &rxpos,&rypos); + eassert(rxposdata, b->data, a->bytes_per_line * a->height); } +static void wait_for_stability(Snapshot **output, + const Snapshot *previously, + void (*with_keypress)(void), + const char *fmt, ...) + FMT(4,5); + static void wait_for_stability(Snapshot **output, const Snapshot *previously, void (*with_keypress)(void), const char *fmt, ...) { + va_list al; + va_start(al,fmt); + Snapshot *last=0; int r; /* waits longer if we're going to return an image identical to previously @@ -119,12 +182,9 @@ static void wait_for_stability(Snapshot **output, last_input, previously); char *doing; - va_list al; - va_start(al,fmt); - r= asprintf(&doing,fmt,al); eassert(r>=0); - va_end(al); + r= vasprintf(&doing,fmt,al); eassert(r>=0); - progress(doing); + progress("%s",doing); for (;;) { double at_snapshot= timestamp(); @@ -144,7 +204,7 @@ static void wait_for_stability(Snapshot **output, break; } - progress_spinner(doing); + progress_spinner("%s",doing); debugf("PAGING wait_for_stability retry\n"); @@ -159,13 +219,7 @@ static void wait_for_stability(Snapshot **output, free_snapshot(&last); free(doing); debugf("PAGING wait_for_stability done.\n"); -} - -static void translate_coords_toroot(int wx, int wy, int *rx, int *ry) { - int r; - Window dummy; - r= XTranslateCoordinates(disp, id,attr.root, wx,wy, rx,ry, &dummy); - eassert(r); + va_end(al); } static void raise_and_get_details(void) { @@ -173,7 +227,6 @@ static void raise_and_get_details(void) { int evbase,errbase,majver,minver; int wxpos, wypos; unsigned bd,depth; - Window dummy; progress("raising and checking YPP client window..."); @@ -202,20 +255,11 @@ static void raise_and_get_details(void) { eassert(wwidth >= 320 && wheight >= 320); - int rxpos, rypos; - unsigned rwidth, rheight; - r= XGetGeometry(disp,attr.root, &dummy, &rxpos,&rypos, - &rwidth, &rheight, - &bd,&depth); - - translate_coords_toroot(0,0, &rxpos,&rypos); - eassert(rxpos>=0 && rypos>=0); - - translate_coords_toroot(wwidth-1,wheight-1, &rxpos,&rypos); - eassert(rxpost +set args --screenshot-only +break pages.c:375 run