lehors@modja.inria.fr (Arnaud Le Hors) (08/28/90)
Here is a fix to a little bug reported by "Gilligan" <thoth@reef.cis.ufl.edu> in the previously posted package (shar file) which you should apply as follows: patch create.c < fix1 with fix1: --- cut here --- 7c7 < * $Id: xpm.shar,v 2.1 90/08/24 19:07:31 lehors Exp $ --- > * $Id: xpm.shar,v 2.2 90/08/27 11:16:48 lehors Exp $ 229c229 < free(dptr); --- > free(bptr); -- Note: This has already been applied to the package available on expo.lcs.mit.edu and avahi.inria.fr And here is an "ugly perl script" (as he said) from Gilligan to translate xpm format 1 files to the new format. May be ugly, and may not work with all the XPM1 files, but is definitly useful and works for me so far. (Thanks for your contribution.) xpm1to2: ---- cut here --- #!/usr/local/bin/perl sub checkname { if ($_[0] ne $_[1]) { printf STDERR "warning, name inconsitencies in %s %s!=%s\n", $_[2], $_[0], $_[1]; } } printf "/* XPM2 C */\n"; ($name, $format) = (<> =~ /^#define (\w+)_format (\d+)$/); ($name2, $width) = (<> =~ /^#define (\w+)_width (\d+)$/); &checkname($name, $name2, "width"); ($name2, $height) = (<> =~ /^#define (\w+)_height (\d+)$/); &checkname($name, $name2, "height"); ($name2, $ncolors) = (<> =~ /^#define (\w+)_ncolors (\d+)$/); &checkname($name, $name2, "ncolors"); ($name2, $chars_per_pixel) = (<> =~ /^#define (\w+)_chars_per_pixel (\d+)$/); &checkname($name, $name2, "chars per pixel"); ($name2) = (<> =~ /^static char \* (\w+)_colors\[] = {$/); &checkname($name, $name2, "colors"); printf "static char * %s[] = {\n", $name; printf "/* %s pixmap\n * width height ncolors chars_per_pixel */\n", $name; printf "\"%s %s %s %s \",\n", $width, $height, $ncolors, $chars_per_pixel; $idx = 0; while ( ($_ = <>) =~ m/^\s*"[^"]+"\s*,\s*"[^"]+"(,)?$/ ) { ($codes[$idx], $color_name[$idx]) = /^\s*"([^"]+)"\s*,\s*"([^"]+)"(,)?$/; $idx++; } if ($idx != $ncolors) { printf STDERR "Warning, ncolors mismatch reading color %d != %d\n", $ncolors, $idx; } for ($idx=0; $idx<$ncolors; $idx++) { printf "\"%s c %s \t s s_%s \",\n", $codes[$idx], $color_name[$idx], $color_name[$idx]; } ($name2) = ( <> =~ /^static char \* (\w+)_pixels\[] = {$/); &checkname($name, $name2, "pixels"); printf "/* pixels */\n"; while ( ! ( ($_ = <>) =~ /^} ;$/) ) { printf $_; } printf "} ;\n"; -- Arnaud LE HORS BULL Research FRANCE -- Koala Project | Email : lehors@mirsa.inria.fr Inria - Sophia Antipolis | Phone : (33) 93 65 77 71 2004, Route des Lucioles | Telex : 97 00 50 F 06565 Valbonne CEDEX France | Fax : (33) 93 65 77 66