NOT appropiate exception if just ; entered
Brought to you by:
evenbit
// if just a delimiter entered,
// does not throw ex.ConversionError
program bugInExceptInConv;
#include( "stdlib.hhf" )
static
inStr: string;
u32: uns32;
nums: cset:= {'0'..'9'};
begin bugInExceptInConv;
forever
try
stdout.put( "Testing 'input number as string' : " );
stdin.flushInput();
stdin.a_gets();
mov( eax, inStr );
conv.strTou32( inStr, 0 );
mov( eax, u32 );
stdout.put( nl "u32 = ", u32, nl nl );
exception( ex.ConversionError )
stdout.puts
(
nl "Input value contained illegal characters. Re-enter. " nl
);
exception( ex.ValueOutOfRange )
stdout.puts
(
nl "Input value was NOT in an acceptable range. Re-enter. " nl
);
endtry;
str.cpy( "", inStr );
str.free( inStr );
endfor;
end bugInExceptInConv;
Logged In: YES
user_id=2022655
Originator: YES
suggest adding these two lines in file conv_atou32.hla
whileDelimLoop:
NextChar;
cmp( eax, $0 ); // ADDED to handle case of zero length string //
je convError; // ADDED to handle case of zero length string //
cmp( eax, $80 );
jae IllegalChar;
bt( eax, (type dword Delimiters ) );
jc whileDelimLoop;