[PATCH 1/2] Fix al_fputc on big-endian.

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


It called al_fwrite to write the first byte of an int
which is completely broken on big-endian.
---
 src/file.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/file.c b/src/file.c
index 0b654b5..270a5bf 100644
--- a/src/file.c
+++ b/src/file.c
@@ -205,9 +205,10 @@ int al_fgetc(ALLEGRO_FILE *f)
  */
 int al_fputc(ALLEGRO_FILE *f, int c)
 {
+   uint8_t b = (c & 0xff);
    ASSERT(f);
 
-   if (al_fwrite(f, &c, 1) != 1) {
+   if (al_fwrite(f, &b, 1) != 1) {
       return EOF;
    }
 
-- 
1.7.4.4


--Q358RQx7tKSpgwgP--




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/