| Fix bugs in farbfeld(5)-example - farbfeld - suckless image format with convers… | |
| git clone git://git.suckless.org/farbfeld | |
| Log | |
| Files | |
| Refs | |
| README | |
| LICENSE | |
| --- | |
| commit ac1630a81790f5db946d7091e08b758714c8cd19 | |
| parent 86495f8058518f7064f2ddda92314aa42163b4c0 | |
| Author: FRIGN <[email protected]> | |
| Date: Tue, 5 Jan 2016 01:39:10 +0100 | |
| Fix bugs in farbfeld(5)-example | |
| 1) We forgot to write the header out again (no changes, but else the | |
| format would have obviously been broken) | |
| 2) The order of 'size' and 'count' was wrong in the fread- and fwrite- | |
| calls inside the loops, and the checks were failing. | |
| now this is fixed. | |
| Diffstat: | |
| M farbfeld.5 | 9 +++++++-- | |
| 1 file changed, 7 insertions(+), 2 deletions(-) | |
| --- | |
| diff --git a/farbfeld.5 b/farbfeld.5 | |
| @@ -72,9 +72,14 @@ if (memcmp("farbfeld", hdr, strlen("farbfeld"))) { | |
| width = ntohl(*((uint32_t *)(hdr + 8))); | |
| height = ntohl(*((uint32_t *)(hdr + 12))); | |
| +if (fwrite(hdr, 1, sizeof(hdr), outfile) != sizeof(hdr)) { | |
| + fprintf(stderr, "write error\\n"); | |
| + exit(1); | |
| +} | |
| + | |
| for (i = 0; i < height; i++) { | |
| for (j = 0; j < width; j++) { | |
| - if (fread(rgba, 4, sizeof(uint16_t), infile) != 4) { | |
| + if (fread(rgba, sizeof(uint16_t), 4, infile) != 4) { | |
| fprintf(stderr, "unexpected EOF\\n"); | |
| exit(1); | |
| } | |
| @@ -90,7 +95,7 @@ for (i = 0; i < height; i++) { | |
| for (k = 0; k < 4; k++) { | |
| rgba[k] = htons(rgba[k]); | |
| } | |
| - if (fwrite(rgba, 4, sizeof(uint16_t), outfile) != 4) { | |
| + if (fwrite(rgba, sizeof(uint16_t), 4, outfile) != 4) { | |
| fprintf(stderr, "write error\\n"); | |
| exit(1); | |
| } |