Category : Files from Magazines
Archive   : CUJ0894.ZIP
Filename : ISGETFFL.C

 
Output of file : ISGETFFL.C contained in archive : CUJ0894.ZIP
---------------- Listing 11: member function _Getffld(char *) ---------

// isgetffl -- istream::_Getffld(char *)
#include
#include
#include
#include
#include "xmath.h"

int istream::_Getffld(char ac[MAX_EXP_DIG+MAX_SIG_DIG+16])
{ // extract a floating field
char *p, seen;
int ch, nsig;
int pten;
p = ac, ch = rdbuf()->sbumpc();
pten = 0;
if (ch == '+' || ch == '-')
*p++ = ch, ch = rdbuf()->sbumpc();
for (seen = 0; ch == '0'; ch = rdbuf()->sbumpc(), seen = 1)
; // strip leading zeros
if (seen)
*p++ = '0'; // put one back
for (nsig = 0; isdigit(ch); ch = rdbuf()->sbumpc(), seen = 1)
if (nsig < MAX_SIG_DIG)
*p++ = ch, ++nsig;
else
++pten;
if (ch == localeconv()->decimal_point[0])
*p++ = ch, ch = rdbuf()->sbumpc();
if (nsig == 0)
{ // strip zeros after point
for (; ch == '0'; ch = rdbuf()->sbumpc(), seen = 1)
--pten;
if (pten < 0)
*p++ = '0', ++pten; // put one back
}
for (; isdigit(ch); ch = rdbuf()->sbumpc(), seen = 1)
if (nsig < MAX_SIG_DIG)
*p++ = ch, ++nsig;
if (seen && (ch == 'e' || ch == 'E'))
{ // parse exponent
*p++ = ch, ch = rdbuf()->sbumpc();
if (ch == '+' || ch == '-')
*p++ = ch, ch = rdbuf()->sbumpc();
for (seen = 0; ch == '0'; ch = rdbuf()->sbumpc(), seen = 1)
; // strip leading exponent zeros
if (seen)
*p++ = '0'; // put one back
for (nsig = 0; isdigit(ch); ch = rdbuf()->sbumpc(), seen = 1)
if (nsig < MAX_EXP_DIG)
*p++ = ch, ++nsig;
}
if (ch != EOF)
rdbuf()->sputbackc(ch);
if (!seen)
p = ac;
*p = '\0';
return (pten);
}


  3 Responses to “Category : Files from Magazines
Archive   : CUJ0894.ZIP
Filename : ISGETFFL.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/