On Thu, 23 Sep 2010, Tamas TEVESZ wrote:
oops, so excited about having killed the thing that drove me crazy
that i left half of it out.
>From bcf23f31c2344b1b69b26388447da495ecbf4a5f Mon Sep 17 00:00:00 2001
From: Tamas TEVESZ <[email protected]>
Date: Thu, 23 Sep 2010 01:58:09 +0200
Subject: [PATCH] Ungeneralize wrlib DEBUG
Plus debug messages belong on stderr.
Signed-off-by: Tamas TEVESZ <[email protected]>
---
wrlib/context.c | 28 ++++++++++++++--------------
wrlib/convert.c | 29 +++++++++++++++--------------
2 files changed, 29 insertions(+), 28 deletions(-)
diff --git a/wrlib/context.c b/wrlib/context.c
index fd484c7..0fe956c 100644
--- a/wrlib/context.c
+++ b/wrlib/context.c
@@ -263,8 +263,8 @@ static Bool allocatePseudoColor(RContext * ctx)
colors[i].flags = DoRed | DoGreen |
DoBlue;
break; /* succeeded, don't need to
retry */
}
-#ifdef DEBUG
- printf("close color allocation failed.
Retrying...\n");
+#ifdef WRLIB_DEBUG
+ fputs("close color allocation failed.
Retrying...\n", stderr);
#endif
}
}
@@ -323,18 +323,18 @@ static XColor *allocateGrayScale(RContext * ctx)
}
/* try to allocate the colors */
for (i = 0; i < ncolors; i++) {
-#ifdef DEBUG
- printf("trying:%x,%x,%x\n", colors[i].red, colors[i].green,
colors[i].blue);
+#ifdef WRLIB_DEBUG
+ fprintf(stderr, "trying:%x,%x,%x\n", colors[i].red,
colors[i].green, colors[i].blue);
#endif
if (!XAllocColor(ctx->dpy, ctx->cmap, &(colors[i]))) {
colors[i].flags = 0; /* failed */
-#ifdef DEBUG
- printf("failed:%x,%x,%x\n", colors[i].red,
colors[i].green, colors[i].blue);
+#ifdef WRLIB_DEBUG
+ fprintf(stderr, "failed:%x,%x,%x\n", colors[i].red,
colors[i].green, colors[i].blue);
#endif
} else {
colors[i].flags = DoRed | DoGreen | DoBlue;
-#ifdef DEBUG
- printf("success:%x,%x,%x\n", colors[i].red,
colors[i].green, colors[i].blue);
+#ifdef WRLIB_DEBUG
+ fprintf(stderr, "success:%x,%x,%x\n", colors[i].red,
colors[i].green, colors[i].blue);
#endif
}
}
@@ -367,10 +367,10 @@ static XColor *allocateGrayScale(RContext * ctx)
}
}
/* allocate closest color found */
-#ifdef DEBUG
- printf("best match:%x,%x,%x => %x,%x,%x\n",
colors[i].red, colors[i].green,
- colors[i].blue, avcolors[closest].red,
avcolors[closest].green,
- avcolors[closest].blue);
+#ifdef WRLIB_DEBUG
+ fprintf(stderr, "best match:%x,%x,%x =>
%x,%x,%x\n",
+ colors[i].red, colors[i].green,
colors[i].blue,
+ avcolors[closest].red,
avcolors[closest].green, avcolors[closest].blue);
#endif
colors[i].red = avcolors[closest].red;
colors[i].green = avcolors[closest].green;
@@ -379,8 +379,8 @@ static XColor *allocateGrayScale(RContext * ctx)
colors[i].flags = DoRed | DoGreen |
DoBlue;
break; /* succeeded, don't need to
retry */
}
-#ifdef DEBUG
- printf("close color allocation failed.
Retrying...\n");
+#ifdef WRLIB_DEBUG
+ fputs("close color allocation failed.
Retrying...\n", stderr);
#endif
}
}
diff --git a/wrlib/convert.c b/wrlib/convert.c
index 3f04556..139f946 100644
--- a/wrlib/convert.c
+++ b/wrlib/convert.c
@@ -327,8 +327,8 @@ static RXImage *image2TrueColor(RContext * ctx, RImage *
image)
unsigned char *ptr = image->data;
/* fake match */
-#ifdef DEBUG
- puts("true color match");
+#ifdef WRLIB_DEBUG
+ fputs("true color match\n", stderr);
#endif
if (rmask == 0xff && gmask == 0xff && bmask == 0xff) {
for (y = 0; y < image->height; y++) {
@@ -356,8 +356,8 @@ static RXImage *image2TrueColor(RContext * ctx, RImage *
image)
const int dg = 0xff / gmask;
const int db = 0xff / bmask;
-#ifdef DEBUG
- puts("true color dither");
+#ifdef WRLIB_DEBUG
+ fputs("true color dither\n", stderr);
#endif
#ifdef ASM_X86_MMX
@@ -538,8 +538,8 @@ static RXImage *image2PseudoColor(RContext * ctx, RImage *
image)
if (ctx->attribs->render_mode == RBestMatchRendering) {
/* fake match */
-#ifdef DEBUG
- printf("pseudo color match with %d colors per channel\n", cpc);
+#ifdef WRLIB_DEBUG
+ fprintf(stderr, "pseudo color match with %d colors per
channel\n", cpc);
#endif
for (y = 0; y < image->height; y++) {
for (x = 0; x < image->width; x++, ptr += channels - 3)
{
@@ -560,8 +560,8 @@ static RXImage *image2PseudoColor(RContext * ctx, RImage *
image)
const int dg = 0xff / gmask;
const int db = 0xff / bmask;
-#ifdef DEBUG
- printf("pseudo color dithering with %d colors per channel\n",
cpc);
+#ifdef WRLIB_DEBUG
+ fprintf(stderr, "pseudo color dithering with %d colors per
channel\n", cpc);
#endif
err = malloc(4 * (image->width + 3));
nerr = malloc(4 * (image->width + 3));
@@ -638,8 +638,9 @@ static RXImage *image2StandardPseudoColor(RContext * ctx,
RImage * image)
int rer, ger, ber;
int x1, ofs;
-#ifdef DEBUG
- printf("pseudo color dithering with %d colors per channel\n",
ctx->attribs->colors_per_channel);
+#ifdef WRLIB_DEBUG
+ fprintf(stderr, "pseudo color dithering with %d colors per
channel\n",
+ ctx->attribs->colors_per_channel);
#endif
err = (short *)malloc(3 * (image->width + 2) * sizeof(short));
nerr = (short *)malloc(3 * (image->width + 2) * sizeof(short));
@@ -769,8 +770,8 @@ static RXImage *image2GrayScale(RContext * ctx, RImage *
image)
if (ctx->attribs->render_mode == RBestMatchRendering) {
/* fake match */
-#ifdef DEBUG
- printf("grayscale match with %d colors per channel\n", cpc);
+#ifdef WRLIB_DEBUG
+ fprintf(stderr, "grayscale match with %d colors per channel\n",
cpc);
#endif
for (y = 0; y < image->height; y++) {
for (x = 0; x < image->width; x++) {
@@ -789,8 +790,8 @@ static RXImage *image2GrayScale(RContext * ctx, RImage *
image)
int ger;
const int dg = 0xff / gmask;
-#ifdef DEBUG
- printf("grayscale dither with %d colors per channel\n", cpc);
+#ifdef WRLIB_DEBUG
+ fprintf(stderr, "grayscale dither with %d colors per
channel\n", cpc);
#endif
gerr = (short *)malloc((image->width + 2) * sizeof(short));
ngerr = (short *)malloc((image->width + 2) * sizeof(short));
--
1.7.0.4
--
[-]
mkdir /nonexistentFrom bcf23f31c2344b1b69b26388447da495ecbf4a5f Mon Sep 17 00:00:00 2001
From: Tamas TEVESZ <[email protected]>
Date: Thu, 23 Sep 2010 01:58:09 +0200
Subject: [PATCH] Ungeneralize wrlib DEBUG
Plus debug messages belong on stderr.
Signed-off-by: Tamas TEVESZ <[email protected]>
---
wrlib/context.c | 28 ++++++++++++++--------------
wrlib/convert.c | 29 +++++++++++++++--------------
2 files changed, 29 insertions(+), 28 deletions(-)
diff --git a/wrlib/context.c b/wrlib/context.c
index fd484c7..0fe956c 100644
--- a/wrlib/context.c
+++ b/wrlib/context.c
@@ -263,8 +263,8 @@ static Bool allocatePseudoColor(RContext * ctx)
colors[i].flags = DoRed | DoGreen | DoBlue;
break; /* succeeded, don't need to retry */
}
-#ifdef DEBUG
- printf("close color allocation failed. Retrying...\n");
+#ifdef WRLIB_DEBUG
+ fputs("close color allocation failed. Retrying...\n", stderr);
#endif
}
}
@@ -323,18 +323,18 @@ static XColor *allocateGrayScale(RContext * ctx)
}
/* try to allocate the colors */
for (i = 0; i < ncolors; i++) {
-#ifdef DEBUG
- printf("trying:%x,%x,%x\n", colors[i].red, colors[i].green, colors[i].blue);
+#ifdef WRLIB_DEBUG
+ fprintf(stderr, "trying:%x,%x,%x\n", colors[i].red, colors[i].green, colors[i].blue);
#endif
if (!XAllocColor(ctx->dpy, ctx->cmap, &(colors[i]))) {
colors[i].flags = 0; /* failed */
-#ifdef DEBUG
- printf("failed:%x,%x,%x\n", colors[i].red, colors[i].green, colors[i].blue);
+#ifdef WRLIB_DEBUG
+ fprintf(stderr, "failed:%x,%x,%x\n", colors[i].red, colors[i].green, colors[i].blue);
#endif
} else {
colors[i].flags = DoRed | DoGreen | DoBlue;
-#ifdef DEBUG
- printf("success:%x,%x,%x\n", colors[i].red, colors[i].green, colors[i].blue);
+#ifdef WRLIB_DEBUG
+ fprintf(stderr, "success:%x,%x,%x\n", colors[i].red, colors[i].green, colors[i].blue);
#endif
}
}
@@ -367,10 +367,10 @@ static XColor *allocateGrayScale(RContext * ctx)
}
}
/* allocate closest color found */
-#ifdef DEBUG
- printf("best match:%x,%x,%x => %x,%x,%x\n", colors[i].red, colors[i].green,
- colors[i].blue, avcolors[closest].red, avcolors[closest].green,
- avcolors[closest].blue);
+#ifdef WRLIB_DEBUG
+ fprintf(stderr, "best match:%x,%x,%x => %x,%x,%x\n",
+ colors[i].red, colors[i].green, colors[i].blue,
+ avcolors[closest].red, avcolors[closest].green, avcolors[closest].blue);
#endif
colors[i].red = avcolors[closest].red;
colors[i].green = avcolors[closest].green;
@@ -379,8 +379,8 @@ static XColor *allocateGrayScale(RContext * ctx)
colors[i].flags = DoRed | DoGreen | DoBlue;
break; /* succeeded, don't need to retry */
}
-#ifdef DEBUG
- printf("close color allocation failed. Retrying...\n");
+#ifdef WRLIB_DEBUG
+ fputs("close color allocation failed. Retrying...\n", stderr);
#endif
}
}
diff --git a/wrlib/convert.c b/wrlib/convert.c
index 3f04556..139f946 100644
--- a/wrlib/convert.c
+++ b/wrlib/convert.c
@@ -327,8 +327,8 @@ static RXImage *image2TrueColor(RContext * ctx, RImage * image)
unsigned char *ptr = image->data;
/* fake match */
-#ifdef DEBUG
- puts("true color match");
+#ifdef WRLIB_DEBUG
+ fputs("true color match\n", stderr);
#endif
if (rmask == 0xff && gmask == 0xff && bmask == 0xff) {
for (y = 0; y < image->height; y++) {
@@ -356,8 +356,8 @@ static RXImage *image2TrueColor(RContext * ctx, RImage * image)
const int dg = 0xff / gmask;
const int db = 0xff / bmask;
-#ifdef DEBUG
- puts("true color dither");
+#ifdef WRLIB_DEBUG
+ fputs("true color dither\n", stderr);
#endif
#ifdef ASM_X86_MMX
@@ -538,8 +538,8 @@ static RXImage *image2PseudoColor(RContext * ctx, RImage * image)
if (ctx->attribs->render_mode == RBestMatchRendering) {
/* fake match */
-#ifdef DEBUG
- printf("pseudo color match with %d colors per channel\n", cpc);
+#ifdef WRLIB_DEBUG
+ fprintf(stderr, "pseudo color match with %d colors per channel\n", cpc);
#endif
for (y = 0; y < image->height; y++) {
for (x = 0; x < image->width; x++, ptr += channels - 3) {
@@ -560,8 +560,8 @@ static RXImage *image2PseudoColor(RContext * ctx, RImage * image)
const int dg = 0xff / gmask;
const int db = 0xff / bmask;
-#ifdef DEBUG
- printf("pseudo color dithering with %d colors per channel\n", cpc);
+#ifdef WRLIB_DEBUG
+ fprintf(stderr, "pseudo color dithering with %d colors per channel\n", cpc);
#endif
err = malloc(4 * (image->width + 3));
nerr = malloc(4 * (image->width + 3));
@@ -638,8 +638,9 @@ static RXImage *image2StandardPseudoColor(RContext * ctx, RImage * image)
int rer, ger, ber;
int x1, ofs;
-#ifdef DEBUG
- printf("pseudo color dithering with %d colors per channel\n", ctx->attribs->colors_per_channel);
+#ifdef WRLIB_DEBUG
+ fprintf(stderr, "pseudo color dithering with %d colors per channel\n",
+ ctx->attribs->colors_per_channel);
#endif
err = (short *)malloc(3 * (image->width + 2) * sizeof(short));
nerr = (short *)malloc(3 * (image->width + 2) * sizeof(short));
@@ -769,8 +770,8 @@ static RXImage *image2GrayScale(RContext * ctx, RImage * image)
if (ctx->attribs->render_mode == RBestMatchRendering) {
/* fake match */
-#ifdef DEBUG
- printf("grayscale match with %d colors per channel\n", cpc);
+#ifdef WRLIB_DEBUG
+ fprintf(stderr, "grayscale match with %d colors per channel\n", cpc);
#endif
for (y = 0; y < image->height; y++) {
for (x = 0; x < image->width; x++) {
@@ -789,8 +790,8 @@ static RXImage *image2GrayScale(RContext * ctx, RImage * image)
int ger;
const int dg = 0xff / gmask;
-#ifdef DEBUG
- printf("grayscale dither with %d colors per channel\n", cpc);
+#ifdef WRLIB_DEBUG
+ fprintf(stderr, "grayscale dither with %d colors per channel\n", cpc);
#endif
gerr = (short *)malloc((image->width + 2) * sizeof(short));
ngerr = (short *)malloc((image->width + 2) * sizeof(short));
--
1.7.0.4