Hi!
12-Июн-2006 04:55 [EMAIL PROTECTED] (Blair Campbell) wrote to
[EMAIL PROTECTED]:
BC> +++ cmdinput.c 12 Jun 2006 04:55:42 -0000 1.7
BC> static unsigned orgx, orgy; /* start of current line */
BC> +int mywherex( void )
BC> + return( int )( *( ( char far * )MK_FP( 0x0040, 0x0050 ) ) + 1 );
Bug! Because in TC/BC `char' is signed by default, in video modes with
132 columns (more than 128 columns) you get sign extension and you
mywherex() returns -126 instead 130.
BC> +static int mywherey( void )
And why mywherey() is static, whereas mywherex() - not?
BC> + return( int )( *( ( char far * )MK_FP( 0x0040, 0x0051 ) ) + 1 );
BC> +}
Second, code above not bug, but wrong, because you return position
only on video page 0, whereas active may be another video page. Ie., you
should use byte at 0:62 as index in array of positions:
typedef unsigned char byte; /* eliminate troubles with sign extension */
#define MK_PTR(type,seg,ofs) \
((type FAR*) MK_FP (seg, ofs)) /* safer edition of MK_FP */
typedef struct { byte col, row; } SCRPOS;
#define _scr_page (* MK_PTR (volatile const byte, 0, 0x462))
#define _scr_pos_array MK_PTR (volatile const SCRPOS, 0, 0x450)
unsigned mywherex (void) {
return _scr_pos_array [_scr_page].col + 1;
}
unsigned mywherey (void) {
return _scr_pos_array [_scr_page].row + 1;
}
BC> +void outc(char c)
BC> + fflush( stdout );
BC> write( 1, &c, 1 );
Why not use fwrite() here?
BC> +++ fcompl2.c 12 Jun 2006 04:55:42 -0000 1.4
BC> +#undef putchar
BC> +#define putchar outc
Why not use outc() explicitly?!
BC> +++ cbreak.c 12 Jun 2006 04:55:42 -0000 1.3
BC> +void mycprintf( char *fmt, ... )
BC> + vsprintf( buffer, fmt, args );
BC> +#define cputs mycprintf
Then you in trouble, if there will be encountered "%" in string.
BC> +++ prprompt.c 12 Jun 2006 04:55:42 -0000 1.5
BC> +#define putchar outc
Same question: why not use outc() explicitly, especially you anyway
change all occurrence of putchar()?!
BC> - case 'E': putchar("\33"); break; /* Decimal 27 */
BC> - case 'H': putchar("\10"); break; /* Decimal 8 */
BC> + case 'E': putchar('27'); break; /* Decimal 27 */
BC> + case 'H': putchar('8'); break; /* Decimal 8 */
Bug! You should omit apostrophes (use "outc(8)"), or add backslash
("outc('\x8')").
_______________________________________________
Freedos-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freedos-devel