mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Andreas Bießmann" <andreas@biessmann.de>
To: linux-kernel@vger.kernel.org
Cc: "Andreas Bießmann" <andreas@biessmann.de>
Subject: [PATCH] scripts/pnmtologo: fix for plain PBM
Date: Thu, 18 Oct 2012 11:08:49 +0200	[thread overview]
Message-ID: <1350551329-3521-1-git-send-email-andreas@biessmann.de> (raw)

PBM generated with current tools do not have a whitespace between the digits.
Therefore the pnmtologo tool fails to gernerate the required C-Array for these
images.  This patch fixes that behaviour and can handle both 'old style' and
'new style' PBM files.

Signed-off-by: Andreas Bießmann <andreas@biessmann.de>
---
 scripts/pnmtologo.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
index 5c11312..66f8d7a 100644
--- a/scripts/pnmtologo.c
+++ b/scripts/pnmtologo.c
@@ -74,6 +74,7 @@ static unsigned int logo_height;
 static struct color **logo_data;
 static struct color logo_clut[MAX_LINUX_LOGO_COLORS];
 static unsigned int logo_clutsize;
+static int is_plain_pbm = 0;
 
 static void die(const char *fmt, ...)
     __attribute__ ((noreturn)) __attribute ((format (printf, 1, 2)));
@@ -103,6 +104,11 @@ static unsigned int get_number(FILE *fp)
     val = 0;
     while (isdigit(c)) {
 	val = 10*val+c-'0';
+	/* some PBM are 'broken'; GiMP for example exports a PBM without space
+	 * between the digits. This is Ok cause we know a PBM can only have a '1'
+	 * or a '0' for the digit. */
+	if (is_plain_pbm)
+		break;
 	c = fgetc(fp);
 	if (c == EOF)
 	    die("%s: end of file\n", filename);
@@ -167,6 +173,7 @@ static void read_image(void)
     switch (magic) {
 	case '1':
 	    /* Plain PBM */
+	    is_plain_pbm = 1;
 	    for (i = 0; i < logo_height; i++)
 		for (j = 0; j < logo_width; j++)
 		    logo_data[i][j].red = logo_data[i][j].green =
-- 
1.7.10.4


             reply	other threads:[~2012-10-18  9:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-18  9:08 Andreas Bießmann [this message]
2012-11-20 10:57 ` Michal Marek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1350551329-3521-1-git-send-email-andreas@biessmann.de \
    --to=andreas@biessmann.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®