mirror of
https://github.com/holub/mame
synced 2025-06-04 20:06:28 +03:00
From: Atari Ace <atari_ace@verizon.net>
Date: Tue, Dec 22, 2009 at 4:44 PM Subject: [patch] Fix srcclean/src2html bugs, misbalanced tokens and visible whitespace errors To: submit@mamedev.org Cc: atariace@hotmail.com Hi mamedev, While experimenting with srcclean and src2html as indentation validators, I stumbled across a couple of bugs. The first is that srcclean doesn't properly handle /*...*//. It sees the last / char at the end as the second / of an inline comment, where it might be a division token or the start of either type of comment. The second bug is that src2html improperly handles strings with embedded quotes preceded by escaped backslashes, e.g. "ab\\\"cd". It believes the string terminated in the middle, and the last quote starts a new string. This issue is unlikely in actual code, but should be handled correctly. The first patch fixes these, and a some cases where there are dangling/missing tokens which my validation tools are noticing. These occur in some unused macros, dead code sections, and in some macros that are deliberately misbalanced (v9938.c, psx.c). In the deliberate cases, I balanced the braces by making exactly one open and one close macro and using those throughout. The second patch is then a set of visible whitespace "problems". Cases where the closing brace isn't at the same indent level as the open brace, and some cases where the indent level isn't a multiple of four. In the case of ssv.c I folded the assignments into init_ssv() to simplify the code and restore the brace balance, otherwise I kept to simply adding or removing whitespace. ~aa
This commit is contained in:
parent
668dc94b00
commit
505f0d7caf
@ -140,7 +140,7 @@ INLINE v810_state *get_safe_token(const device_config *device)
|
||||
#define D16(x) (((x)&0xffff)|(((x)&0x8000)?0xffff0000:0))
|
||||
#define D26(x,y) ((y)|((x&0x3ff)<<16 )|((x&0x200)?0xfc000000:0))
|
||||
#define D9(x) ((x&0x1ff)|((x&0x100)?0xfffffe00:0))
|
||||
#define SO(opcode) ((opcode)&0xfc00)>>10)
|
||||
#define SO(opcode) (((opcode)&0xfc00)>>10)
|
||||
|
||||
#define CHECK_CY(x) cpustate->PSW=(cpustate->PSW & ~8)|(((x) & (((UINT64)1) << 32)) ? 8 : 0)
|
||||
#define CHECK_OVADD(x,y,z) cpustate->PSW=(cpustate->PSW & ~0x00000004) |(( ((x) ^ (z)) & ((y) ^ (z)) & 0x80000000) ? 4: 0)
|
||||
|
@ -1567,7 +1567,6 @@ static int init_tables(void)
|
||||
for (i=0; i<13; i++)
|
||||
logerror(", [%02i] %4x", i*2, tl_tab[ x*2 /*+1*/ + i*2*TL_RES_LEN ]);
|
||||
logerror("\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/*logerror("FM.C: TL_TAB_LEN = %i elements (%i bytes)\n",TL_TAB_LEN, (int)sizeof(tl_tab));*/
|
||||
|
@ -1777,7 +1777,6 @@ static int init_tables(void)
|
||||
for (i=0; i<13; i++)
|
||||
logerror(", [%02i] %4x", i*2, tl_tab[ x*2 /*+1*/ + i*2*TL_RES_LEN ]);
|
||||
logerror("\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/*logerror("FM.C: TL_TAB_LEN = %i elements (%i bytes)\n",TL_TAB_LEN, (int)sizeof(tl_tab));*/
|
||||
|
@ -1607,6 +1607,8 @@ void v9938_update_mouse_state(int which, int mx_delta, int my_delta, int button_
|
||||
#define pre_loop \
|
||||
while ((cnt-=delta) > 0) {
|
||||
|
||||
#define post_loop \
|
||||
}
|
||||
|
||||
/* Loop over DX, DY */
|
||||
#define post__x_y(MX) \
|
||||
@ -1618,7 +1620,7 @@ void v9938_update_mouse_state(int which, int mx_delta, int my_delta, int button_
|
||||
ANX=NX; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
post_loop
|
||||
|
||||
/* Loop over DX, SY, DY */
|
||||
#define post__xyy(MX) \
|
||||
@ -1628,7 +1630,7 @@ void v9938_update_mouse_state(int which, int mx_delta, int my_delta, int button_
|
||||
else \
|
||||
ADX=DX; \
|
||||
} \
|
||||
}
|
||||
post_loop
|
||||
|
||||
/* Loop over SX, DX, SY, DY */
|
||||
#define post_xxyy(MX) \
|
||||
@ -1641,7 +1643,7 @@ void v9938_update_mouse_state(int which, int mx_delta, int my_delta, int button_
|
||||
ANX=NX; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
post_loop
|
||||
|
||||
/*************************************************************/
|
||||
/** Function prototypes **/
|
||||
@ -1894,7 +1896,7 @@ void SrchEngine(void)
|
||||
VDPStatus[2]&=0xEF; /* Border not detected */ \
|
||||
break; \
|
||||
} \
|
||||
}
|
||||
post_loop
|
||||
|
||||
switch (ScrMode) {
|
||||
default:
|
||||
@ -1952,7 +1954,8 @@ void LineEngine(void)
|
||||
ASX&=1023; /* Mask to 10 bits range */ \
|
||||
if (ADX++==NX || (DX&MX)) \
|
||||
break; \
|
||||
}
|
||||
post_loop
|
||||
|
||||
#define post_lineymaj(MX) \
|
||||
DY+=TY; \
|
||||
if ((ASX-=NY)<0) { \
|
||||
@ -1962,7 +1965,7 @@ void LineEngine(void)
|
||||
ASX&=1023; /* Mask to 10 bits range */ \
|
||||
if (ADX++==NX || (DX&MX)) \
|
||||
break; \
|
||||
}
|
||||
post_loop
|
||||
|
||||
if ((VDP[45]&0x01)==0)
|
||||
/* X-Axis is major direction */
|
||||
|
@ -146,6 +146,7 @@ static WRITE16_HANDLER( pirates_out_w )
|
||||
static CUSTOM_INPUT( prot_r )
|
||||
{
|
||||
// static int prot = 0xa3;
|
||||
// offs_t pc;
|
||||
int bit;
|
||||
|
||||
// logerror("%s: IN1_r\n",cpuexec_describe_context(field->port->machine));
|
||||
@ -155,16 +156,17 @@ static CUSTOM_INPUT( prot_r )
|
||||
602e and 62a6 */
|
||||
/* For Genix, see 6576 for setting values and 67c2,d3b4 and dbc2 for tests. */
|
||||
|
||||
if (cpu_get_pc(cputag_get_cpu(field->port->machine, "main")) == 0x6134)
|
||||
pc = cpu_get_pc(cputag_get_cpu(field->port->machine, "main"));
|
||||
if (pc == 0x6134)
|
||||
{
|
||||
bit = prot & 1;
|
||||
prot = (prot >> 1) | (bit << 7);
|
||||
}
|
||||
else if (cputag_get_cpu(field->port->machine, "main")) == 0x6020)
|
||||
else if (pc == 0x6020)
|
||||
bit = 0;
|
||||
else if (cputag_get_cpu(field->port->machine, "main")) == 0x6168)
|
||||
else if (pc == 0x6168)
|
||||
bit = 0;
|
||||
else if (cputag_get_cpu(field->port->machine, "main")) == 0x61cc)
|
||||
else if (pc == 0x61cc)
|
||||
bit = 1;
|
||||
else
|
||||
#endif
|
||||
|
@ -2795,7 +2795,7 @@ VIDEO_UPDATE( cps1 )
|
||||
#if 0
|
||||
if ( (cps2_port(screen->machine, CPS2_OBJ_BASE) != 0x7080 && cps2_port(screen->machine, CPS2_OBJ_BASE) != 0x7000) ||
|
||||
cps2_port(screen->machine, CPS2_OBJ_UK1) != 0x807d ||
|
||||
(cps2_port(screen->machine, CPS2_OBJ_UK2) != 0x0000 && cps2_port(screen->machine, CPS2_OBJ_UK2) != 0x1101 && cps2_port(screen->machine, CPS2_OBJ_UK2) != 0x0001) ||
|
||||
(cps2_port(screen->machine, CPS2_OBJ_UK2) != 0x0000 && cps2_port(screen->machine, CPS2_OBJ_UK2) != 0x1101 && cps2_port(screen->machine, CPS2_OBJ_UK2) != 0x0001))
|
||||
popmessage("base %04x uk1 %04x uk2 %04x",
|
||||
cps2_port(screen->machine, CPS2_OBJ_BASE),
|
||||
cps2_port(screen->machine, CPS2_OBJ_UK1),
|
||||
|
@ -1154,19 +1154,23 @@ INLINE void decode_tpage( running_machine *machine, struct PSXGPU *p_psxgpu, UIN
|
||||
#define FLATTEXTUREDRECTANGLEUPDATE \
|
||||
n_u += n_du;
|
||||
|
||||
#define TEXTURE4BIT( TXV, TXU ) \
|
||||
#define TEXTURE_LOOP \
|
||||
while( n_distance > 0 ) \
|
||||
{ \
|
||||
{
|
||||
|
||||
#define TEXTURE_ENDLOOP \
|
||||
}
|
||||
|
||||
#define TEXTURE4BIT( TXV, TXU ) \
|
||||
TEXTURE_LOOP \
|
||||
n_bgr = p_clut[ ( *( m_p_p_vram[ n_ty + TXV ] + n_tx + ( TXU >> 2 ) ) >> ( ( TXU & 0x03 ) << 2 ) ) & 0x0f ];
|
||||
|
||||
#define TEXTURE8BIT( TXV, TXU ) \
|
||||
while( n_distance > 0 ) \
|
||||
{ \
|
||||
TEXTURE_LOOP \
|
||||
n_bgr = p_clut[ ( *( m_p_p_vram[ n_ty + TXV ] + n_tx + ( TXU >> 1 ) ) >> ( ( TXU & 0x01 ) << 3 ) ) & 0xff ];
|
||||
|
||||
#define TEXTURE15BIT( TXV, TXU ) \
|
||||
while( n_distance > 0 ) \
|
||||
{ \
|
||||
TEXTURE_LOOP \
|
||||
n_bgr = *( m_p_p_vram[ n_ty + TXV ] + n_tx + TXU );
|
||||
|
||||
#define TEXTUREWINDOW4BIT( TXV, TXU ) TEXTURE4BIT( ( TXV & m_n_twh ), ( TXU & m_n_tww ) )
|
||||
@ -1174,22 +1178,19 @@ INLINE void decode_tpage( running_machine *machine, struct PSXGPU *p_psxgpu, UIN
|
||||
#define TEXTUREWINDOW15BIT( TXV, TXU ) TEXTURE15BIT( ( TXV & m_n_twh ), ( TXU & m_n_tww ) )
|
||||
|
||||
#define TEXTUREINTERLEAVED4BIT( TXV, TXU ) \
|
||||
while( n_distance > 0 ) \
|
||||
{ \
|
||||
TEXTURE_LOOP \
|
||||
int n_xi = ( ( TXU >> 2 ) & ~0x3c ) + ( ( TXV << 2 ) & 0x3c ); \
|
||||
int n_yi = ( TXV & ~0xf ) + ( ( TXU >> 4 ) & 0xf ); \
|
||||
n_bgr = p_clut[ ( *( m_p_p_vram[ n_ty + n_yi ] + n_tx + n_xi ) >> ( ( TXU & 0x03 ) << 2 ) ) & 0x0f ];
|
||||
|
||||
#define TEXTUREINTERLEAVED8BIT( TXV, TXU ) \
|
||||
while( n_distance > 0 ) \
|
||||
{ \
|
||||
TEXTURE_LOOP \
|
||||
int n_xi = ( ( TXU >> 1 ) & ~0x78 ) + ( ( TXU << 2 ) & 0x40 ) + ( ( TXV << 3 ) & 0x38 ); \
|
||||
int n_yi = ( TXV & ~0x7 ) + ( ( TXU >> 5 ) & 0x7 ); \
|
||||
n_bgr = p_clut[ ( *( m_p_p_vram[ n_ty + n_yi ] + n_tx + n_xi ) >> ( ( TXU & 0x01 ) << 3 ) ) & 0xff ];
|
||||
|
||||
#define TEXTUREINTERLEAVED15BIT( TXV, TXU ) \
|
||||
while( n_distance > 0 ) \
|
||||
{ \
|
||||
TEXTURE_LOOP \
|
||||
int n_xi = TXU; \
|
||||
int n_yi = TXV; \
|
||||
n_bgr = *( m_p_p_vram[ n_ty + n_yi ] + n_tx + n_xi );
|
||||
@ -1209,7 +1210,7 @@ INLINE void decode_tpage( running_machine *machine, struct PSXGPU *p_psxgpu, UIN
|
||||
p_vram++; \
|
||||
PIXELUPDATE \
|
||||
n_distance--; \
|
||||
}
|
||||
TEXTURE_ENDLOOP
|
||||
|
||||
#define TRANSPARENTPIXEL( PIXELUPDATE ) \
|
||||
if( n_bgr != 0 ) \
|
||||
@ -1232,7 +1233,7 @@ INLINE void decode_tpage( running_machine *machine, struct PSXGPU *p_psxgpu, UIN
|
||||
p_vram++; \
|
||||
PIXELUPDATE \
|
||||
n_distance--; \
|
||||
}
|
||||
TEXTURE_ENDLOOP
|
||||
|
||||
#define TEXTUREFILL( PIXELUPDATE, TXU, TXV ) \
|
||||
if( n_distance > ( (INT32)m_n_drawarea_x2 - n_x ) + 1 ) \
|
||||
|
@ -1753,12 +1753,12 @@ bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09
|
||||
\----------|----------|----------|----------|----------|----------|----------|---------*/
|
||||
|
||||
#define STV_VDP2_LNCLEN ((stv_vdp2_regs[0x0e8/4] >> 16)&0x0000ffff)
|
||||
#define STV_VDP2_SPLCEN ((STV_VDP2_LNCLEN) & 0x0020) >> 5)
|
||||
#define STV_VDP2_R0LCEN ((STV_VDP2_LNCLEN) & 0x0010) >> 4)
|
||||
#define STV_VDP2_N3LCEN ((STV_VDP2_LNCLEN) & 0x0008) >> 3)
|
||||
#define STV_VDP2_N2LCEN ((STV_VDP2_LNCLEN) & 0x0004) >> 2)
|
||||
#define STV_VDP2_N1LCEN ((STV_VDP2_LNCLEN) & 0x0002) >> 1)
|
||||
#define STV_VDP2_N0LCEN ((STV_VDP2_LNCLEN) & 0x0001) >> 0)
|
||||
#define STV_VDP2_SPLCEN ((STV_VDP2_LNCLEN & 0x0020) >> 5)
|
||||
#define STV_VDP2_R0LCEN ((STV_VDP2_LNCLEN & 0x0010) >> 4)
|
||||
#define STV_VDP2_N3LCEN ((STV_VDP2_LNCLEN & 0x0008) >> 3)
|
||||
#define STV_VDP2_N2LCEN ((STV_VDP2_LNCLEN & 0x0004) >> 2)
|
||||
#define STV_VDP2_N1LCEN ((STV_VDP2_LNCLEN & 0x0002) >> 1)
|
||||
#define STV_VDP2_N0LCEN ((STV_VDP2_LNCLEN & 0x0001) >> 0)
|
||||
|
||||
/* 1800ea - Special Priority Mode
|
||||
bit-> /----15----|----14----|----13----|----12----|----11----|----10----|----09----|----08----\
|
||||
|
@ -1357,7 +1357,7 @@ void nvsram( offs_t offset, UINT16 data )
|
||||
if( i%16 == 0 )
|
||||
logerror( "%04X: ", offset );
|
||||
logerror( "%02X ", data );
|
||||
ascii[i%16] = ( data > 0x20) ? data : '.' );
|
||||
ascii[i%16] = (data > 0x20) ? data : '.';
|
||||
if( i%16 == 15 )
|
||||
logerror( "| %-16.16s\n", ascii );
|
||||
}
|
||||
|
@ -590,6 +590,7 @@ static int output_file(file_type type, int srcrootlen, int dstrootlen, const ast
|
||||
int quotes_are_linked = FALSE;
|
||||
char in_quotes = 0;
|
||||
int curcol = 0;
|
||||
int escape = 0;
|
||||
|
||||
/* start with the line number */
|
||||
dstptr += sprintf(dstptr, "<span class=\"linenum\">%5d</span> ", linenum++);
|
||||
@ -704,7 +705,7 @@ static int output_file(file_type type, int srcrootlen, int dstrootlen, const ast
|
||||
}
|
||||
|
||||
/* track closing quotes */
|
||||
else if (!in_comment && !in_inline_comment && in_quotes && ch == in_quotes && (type != FILE_TYPE_C || srcptr[-2] != '\\' || srcptr[-3] == '\\'))
|
||||
else if (!in_comment && !in_inline_comment && in_quotes && ch == in_quotes && !escape)
|
||||
{
|
||||
if (quotes_are_linked)
|
||||
dstptr += sprintf(dstptr, "</a>");
|
||||
@ -727,6 +728,10 @@ static int output_file(file_type type, int srcrootlen, int dstrootlen, const ast
|
||||
*dstptr++ = ch;
|
||||
curcol++;
|
||||
}
|
||||
|
||||
/* Update escape state */
|
||||
if (in_quotes)
|
||||
escape = (ch == '\\' && type == FILE_TYPE_C) ? !escape : 0;
|
||||
}
|
||||
|
||||
/* finish inline comments */
|
||||
|
@ -128,6 +128,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (!in_c_string && !in_cpp_comment)
|
||||
{
|
||||
int consume = TRUE;
|
||||
|
||||
/* track whether or not we are within a C-style comment */
|
||||
if (!in_c_comment && ch == '/' && original[src] == '*')
|
||||
in_c_comment = TRUE;
|
||||
@ -135,8 +137,17 @@ int main(int argc, char *argv[])
|
||||
in_c_comment = FALSE;
|
||||
|
||||
/* track whether or not we are within a C++-style comment */
|
||||
if (!in_c_comment && ch == '/' && original[src] == '/')
|
||||
else if (!in_c_comment && ch == '/' && original[src] == '/')
|
||||
in_cpp_comment = TRUE;
|
||||
else
|
||||
consume = FALSE;
|
||||
|
||||
if (consume)
|
||||
{
|
||||
modified[dst++] = ch;
|
||||
col++;
|
||||
ch = original[src++];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user