mirror of
https://github.com/yann64/haikuports.git
synced 2026-04-14 07:40:07 +02:00
124 lines
4.6 KiB
Plaintext
124 lines
4.6 KiB
Plaintext
From 3e80dac7bfb6f5c24a75eef84a787bf3204a00cf Mon Sep 17 00:00:00 2001
|
|
From: Adrien Destugues <pulkomandy@gmail.com>
|
|
Date: Tue, 12 May 2015 18:41:28 +0200
|
|
Subject: C89 "declaration after statement" fixes.
|
|
|
|
|
|
diff --git a/pzx_read.c b/pzx_read.c
|
|
index 64ea969..cbdae60 100644
|
|
--- a/pzx_read.c
|
|
+++ b/pzx_read.c
|
|
@@ -238,6 +238,15 @@ read_data_block( libspectrum_tape *tape, const libspectrum_byte **buffer,
|
|
libspectrum_byte *data;
|
|
|
|
libspectrum_error error;
|
|
+ libspectrum_dword count;
|
|
+ int initial_level;
|
|
+ size_t count_bytes;
|
|
+ size_t bits_in_last_byte;
|
|
+ libspectrum_word tail;
|
|
+ libspectrum_byte p0_count;
|
|
+ libspectrum_byte p1_count;
|
|
+ libspectrum_word *p0_pulses;
|
|
+ libspectrum_word *p1_pulses;
|
|
|
|
/* Check there's enough left in the buffer for all the metadata */
|
|
if( data_length < 8 ) {
|
|
@@ -249,16 +258,16 @@ read_data_block( libspectrum_tape *tape, const libspectrum_byte **buffer,
|
|
}
|
|
|
|
/* Get the metadata */
|
|
- libspectrum_dword count = libspectrum_read_dword( buffer );
|
|
- int initial_level = !!(count & 0x80000000);
|
|
+ count = libspectrum_read_dword( buffer );
|
|
+ initial_level = !!(count & 0x80000000);
|
|
count &= 0x7fffffff;
|
|
- size_t count_bytes = ceil( count / (double)LIBSPECTRUM_BITS_IN_BYTE );
|
|
- size_t bits_in_last_byte =
|
|
+ count_bytes = ceil( count / (double)LIBSPECTRUM_BITS_IN_BYTE );
|
|
+ bits_in_last_byte =
|
|
count % LIBSPECTRUM_BITS_IN_BYTE ?
|
|
count % LIBSPECTRUM_BITS_IN_BYTE : LIBSPECTRUM_BITS_IN_BYTE;
|
|
- libspectrum_word tail = libspectrum_read_word( buffer );
|
|
- libspectrum_byte p0_count = **buffer; (*buffer)++;
|
|
- libspectrum_byte p1_count = **buffer; (*buffer)++;
|
|
+ tail = libspectrum_read_word( buffer );
|
|
+ p0_count = **buffer; (*buffer)++;
|
|
+ p1_count = **buffer; (*buffer)++;
|
|
|
|
/* need to confirm that we have enough length left for the pulse definitions
|
|
*/
|
|
@@ -270,13 +279,11 @@ read_data_block( libspectrum_tape *tape, const libspectrum_byte **buffer,
|
|
return LIBSPECTRUM_ERROR_CORRUPT;
|
|
}
|
|
|
|
- libspectrum_word *p0_pulses;
|
|
error = pzx_read_data( buffer, block_end,
|
|
p0_count * sizeof( libspectrum_word ),
|
|
(libspectrum_byte**)&p0_pulses );
|
|
if( error ) return error;
|
|
|
|
- libspectrum_word *p1_pulses;
|
|
error = pzx_read_data( buffer, block_end,
|
|
p1_count * sizeof( libspectrum_word ),
|
|
(libspectrum_byte**)&p1_pulses );
|
|
@@ -462,6 +469,7 @@ read_stop_block( libspectrum_tape *tape, const libspectrum_byte **buffer,
|
|
pzx_context *ctx )
|
|
{
|
|
libspectrum_tape_block *block;
|
|
+ libspectrum_word flags;
|
|
|
|
if( data_length < 2 ) {
|
|
libspectrum_print_error( LIBSPECTRUM_ERROR_CORRUPT,
|
|
@@ -469,7 +477,7 @@ read_stop_block( libspectrum_tape *tape, const libspectrum_byte **buffer,
|
|
return LIBSPECTRUM_ERROR_CORRUPT;
|
|
}
|
|
|
|
- libspectrum_word flags = libspectrum_read_word( buffer );
|
|
+ flags = libspectrum_read_word( buffer );
|
|
|
|
if( flags == PZXF_STOP48 ) {
|
|
block = libspectrum_tape_block_alloc( LIBSPECTRUM_TAPE_BLOCK_STOP48 );
|
|
diff --git a/szx.c b/szx.c
|
|
index 214184a..cf8bb8d 100644
|
|
--- a/szx.c
|
|
+++ b/szx.c
|
|
@@ -577,10 +577,12 @@ read_crtr_chunk( libspectrum_snap *snap, libspectrum_word version GCC_UNUSED,
|
|
/* This is ugly, but I can't see a better way to do it */
|
|
if( sizeof( libspectrum_byte ) == sizeof( char ) ) {
|
|
char *custom = libspectrum_malloc( data_length + 1 );
|
|
+ char *libspectrum;
|
|
+
|
|
memcpy( custom, *buffer, data_length );
|
|
custom[data_length] = 0;
|
|
|
|
- char *libspectrum = strstr( custom, libspectrum_string );
|
|
+ libspectrum = strstr( custom, libspectrum_string );
|
|
if( libspectrum ) {
|
|
int matches, v1, v2, v3;
|
|
libspectrum += strlen( libspectrum_string );
|
|
diff --git a/tzx_write.c b/tzx_write.c
|
|
index 8dec404..1981ea1 100644
|
|
--- a/tzx_write.c
|
|
+++ b/tzx_write.c
|
|
@@ -970,6 +970,7 @@ tzx_write_data_block( libspectrum_tape_block *block, libspectrum_byte **buffer,
|
|
{
|
|
libspectrum_tape_block *pure_data;
|
|
size_t data_length;
|
|
+ libspectrum_byte *data;
|
|
|
|
/* Pure data block can only have two identical pulses for bit 0 and bit 1 */
|
|
if( libspectrum_tape_block_bit0_pulse_count( block ) != 2 ||
|
|
@@ -998,7 +999,7 @@ tzx_write_data_block( libspectrum_tape_block *block, libspectrum_byte **buffer,
|
|
/* And the actual data */
|
|
data_length = libspectrum_tape_block_data_length( block );
|
|
libspectrum_tape_block_set_data_length( pure_data, data_length );
|
|
- libspectrum_byte *data = libspectrum_malloc( data_length * sizeof( *data ) );
|
|
+ data = libspectrum_malloc( data_length * sizeof( *data ) );
|
|
memcpy( data, libspectrum_tape_block_data( block ), data_length );
|
|
libspectrum_tape_block_set_data( pure_data, data );
|
|
|
|
--
|
|
2.2.2
|
|
|