This let me compare against the host for #225.
---
 tests/file.test   | 2 +-
 toys/posix/file.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
From fb446f1a8dba54473863a5460e408767617cc551 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <e...@google.com>
Date: Tue, 16 Jun 2020 09:33:44 -0700
Subject: [PATCH] file: add GIF version information.

This let me compare against the host for #225.
---
 tests/file.test   | 2 +-
 toys/posix/file.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/file.test b/tests/file.test
index 90acfa4c..7cf84981 100755
--- a/tests/file.test
+++ b/tests/file.test
@@ -36,7 +36,7 @@ testing "7z file" "file $FILES/tar/tar.7z | sed 's|$FILES/||'" \
 testing "zip file" "file $FILES/zip/example.zip | sed 's|$FILES/||'" \
     "zip/example.zip: Zip archive data, requires at least v1.0 to extract\n" "" ""
 echo R0lGODlhIAAgAMZHAAAAABYWFiYmJioqKi4uLjIy | base64 -d > gif
-testing "gif file" "file gif" "gif: GIF image data, 32 x 32\n" "" ""
+testing "gif file" "file gif" "gif: GIF image data, version 89a, 32 x 32\n" "" ""
 rm -f gif
 
 # TODO: check in a genuine minimal .dex
diff --git a/toys/posix/file.c b/toys/posix/file.c
index 6fa51102..5ec24919 100644
--- a/toys/posix/file.c
+++ b/toys/posix/file.c
@@ -225,8 +225,8 @@ static void do_regular_file(int fd, char *name)
 
   // https://www.w3.org/Graphics/GIF/spec-gif89a.txt
   } else if (len>16 && (strstart(&s, "GIF87a") || strstart(&s, "GIF89a")))
-    xprintf("GIF image data, %d x %d\n",
-      (int)peek_le(s, 2), (int)peek_le(s+2, 2));
+    xprintf("GIF image data, version %3.3s, %d x %d\n",
+      s-3, (int)peek_le(s, 2), (int)peek_le(s+2, 2));
 
   // TODO: parsing JPEG for width/height is harder than GIF or PNG.
   else if (len>32 && !memcmp(toybuf, "\xff\xd8", 2)) xputs("JPEG image data");
-- 
2.27.0.290.gba653c62da-goog

_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to