From e8746fec96739a1c29de8209a9b157e197738aa0 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Wed, 11 Sep 2024 16:39:11 +0200 Subject: [PATCH] syntax "else" --- src/cpu.c | 53 +++------ src/dis.c | 13 +-- src/disk_io.c | 16 +-- src/disk_io_obj.c | 12 +- src/display.c | 4 +- src/emulator.c | 8 +- src/flash49.c | 2 - src/hw_config.c | 278 +++++++++++++++++++++++----------------------- src/keyb.c | 24 +--- src/main.c | 6 +- src/modules.c | 43 ++----- src/modules.h | 2 + src/monitor.c | 4 +- src/pack.c | 4 +- src/romram.c | 10 +- src/serial.c | 16 +-- src/x11.c | 33 ++---- src/x_func.c | 16 +-- 18 files changed, 200 insertions(+), 344 deletions(-) diff --git a/src/cpu.c b/src/cpu.c index 09e7ff5..a79df1f 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -1,4 +1,3 @@ - /* ------------------------------------------------------------------------- saturn - A poor-man's emulator of some HP calculators Copyright (C) 1998-2000 Ivan Cibrario Bertolotti @@ -219,9 +218,7 @@ static void ExecRTI( void ) cpu_status.int_service = 1; cpu_status.int_pending = INT_REQUEST_NONE; cpu_status.PC = INT_HANDLER_PC; - } - - else { + } else { /* Reenable interrupts and return */ debug0( DEBUG_C_INT, CPU_I_RTI_END ); @@ -795,9 +792,7 @@ static void AddRR( register Nibble* d, register const Nibble* a, register const d[ n ] = ( Nibble )( s & NIBBLE_MASK ); carry = ( ( s & ~NIBBLE_MASK ) != 0 ); } - } - - else { + } else { for ( n = lo; n <= hi; n++ ) { s = a[ n ] + b[ n ] + carry; d[ n ] = dec_sum[ s ]; @@ -827,9 +822,7 @@ static void IncrR( register Nibble* d, int fs ) d[ n ] = ( Nibble )( s & NIBBLE_MASK ); carry = ( ( s & ~NIBBLE_MASK ) != 0 ); } - } - - else { + } else { for ( n = lo; n <= hi; n++ ) { s = d[ n ] + carry; d[ n ] = dec_sum[ s ]; @@ -859,9 +852,7 @@ static void SubRR( register Nibble* d, register Nibble* a, register Nibble* b, i d[ n ] = ( Nibble )( s & NIBBLE_MASK ); carry = ( ( s & ~NIBBLE_MASK ) != 0 ); } - } - - else { + } else { for ( n = lo; n <= hi; n++ ) { s = a[ n ] - b[ n ] - carry; d[ n ] = dec_sub[ s ]; @@ -891,9 +882,7 @@ static void DecrR( register Nibble* d, int fs ) d[ n ] = ( Nibble )( s & NIBBLE_MASK ); carry = ( ( s & ~NIBBLE_MASK ) != 0 ); } - } - - else { + } else { for ( n = lo; n <= hi; n++ ) { s = d[ n ] - carry; d[ n ] = dec_sub[ s ]; @@ -1053,9 +1042,7 @@ static void TwoComplR( register Nibble* d, int fs ) nz = nz || ( d[ n ] != ( Nibble )0 ); } - } - - else { + } else { for ( n = lo; n <= hi; n++ ) { s = -d[ n ] - carry; d[ n ] = dec_sub[ s ]; @@ -1079,9 +1066,7 @@ static void OneComplR( register Nibble* d, int fs ) if ( cpu_status.hexmode ) { for ( n = lo; n <= hi; n++ ) d[ n ] = ( 0xF - d[ n ] ) & NIBBLE_MASK; - } - - else { + } else { for ( n = lo; n <= hi; n++ ) d[ n ] = dec_one_c[ ( int )d[ n ] ]; } @@ -1189,9 +1174,7 @@ static void ExecGOYES_RTNYES( void ) cpu_status.PC = PopRSTK(); else cpu_status.PC += offset; - } - - else + } else /* Not taken */ cpu_status.PC += 2; } @@ -1668,9 +1651,7 @@ static void ExecGroup_0( void ) if ( cpu_status.P == NIBBLE_MASK ) { SetP( 0 ); cpu_status.carry = 1; - } - - else { + } else { SetP( cpu_status.P + 1 ); cpu_status.carry = 0; } @@ -1682,9 +1663,7 @@ static void ExecGroup_0( void ) if ( cpu_status.P == ( Nibble )0 ) { SetP( NIBBLE_MASK ); cpu_status.carry = 1; - } - - else { + } else { SetP( cpu_status.P - 1 ); cpu_status.carry = 0; } @@ -2674,9 +2653,7 @@ void CpuIntRequest( enum IntRequest ireq ) cpu_status.PC = INT_HANDLER_PC; debug1( DEBUG_C_INT, CPU_I_INT, ( ireq == INT_REQUEST_NMI ? "NMI" : "IRQ" ) ); - } - - else { + } else { /* int_service is set; save the request for later processing */ cpu_status.int_pending = ireq; @@ -3020,9 +2997,7 @@ void OneStep( void ) cpu_status.PC = PopRSTK(); else cpu_status.PC += offset; - } - - else + } else cpu_status.PC += 2; break; @@ -3034,9 +3009,7 @@ void OneStep( void ) cpu_status.PC = PopRSTK(); else cpu_status.PC += offset; - } - - else + } else cpu_status.PC += 2; break; diff --git a/src/dis.c b/src/dis.c index 7f0d4ff..7e593f3 100644 --- a/src/dis.c +++ b/src/dis.c @@ -188,7 +188,6 @@ static Address DisGOYES_RTNYES( Address pc, char* ob ) if ( offset == 0 ) sprintf( ob, "\n\tRTNYES" ); - else sprintf( ob, "\n\tGOYES\tA_%05X\t* Offset [%d]d", pc + offset, offset ); @@ -234,11 +233,9 @@ static Address DisRTNC_GOC( Address pc, char* ob ) if ( offset == 0 ) /* RTNC */ sprintf( ob, "RTNC" ); - else if ( offset == 2 ) /* NOP3 */ sprintf( ob, "NOP3" ); - else /* GOC */ sprintf( ob, "GOC\tA_%05X\t* Offset [%d]d", pc + offset, offset ); @@ -255,7 +252,6 @@ static Address DisRTNNC_GONC( Address pc, char* ob ) if ( offset == 0 ) /* RTNNC */ sprintf( ob, "RTNNC" ); - else /* GONC */ sprintf( ob, "GONC\tA_%05X\t* Offset [%d]d", pc + offset, offset ); @@ -273,15 +269,11 @@ static Address DisGOTO( Address pc, char* ob ) /* NOP4 */ sprintf( ob, "NOP4" ); pc += 3; - } - - else if ( offset == 4 ) { + } else if ( offset == 4 ) { /* NOP5 */ sprintf( ob, "NOP5" ); pc += 4; - } - - else { + } else { sprintf( ob, "GOTO\tA_%05X\t* Offset [%d]d", pc + offset, offset ); pc += 3; } @@ -1357,7 +1349,6 @@ static Address DisGroup_1( Address pc, char* ob ) if ( is ) /* Immediate field selector */ DisIMM_FIELD_SEL( f, ob ); - else /* Regular field selector */ DisFIELD_SEL( f, ob ); diff --git a/src/disk_io.c b/src/disk_io.c index 8c8355e..1fbcd94 100644 --- a/src/disk_io.c +++ b/src/disk_io.c @@ -117,9 +117,7 @@ int ReadNibblesFromFile( const char* name, int size, Nibble* dest ) if ( ( f = fopen( name, "rb" ) ) == ( FILE* )NULL ) { ChfErrnoCondition; ChfCondition st = DISK_IO_E_OPEN, CHF_ERROR, name ChfEnd; - } - - else { + } else { for ( i = 0; i < size; ) { by = getc( f ); @@ -177,9 +175,7 @@ int WriteNibblesToFile( const Nibble* src, int size, const char* name ) if ( ( f = fopen( name, "wb" ) ) == ( FILE* )NULL ) { ChfErrnoCondition; ChfCondition st = DISK_IO_E_OPEN, CHF_ERROR, name ChfEnd; - } - - else { + } else { for ( i = 0; i < size; ) { by = ( int )src[ i++ ]; by |= ( int )src[ i++ ] << 4; @@ -234,9 +230,7 @@ int ReadStructFromFile( const char* name, size_t s_size, void* s ) if ( ( f = fopen( name, "rb" ) ) == ( FILE* )NULL ) { ChfErrnoCondition; ChfCondition st = DISK_IO_E_OPEN, CHF_ERROR, name ChfEnd; - } - - else { + } else { if ( fread( s, s_size, ( size_t )1, f ) != 1 ) { ChfErrnoCondition; ChfCondition st = DISK_IO_E_READ, CHF_ERROR, name ChfEnd; @@ -284,9 +278,7 @@ int WriteStructToFile( const void* s, size_t s_size, const char* name ) if ( ( f = fopen( name, "wb" ) ) == ( FILE* )NULL ) { ChfErrnoCondition; ChfCondition st = DISK_IO_E_OPEN, CHF_ERROR, name ChfEnd; - } - - else { + } else { if ( fwrite( s, s_size, ( size_t )1, f ) != 1 ) { ChfErrnoCondition; ChfCondition st = DISK_IO_E_WRITE, CHF_ERROR, name ChfEnd; diff --git a/src/disk_io_obj.c b/src/disk_io_obj.c index d3b72ae..c603cd7 100644 --- a/src/disk_io_obj.c +++ b/src/disk_io_obj.c @@ -144,9 +144,7 @@ int ReadObjectFromFile( const char* name, const char* hdr, Address start, Addres if ( ( f = fopen( name, "rb" ) ) == ( FILE* )NULL ) { ChfErrnoCondition; ChfCondition st = DISK_IO_E_OPEN, CHF_ERROR, name ChfEnd; - } - - else { + } else { /* Check and skip header */ for ( i = 0; i < hdr_len; i++ ) { by = getc( f ); @@ -155,9 +153,7 @@ int ReadObjectFromFile( const char* name, const char* hdr, Address start, Addres ChfErrnoCondition; ChfCondition st = DISK_IO_E_GETC, CHF_ERROR, name ChfEnd; break; - } - - else if ( hdr[ i ] != '?' && by != hdr[ i ] ) { + } else if ( hdr[ i ] != '?' && by != hdr[ i ] ) { ChfCondition st = DISK_IO_E_BAD_HDR, CHF_ERROR, name ChfEnd; break; } @@ -245,9 +241,7 @@ int WriteObjectToFile( Address start, Address end, const char* hdr, const char* if ( ( f = fopen( name, "wb" ) ) == ( FILE* )NULL ) { ChfErrnoCondition; ChfCondition st = DISK_IO_E_OPEN, CHF_ERROR, name ChfEnd; - } - - else { + } else { /* Write header; replace wildcard character '?' with 'S' */ for ( i = 0; i < hdr_len; i++ ) { if ( putc( hdr[ i ] == '?' ? 'S' : hdr[ i ], f ) == EOF ) { diff --git a/src/display.c b/src/display.c index adfd124..7eaa011 100644 --- a/src/display.c +++ b/src/display.c @@ -496,9 +496,7 @@ void DrawLcd( void ) XCopyArea( display, ann_pixmap[ y ], window, gc, 0, 0, /* src_x, src_y */ ann_data[ y ].w, ann_data[ y ].h, /* width, height */ ann_data[ y ].x, ann_data[ y ].y ); - } - - else { + } else { XClearArea( display, window, ann_data[ y ].x, ann_data[ y ].y, ann_data[ y ].w, ann_data[ y ].h, False /* No exposures */ ); } diff --git a/src/emulator.c b/src/emulator.c index 513e2ad..b50b597 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -480,9 +480,7 @@ static ChfAction EmulatorLoopHandler( const ChfDescriptor* d, const ChfState s, /* Condition Code not handled; resignal */ act = CHF_RESIGNAL; } - } - - else + } else /* Condition from other modules; resignal */ act = CHF_RESIGNAL; @@ -543,9 +541,7 @@ void Emulator( void ) /* Activate emulator loop */ EmulatorLoop(); - } - - else { + } else { /* Unwinding after an emulator interrupt */ } } diff --git a/src/flash49.c b/src/flash49.c index 65e6e1a..4805459 100644 --- a/src/flash49.c +++ b/src/flash49.c @@ -412,7 +412,6 @@ Nibble FlashRead49( XAddress address ) if ( IsOdd( address ) ) /* Odd address, return buffered data from previous read */ result = HighNibble( r_buffer ); - else { /* Even address, invoke FSM */ r_buffer = FSM( FLASH_CYCLE_READ, ByteAddress( address ), 0 ); @@ -458,7 +457,6 @@ void FlashWrite49( XAddress address, Nibble datum ) if ( IsOdd( address ) ) /* Odd address, invoke FSM; ignore result */ FSM( FLASH_CYCLE_WRITE, ByteAddress( address ), w_buffer | ShiftHigh( datum ) ); - else /* Even address, buffer datum */ w_buffer = datum; diff --git a/src/hw_config.c b/src/hw_config.c index d45c3e5..030131b 100644 --- a/src/hw_config.c +++ b/src/hw_config.c @@ -154,145 +154,143 @@ static const struct { const char* hw; ModDescription description; } table[] = { - {"hp48", - { - { - "ROM (ROM)", - 0x00, - 0, - RomInit, - RomSave, - RomRead, - RomWrite, - MOD_CONFIGURED, - 0x00000, - 0xFFFFF, - }, - { - "Hardware Regs. (HDW)", - 0x19, - 5, - HdwInit, - HdwSave, - HdwRead, - HdwWrite, - MOD_SIZE_CONFIGURED, - 0x00000, - 0x00040, - }, - { - "Internal RAM (RAM)", - 0x03, - 4, - RamInit, - RamSave, - RamRead, - RamWrite, - MOD_UNCONFIGURED, - 0, - 0, - }, - { - "Bank Select (CE1)", - 0x05, - 2, - Ce1Init, - Ce1Save, - Ce1Read, - Ce1Write, - MOD_UNCONFIGURED, - 0, - 0, - }, - { - "Port 1 Control (CE2)", - 0x07, - 3, - Ce2Init, - Ce2Save, - Ce2Read, - Ce2Write, - MOD_UNCONFIGURED, - 0, - 0, - }, - { - "Port 2 Control (NCE3)", - 0x01, - 1, - NCe3Init, - NCe3Save, - NCe3Read, - NCe3Write, - MOD_UNCONFIGURED, - 0, - 0, - } } }, + {"hp48", + { { + "ROM (ROM)", + 0x00, + 0, + RomInit, + RomSave, + RomRead, + RomWrite, + MOD_CONFIGURED, + 0x00000, + 0xFFFFF, + }, + { + "Hardware Regs. (HDW)", + 0x19, + 5, + HdwInit, + HdwSave, + HdwRead, + HdwWrite, + MOD_SIZE_CONFIGURED, + 0x00000, + 0x00040, + }, + { + "Internal RAM (RAM)", + 0x03, + 4, + RamInit, + RamSave, + RamRead, + RamWrite, + MOD_UNCONFIGURED, + 0, + 0, + }, + { + "Bank Select (CE1)", + 0x05, + 2, + Ce1Init, + Ce1Save, + Ce1Read, + Ce1Write, + MOD_UNCONFIGURED, + 0, + 0, + }, + { + "Port 1 Control (CE2)", + 0x07, + 3, + Ce2Init, + Ce2Save, + Ce2Read, + Ce2Write, + MOD_UNCONFIGURED, + 0, + 0, + }, + { + "Port 2 Control (NCE3)", + 0x01, + 1, + NCe3Init, + NCe3Save, + NCe3Read, + NCe3Write, + MOD_UNCONFIGURED, + 0, + 0, + } } }, - {"hp49", - { - { - "ROM (ROM)", - 0x00, - 0, - RomInit49, - RomSave49, - RomRead49, - RomWrite49, - MOD_CONFIGURED, - 0x00000, - 0xFFFFF, - }, - { - "Hardware Regs. (HDW)", - 0x19, - 5, - HdwInit, - HdwSave, - HdwRead, - HdwWrite, - MOD_SIZE_CONFIGURED, - 0x00000, - 0x00040, - }, - { - "IRAM (RAM)", - 0x03, - 4, - RamInit49, - RamSave49, - RamRead49, - RamWrite49, - MOD_UNCONFIGURED, - 0, - 0, - }, - { - "Bank Select (CE1)", - 0x05, - 2, - Ce1Init49, - Ce1Save49, - Ce1Read49, - Ce1Write49, - MOD_UNCONFIGURED, - 0, - 0, - }, - { - "ERAM Bank 0 (CE2)", - 0x07, - 3, - Ce2Init49, - Ce2Save49, - Ce2Read49, - Ce2Write49, - MOD_UNCONFIGURED, - 0, - 0, - }, - { "ERAM Bank 1 (NCE3)", 0x01, 1, NCe3Init49, NCe3Save49, NCe3Read49, NCe3Write49, MOD_UNCONFIGURED, 0, 0, - MOD_MAP_FLAGS_ABS } }} + {"hp49", + { { + "ROM (ROM)", + 0x00, + 0, + RomInit49, + RomSave49, + RomRead49, + RomWrite49, + MOD_CONFIGURED, + 0x00000, + 0xFFFFF, + }, + { + "Hardware Regs. (HDW)", + 0x19, + 5, + HdwInit, + HdwSave, + HdwRead, + HdwWrite, + MOD_SIZE_CONFIGURED, + 0x00000, + 0x00040, + }, + { + "IRAM (RAM)", + 0x03, + 4, + RamInit49, + RamSave49, + RamRead49, + RamWrite49, + MOD_UNCONFIGURED, + 0, + 0, + }, + { + "Bank Select (CE1)", + 0x05, + 2, + Ce1Init49, + Ce1Save49, + Ce1Read49, + Ce1Write49, + MOD_UNCONFIGURED, + 0, + 0, + }, + { + "ERAM Bank 0 (CE2)", + 0x07, + 3, + Ce2Init49, + Ce2Save49, + Ce2Read49, + Ce2Write49, + MOD_UNCONFIGURED, + 0, + 0, + }, + { "ERAM Bank 1 (NCE3)", 0x01, 1, NCe3Init49, NCe3Save49, NCe3Read49, NCe3Write49, MOD_UNCONFIGURED, 0, 0, + MOD_MAP_FLAGS_ABS } }} }; #define N_DESCRIPTIONS ( sizeof( table ) / sizeof( table[ 0 ] ) ) @@ -336,8 +334,6 @@ void ModSelectDescription( const char* hw ) if ( i == N_DESCRIPTIONS ) { ChfCondition MOD_E_NO_MATCH, CHF_ERROR, hw ChfEnd; ChfSignal(); - } - - else + } else ModRegisterDescription( table[ i ].description ); } diff --git a/src/keyb.c b/src/keyb.c index 74f1305..0a315a8 100644 --- a/src/keyb.c +++ b/src/keyb.c @@ -218,22 +218,16 @@ void KeybPress( const char* key ) /* Post an interrupt request to the CPU */ CpuIntRequest( INT_REQUEST_NMI ); - } - - else { + } else { int in_val, out_bit; if ( sscanf( key, "%x/%x", &out_bit, &in_val ) != 2 ) { ChfCondition MOD_W_BAD_KEY, CHF_WARNING, key ChfEnd; ChfSignal(); - } - - else if ( out_bit < 0 || out_bit >= OUT_BITS ) { + } else if ( out_bit < 0 || out_bit >= OUT_BITS ) { ChfCondition MOD_W_BAD_OUT_BIT, CHF_WARNING, out_bit ChfEnd; ChfSignal(); - } - - else { + } else { /* Update the cur_in array */ cur_in[ out_bit ] |= in_val; @@ -276,22 +270,16 @@ void KeybRelease( const char* key ) /* Reset all 0x8000 lines */ for ( i = 0; i < OUT_BITS; i++ ) cur_in[ i ] &= 0x7FFF; - } - - else { + } else { int in_val, out_bit; if ( sscanf( key, "%x/%x", &out_bit, &in_val ) != 2 ) { ChfCondition MOD_W_BAD_KEY, CHF_WARNING, key ChfEnd; ChfSignal(); - } - - else if ( out_bit < 0 || out_bit >= OUT_BITS ) { + } else if ( out_bit < 0 || out_bit >= OUT_BITS ) { ChfCondition MOD_W_BAD_OUT_BIT, CHF_WARNING, out_bit ChfEnd; ChfSignal(); - } - - else { + } else { /* Update the cur_in array */ cur_in[ out_bit ] &= ~in_val; } diff --git a/src/main.c b/src/main.c index f385309..bc8111b 100644 --- a/src/main.c +++ b/src/main.c @@ -210,7 +210,6 @@ int main( int argc, char* argv[] ) ) ) != CHF_S_OK || ChfGetMessage( CHF_MODULE_ID, MAIN_M_COPYRIGHT, NULL ) == NULL ) fprintf( stderr, "saturn-E-Primary Chf initialization failed (%d)\n", st ); - else break; @@ -232,7 +231,6 @@ int main( int argc, char* argv[] ) ) ) != CHF_S_OK || ChfGetMessage( CHF_MODULE_ID, MAIN_M_COPYRIGHT, NULL ) == NULL ) fprintf( stderr, "saturn-E-Alternate Chf initialization failed (%d)\n", st ); - else break; @@ -283,9 +281,7 @@ int main( int argc, char* argv[] ) /* Invoke Monitor */ void Monitor( void ); Monitor(); - } - - else + } else /* Call Emulator directly */ Emulator(); diff --git a/src/modules.c b/src/modules.c index bb223ea..b77f49c 100644 --- a/src/modules.c +++ b/src/modules.c @@ -334,9 +334,7 @@ static void RebuildPageTable( int lo, int hi ) mod_map.page_table[ page ].rel_base_addr = 0x00000; mod_map.page_table[ page ].read = BadRead; mod_map.page_table[ page ].write = BadWrite; - } - - else { + } else { /* The page is mapped 3.3: If the MOD_MAP_FLAGS_ABS is set in the winner's module description, the base address of the page is set to its @@ -524,7 +522,6 @@ static void ReplaceModMap( struct ModMap** d, const struct ModMap* s ) if ( *d == ( struct ModMap* )NULL ) /* Allocation needed; cache cleared after allocation */ *d = CopyModMap( NewModMap(), s ); - else { CopyModMap( *d, s ); IncPerfCtr( repl_c ); @@ -732,16 +729,12 @@ struct ModCacheTableEntry* SelectConfigVictim( int retry ) FlushCache( mod_map_ptr ); victim = SelectConfigVictim( 0 ); - } - - else { + } else { /* Unable to find a victim; retry is not an option; give up */ ChfCondition MOD_F_NO_VICTIM, CHF_FATAL ChfEnd; ChfSignal(); } - } - - else + } else /* Found a victim; update next-victim index */ mod_map.cache.victim = v; @@ -852,9 +845,7 @@ static void FreeModMap( struct ModMap* p ) cache_head = p->cache.link; free( p ); DecPerfCtr( alloc_c ); - } - - else { + } else { /* Scan the cache; at end, n is either null (!) or points to the cache entry that immediately precedes p */ @@ -990,9 +981,7 @@ void ModInit( void ) /* Reset all modules */ ModReset(); - } - - else { + } else { /* Rebuild page table (not saved on disk) */ RebuildPageTable( 0, N_PAGE_TABLE_ENTRIES - 1 ); } @@ -1099,7 +1088,6 @@ Address ModGetID( void ) if ( mod == N_MOD ) /* All modules are configured */ id = ( Address )0x00000; - else /* Build the module id */ id = ( mod_map.map_info[ mod ].abs_base_addr & 0xFFF00 ) | @@ -1273,16 +1261,12 @@ void ModConfig( Address config_info ) /* All modules are configured - Signal a warning */ ChfCondition MOD_W_BAD_CONFIG, CHF_WARNING, config_info ChfEnd; ChfSignal(); - } - - else { + } else { if ( mod_map.map_info[ mod ].config == MOD_UNCONFIGURED ) { /* The module was unconfigured; configure its size */ mod_map.map_info[ mod ].size = 0x100000 - config_info; mod_map.map_info[ mod ].config = MOD_SIZE_CONFIGURED; - } - - else { + } else { /* The module size was already configured; configure its base address */ mod_map.map_info[ mod ].abs_base_addr = config_info; mod_map.map_info[ mod ].config = MOD_CONFIGURED; @@ -1356,15 +1340,11 @@ void ModUnconfig( Address unconfig_info ) */ ChfCondition MOD_W_BAD_UNCONFIG, CHF_WARNING, unconfig_info ChfEnd; ChfSignal(); - } - - else if ( mod_description[ mod ].r_config == MOD_CONFIGURED ) { + } else if ( mod_description[ mod ].r_config == MOD_CONFIGURED ) { /* The module is automatically configured after reset; it can never be unconfigured. */ - } - - else { + } else { /* Unconfiguring module 'mod': ACCESS UNCONFIG CACHE */ if ( ( nxt = AccessUnconfigCache( mod ) ) != ( struct ModMap* )NULL ) { /* CACHE HIT; switch mod_map_ptr */ @@ -1424,9 +1404,7 @@ void ModUnconfig( Address unconfig_info ) IncPerfCtr( lhit_c ); debug0( DEBUG_C_MOD_CACHE, MOD_I_UNCONFIG_L_HIT ); - } - - else { + } else { /* Continue to use the new map with no caching information, and hope that further configuration activities will link it back in the immediate future. @@ -1588,7 +1566,6 @@ void ModMapCheck( Address addr, char ob[ MOD_MAP_CHECK_OB_SIZE ] ) if ( ( mod = mod_map.page_table[ page ].index ) == MOD_NO_MOD_INDEX ) sprintf( ob, ChfGetMessage( CHF_MODULE_ID, MOD_M_NOT_MAPPED, "" ), addr ); - else { Address rel_addr; rel_addr = mod_map.page_table[ page ].rel_base_addr | offset; diff --git a/src/modules.h b/src/modules.h index daf7148..777760e 100644 --- a/src/modules.h +++ b/src/modules.h @@ -120,6 +120,8 @@ .- */ +#include "cpu.h" + /*--------------------------------------------------------------------------- Data type definitions - require config.h, machdep.h, cpu.h ---------------------------------------------------------------------------*/ diff --git a/src/monitor.c b/src/monitor.c index 51e86a3..6fe41f9 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -355,9 +355,7 @@ void Monitor( void ) if ( InvokeCommand( tk ) ) ChfCondition CPU_W_BAD_MONITOR_CMD, CHF_WARNING, tk ChfEnd; ChfSignal(); - } - - else { + } else { /* Save command */ strcpy( old_cmd, cmd ); diff --git a/src/pack.c b/src/pack.c index 8ab924f..949fafa 100644 --- a/src/pack.c +++ b/src/pack.c @@ -173,9 +173,7 @@ int main( int argc, char* argv[] ) if ( st != CHF_S_OK && st != CHF_F_CATOPEN ) { fprintf( stderr, "Chf initialization failed\n" ); exit( ABNORMAL_EXIT_CODE ); - } - - else { + } else { fprintf( stderr, "Default message catalog open failed; trying alternate\n" ); /* Bring down Chf before initializing it again */ diff --git a/src/romram.c b/src/romram.c index 87efc6d..b866f7e 100644 --- a/src/romram.c +++ b/src/romram.c @@ -550,15 +550,12 @@ void Ce2Init( void ) ( void )memset( mod_status_port_1, 0, sizeof( mod_status_port_1 ) ); new_status = mod_status_hdw.card_status & ~( CE2_CARD_PRESENT | CE2_CARD_WE ); - } - - else { + } else { /* Card present; check write protection */ new_status = mod_status_hdw.card_status | CE2_CARD_PRESENT; if ( access( args.port_1_file_name, W_OK ) == 0 ) new_status |= CE2_CARD_WE; - else { new_status &= ~CE2_CARD_WE; @@ -712,15 +709,12 @@ void NCe3Init( void ) ( void )memset( mod_status_port_2, 0, sizeof( mod_status_port_2 ) ); new_status = mod_status_hdw.card_status & ~( NCE3_CARD_PRESENT | NCE3_CARD_WE ); - } - - else { + } else { /* Card present; check write protection */ new_status = mod_status_hdw.card_status | NCE3_CARD_PRESENT; if ( access( args.port_2_file_name, W_OK ) == 0 ) new_status |= NCE3_CARD_WE; - else { new_status &= ~NCE3_CARD_WE; diff --git a/src/serial.c b/src/serial.c index 690be15..dc2831f 100644 --- a/src/serial.c +++ b/src/serial.c @@ -542,9 +542,7 @@ const char* SerialInit( void ) ChfErrnoCondition; ChfCondition SERIAL_F_OPENPTY, CHF_FATAL ChfEnd; ChfSignal(); - } - - else { + } else { int cur_flags; pty_name = ttyname( slave_pty ); @@ -569,9 +567,7 @@ const char* SerialInit( void ) ChfErrnoCondition; ChfCondition SERIAL_F_OPEN_MASTER, CHF_FATAL, PTY_MASTER ChfEnd; ChfSignal(); - } - - else { + } else { /* Master side opened ok; change permissions and unlock slave side */ if ( grantpt( master_pty ) < 0 ) { @@ -895,9 +891,7 @@ int8 Serial_RBR_Read( void ) /* Pull one character from rbr, if not empty */ if ( FullSlots( rrb ) > 0 ) { Pull( rrb, &rx ); - } - - else { + } else { /* rrb is empty */ #ifndef HP49_SUPPORT @@ -1091,9 +1085,7 @@ void Serial_TBR_Write( int8 d ) /* Pull one character from rbr, if not empty */ if ( EmptySlots( trb ) > 0 ) { Push( trb, d ); - } - - else { + } else { /* trb is full; discard character */ ChfCondition SERIAL_W_FULL_TRB, CHF_WARNING, tcs ChfEnd; ChfSignal(); diff --git a/src/x11.c b/src/x11.c index 5fc4a67..2ecd664 100644 --- a/src/x11.c +++ b/src/x11.c @@ -429,9 +429,7 @@ static void kbdButtonDisarmed( Widget w, XtPointer client_data, XtPointer call_d if ( TimeDiff( event->xbutton.time, arm_time ) > LONG_PRESS_THR ) { /* Button pressed for more than LONG_PRESS_THR; keep it pressed */ XmToggleButtonSetState( w, True, False ); - } - - else + } else #endif if ( event->type == ButtonRelease && event->xbutton.button == 3 ) { @@ -564,9 +562,7 @@ static void fsbButtonPressed( Widget w, XtPointer client_data, XtPointer call_da if ( proceed && !XmStringGetLtoR( fsb_data->value, XmFONTLIST_DEFAULT_TAG, &value ) ) { ChfCondition X11_E_NO_FSB_TSEG, CHF_ERROR ChfEnd; ChfSignal(); - } - - else { + } else { /* Invoke continuation; value is meaningful only when proceed is true. */ @@ -577,9 +573,7 @@ static void fsbButtonPressed( Widget w, XtPointer client_data, XtPointer call_da */ XtFree( value ); } - } - - else { + } else { /* Continuation not set; do nothing */ ChfCondition X11_W_NO_FSB_CONT, CHF_WARNING ChfEnd; ChfSignal(); @@ -630,9 +624,7 @@ static XmString XmStringFromString( char* s, XmString sep, XmString spc ) /* Skip current segment and start a new one */ p++; s = p; - } - - else + } else /* Current segment continues */ p++; } @@ -673,9 +665,7 @@ static ChfAction ErrorDialogHandler( const ChfDescriptor* d, const ChfState s, C No point to use a message window; resignal now. */ act = CHF_RESIGNAL; - } - - else if ( ChfGetModuleId( d ) == SERIAL_CHF_MODULE_ID && ChfGetConditionCode( d ) == SERIAL_I_PTY_NAME ) { + } else if ( ChfGetModuleId( d ) == SERIAL_CHF_MODULE_ID && ChfGetConditionCode( d ) == SERIAL_I_PTY_NAME ) { /* Pseudo-terminal message; this is very important. Put it into the message display area. @@ -693,9 +683,7 @@ static ChfAction ErrorDialogHandler( const ChfDescriptor* d, const ChfState s, C XtSetValues( msg_text_field, xt_args, n ); act = CHF_CONTINUE; - } - - else { + } else { /* If maximum value of error_dialog_count has been reached, resignal. */ @@ -704,11 +692,8 @@ static ChfAction ErrorDialogHandler( const ChfDescriptor* d, const ChfState s, C ChfSignal(); act = CHF_RESIGNAL; - } - - else if ( error_dialog_count > MAX_ERROR_DIALOG_COUNT ) + } else if ( error_dialog_count > MAX_ERROR_DIALOG_COUNT ) act = CHF_RESIGNAL; - else { unsigned char dialog_type = XmDIALOG_INFORMATION; XmString sep = XmStringSeparatorCreate(); @@ -1403,9 +1388,7 @@ static void ResetToggleButtons( Widget w ) /* Disarm the ToggleButton */ XtCallActionProc( w, "Disarm", &xe, NULL, 0 ); - } - - else if ( XtIsComposite( w ) ) { + } else if ( XtIsComposite( w ) ) { WidgetList children; Cardinal num_children; int c; diff --git a/src/x_func.c b/src/x_func.c index 6cc5656..82c1966 100644 --- a/src/x_func.c +++ b/src/x_func.c @@ -181,7 +181,6 @@ static void SetSpeed( Nibble function_code ) /* Notify the user about the speed change */ if ( cpu_status.inner_loop_max ) ChfCondition X_FUNC_I_SET_SPEED, CHF_INFO, new_speed ChfEnd; - else ChfCondition X_FUNC_I_MAX_SPEED, CHF_INFO ChfEnd; @@ -235,9 +234,7 @@ static void KgetContinuation( int proceed, char* file_name ) if ( !proceed ) { ChfCondition X_FUNC_W_ABORTED, CHF_WARNING ChfEnd; ChfSignal(); - } - - else { + } else { /* Ok to proceed; read: - target start address from A[A] - target end address from C[A] @@ -267,9 +264,7 @@ static void SendContinuation( int proceed, char* file_name ) if ( !proceed ) { ChfCondition X_FUNC_W_ABORTED, CHF_WARNING ChfEnd; ChfSignal(); - } - - else { + } else { /* Ok to proceed; read: - source start address from A[A] - source end address from C[A] @@ -319,9 +314,7 @@ static void SetupXfer( int msg, const char* def_msg, FsbContinuation cont ) XtFree( fsb_file ); ( void )CpuHaltRequest(); - } - - else { + } else { ChfCondition X_FUNC_E_NO_HALT, CHF_ERROR ChfEnd; ChfSignal(); } @@ -337,7 +330,6 @@ static void Kget( Nibble function_code ) /* Setup File Selection Box if transfers are *not* in batch mode */ if ( !args.batchXfer ) SetupXfer( X_FUNC_M_KGET, "Kget", KgetContinuation ); - else { /* Ok to proceed; read: - file name from @D1 @@ -370,7 +362,6 @@ static void Send( Nibble function_code ) /* Setup File Selection Box if transfers are *not* in batch mode */ if ( !args.batchXfer ) SetupXfer( X_FUNC_M_SEND, "Send", SendContinuation ); - else { /* Ok to proceed; read: - file name from @D1 @@ -449,7 +440,6 @@ void ExtendedFunction( Nibble function_code ) ChfCondition X_FUNC_W_BAD_CODE, CHF_WARNING, function_code ChfEnd; ChfSignal(); } - /* Dispatch */ else function[ ( int )function_code ]( function_code );