@@ 367,13 367,9 @@ sub makeSource {
my $thisByte = '';
my $readResult;
- if ($counter+1 >= $length) { # At the end?
- $thisByte = '\0' if ($self->options->nullTerminator); # A null terminator
- $readResult = 1;
- } else {
- my $pInHandle = $pIn->handle;
- my $ref = \$thisByte;
- $readResult = read($pInHandle, $ref, 1);
+ my $pInHandle = $pIn->handle;
+ if ($readResult = read($pInHandle, my $bytes, 1)) {
+ $thisByte = $bytes;
}
if ($readResult >= 1) {
@@ 392,6 388,11 @@ sub makeSource {
$counter++;
}
+ # FIXME: This logic may be wrong in the C version
+ if ($self->options->nullTerminator) { # A null terminator
+ printf($pOutHandle "\'\\x%02X\'", 0);
+ }
+
printf($pOutHandle "\n};\n");
return;
}
@@ 8,5 8,5 @@ all:
test: all
../bin/raw2c --header=data/output/blobs.h --symbol=__rawimage_DB4r4knLS -q data/horatio.png data/output/horatio.c
- diff -u data/output/horatio.c data/ref.c
- diff -u data/output/blobs.h data/ref.h
+ diff -u data/ref.c data/output/horatio.c
+ diff -u data/ref.h data/output/blobs.h
@@ 765,5 765,5 @@ const char __rawimage_DB4r4knLS[] = {
'\xF1', '\x8B', '\x37', '\xDE', '\xA6', '\x5E', '\x4B', '\xF9',
'\x7F', '\x83', '\xB5', '\x23', '\x5F', '\xFC', '\x40', '\xB0',
'\xBF', '\x00', '\x00', '\x00', '\x00', '\x49', '\x45', '\x4E',
- '\x44', '\xAE', '\x42', '\x60', '\x60'
+ '\x44', '\xAE', '\x42', '\x60', '\x82'
};