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:
commit
2a476e19e9
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue