1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-07-01 09:10:37 +00:00

Merge pull request #153 from lstricklan/development

Fixes to libqb.cpp for random file record length and to msbin.c for MBF encoding
This commit is contained in:
Fellippe Heitor 2021-03-24 01:28:31 -03:00 committed by GitHub
commit 2a476e19e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View file

@ -13037,7 +13037,7 @@ void sub_open(qbs *name,int32 type,int32 access,int32 sharing,int32 i,int64 reco
if (type==1){//set record length
f->record_length=128;
if (passed) if (record_length!=-1) f->record_length=record_length;
f->field_buffer=(uint8*)calloc(record_length,1);
f->field_buffer=(uint8*)calloc(f->record_length,1);
}
if (type==5){//seek eof

View file

@ -214,7 +214,7 @@ int32 _dieeetomsbin(double *src8, double *dest8)
/* Make a clobberable copy of the source number */
memcpy(ieee,src8,8); //strncpy((char *)ieee,(char *)src8,8);
for (i=0; i<8; i++) msbin[i] = 0;
memset(msbin, 0, sizeof(*dest8)); //for (i=0; i<8; i++) msbin[i] = 0;
/* If all are zero in src8, the msbin should be zero */
for (i=0; i<8; i++) any_on |= ieee[i];
@ -222,12 +222,15 @@ int32 _dieeetomsbin(double *src8, double *dest8)
sign = ieee[7] & 0x80;
msbin[6] |= sign;
msbin_exp = (unsigned)(ieee[7] & 0x7f) * 0x10;
msbin_exp = (unsigned)(ieee[7] & 0x7f) << 4; //(unsigned)(ieee[7] & 0x7f) * 0x10;
msbin_exp += ieee[6] >> 4;
if (msbin_exp-0x3ff > 0x80) return 1;
msbin[7] = msbin_exp - 0x3ff + 0x80 + 1;
// verify the exponent is in range for MBF encoding
msbin_exp = msbin_exp - 0x3ff + 0x80 + 1;
if ((msbin_exp & 0xff00) != 0) return 1;
msbin[7] = msbin_exp;
// if (msbin_exp-0x3ff > 0x80) return 1;
// msbin[7] = msbin_exp - 0x3ff + 0x80 + 1;
/* The ieee mantissa must be shifted up 3 bits */
ieee[6] &= 0x0f; /* mask out the exponent in the second byte */