Gfxprim
Threads by month
- ----- 2026 -----
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
September 2012
- 1 participants
- 4 discussions
[repo.or.cz] gfxprim.git branch master updated: 2370df5de0e544ff861f5c18a9ddb430d306301e
by metan 27 Sep '12
by metan 27 Sep '12
27 Sep '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via 2370df5de0e544ff861f5c18a9ddb430d306301e (commit)
via 62334a32c731a5452fb460a76373c7ee7e241d8b (commit)
via 78a4c679dd65e8dca7ffedc1e58357036baf9917 (commit)
via 9134135c2343714cde81a93c58cee3111d80aa48 (commit)
via ea25d6c8a8b8ecb3a1f874d05a2c5705de7b8837 (commit)
via 8fa145ac2bca9ebb15fd25965c6d9afe5b2de7a0 (commit)
via 94aa52632f9ade7a52a8e419b9e2d1b6309e57a2 (commit)
via f8b2d14ae8aa2c8fb6f64ccae23cc8298eea3381 (commit)
via e4a59032ce9295e40e84c5003d5e813553b52f2e (commit)
via c643ecb4b3d832e7b3afeff095c3f453ee3d573f (commit)
via b3b68550f6431afd3dd5a441e38212d09b22bdda (commit)
via 3095a596cffe0dca94e5a773828af6fc0365f9d4 (commit)
from f7abc056071b6987bd8ddf3b3e21b76fb2faa593 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/2370df5de0e544ff861f5c18a9ddb430d306…
commit 2370df5de0e544ff861f5c18a9ddb430d306301e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Sep 27 14:10:53 2012 +0200
doc: Cleaned up loaders docs, more to come.
diff --git a/doc/loaders.txt b/doc/loaders.txt
index 0f31498..99ed35d 100644
--- a/doc/loaders.txt
+++ b/doc/loaders.txt
@@ -1,18 +1,26 @@
Context loaders
---------------
-This part of gfxprim library aims to create API to load/save images from/to
-common image file formats.
+This part of GFXprim library aims to create API to load and save images
+from/to common image file formats.
All loading functions returns a pointer to allocated and loaded image or upon
-a failure 'NULL' is returned and 'errno' is set.
+a failure 'NULL' and 'errno' is set.
-The possible errno values are:
+All saving functions returns zero on success and non-zero on failure and
+'errno' is set. If image saving is aborted by a callback, the opened file is
+closed and removed from a filesystem before the call returns.
-* anything returned by fopen(), fclose(), fseek(), ...
-* 'ENOSYS' if library wasn't compiled with particular library support
-* 'ENOMEM' as returned by malloc()
-* 'EIO'/'EILSEQ' invalid image data
-* 'ECANCELED' loading canceled from callback
+The possible 'errno' values (for both loading and saving) are:
+
+* anything returned by +open()+, +close()+, +lseek()+, +read()+, +write()+, ...
+ - 'ENOENT' if file doesn't exist
+ - 'EACCES' if process doesn't have rights
+ - etc.
+
+* 'ENOSYS' if GFXprim wasn't compiled with particular library support
+* 'ENOMEM' if returned by +malloc()+
+* 'EIO' invalid image data (wrong signature, header or image data)
+* 'ECANCELED' action canceled by returning non-zero from within a callback
Common Loader
~~~~~~~~~~~~~
@@ -27,7 +35,8 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
Loads image from a file. The format is now matched by an image file extension.
-File signature loading method is on the TODO.
+Fallback to file signature if file content doesn't match it's extension is on
+the TODO.
[source,c]
-------------------------------------------------------------------------------
@@ -44,16 +53,11 @@ file extension, if extension is invalid or if support for requested image
format wasn't compiled in, non-zero is returned and 'errno' is set to
'ENOSYS'.
-Returns zero on success and non-zero on failure and 'errno' is set. The
-possible errno values are 'ENOSYS' for unknown format and anything that could
-be returned by 'fopen()', 'open()', 'fwrite()', 'write()', 'seek()', etc...
-
PNG
~~~
-The 'PNG' loading support is optionally implemented by libpng.
+The 'PNG' image support is implemented by the libpng library.
-Just now, the 'PNG' support is not fully finished. Images with alpha channel
-are not supported yet.
+WARNING: PNG images with alpha channel are not supported yet.
[source,c]
-------------------------------------------------------------------------------
@@ -68,8 +72,6 @@ Opens file and checks for 'PNG' signature. Returns zero on success (file
could be opened, signature matches), the opened file is returned and the file
position points right after the end of the 'PNG' signature.
-Upon failure 'errno' is filled.
-
This function is semi-internal, you should rather use functions listed below.
[source,c]
@@ -108,17 +110,13 @@ int GP_SavePNG(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback);
-------------------------------------------------------------------------------
-Writes a Context into a 'PNG' image. If aborted by a callback, the opened file
-is closed and removed before the call returns non-zero and 'errno' is set to
-'ECANCELED'.
-
Currently only 'RGB888' format is supported, you should convert the
'GP_Context' to 'RGB888' before calling this function otherwise non-zero is
returned and 'errno' is set to 'ENOSYS'.
JPEG
~~~~
-The 'JPEG' loading support is optionally implemented by jpeg library.
+The 'JPEG' image support is implemented by the jpeg library.
[source,c]
-------------------------------------------------------------------------------
@@ -185,7 +183,7 @@ convert the context into one of them before this functions is called.
GIF
~~~
-The 'GIF' format is supported optionally by giflib library.
+The 'GIF' image support is implemented by the giflib library.
[source,c]
-------------------------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/62334a32c731a5452fb460a76373c7ee7e24…
commit 62334a32c731a5452fb460a76373c7ee7e241d8b
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Sep 27 13:31:13 2012 +0200
tests: framework: slight change in html output.
diff --git a/tests/framework/tst_log.c b/tests/framework/tst_log.c
index 7c6a82c..5ab46a6 100644
--- a/tests/framework/tst_log.c
+++ b/tests/framework/tst_log.c
@@ -186,12 +186,19 @@ static int append_html(struct tst_job *job, FILE *f)
{
const char *padd = " ";
int sec, nsec;
+ static int hack_counter = 0;
+ const char *bgcol;
tst_diff_timespec(&sec, &nsec, &job->start_time, &job->stop_time);
+ if (hack_counter)
+ bgcol = "#ccccee";
+ else
+ bgcol = "#ddddee";
+
fprintf(f, "%s<tr>n", padd);
- fprintf(f, "%s <td bgcolor="#ccccee">%s </td>n", padd, job->test->name);
- fprintf(f, "%s <td bgcolor="#ccccee">n", padd);
+ fprintf(f, "%s <td bgcolor="%s">%s </td>n", padd, bgcol, job->test->name);
+ fprintf(f, "%s <td bgcolor="%s">n", padd, bgcol);
fprintf(f, "%s <center><small><font color="#222">%i.%03is %i.%03is</font></small></center>",
padd, sec, nsec/1000000, (int)job->cpu_time.tv_sec, (int)job->cpu_time.tv_nsec/1000000);
fprintf(f, "%s </td>n", padd);
@@ -213,7 +220,9 @@ static int append_html(struct tst_job *job, FILE *f)
}
fprintf(f, "%s</tr>n", padd);
-
+
+ hack_counter = !hack_counter;
+
return 0;
}
http://repo.or.cz/w/gfxprim.git/commit/78a4c679dd65e8dca7ffedc1e58357036baf…
commit 78a4c679dd65e8dca7ffedc1e58357036baf9917
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Sep 27 13:18:45 2012 +0200
loaders: bmp: Fix errno on invalid signature.
diff --git a/libs/loaders/GP_BMP.c b/libs/loaders/GP_BMP.c
index d7ac6c5..0b1f7f5 100644
--- a/libs/loaders/GP_BMP.c
+++ b/libs/loaders/GP_BMP.c
@@ -535,7 +535,7 @@ int GP_OpenBMP(const char *src_path, FILE **f,
GP_DEBUG(1, "Unexpected bitmap header 0x%02x (%c) 0x%02x (%c)",
ch1, isascii(ch1) ? ch1 : ' ',
ch2, isascii(ch2) ? ch2 : ' ');
- err = EILSEQ;
+ err = EIO;
goto err1;
}
http://repo.or.cz/w/gfxprim.git/commit/9134135c2343714cde81a93c58cee3111d80…
commit 9134135c2343714cde81a93c58cee3111d80aa48
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Sep 27 13:18:04 2012 +0200
tests: loaders: Add tests for EIO.
diff --git a/tests/loaders/loaders_suite.c b/tests/loaders/loaders_suite.c
index b35b855..aa2fa92 100644
--- a/tests/loaders/loaders_suite.c
+++ b/tests/loaders/loaders_suite.c
@@ -58,8 +58,6 @@ static int save_img(enum fmt fmt, const GP_Context *img, const char *name)
snprintf(buf, sizeof(buf), "%s.%s", name, strfmt(fmt));
- tst_report(0, "Saving %s", buf);
-
switch (fmt) {
case PNG:
return GP_SavePNG(img, buf, NULL);
@@ -257,6 +255,63 @@ static int test_BMP_Load_EACCES(void)
return load_eacces(BMP);
}
+static int load_eio(enum fmt fmt)
+{
+ char buf[256];
+ GP_Context *img;
+
+ snprintf(buf, sizeof(buf), "test.%s", strfmt(fmt));
+
+ FILE *f = fopen(buf, "w");
+
+ if (f == NULL) {
+ tst_report(0, "Failed to create file 'test'");
+ return TST_INTERR;
+ }
+
+ fclose(f);
+
+ img = load(fmt, "test");
+
+ if (img != NULL) {
+ tst_report(0, "Test succedded unexpectedly");
+ return TST_FAILED;
+ }
+
+ if (errno == ENOSYS) {
+ tst_report(0, "Load %s: ENOSYS", strfmt(fmt));
+ return TST_SKIPPED;
+ }
+
+ if (errno != EIO) {
+ tst_report(0, "Expected errno = EIO, have %s",
+ strerror(errno));
+ return TST_FAILED;
+ }
+
+ return TST_SUCCESS;
+}
+
+static int test_PNG_Load_EIO(void)
+{
+ return load_eio(PNG);
+}
+
+static int test_JPG_Load_EIO(void)
+{
+ return load_eio(JPG);
+}
+
+static int test_GIF_Load_EIO(void)
+{
+ return load_eio(GIF);
+}
+
+static int test_BMP_Load_EIO(void)
+{
+ return load_eio(BMP);
+}
+
/*
* We test that a correct cleanup is done after aborting the image load from a
* callback.
@@ -460,6 +515,15 @@ const struct tst_suite tst_suite = {
{.name = "BMP Load EACCES", .tst_fn = test_BMP_Load_EACCES,
.flags = TST_TMPDIR},
+ {.name = "PNG Load EIO", .tst_fn = test_PNG_Load_EIO,
+ .flags = TST_TMPDIR},
+ {.name = "JPG Load EIO", .tst_fn = test_JPG_Load_EIO,
+ .flags = TST_TMPDIR},
+ {.name = "GIF Load EIO", .tst_fn = test_GIF_Load_EIO,
+ .flags = TST_TMPDIR},
+ {.name = "BMP Load EIO", .tst_fn = test_BMP_Load_EIO,
+ .flags = TST_TMPDIR},
+
/* Generic GP_LoadImage test */
{.name = "Image Load", .tst_fn = test_Load,
.flags = TST_TMPDIR},
http://repo.or.cz/w/gfxprim.git/commit/ea25d6c8a8b8ecb3a1f874d05a2c5705de7b…
commit ea25d6c8a8b8ecb3a1f874d05a2c5705de7b8837
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Sep 27 13:11:16 2012 +0200
loaders: gif: Fix errno handling.
diff --git a/libs/loaders/GP_GIF.c b/libs/loaders/GP_GIF.c
index 15e0c44..262e5d9 100644
--- a/libs/loaders/GP_GIF.c
+++ b/libs/loaders/GP_GIF.c
@@ -48,11 +48,21 @@ int GP_OpenGIF(const char *src_path, void **f)
{
GifFileType *gf;
+ errno = 0;
+
gf = DGifOpenFileName(src_path);
if (gf == NULL) {
- //TODO: error handling
- errno = EIO;
+ /*
+ * The giflib uses open() so when we got a failure and errno
+ * is set => open() has failed.
+ *
+ * When errno is not set the file content was not valid so we
+ * set errno to EIO.
+ */
+ if (errno == 0)
+ errno = EIO;
+
return 1;
}
http://repo.or.cz/w/gfxprim.git/commit/8fa145ac2bca9ebb15fd25965c6d9afe5b2d…
commit 8fa145ac2bca9ebb15fd25965c6d9afe5b2de7a0
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Sep 27 12:58:39 2012 +0200
tests: loaders: Add tests for EACCES + cleanup.
diff --git a/tests/loaders/loaders_suite.c b/tests/loaders/loaders_suite.c
index 5736829..b35b855 100644
--- a/tests/loaders/loaders_suite.c
+++ b/tests/loaders/loaders_suite.c
@@ -22,6 +22,7 @@
#include <string.h>
#include <errno.h>
+#include <sys/stat.h>
#include <core/GP_Context.h>
#include <loaders/GP_Loaders.h>
@@ -32,6 +33,7 @@ enum fmt {
PNG,
JPG,
GIF,
+ BMP,
};
static const char *strfmt(enum fmt fmt)
@@ -43,35 +45,66 @@ static const char *strfmt(enum fmt fmt)
return "JPG";
case GIF:
return "GIF";
+ case BMP:
+ return "BMP";
};
return "INVALID";
}
-static int load_save(enum fmt fmt, GP_Size w, GP_Size h)
+static int save_img(enum fmt fmt, const GP_Context *img, const char *name)
{
- GP_Context *img, *res = NULL;
+ char buf[256];
- img = GP_ContextAlloc(w, h, GP_PIXEL_RGB888);
-
- if (img == NULL) {
- tst_report(0, "GP_ContextAlloc failed");
- return TST_FAILED;
+ snprintf(buf, sizeof(buf), "%s.%s", name, strfmt(fmt));
+
+ tst_report(0, "Saving %s", buf);
+
+ switch (fmt) {
+ case PNG:
+ return GP_SavePNG(img, buf, NULL);
+ case JPG:
+ return GP_SaveJPG(img, buf, NULL);
+ default:
+ tst_report(0, "WARNING: trying to save %s", strfmt(fmt));
+ exit(TST_INTERR);
}
+}
+
+static GP_Context *load(enum fmt fmt, const char *name)
+{
+ char buf[256];
- int ret = 1;
+ snprintf(buf, sizeof(buf), "%s.%s", name, strfmt(fmt));
switch (fmt) {
case PNG:
- ret = GP_SavePNG(img, "test.png", NULL);
- break;
+ return GP_LoadPNG(buf, NULL);
case JPG:
- ret = GP_SaveJPG(img, "test.jpg", NULL);
- break;
+ return GP_LoadJPG(buf, NULL);
+ case GIF:
+ return GP_LoadGIF(buf, NULL);
+ case BMP:
+ return GP_LoadBMP(buf, NULL);
default:
+ tst_report(0, "WARNING: trying to load %s", strfmt(fmt));
+ exit(TST_INTERR);
+ }
+}
+
+static int save_load(enum fmt fmt, GP_Size w, GP_Size h)
+{
+ GP_Context *img, *res;
+
+ img = GP_ContextAlloc(w, h, GP_PIXEL_RGB888);
+
+ if (img == NULL) {
+ tst_report(0, "GP_ContextAlloc failed");
return TST_INTERR;
}
+ int ret = save_img(fmt, img, "test");
+
if (ret) {
if (errno == ENOSYS) {
tst_report(0, "Save %s: ENOSYS", strfmt(fmt));
@@ -83,16 +116,7 @@ static int load_save(enum fmt fmt, GP_Size w, GP_Size h)
return TST_FAILED;
}
- switch (fmt) {
- case PNG:
- res = GP_LoadPNG("test.png", NULL);
- break;
- case JPG:
- res = GP_LoadJPG("test.jpg", NULL);
- break;
- default:
- return TST_INTERR;
- }
+ res = load(fmt, "test");
if (res == NULL) {
tst_report(0, "Failed to load %s: %s",
@@ -106,41 +130,31 @@ static int load_save(enum fmt fmt, GP_Size w, GP_Size h)
return TST_SUCCESS;
}
-static int test_PNG_Load_Save(void)
+static int test_PNG_Save_Load(void)
{
- return load_save(PNG, 100, 100);
+ return save_load(PNG, 100, 100);
}
-static int test_JPG_Load_Save(void)
+static int test_JPG_Save_Load(void)
{
- return load_save(JPG, 100, 100);
+ return save_load(JPG, 100, 100);
}
static int test_PNG_stress(void)
{
- return load_save(PNG, 2000, 2000);
+ return save_load(PNG, 2000, 2000);
}
static int test_JPG_stress(void)
{
- return load_save(JPG, 2000, 2000);
+ return save_load(JPG, 2000, 2000);
}
static int load_enoent(enum fmt fmt)
{
- GP_Context *img = NULL;
-
- switch (fmt) {
- case PNG:
- img = GP_LoadPNG("nonexistent.png", NULL);
- break;
- case JPG:
- img = GP_LoadJPG("nonexistent.jpg", NULL);
- break;
- case GIF:
- img = GP_LoadGIF("nonexistent.gif", NULL);
- break;
- }
+ GP_Context *img;
+
+ img = load(fmt, "nonexistent");
if (img != NULL) {
tst_report(0, "Test succedded unexpectedly");
@@ -176,15 +190,82 @@ static int test_GIF_Load_ENOENT(void)
return load_enoent(GIF);
}
-static int abort_callback(GP_ProgressCallback *self __attribute__((unused)))
+static int test_BMP_Load_ENOENT(void)
{
- return 1;
+ return load_enoent(BMP);
+}
+
+static int load_eacces(enum fmt fmt)
+{
+ char buf[256];
+ GP_Context *img;
+
+ snprintf(buf, sizeof(buf), "test.%s", strfmt(fmt));
+
+ FILE *f = fopen(buf, "w");
+
+ if (f == NULL) {
+ tst_report(0, "Failed to create file 'test'");
+ return TST_INTERR;
+ }
+
+ fclose(f);
+
+ if (chmod(buf, 200)) {
+ tst_report(0, "chmod failed: %s", strerror(errno));
+ return TST_INTERR;
+ }
+
+ img = load(fmt, "test");
+
+ if (img != NULL) {
+ tst_report(0, "Test succedded unexpectedly");
+ return TST_FAILED;
+ }
+
+ if (errno == ENOSYS) {
+ tst_report(0, "Load %s: ENOSYS", strfmt(fmt));
+ return TST_SKIPPED;
+ }
+
+ if (errno != EACCES) {
+ tst_report(0, "Expected errno = EACCES, have %s",
+ strerror(errno));
+ return TST_FAILED;
+ }
+
+ return TST_SUCCESS;
+}
+
+static int test_PNG_Load_EACCES(void)
+{
+ return load_eacces(PNG);
+}
+
+static int test_JPG_Load_EACCES(void)
+{
+ return load_eacces(JPG);
+}
+
+static int test_GIF_Load_EACCES(void)
+{
+ return load_eacces(GIF);
+}
+
+static int test_BMP_Load_EACCES(void)
+{
+ return load_eacces(BMP);
}
/*
* We test that a correct cleanup is done after aborting the image load from a
* callback.
*/
+static int abort_callback(GP_ProgressCallback *self __attribute__((unused)))
+{
+ return 1;
+}
+
static int test_PNG_Save_abort(void)
{
GP_Context *img;
@@ -291,7 +372,7 @@ static struct file_testcase file_testcases[] = {
{"not_here.jpg", 0, ENOENT},
- //TODO: EPERM
+ //TODO: EACCES
{NULL, 0, 0}
};
@@ -328,7 +409,7 @@ static int test_Load(void)
continue;
}
- if (errno == ENOSYS) {
+ if (file_testcases[i].expected_errno != ENOSYS && errno == ENOSYS) {
tst_report(0, "Load Image '%s': ENOSYS",
file_testcases[i].filename);
continue;
@@ -360,26 +441,47 @@ static int test_Load(void)
const struct tst_suite tst_suite = {
.suite_name = "Image Loaders testsuite",
.tests = {
- {.name = "PNG Load/Save", .tst_fn = test_PNG_Load_Save,
- .flags = TST_TMPDIR | TST_CHECK_MALLOC},
- {.name = "JPG Load/Save", .tst_fn = test_JPG_Load_Save,
- .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+ /* Correct errno tests */
{.name = "PNG Load ENOENT", .tst_fn = test_PNG_Load_ENOENT,
.flags = TST_TMPDIR},
{.name = "JPG Load ENOENT", .tst_fn = test_JPG_Load_ENOENT,
.flags = TST_TMPDIR},
{.name = "GIF Load ENOENT", .tst_fn = test_GIF_Load_ENOENT,
.flags = TST_TMPDIR},
+ {.name = "BMP Load ENOENT", .tst_fn = test_BMP_Load_ENOENT,
+ .flags = TST_TMPDIR},
+
+ {.name = "PNG Load EACCES", .tst_fn = test_PNG_Load_EACCES,
+ .flags = TST_TMPDIR},
+ {.name = "JPG Load EACCES", .tst_fn = test_JPG_Load_EACCES,
+ .flags = TST_TMPDIR},
+ {.name = "GIF Load EACCES", .tst_fn = test_GIF_Load_EACCES,
+ .flags = TST_TMPDIR},
+ {.name = "BMP Load EACCES", .tst_fn = test_BMP_Load_EACCES,
+ .flags = TST_TMPDIR},
+
+ /* Generic GP_LoadImage test */
+ {.name = "Image Load", .tst_fn = test_Load,
+ .flags = TST_TMPDIR},
+
+ /* Callback abort tests */
{.name = "PNG Load abort", .tst_fn = test_PNG_Load_abort,
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
{.name = "PNG Save abort", .tst_fn = test_PNG_Save_abort,
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
- {.name = "Image Load", .tst_fn = test_Load,
- .flags = TST_TMPDIR},
- {.name = "PNG stress", .tst_fn = test_PNG_stress,
+
+ /* Basic Save Load tests */
+ {.name = "PNG Save Load", .tst_fn = test_PNG_Save_Load,
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+ {.name = "JPG Save Load", .tst_fn = test_JPG_Save_Load,
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
- {.name = "JPG stress", .tst_fn = test_JPG_stress,
+
+ /* Stress Save Load tests */
+ {.name = "PNG Stress", .tst_fn = test_PNG_stress,
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+ {.name = "JPG Stress", .tst_fn = test_JPG_stress,
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
+
{.name = NULL},
}
};
http://repo.or.cz/w/gfxprim.git/commit/94aa52632f9ade7a52a8e419b9e2d1b6309e…
commit 94aa52632f9ade7a52a8e419b9e2d1b6309e57a2
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Sep 27 12:57:42 2012 +0200
loaders: Fix typo that misidentified BMP as GIF.
diff --git a/libs/loaders/GP_Loaders.c b/libs/loaders/GP_Loaders.c
index 4e3c3d6..b142e93 100644
--- a/libs/loaders/GP_Loaders.c
+++ b/libs/loaders/GP_Loaders.c
@@ -158,7 +158,7 @@ GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
case GP_FMT_GIF:
return GP_LoadGIF(src_path, callback);
case GP_FMT_BMP:
- return GP_LoadGIF(src_path, callback);
+ return GP_LoadBMP(src_path, callback);
case GP_FMT_PBM:
return GP_LoadPBM(src_path, callback);
case GP_FMT_PGM:
http://repo.or.cz/w/gfxprim.git/commit/f8b2d14ae8aa2c8fb6f64ccae23cc8298eea…
commit f8b2d14ae8aa2c8fb6f64ccae23cc8298eea3381
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Sep 27 11:56:54 2012 +0200
tests: loaders: Skip tests on ENOSYS.
Fix the tests to return SKIPPED status when particular library is not
compiled in.
diff --git a/tests/loaders/loaders_suite.c b/tests/loaders/loaders_suite.c
index 1308737..5736829 100644
--- a/tests/loaders/loaders_suite.c
+++ b/tests/loaders/loaders_suite.c
@@ -31,6 +31,7 @@
enum fmt {
PNG,
JPG,
+ GIF,
};
static const char *strfmt(enum fmt fmt)
@@ -40,6 +41,8 @@ static const char *strfmt(enum fmt fmt)
return "PNG";
case JPG:
return "JPG";
+ case GIF:
+ return "GIF";
};
return "INVALID";
@@ -65,9 +68,16 @@ static int load_save(enum fmt fmt, GP_Size w, GP_Size h)
case JPG:
ret = GP_SaveJPG(img, "test.jpg", NULL);
break;
+ default:
+ return TST_INTERR;
}
if (ret) {
+ if (errno == ENOSYS) {
+ tst_report(0, "Save %s: ENOSYS", strfmt(fmt));
+ return TST_SKIPPED;
+ }
+
tst_report(0, "Failed to save %s: %s",
strfmt(fmt), strerror(errno));
return TST_FAILED;
@@ -80,6 +90,8 @@ static int load_save(enum fmt fmt, GP_Size w, GP_Size h)
case JPG:
res = GP_LoadJPG("test.jpg", NULL);
break;
+ default:
+ return TST_INTERR;
}
if (res == NULL) {
@@ -114,20 +126,33 @@ static int test_JPG_stress(void)
return load_save(JPG, 2000, 2000);
}
-static int test_PNG_Load_fail(void)
+static int load_enoent(enum fmt fmt)
{
- GP_Context *img;
-
- img = GP_LoadPNG("nonexistent.png", NULL);
-
- int saved_errno = errno;
+ GP_Context *img = NULL;
+ switch (fmt) {
+ case PNG:
+ img = GP_LoadPNG("nonexistent.png", NULL);
+ break;
+ case JPG:
+ img = GP_LoadJPG("nonexistent.jpg", NULL);
+ break;
+ case GIF:
+ img = GP_LoadGIF("nonexistent.gif", NULL);
+ break;
+ }
+
if (img != NULL) {
tst_report(0, "Test succedded unexpectedly");
return TST_FAILED;
}
+
+ if (errno == ENOSYS) {
+ tst_report(0, "Load %s: ENOSYS", strfmt(fmt));
+ return TST_SKIPPED;
+ }
- if (saved_errno != ENOENT) {
+ if (errno != ENOENT) {
tst_report(0, "Expected errno = ENOENT, have %s",
strerror(errno));
return TST_FAILED;
@@ -136,26 +161,19 @@ static int test_PNG_Load_fail(void)
return TST_SUCCESS;
}
-static int test_JPG_Load_fail(void)
+static int test_PNG_Load_ENOENT(void)
{
- GP_Context *img;
-
- img = GP_LoadJPG("nonexistent.png", NULL);
-
- int saved_errno = errno;
-
- if (img != NULL) {
- tst_report(0, "Test succedded unexpectedly");
- return TST_FAILED;
- }
+ return load_enoent(PNG);
+}
- if (saved_errno != ENOENT) {
- tst_report(0, "Expected errno = ENOENT, have %s",
- strerror(errno));
- return TST_FAILED;
- }
+static int test_JPG_Load_ENOENT(void)
+{
+ return load_enoent(JPG);
+}
- return TST_SUCCESS;
+static int test_GIF_Load_ENOENT(void)
+{
+ return load_enoent(GIF);
}
static int abort_callback(GP_ProgressCallback *self __attribute__((unused)))
@@ -180,11 +198,14 @@ static int test_PNG_Save_abort(void)
return TST_FAILED;
}
- int saved_errno = errno;
-
- if (saved_errno != ECANCELED) {
+ if (errno == ENOSYS) {
+ tst_report(0, "Load PNG: ENOSYS");
+ return TST_SKIPPED;
+ }
+
+ if (errno != ECANCELED) {
tst_report(0, "Expected errno = ECANCELED, have %s",
- strerror(saved_errno));
+ strerror(errno));
return TST_FAILED;
}
@@ -200,6 +221,12 @@ static int test_PNG_Load_abort(void)
img = GP_ContextAlloc(100, 100, GP_PIXEL_RGB888);
if (GP_SavePNG(img, "test.png", NULL)) {
+
+ if (errno == ENOSYS) {
+ tst_report(0, "Save PNG: ENOSYS");
+ return TST_SKIPPED;
+ }
+
tst_report(0, "Failed to save PNG: %s", strerror(errno));
return TST_FAILED;
}
@@ -271,7 +298,7 @@ static struct file_testcase file_testcases[] = {
static int test_Load(void)
{
- unsigned int i, fail = 0;
+ unsigned int i, fail = 0, success = 0;
/* Create empty files */
for (i = 0; file_testcases[i].filename != NULL; i++) {
@@ -298,9 +325,16 @@ static int test_Load(void)
tst_report(0, "GP_LoadImage('%s') succeeded "
"unexpectedly", file_testcases[i].filename);
fail++;
+ continue;
+ }
+
+ if (errno == ENOSYS) {
+ tst_report(0, "Load Image '%s': ENOSYS",
+ file_testcases[i].filename);
+ continue;
}
- if (ret == NULL && file_testcases[i].expected_errno != errno) {
+ if (file_testcases[i].expected_errno != errno) {
tst_report(0, "Expected errno %i (%s) got %i (%s) on '%s'",
file_testcases[i].expected_errno,
strerror(file_testcases[i].expected_errno),
@@ -308,13 +342,19 @@ static int test_Load(void)
strerror(saved_errno),
file_testcases[i].filename);
fail++;
+ continue;
}
+
+ success++;
}
if (fail)
return TST_FAILED;
- return TST_SUCCESS;
+ if (success)
+ return TST_SUCCESS;
+
+ return TST_SKIPPED;
}
const struct tst_suite tst_suite = {
@@ -324,9 +364,11 @@ const struct tst_suite tst_suite = {
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
{.name = "JPG Load/Save", .tst_fn = test_JPG_Load_Save,
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
- {.name = "PNG Load fail", .tst_fn = test_PNG_Load_fail,
+ {.name = "PNG Load ENOENT", .tst_fn = test_PNG_Load_ENOENT,
+ .flags = TST_TMPDIR},
+ {.name = "JPG Load ENOENT", .tst_fn = test_JPG_Load_ENOENT,
.flags = TST_TMPDIR},
- {.name = "JPG Load fail", .tst_fn = test_JPG_Load_fail,
+ {.name = "GIF Load ENOENT", .tst_fn = test_GIF_Load_ENOENT,
.flags = TST_TMPDIR},
{.name = "PNG Load abort", .tst_fn = test_PNG_Load_abort,
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
http://repo.or.cz/w/gfxprim.git/commit/e4a59032ce9295e40e84c5003d5e813553b5…
commit e4a59032ce9295e40e84c5003d5e813553b52f2e
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Sep 27 11:55:39 2012 +0200
loaders: jpg: Fix ENOSYS stubs.
diff --git a/libs/loaders/GP_JPG.c b/libs/loaders/GP_JPG.c
index fbf57c6..bece7d5 100644
--- a/libs/loaders/GP_JPG.c
+++ b/libs/loaders/GP_JPG.c
@@ -418,14 +418,14 @@ GP_Context *GP_LoadJPG(const char GP_UNUSED(*src_path),
int GP_ReadJPGMetaData(FILE GP_UNUSED(*f), GP_MetaData GP_UNUSED(*data))
{
errno = ENOSYS;
- return NULL;
+ return 1;
}
int GP_LoadJPGMetaData(const char GP_UNUSED(*src_path),
GP_MetaData GP_UNUSED(*data))
{
errno = ENOSYS;
- return NULL;
+ return 1;
}
int GP_SaveJPG(const GP_Context GP_UNUSED(*src),
http://repo.or.cz/w/gfxprim.git/commit/c643ecb4b3d832e7b3afeff095c3f453ee3d…
commit c643ecb4b3d832e7b3afeff095c3f453ee3d573f
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Sep 27 11:35:58 2012 +0200
tests: framework: Introduce SKIPPED test result.
The SKIPPED test result is intended for situations
where current configuration doesn't allow the test
to run (i.e. ENOSYS from libcall, not enough RAM, etc.).
diff --git a/tests/framework/test.c b/tests/framework/test.c
index 914f2d2..0e9e9df 100644
--- a/tests/framework/test.c
+++ b/tests/framework/test.c
@@ -186,10 +186,16 @@ int fail_FILE(void)
return TST_SUCCESS;
}
+static int skipped_fn(void)
+{
+ return TST_SKIPPED;
+}
+
const struct tst_suite tst_suite = {
.suite_name = "Testing Framework Example",
.tests = {
{.name = "Success test", .tst_fn = success_fn},
+ {.name = "Skipped test", .tst_fn = skipped_fn},
{.name = "Sigsegv test", .tst_fn = sigsegv_fn},
{.name = "Failed test", .tst_fn = failed_fn},
{.name = "Stack overflow test", .tst_fn = stack_overflow_fn},
diff --git a/tests/framework/tst_job.c b/tests/framework/tst_job.c
index 652b038..f483578 100644
--- a/tests/framework/tst_job.c
+++ b/tests/framework/tst_job.c
@@ -72,6 +72,9 @@ static void stop_test(struct tst_job *job)
case TST_SUCCESS:
result = "[ e[1;32mSUCCESSe[0m ]";
break;
+ case TST_SKIPPED:
+ result = "[ e[1;30mSKIPPEDe[0m ]";
+ break;
case TST_INTERR:
result = "[ e[1;31mINTERNAL ERRORe[0m ]";
break;
diff --git a/tests/framework/tst_log.c b/tests/framework/tst_log.c
index 6535ae8..7c6a82c 100644
--- a/tests/framework/tst_log.c
+++ b/tests/framework/tst_log.c
@@ -34,6 +34,8 @@ static const char *ret_to_bg_color(enum tst_ret ret)
switch (ret) {
case TST_SUCCESS:
return "#008000";
+ case TST_SKIPPED:
+ return "#888888";
case TST_INTERR:
return "#800000";
case TST_SIGSEGV:
@@ -58,6 +60,8 @@ static const char *ret_to_str(enum tst_ret ret)
switch (ret) {
case TST_SUCCESS:
return "Success";
+ case TST_SKIPPED:
+ return "Skipped";
case TST_INTERR:
return "Internal Error";
case TST_SIGSEGV:
diff --git a/tests/framework/tst_test.h b/tests/framework/tst_test.h
index 27eaff5..4eb97e0 100644
--- a/tests/framework/tst_test.h
+++ b/tests/framework/tst_test.h
@@ -24,13 +24,14 @@
#define TST_TEST_H
enum tst_ret {
- TST_SUCCESS, /* Test succedded */
- TST_INTERR, /* Test framework error */
- TST_SIGSEGV, /* Test ended with SIGSEGV */
- TST_TIMEOUT, /* Test hasn't finished in time */
- TST_ABORTED, /* The abort() was called (possible double free) */
- TST_MEMLEAK, /* Memory leak was detected */
- TST_FAILED, /* Test failed */
+ TST_SUCCESS, /* Test succedded */
+ TST_SKIPPED, /* Test skipped due to not enough memory, ENOSYS ... */
+ TST_INTERR, /* Test framework error */
+ TST_SIGSEGV, /* Test ended with SIGSEGV */
+ TST_TIMEOUT, /* Test hasn't finished in time */
+ TST_ABORTED, /* The abort() was called (possible double free) */
+ TST_MEMLEAK, /* Memory leak was detected */
+ TST_FAILED, /* Test failed */
TST_MAX = TST_FAILED+1,
};
http://repo.or.cz/w/gfxprim.git/commit/b3b68550f6431afd3dd5a441e38212d09b22…
commit b3b68550f6431afd3dd5a441e38212d09b22bdda
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Sep 27 11:27:14 2012 +0200
loaders: png: Fix ENOSYS stubs.
diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c
index 73b129a..7cf7441 100644
--- a/libs/loaders/GP_PNG.c
+++ b/libs/loaders/GP_PNG.c
@@ -570,13 +570,13 @@ GP_Context *GP_LoadPNG(const char GP_UNUSED(*src_path),
int GP_ReadPNGMetaData(FILE GP_UNUSED(*f), GP_MetaData GP_UNUSED(*data))
{
errno = ENOSYS;
- return NULL;
+ return 1;
}
int GP_LoadPNGMetaData(const char GP_UNUSED(*src_path), GP_MetaData GP_UNUSED(*data))
{
errno = ENOSYS;
- return NULL;
+ return 1;
}
int GP_SavePNG(const GP_Context GP_UNUSED(*src),
http://repo.or.cz/w/gfxprim.git/commit/3095a596cffe0dca94e5a773828af6fc0365…
commit 3095a596cffe0dca94e5a773828af6fc0365f9d4
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Thu Sep 27 11:24:43 2012 +0200
tests: loaders: Simplify tests code.
diff --git a/tests/loaders/loaders_suite.c b/tests/loaders/loaders_suite.c
index 918b139..1308737 100644
--- a/tests/loaders/loaders_suite.c
+++ b/tests/loaders/loaders_suite.c
@@ -28,45 +28,63 @@
#include "tst_test.h"
-static int test_PNG_Load_Save(void)
+enum fmt {
+ PNG,
+ JPG,
+};
+
+static const char *strfmt(enum fmt fmt)
{
- GP_Context *img, *res;
+ switch (fmt) {
+ case PNG:
+ return "PNG";
+ case JPG:
+ return "JPG";
+ };
+
+ return "INVALID";
+}
- img = GP_ContextAlloc(100, 100, GP_PIXEL_RGB888);
+static int load_save(enum fmt fmt, GP_Size w, GP_Size h)
+{
+ GP_Context *img, *res = NULL;
- if (GP_SavePNG(img, "test.png", NULL)) {
- tst_report(0, "Failed to save PNG: %s", strerror(errno));
+ img = GP_ContextAlloc(w, h, GP_PIXEL_RGB888);
+
+ if (img == NULL) {
+ tst_report(0, "GP_ContextAlloc failed");
return TST_FAILED;
}
- res = GP_LoadPNG("test.png", NULL);
+ int ret = 1;
- if (res == NULL) {
- tst_report(0, "Failed to load PNG: %s", strerror(errno));
- return TST_FAILED;
+ switch (fmt) {
+ case PNG:
+ ret = GP_SavePNG(img, "test.png", NULL);
+ break;
+ case JPG:
+ ret = GP_SaveJPG(img, "test.jpg", NULL);
+ break;
}
- GP_ContextFree(img);
- GP_ContextFree(res);
-
- return TST_SUCCESS;
-}
-
-static int test_JPG_Load_Save(void)
-{
- GP_Context *img, *res;
-
- img = GP_ContextAlloc(100, 100, GP_PIXEL_RGB888);
-
- if (GP_SaveJPG(img, "test.jpg", NULL)) {
- tst_report(0, "Failed to save JPG: %s", strerror(errno));
+ if (ret) {
+ tst_report(0, "Failed to save %s: %s",
+ strfmt(fmt), strerror(errno));
return TST_FAILED;
}
- res = GP_LoadJPG("test.jpg", NULL);
+ switch (fmt) {
+ case PNG:
+ res = GP_LoadPNG("test.png", NULL);
+ break;
+ case JPG:
+ res = GP_LoadJPG("test.jpg", NULL);
+ break;
+ }
if (res == NULL) {
- tst_report(0, "Failed to load JPG: %s", strerror(errno));
+ tst_report(0, "Failed to load %s: %s",
+ strfmt(fmt), strerror(errno));
return TST_FAILED;
}
@@ -76,6 +94,26 @@ static int test_JPG_Load_Save(void)
return TST_SUCCESS;
}
+static int test_PNG_Load_Save(void)
+{
+ return load_save(PNG, 100, 100);
+}
+
+static int test_JPG_Load_Save(void)
+{
+ return load_save(JPG, 100, 100);
+}
+
+static int test_PNG_stress(void)
+{
+ return load_save(PNG, 2000, 2000);
+}
+
+static int test_JPG_stress(void)
+{
+ return load_save(JPG, 2000, 2000);
+}
+
static int test_PNG_Load_fail(void)
{
GP_Context *img;
@@ -188,38 +226,6 @@ static int test_PNG_Load_abort(void)
return TST_SUCCESS;
}
-/*
- * PNG stress test, let it save and load 10MB image.
- */
-static int test_PNG_stress(void)
-{
- GP_Context *img;
-
- img = GP_ContextAlloc(2000, 2000, GP_PIXEL_RGB888);
-
- if (img == NULL) {
- tst_report(0, "GP_ContextAlloc failed");
- return TST_FAILED;
- }
-
- if (GP_SavePNG(img, "test.png", NULL)) {
- tst_report(0, "GP_SavePNG failed with: %s", strerror(errno));
- return TST_FAILED;
- }
-
- GP_ContextFree(img);
-
- img = GP_LoadPNG("test.png", NULL);
-
- if (img == NULL) {
- tst_report(0, "GP_LoadPNG failed with: %s", strerror(errno));
- return TST_FAILED;
- }
-
- GP_ContextFree(img);
-
- return TST_SUCCESS;
-}
/*
* Loaders test. Hammers the GP_LoadImage() interface with plenty of
@@ -242,6 +248,7 @@ static struct file_testcase file_testcases[] = {
{"jpg.", 1, ENOSYS},
{"gif.", 1, ENOSYS},
{"jpeg.", 1, ENOSYS},
+ {"bmp.", 1, ENOSYS},
{".jpg", 1, EIO},
{"img.jpg", 1, EIO},
@@ -249,12 +256,16 @@ static struct file_testcase file_testcases[] = {
{"img.png", 1, EIO},
{".gif", 1, EIO},
{"img.gif", 1, EIO},
+ {".bmp", 1, EIO},
+ {"img.bmp", 1, EIO},
{".pbm", 1, EIO},
{".pgm", 1, EIO},
{".ppm", 1, EIO},
{"not_here.jpg", 0, ENOENT},
+ //TODO: EPERM
+
{NULL, 0, 0}
};
@@ -321,10 +332,12 @@ const struct tst_suite tst_suite = {
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
{.name = "PNG Save abort", .tst_fn = test_PNG_Save_abort,
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
- {.name = "PNG stress", .tst_fn = test_PNG_stress,
- .flags = TST_TMPDIR | TST_CHECK_MALLOC},
{.name = "Image Load", .tst_fn = test_Load,
.flags = TST_TMPDIR},
+ {.name = "PNG stress", .tst_fn = test_PNG_stress,
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
+ {.name = "JPG stress", .tst_fn = test_JPG_stress,
+ .flags = TST_TMPDIR | TST_CHECK_MALLOC},
{.name = NULL},
}
};
-----------------------------------------------------------------------
Summary of changes:
doc/loaders.txt | 48 +++---
libs/loaders/GP_BMP.c | 2 +-
libs/loaders/GP_GIF.c | 14 ++-
libs/loaders/GP_JPG.c | 4 +-
libs/loaders/GP_Loaders.c | 2 +-
libs/loaders/GP_PNG.c | 4 +-
tests/framework/test.c | 6 +
tests/framework/tst_job.c | 3 +
tests/framework/tst_log.c | 19 ++-
tests/framework/tst_test.h | 15 +-
tests/loaders/loaders_suite.c | 379 ++++++++++++++++++++++++++++++++---------
11 files changed, 374 insertions(+), 122 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: f7abc056071b6987bd8ddf3b3e21b76fb2faa593
by metan 14 Sep '12
by metan 14 Sep '12
14 Sep '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via f7abc056071b6987bd8ddf3b3e21b76fb2faa593 (commit)
via f8f4f70933e49090c3910415315730aaf23cfa71 (commit)
via e09dcfd1600590e8bc57039293fbf39eba0d6fd2 (commit)
from 5e9ae922f961ce558878ad261b34db3dd7a99b6d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/f7abc056071b6987bd8ddf3b3e21b76fb2fa…
commit f7abc056071b6987bd8ddf3b3e21b76fb2faa593
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Sep 14 17:20:48 2012 +0200
loaders: Small fixes in errno handling code.
diff --git a/libs/loaders/GP_PBM.c b/libs/loaders/GP_PBM.c
index ac7dc30..2c11138 100644
--- a/libs/loaders/GP_PBM.c
+++ b/libs/loaders/GP_PBM.c
@@ -54,28 +54,34 @@ GP_Context *GP_LoadPBM(const char *src_path, GP_ProgressCallback *callback)
FILE *f;
GP_Context *ret;
uint32_t w, h;
+ int err;
f = fopen(src_path, "r");
if (f == NULL)
return NULL;
- if (fgetc(f) != 'P' || fgetc(f) != '1')
+ if (fgetc(f) != 'P' || fgetc(f) != '1') {
+ err = feof(f) ? EIO : EINVAL;
goto err1;
+ }
- if (fscanf(f, "%"PRIu32"%"PRIu32, &w, &h) < 2)
+ if (fscanf(f, "%"PRIu32"%"PRIu32, &w, &h) < 2) {
+ err = EIO;
goto err1;
+ }
ret = GP_ContextAlloc(w, h, GP_PIXEL_G1);
if (ret == NULL) {
- fclose(f);
- errno = ENOMEM;
- return NULL;
+ err = ENOMEM;
+ goto err1;
}
- if (GP_PXMLoad1bpp(f, ret))
+ if (GP_PXMLoad1bpp(f, ret)) {
+ err = EINVAL;
goto err2;
+ }
fclose(f);
return ret;
@@ -83,6 +89,7 @@ err2:
free(ret);
err1:
fclose(f);
+ errno = err;
return NULL;
}
diff --git a/libs/loaders/GP_PGM.c b/libs/loaders/GP_PGM.c
index 9ae8c64..055df97 100644
--- a/libs/loaders/GP_PGM.c
+++ b/libs/loaders/GP_PGM.c
@@ -92,6 +92,11 @@ GP_Context *GP_LoadPGM(const char *src_path, GP_ProgressCallback *callback)
h1 = fgetc(f);
h2 = fgetc(f);
+ if (feof(f)) {
+ err = EIO;
+ goto err1;
+ }
+
if (h1 != 'P' || h2 != '2') {
GP_DEBUG(1, "Invalid PGM header '%c%c' (0x%2x 0x%2x)",
isprint(h1) ? h1 : ' ', isprint(h2) ? h2 : ' ',
diff --git a/libs/loaders/GP_PNG.c b/libs/loaders/GP_PNG.c
index 2d099fd..73b129a 100644
--- a/libs/loaders/GP_PNG.c
+++ b/libs/loaders/GP_PNG.c
@@ -58,7 +58,7 @@ int GP_OpenPNG(const char *src_path, FILE **f)
}
if (fread(sig, 1, 8, *f) <= 0) {
- err = errno;
+ err = EIO;
GP_DEBUG(1, "Failed to read '%s' : %s",
src_path, strerror(errno));
goto err2;
@@ -67,7 +67,7 @@ int GP_OpenPNG(const char *src_path, FILE **f)
if (png_sig_cmp(sig, 0, 8)) {
GP_DEBUG(1, "Invalid file header, '%s' not a PNG image?",
src_path);
- err = EILSEQ;
+ err = EINVAL;
goto err2;
}
diff --git a/libs/loaders/GP_PNM.c b/libs/loaders/GP_PNM.c
index 261b75f..6e7946e 100644
--- a/libs/loaders/GP_PNM.c
+++ b/libs/loaders/GP_PNM.c
@@ -88,7 +88,7 @@ FILE *GP_ReadPNM(const char *src_path, char *fmt,
uint32_t *w, uint32_t *h, uint32_t *depth)
{
FILE *f = fopen(src_path, "r");
- int ch;
+ int ch, err;
if (f == NULL) {
GP_DEBUG(1, "Failed to open file '%s': %s",
@@ -98,9 +98,15 @@ FILE *GP_ReadPNM(const char *src_path, char *fmt,
ch = fgetc(f);
+ if (ch == EOF) {
+ err = EIO;
+ goto err1;
+ }
+
if (ch != 'P') {
GP_DEBUG(1, "Invalid PNM header start '%c' (0x%2x) expecting 'P'",
isprint(ch) ? ch : ' ', ch);
+ err = EINVAL;
goto err1;
}
@@ -119,6 +125,7 @@ FILE *GP_ReadPNM(const char *src_path, char *fmt,
default:
GP_DEBUG(1, "Invalid PNM format 'P%c' (0x%2x)",
isprint(ch) ? ch : ' ', ch);
+ err = EINVAL;
goto err1;
}
@@ -128,6 +135,7 @@ FILE *GP_ReadPNM(const char *src_path, char *fmt,
if (fscanf(f, "%"PRIu32"n", w) < 1) {
GP_DEBUG(1, "Failed to read PNM header width");
+ err = EINVAL;
goto err1;
}
@@ -135,6 +143,7 @@ FILE *GP_ReadPNM(const char *src_path, char *fmt,
if (fscanf(f, "%"PRIu32"n", h) < 1) {
GP_DEBUG(1, "Failed to read PNM header height");
+ err = EINVAL;
goto err1;
}
@@ -148,12 +157,14 @@ FILE *GP_ReadPNM(const char *src_path, char *fmt,
if (fscanf(f, "%"PRIu32"n", depth) < 1) {
GP_DEBUG(1, "Failed to read PNM header depth");
+ err = EINVAL;
goto err1;
}
return f;
err1:
fclose(f);
+ errno = err;
return NULL;
}
http://repo.or.cz/w/gfxprim.git/commit/f8f4f70933e49090c3910415315730aaf23c…
commit f8f4f70933e49090c3910415315730aaf23cfa71
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Sep 14 17:15:54 2012 +0200
tests: Add common image loader tests.
diff --git a/tests/loaders/loaders_suite.c b/tests/loaders/loaders_suite.c
index cb7f398..918b139 100644
--- a/tests/loaders/loaders_suite.c
+++ b/tests/loaders/loaders_suite.c
@@ -221,6 +221,91 @@ static int test_PNG_stress(void)
return TST_SUCCESS;
}
+/*
+ * Loaders test. Hammers the GP_LoadImage() interface with plenty of
+ * unexpected filenames.
+ */
+struct file_testcase {
+ const char *filename;
+ int create;
+ int expected_errno;
+};
+
+static struct file_testcase file_testcases[] = {
+ {"a", 1, ENOSYS},
+ {".a", 1, ENOSYS},
+ {"a.", 1, ENOSYS},
+ {".bc", 1, ENOSYS},
+ {"bc", 1, ENOSYS},
+ {"abc", 1, ENOSYS},
+ {"png.", 1, ENOSYS},
+ {"jpg.", 1, ENOSYS},
+ {"gif.", 1, ENOSYS},
+ {"jpeg.", 1, ENOSYS},
+
+ {".jpg", 1, EIO},
+ {"img.jpg", 1, EIO},
+ {".png", 1, EIO},
+ {"img.png", 1, EIO},
+ {".gif", 1, EIO},
+ {"img.gif", 1, EIO},
+ {".pbm", 1, EIO},
+ {".pgm", 1, EIO},
+ {".ppm", 1, EIO},
+
+ {"not_here.jpg", 0, ENOENT},
+
+ {NULL, 0, 0}
+};
+
+static int test_Load(void)
+{
+ unsigned int i, fail = 0;
+
+ /* Create empty files */
+ for (i = 0; file_testcases[i].filename != NULL; i++) {
+
+ if (file_testcases[i].create != 1)
+ continue;
+
+ FILE *f = fopen(file_testcases[i].filename, "w");
+
+ if (f != NULL)
+ fclose(f);
+ }
+
+ for (i = 0; file_testcases[i].filename != NULL; i++) {
+ GP_Context *ret;
+
+ errno = 0;
+
+ ret = GP_LoadImage(file_testcases[i].filename, NULL);
+
+ int saved_errno = errno;
+
+ if (ret != NULL) {
+ tst_report(0, "GP_LoadImage('%s') succeeded "
+ "unexpectedly", file_testcases[i].filename);
+ fail++;
+ }
+
+ if (ret == NULL && file_testcases[i].expected_errno != errno) {
+ tst_report(0, "Expected errno %i (%s) got %i (%s) on '%s'",
+ file_testcases[i].expected_errno,
+ strerror(file_testcases[i].expected_errno),
+ saved_errno,
+ strerror(saved_errno),
+ file_testcases[i].filename);
+ fail++;
+ }
+ }
+
+ if (fail)
+ return TST_FAILED;
+
+ return TST_SUCCESS;
+}
+
const struct tst_suite tst_suite = {
.suite_name = "Image Loaders testsuite",
.tests = {
@@ -238,6 +323,8 @@ const struct tst_suite tst_suite = {
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
{.name = "PNG stress", .tst_fn = test_PNG_stress,
.flags = TST_TMPDIR | TST_CHECK_MALLOC},
+ {.name = "Image Load", .tst_fn = test_Load,
+ .flags = TST_TMPDIR},
{.name = NULL},
}
};
http://repo.or.cz/w/gfxprim.git/commit/e09dcfd1600590e8bc57039293fbf39eba0d…
commit e09dcfd1600590e8bc57039293fbf39eba0d6fd2
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Fri Sep 14 16:42:54 2012 +0200
loaders: Simplify the image format detection code.
diff --git a/libs/loaders/GP_Loaders.c b/libs/loaders/GP_Loaders.c
index 5700aa4..4e3c3d6 100644
--- a/libs/loaders/GP_Loaders.c
+++ b/libs/loaders/GP_Loaders.c
@@ -34,108 +34,141 @@
#include "GP_Loaders.h"
-GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
+enum GP_ImageFmt {
+ GP_FMT_UNKNOWN,
+ GP_FMT_PNG,
+ GP_FMT_JPG,
+ GP_FMT_BMP,
+ GP_FMT_GIF,
+ GP_FMT_PBM,
+ GP_FMT_PGM,
+ GP_FMT_PPM,
+};
+
+enum GP_ImageFmt filename_to_fmt(const char *path)
{
- int len, saved_errno;
-
- if (access(src_path, R_OK)) {
-
- saved_errno = errno;
-
- GP_DEBUG(1, "Failed to access file '%s' : %s",
- src_path, strerror(errno));
-
- errno = saved_errno;
-
- return NULL;
- }
-
- len = strlen(src_path);
+ size_t len = strlen(path);
if (len < 3)
- goto skip_filename_check;
+ return GP_FMT_UNKNOWN;
- switch (src_path[len - 1]) {
+ switch (path[len - 1]) {
/* PNG, JPG, JPEG */
case 'g':
case 'G':
- switch (src_path[len - 2]) {
+ switch (path[len - 2]) {
case 'n':
case 'N':
- if (src_path[len - 3] == 'p' ||
- src_path[len - 3] == 'P')
- return GP_LoadPNG(src_path, callback);
+ if (path[len - 3] == 'p' ||
+ path[len - 3] == 'P')
+ return GP_FMT_PNG;
break;
case 'p':
case 'P':
- if (src_path[len - 3] == 'j' ||
- src_path[len - 3] == 'J')
- return GP_LoadJPG(src_path, callback);
+ if (path[len - 3] == 'j' ||
+ path[len - 3] == 'J')
+ return GP_FMT_JPG;
break;
case 'e':
case 'E':
- if ((src_path[len - 3] == 'p' ||
- src_path[len - 3] == 'P') &&
- (src_path[len - 4] == 'j' ||
- src_path[len - 4] == 'J'))
- return GP_LoadJPG(src_path, callback);
+ if ((path[len - 3] == 'p' ||
+ path[len - 3] == 'P') &&
+ (path[len - 4] == 'j' ||
+ path[len - 4] == 'J'))
+ return GP_FMT_JPG;
break;
}
break;
/* PPM, PGM, PBM, PNM */
case 'm':
case 'M':
- switch (src_path[len - 2]) {
+ switch (path[len - 2]) {
case 'b':
case 'B':
- if (src_path[len - 3] == 'p' ||
- src_path[len - 3] == 'P') {
- return GP_LoadPBM(src_path, callback);
- }
+ if (path[len - 3] == 'p' ||
+ path[len - 3] == 'P')
+ return GP_FMT_PBM;
break;
case 'g':
case 'G':
- if (src_path[len - 3] == 'p' ||
- src_path[len - 3] == 'P') {
- return GP_LoadPGM(src_path, callback);
- }
+ if (path[len - 3] == 'p' ||
+ path[len - 3] == 'P')
+ return GP_FMT_PGM;
break;
case 'p':
case 'P':
- if (src_path[len - 3] == 'p' ||
- src_path[len - 3] == 'P') {
- return GP_LoadPPM(src_path, callback);
- }
+ if (path[len - 3] == 'p' ||
+ path[len - 3] == 'P')
+ return GP_FMT_PPM;
break;
}
break;
/* BMP */
case 'P':
case 'p':
- switch (src_path[len - 2]) {
+ switch (path[len - 2]) {
case 'M':
case 'm':
- if (src_path[len - 3] == 'B' ||
- src_path[len - 3] == 'b')
- return GP_LoadBMP(src_path, callback);
+ if (path[len - 3] == 'B' ||
+ path[len - 3] == 'b')
+ return GP_FMT_BMP;
break;
}
break;
/* GIF */
case 'F':
case 'f':
- switch (src_path[len - 2]) {
+ switch (path[len - 2]) {
case 'I':
case 'i':
- if (src_path[len - 3] == 'G' ||
- src_path[len - 3] == 'g')
- return GP_LoadGIF(src_path, callback);
+ if (path[len - 3] == 'G' ||
+ path[len - 3] == 'g')
+ return GP_FMT_GIF;
break;
}
break;
}
-skip_filename_check:
+ return GP_FMT_UNKNOWN;
+}
+
+GP_Context *GP_LoadImage(const char *src_path, GP_ProgressCallback *callback)
+{
+ int saved_errno;
+
+ if (access(src_path, R_OK)) {
+
+ saved_errno = errno;
+
+ GP_DEBUG(1, "Failed to access file '%s' : %s",
+ src_path, strerror(errno));
+
+ errno = saved_errno;
+
+ return NULL;
+ }
+
+ enum GP_ImageFmt fmt = filename_to_fmt(src_path);
+
+ switch (fmt) {
+ case GP_FMT_JPG:
+ return GP_LoadJPG(src_path, callback);
+ case GP_FMT_PNG:
+ return GP_LoadPNG(src_path, callback);
+ case GP_FMT_GIF:
+ return GP_LoadGIF(src_path, callback);
+ case GP_FMT_BMP:
+ return GP_LoadGIF(src_path, callback);
+ case GP_FMT_PBM:
+ return GP_LoadPBM(src_path, callback);
+ case GP_FMT_PGM:
+ return GP_LoadPGM(src_path, callback);
+ case GP_FMT_PPM:
+ return GP_LoadPPM(src_path, callback);
+
+ case GP_FMT_UNKNOWN:
+ break;
+ }
//TODO file signature based check
errno = ENOSYS;
@@ -144,41 +177,29 @@ skip_filename_check:
int GP_LoadMetaData(const char *src_path, GP_MetaData *data)
{
- int len;
+ int saved_errno;
- len = strlen(src_path);
+ if (access(src_path, R_OK)) {
+
+ saved_errno = errno;
- if (len < 3) {
- errno = ENOSYS;
+ GP_DEBUG(1, "Failed to access file '%s' : %s",
+ src_path, strerror(errno));
+
+ errno = saved_errno;
+
return 1;
}
- switch (src_path[len - 1]) {
- /* PNG, JPG, JPEG */
- case 'g':
- case 'G':
- switch (src_path[len - 2]) {
- case 'n':
- case 'N':
- if (src_path[len - 3] == 'p' ||
- src_path[len - 3] == 'P')
- return GP_LoadPNGMetaData(src_path, data);
- break;
- case 'p':
- case 'P':
- if (src_path[len - 3] == 'j' ||
- src_path[len - 3] == 'J')
- return GP_LoadJPGMetaData(src_path, data);
- break;
- case 'e':
- case 'E':
- if ((src_path[len - 3] == 'p' ||
- src_path[len - 3] == 'P') &&
- (src_path[len - 4] == 'j' ||
- src_path[len - 4] == 'J'))
- return GP_LoadJPGMetaData(src_path, data);
- break;
- }
+ enum GP_ImageFmt fmt = filename_to_fmt(src_path);
+
+ switch (fmt) {
+ case GP_FMT_JPG:
+ return GP_LoadJPGMetaData(src_path, data);
+ case GP_FMT_PNG:
+ return GP_LoadPNGMetaData(src_path, data);
+
+ default:
break;
}
@@ -189,41 +210,15 @@ int GP_LoadMetaData(const char *src_path, GP_MetaData *data)
int GP_SaveImage(const GP_Context *src, const char *dst_path,
GP_ProgressCallback *callback)
{
- int len;
-
- len = strlen(dst_path);
+ enum GP_ImageFmt fmt = filename_to_fmt(dst_path);
- if (len < 3) {
- errno = ENOSYS;
- return 1;
- }
+ switch (fmt) {
+ case GP_FMT_JPG:
+ return GP_SaveJPG(src, dst_path, callback);
+ case GP_FMT_PNG:
+ return GP_SavePNG(src, dst_path, callback);
- switch (dst_path[len - 1]) {
- /* PNG, JPG, JPEG */
- case 'g':
- case 'G':
- switch (dst_path[len - 2]) {
- case 'n':
- case 'N':
- if (dst_path[len - 3] == 'p' ||
- dst_path[len - 3] == 'P')
- return GP_SavePNG(src, dst_path, callback);
- break;
- case 'p':
- case 'P':
- if (dst_path[len - 3] == 'j' ||
- dst_path[len - 3] == 'J')
- return GP_SaveJPG(src, dst_path, callback);
- break;
- case 'e':
- case 'E':
- if ((dst_path[len - 3] == 'p' ||
- dst_path[len - 3] == 'P') &&
- (dst_path[len - 4] == 'j' ||
- dst_path[len - 4] == 'J'))
- return GP_SaveJPG(src, dst_path, callback);
- break;
- }
+ default:
break;
}
-----------------------------------------------------------------------
Summary of changes:
libs/loaders/GP_Loaders.c | 225 ++++++++++++++++++++---------------------
libs/loaders/GP_PBM.c | 19 +++-
libs/loaders/GP_PGM.c | 5 +
libs/loaders/GP_PNG.c | 4 +-
libs/loaders/GP_PNM.c | 13 ++-
tests/loaders/loaders_suite.c | 87 ++++++++++++++++
6 files changed, 229 insertions(+), 124 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 5e9ae922f961ce558878ad261b34db3dd7a99b6d
by metan 14 Sep '12
by metan 14 Sep '12
14 Sep '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via 5e9ae922f961ce558878ad261b34db3dd7a99b6d (commit)
from ed37d412a80d1a2032cc49f00a4e505ac297f7cc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/5e9ae922f961ce558878ad261b34db3dd7a9…
commit 5e9ae922f961ce558878ad261b34db3dd7a99b6d
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Sep 9 10:56:49 2012 +0200
libs: Several small fixes.
Notable Changes:
* Change GP_DEBUG(0, ...) to GP_WARN(...)
* Fix unmapped X11 key 'grave'
* Whitespace fixes
diff --git a/include/filters/GP_Blur.h b/include/filters/GP_Blur.h
index fb0ac26..c008774 100644
--- a/include/filters/GP_Blur.h
+++ b/include/filters/GP_Blur.h
@@ -42,15 +42,15 @@ int GP_FilterGaussianBlurEx(const GP_Context *src,
GP_Coord x_src, GP_Coord y_src,
GP_Size w_src, GP_Size h_src,
GP_Context *dst,
- GP_Coord x_dst, GP_Coord y_dst,
- float x_sigma, float y_sigma,
- GP_ProgressCallback *callback);
+ GP_Coord x_dst, GP_Coord y_dst,
+ float x_sigma, float y_sigma,
+ GP_ProgressCallback *callback);
GP_Context *GP_FilterGaussianBlurExAlloc(const GP_Context *src,
GP_Coord x_src, GP_Coord y_src,
GP_Size w_src, GP_Size h_src,
- float x_sigma, float y_sigma,
- GP_ProgressCallback *callback);
+ float x_sigma, float y_sigma,
+ GP_ProgressCallback *callback);
static inline int GP_FilterGaussianBlur(const GP_Context *src, GP_Context *dst,
float x_sigma, float y_sigma,
diff --git a/include/filters/GP_Convolution.h b/include/filters/GP_Convolution.h
index 858ead6..8c158ff 100644
--- a/include/filters/GP_Convolution.h
+++ b/include/filters/GP_Convolution.h
@@ -100,8 +100,8 @@ static inline int GP_FilterConvolution(const GP_Context *src, GP_Context *dst,
}
static inline GP_Context *GP_FilterConvolutionAlloc(const GP_Context *src,
- const GP_FilterKernel2D *kernel,
- GP_ProgressCallback *callback)
+ const GP_FilterKernel2D *kernel,
+ GP_ProgressCallback *callback)
{
return GP_FilterConvolutionExAlloc(src, 0, 0, src->w, src->h,
kernel, callback);
diff --git a/include/filters/GP_Dither.h b/include/filters/GP_Dither.h
index 55a950c..2c4d321 100644
--- a/include/filters/GP_Dither.h
+++ b/include/filters/GP_Dither.h
@@ -53,8 +53,8 @@
* Semi internal raw version, use at your own risk.
*/
int GP_FilterFloydSteinberg_RGB888_Raw(const GP_Context *src,
- GP_Context *dst,
- GP_ProgressCallback *callback);
+ GP_Context *dst,
+ GP_ProgressCallback *callback);
/*
* Converts RGB888 24bit image to any RGB or Grayscale bitmap.
@@ -75,7 +75,7 @@ int GP_FilterFloydSteinberg_RGB888(const GP_Context *src,
*/
GP_Context *GP_FilterFloydSteinberg_RGB888_Alloc(const GP_Context *src,
GP_PixelType pixel_type,
- GP_ProgressCallback *callback);
+ GP_ProgressCallback *callback);
/*
* Hilbert-Peano space filling curve based dithering.
diff --git a/include/filters/GP_GaussianNoise.h b/include/filters/GP_GaussianNoise.h
index 59d9d35..9e9274e 100644
--- a/include/filters/GP_GaussianNoise.h
+++ b/include/filters/GP_GaussianNoise.h
@@ -40,7 +40,7 @@ int GP_FilterGaussianNoiseAddEx(const GP_Context *src,
GP_Size w_src, GP_Size h_src,
GP_Context *dst,
GP_Coord x_dst, GP_Coord y_dst,
- float sigma, float mu,
+ float sigma, float mu,
GP_ProgressCallback *callback);
GP_Context *GP_FilterGaussianNoiseAddExAlloc(const GP_Context *src,
diff --git a/include/filters/GP_Median.h b/include/filters/GP_Median.h
index 0547793..4a479cf 100644
--- a/include/filters/GP_Median.h
+++ b/include/filters/GP_Median.h
@@ -41,7 +41,7 @@ int GP_FilterMedianEx(const GP_Context *src,
GP_Size w_src, GP_Size h_src,
GP_Context *dst,
GP_Coord x_dst, GP_Coord y_dst,
- int xmed, int ymed,
+ int xmed, int ymed,
GP_ProgressCallback *callback);
GP_Context *GP_FilterMedianExAlloc(const GP_Context *src,
@@ -52,7 +52,7 @@ GP_Context *GP_FilterMedianExAlloc(const GP_Context *src,
static inline int GP_FilterMedian(const GP_Context *src,
GP_Context *dst,
- int xmed, int ymed,
+ int xmed, int ymed,
GP_ProgressCallback *callback)
{
return GP_FilterMedianEx(src, 0, 0, src->w, src->h,
diff --git a/include/filters/GP_Point.h b/include/filters/GP_Point.h
index 31e9747..7032af3 100644
--- a/include/filters/GP_Point.h
+++ b/include/filters/GP_Point.h
@@ -42,7 +42,7 @@ int GP_FilterBrightness_Raw(const GP_Context *src, GP_Context *dst,
GP_Context *GP_FilterBrightness(const GP_Context *src, GP_Context *dst,
GP_FilterParam params[],
- GP_ProgressCallback *callback);
+ GP_ProgressCallback *callback);
/*
* Contrast filter.
@@ -54,11 +54,11 @@ GP_Context *GP_FilterBrightness(const GP_Context *src, GP_Context *dst,
*/
int GP_FilterContrast_Raw(const GP_Context *src, GP_Context *dst,
GP_FilterParam params[],
- GP_ProgressCallback *callback);
+ GP_ProgressCallback *callback);
GP_Context *GP_FilterContrast(const GP_Context *src, GP_Context *dst,
GP_FilterParam params[],
- GP_ProgressCallback *callback);
+ GP_ProgressCallback *callback);
/*
* Invert filter.
@@ -87,7 +87,7 @@ GP_Context *GP_FilterNoise(const GP_Context *src, GP_Context *dst,
*/
GP_Context *GP_FilterPoint(const GP_Context *src, GP_Context *dst,
GP_FilterParam filter_callback[],
- GP_FilterParam priv[],
- GP_ProgressCallback *callback);
+ GP_FilterParam priv[],
+ GP_ProgressCallback *callback);
#endif /* FILTERS_GP_POINT_H */
diff --git a/include/filters/GP_Rotate.h b/include/filters/GP_Rotate.h
index 7c39ced..bafc37a 100644
--- a/include/filters/GP_Rotate.h
+++ b/include/filters/GP_Rotate.h
@@ -170,7 +170,7 @@ int GP_FilterSymmetryByName(const char *symmetry);
int GP_FilterSymmetry(const GP_Context *src, GP_Context *dst,
GP_FilterSymmetries symmetry,
- GP_ProgressCallback *callback);
+ GP_ProgressCallback *callback);
GP_Context *GP_FilterSymmetry_Alloc(const GP_Context *src,
GP_FilterSymmetries symmetry,
diff --git a/include/filters/GP_Sigma.h b/include/filters/GP_Sigma.h
index 1660e5b..18275f0 100644
--- a/include/filters/GP_Sigma.h
+++ b/include/filters/GP_Sigma.h
@@ -48,7 +48,7 @@ int GP_FilterSigmaEx(const GP_Context *src,
GP_Context *dst,
GP_Coord x_dst, GP_Coord y_dst,
int xrad, int yrad, int min, float sigma,
- GP_ProgressCallback *callback);
+ GP_ProgressCallback *callback);
GP_Context *GP_FilterSigmaExAlloc(const GP_Context *src,
GP_Coord x_src, GP_Coord y_src,
@@ -62,7 +62,7 @@ static inline int GP_FilterSigma(const GP_Context *src,
GP_ProgressCallback *callback)
{
return GP_FilterSigmaEx(src, 0, 0, src->w, src->h,
- dst, 0, 0, xrad, yrad, min, sigma, callback);
+ dst, 0, 0, xrad, yrad, min, sigma, callback);
}
static inline GP_Context *GP_FilterSigmaAlloc(const GP_Context *src,
@@ -71,7 +71,7 @@ static inline GP_Context *GP_FilterSigmaAlloc(const GP_Context *src,
GP_ProgressCallback *callback)
{
return GP_FilterSigmaExAlloc(src, 0, 0, src->w, src->h,
- xrad, yrad, min, sigma, callback);
+ xrad, yrad, min, sigma, callback);
}
#endif /* GP_FILTERS_SIGMA_H */
diff --git a/libs/backends/GP_X11.c b/libs/backends/GP_X11.c
index d95e2de..8e08476 100644
--- a/libs/backends/GP_X11.c
+++ b/libs/backends/GP_X11.c
@@ -536,7 +536,7 @@ GP_Backend *GP_BackendX11Init(const char *GP_UNUSED(display),
unsigned int GP_UNUSED(h),
const char *GP_UNUSED(caption))
{
- GP_DEBUG(0, "FATAL: X11 support not compiled in");
+ GP_WARN("FATAL: X11 support not compiled in");
return NULL;
}
diff --git a/libs/input/GP_InputDriverKBD.c b/libs/input/GP_InputDriverKBD.c
index c598c37..9530fca 100644
--- a/libs/input/GP_InputDriverKBD.c
+++ b/libs/input/GP_InputDriverKBD.c
@@ -75,5 +75,5 @@ void GP_InputDriverKBDEventPut(unsigned char ev)
}
}
- GP_DEBUG(0, "Unmapped key %i", keycode);
+ GP_WARN("Unmapped key %i", keycode);
}
diff --git a/libs/input/GP_InputDriverSDL.c b/libs/input/GP_InputDriverSDL.c
index 207cfca..04cf416 100644
--- a/libs/input/GP_InputDriverSDL.c
+++ b/libs/input/GP_InputDriverSDL.c
@@ -120,7 +120,7 @@ void GP_InputDriverSDLEventPut(SDL_Event *ev)
GP_EventPush(GP_EV_REL, GP_EV_REL_WHEEL, -1, NULL);
return;
default:
- GP_DEBUG(0, "Unmapped SDL Mouse button %02x",
+ GP_WARN("Unmapped SDL Mouse button %02x",
ev->button.button);
return;
}
diff --git a/libs/input/GP_InputDriverX11.c b/libs/input/GP_InputDriverX11.c
index 656c232..5caae39 100644
--- a/libs/input/GP_InputDriverX11.c
+++ b/libs/input/GP_InputDriverX11.c
@@ -41,7 +41,7 @@ static uint16_t keycode_table[] = {
GP_KEY_LEFT_CTRL, GP_KEY_A, GP_KEY_S, GP_KEY_D,
GP_KEY_F, GP_KEY_G, GP_KEY_H, GP_KEY_J,
GP_KEY_K, GP_KEY_L, GP_KEY_SEMICOLON, GP_KEY_APOSTROPHE,
- 0, GP_KEY_LEFT_SHIFT, GP_KEY_BACKSLASH, GP_KEY_Z,
+ GP_KEY_GRAVE, GP_KEY_LEFT_SHIFT, GP_KEY_BACKSLASH, GP_KEY_Z,
GP_KEY_X, GP_KEY_C, GP_KEY_V, GP_KEY_B,
GP_KEY_N, GP_KEY_M, GP_KEY_COMMA, GP_KEY_DOT,
GP_KEY_SLASH, GP_KEY_RIGHT_SHIFT, 0, GP_KEY_LEFT_ALT,
@@ -93,8 +93,8 @@ void GP_InputDriverX11EventPut(XEvent *ev)
}
if (key == 0) {
- GP_DEBUG(0, "Unmapped X11 button %02x",
- ev->xbutton.button);
+ GP_WARN("Unmapped X11 button %02x",
+ ev->xbutton.button);
return;
}
@@ -117,14 +117,14 @@ void GP_InputDriverX11EventPut(XEvent *ev)
key = keycode_table[keycode - 9];
if (key == 0) {
- GP_DEBUG(0, "Unmapped X11 keycode %02x", keycode);
+ GP_WARN("Unmapped X11 keycode %02x", keycode);
return;
}
GP_EventPushKey(key, press, NULL);
break;
default:
- GP_DEBUG(0, "Unhandled X11 event type %u", ev->type);
+ GP_WARN("Unhandled X11 event type %u", ev->type);
}
}
-----------------------------------------------------------------------
Summary of changes:
include/filters/GP_Blur.h | 10 +++++-----
include/filters/GP_Convolution.h | 4 ++--
include/filters/GP_Dither.h | 6 +++---
include/filters/GP_GaussianNoise.h | 2 +-
include/filters/GP_Median.h | 4 ++--
include/filters/GP_Point.h | 10 +++++-----
include/filters/GP_Rotate.h | 2 +-
include/filters/GP_Sigma.h | 6 +++---
libs/backends/GP_X11.c | 2 +-
libs/input/GP_InputDriverKBD.c | 2 +-
libs/input/GP_InputDriverSDL.c | 2 +-
libs/input/GP_InputDriverX11.c | 10 +++++-----
12 files changed, 30 insertions(+), 30 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: ed37d412a80d1a2032cc49f00a4e505ac297f7cc
by metan 02 Sep '12
by metan 02 Sep '12
02 Sep '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project gfxprim.git.
The branch, master has been updated
via ed37d412a80d1a2032cc49f00a4e505ac297f7cc (commit)
from 971eefd1c614dfb8969187f90dc32829889a874d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://repo.or.cz/w/gfxprim.git/commit/ed37d412a80d1a2032cc49f00a4e505ac297…
commit ed37d412a80d1a2032cc49f00a4e505ac297f7cc
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Sep 2 17:36:17 2012 +0200
tests: loaders: Add linker path to GFXprim libs.
This fixes build on machines where GFXprim is not installed.
diff --git a/tests/loaders/Makefile b/tests/loaders/Makefile
index 5222d6b..8fb8b15 100644
--- a/tests/loaders/Makefile
+++ b/tests/loaders/Makefile
@@ -3,7 +3,7 @@ include $(TOPDIR)/pre.mk
CSOURCES=$(shell echo *.c)
-LDFLAGS+=-L../framework/
+LDFLAGS+=-L../framework/ -L$(TOPDIR)/build/
LDLIBS+=$(shell $(TOPDIR)/gfxprim-config --libs --libs-loaders)
LDLIBS+=-ltst_preload -ldl -ltst
CFLAGS+=-I../framework/
-----------------------------------------------------------------------
Summary of changes:
tests/loaders/Makefile | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0