From: <zu...@us...> - 2015-05-12 23:30:54
|
Revision: 5254 http://sourceforge.net/p/fuse-emulator/code/5254 Author: zubzero Date: 2015-05-12 23:30:51 +0000 (Tue, 12 May 2015) Log Message: ----------- Avoid mixing declarations and code for C89 compilers (Adrien Destugues) Modified Paths: -------------- trunk/libspectrum/hacking/ChangeLog trunk/libspectrum/pzx_read.c trunk/libspectrum/szx.c trunk/libspectrum/tzx_write.c Modified: trunk/libspectrum/hacking/ChangeLog =================================================================== --- trunk/libspectrum/hacking/ChangeLog 2015-05-12 23:23:49 UTC (rev 5253) +++ trunk/libspectrum/hacking/ChangeLog 2015-05-12 23:30:51 UTC (rev 5254) @@ -1010,3 +1010,5 @@ patch #331) (Gergely Szasz). 20150510 Makefile.am,m4/pkg.m4: add pkg.m4 for PKG_CHECK_MODULES in case the platform doesn't have pkg-config installed (Sergio). +20150512 pzx_read.c,szx.c,tzx_write.c: avoid mixing declarations and code for + C89 compilers (Adrien Destugues) Modified: trunk/libspectrum/pzx_read.c =================================================================== --- trunk/libspectrum/pzx_read.c 2015-05-12 23:23:49 UTC (rev 5253) +++ trunk/libspectrum/pzx_read.c 2015-05-12 23:30:51 UTC (rev 5254) @@ -235,6 +235,15 @@ 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 ) { @@ -246,16 +255,16 @@ } /* 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 */ @@ -267,13 +276,11 @@ 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 ); @@ -455,6 +462,7 @@ pzx_context *ctx ) { libspectrum_tape_block *block; + libspectrum_word flags; if( data_length < 2 ) { libspectrum_print_error( LIBSPECTRUM_ERROR_CORRUPT, @@ -462,7 +470,7 @@ 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 ); Modified: trunk/libspectrum/szx.c =================================================================== --- trunk/libspectrum/szx.c 2015-05-12 23:23:49 UTC (rev 5253) +++ trunk/libspectrum/szx.c 2015-05-12 23:30:51 UTC (rev 5254) @@ -577,10 +577,12 @@ /* This is ugly, but I can't see a better way to do it */ if( sizeof( libspectrum_byte ) == sizeof( char ) ) { char *custom = libspectrum_new( char, 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 ); Modified: trunk/libspectrum/tzx_write.c =================================================================== --- trunk/libspectrum/tzx_write.c 2015-05-12 23:23:49 UTC (rev 5253) +++ trunk/libspectrum/tzx_write.c 2015-05-12 23:30:51 UTC (rev 5254) @@ -971,6 +971,7 @@ { 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 || @@ -999,7 +1000,7 @@ /* 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_new( libspectrum_byte, data_length ); + data = libspectrum_new( libspectrum_byte, data_length ); memcpy( data, libspectrum_tape_block_data( block ), data_length ); libspectrum_tape_block_set_data( pure_data, data ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |