Subversion Repositories Kolibri OS

Rev

Rev 4874 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4874 Rev 4921
Line 146... Line 146...
146
#define FLOATING_POINT
146
#define FLOATING_POINT
147
#endif
147
#endif
148
#endif
148
#endif
Line 149... Line 149...
149
 
149
 
-
 
150
#ifdef STRING_ONLY
150
#ifdef STRING_ONLY
151
#undef _newlib_flockfile_start
151
#undef _flockfile
152
#undef _newlib_flockfile_exit
-
 
153
#undef _newlib_flockfile_end
152
#undef _funlockfile
154
#define _newlib_flockfile_start(x) {}
153
#define _flockfile(x) {}
155
#define _newlib_flockfile_exit(x) {}
154
#define _funlockfile(x) {}
156
#define _newlib_flockfile_end(x) {}
155
#define _ungetc_r _sungetc_r
157
#define _ungetc_r _sungetc_r
156
#define __srefill_r __ssrefill_r
158
#define __srefill_r __ssrefill_r
157
#define _fread_r _sfread_r
159
#define _fread_r _sfread_r
Line 158... Line 160...
158
#endif
160
#endif
159
 
161
 
160
#ifdef FLOATING_POINT
162
#ifdef FLOATING_POINT
-
 
163
#include 
Line 161... Line 164...
161
#include 
164
#include 
162
#include 
165
#include 
163
 
166
 
164
/* Currently a test is made to see if long double processing is warranted.
167
/* Currently a test is made to see if long double processing is warranted.
Line 170... Line 173...
170
extern _LONG_DOUBLE _strtold _PARAMS((char *s, char **sptr));
173
extern _LONG_DOUBLE _strtold _PARAMS((char *s, char **sptr));
171
#endif
174
#endif
Line 172... Line 175...
172
 
175
 
Line 173... Line -...
173
#include "floatio.h"
-
 
174
 
176
#include "floatio.h"
175
#if ((MAXEXP+MAXFRACT+3) > MB_LEN_MAX)
-
 
176
#  define BUF (MAXEXP+MAXFRACT+3)        /* 3 = sign + decimal point + NUL */
-
 
177
#else
-
 
Line 178... Line 177...
178
#  define BUF MB_LEN_MAX
177
 
179
#endif
178
#define BUF (MAXEXP+MAXFRACT+MB_LEN_MAX+2) /* decimal point + sign + NUL */
180
 
179
 
181
/* An upper bound for how long a long prints in decimal.  4 / 13 approximates
180
/* An upper bound for how long a long prints in decimal.  4 / 13 approximates
Line 239... Line 238...
239
#define	CT_CCL		1	/* %[...] conversion */
238
#define	CT_CCL		1	/* %[...] conversion */
240
#define	CT_STRING	2	/* %s conversion */
239
#define	CT_STRING	2	/* %s conversion */
241
#define	CT_INT		3	/* integer, i.e., strtol or strtoul */
240
#define	CT_INT		3	/* integer, i.e., strtol or strtoul */
242
#define	CT_FLOAT	4	/* floating, i.e., strtod */
241
#define	CT_FLOAT	4	/* floating, i.e., strtod */
Line 243... Line -...
243
 
-
 
244
#if 0
242
 
245
#define u_char unsigned char
-
 
246
#endif
-
 
247
#define u_char char
243
#define u_char unsigned char
Line 248... Line 244...
248
#define u_long unsigned long
244
#define u_long unsigned long
249
 
245
 
250
#ifndef _NO_LONGLONG
246
#ifndef _NO_LONGLONG
Line 265... Line 261...
265
_DEFUN(VFSCANF, (fp, fmt, ap),
261
_DEFUN(VFSCANF, (fp, fmt, ap),
266
       register FILE *fp _AND
262
       register FILE *fp _AND
267
       _CONST char *fmt _AND
263
       _CONST char *fmt _AND
268
       va_list ap)
264
       va_list ap)
269
{
265
{
-
 
266
  struct _reent *reent = _REENT;
-
 
267
 
270
  CHECK_INIT(_REENT, fp);
268
  CHECK_INIT(reent, fp);
271
  return __SVFSCANF_R (_REENT, fp, fmt, ap);
269
  return __SVFSCANF_R (reent, fp, fmt, ap);
272
}
270
}
Line 273... Line 271...
273
 
271
 
274
int
272
int
275
_DEFUN(__SVFSCANF, (fp, fmt0, ap),
273
_DEFUN(__SVFSCANF, (fp, fmt0, ap),
Line 494... Line 492...
494
		 : va_arg (ap, void *)))))
492
		 : va_arg (ap, void *)))))
495
#else
493
#else
496
# define GET_ARG(n, ap, type) (va_arg (ap, type))
494
# define GET_ARG(n, ap, type) (va_arg (ap, type))
497
#endif
495
#endif
Line 498... Line 496...
498
 
496
 
Line 499... Line 497...
499
  _flockfile (fp);
497
  _newlib_flockfile_start (fp);
Line 500... Line 498...
500
 
498
 
501
  ORIENT (fp, -1);
499
  ORIENT (fp, -1);
Line 509... Line 507...
509
  for (;;)
507
  for (;;)
510
    {
508
    {
511
#ifndef _MB_CAPABLE
509
#ifndef _MB_CAPABLE
512
      wc = *fmt;
510
      wc = *fmt;
513
#else
511
#else
514
      nbytes = __mbtowc (rptr, &wc, fmt, MB_CUR_MAX, __locale_charset (),
512
      nbytes = __mbtowc (rptr, &wc, (char *) fmt, MB_CUR_MAX,
515
			 &state);
513
			 __locale_charset (), &state);
516
      if (nbytes < 0) {
514
      if (nbytes < 0) {
517
	wc = 0xFFFD; /* Unicode replacement character */
515
	wc = 0xFFFD; /* Unicode replacement character */
518
	nbytes = 1;
516
	nbytes = 1;
519
	memset (&state, 0, sizeof (state));
517
	memset (&state, 0, sizeof (state));
520
      }
518
      }
Line 793... Line 791...
793
 
791
 
794
	  /*
792
	  /*
795
	   * Disgusting backwards compatibility hacks.	XXX
793
	   * Disgusting backwards compatibility hacks.	XXX
796
	   */
794
	   */
797
	case '\0':		/* compat */
795
	case '\0':		/* compat */
798
	  _funlockfile (fp);
796
	  _newlib_flockfile_exit (fp);
Line 799... Line 797...
799
	  return EOF;
797
	  return EOF;
800
 
798
 
801
	default:		/* compat */
799
	default:		/* compat */
Line 1285... Line 1283...
1285
	  long zeroes, exp_adjust;
1283
	  long zeroes, exp_adjust;
1286
	  char *exp_start = NULL;
1284
	  char *exp_start = NULL;
1287
	  unsigned width_left = 0;
1285
	  unsigned width_left = 0;
1288
	  char nancount = 0;
1286
	  char nancount = 0;
1289
	  char infcount = 0;
1287
	  char infcount = 0;
-
 
1288
	  const char *decpt = _localeconv_r (rptr)->decimal_point;
-
 
1289
#ifdef _MB_CAPABLE
-
 
1290
	  int decptpos = 0;
-
 
1291
#endif
1290
#ifdef hardway
1292
#ifdef hardway
1291
	  if (width == 0 || width > sizeof (buf) - 1)
1293
	  if (width == 0 || width > sizeof (buf) - 1)
1292
#else
1294
#else
1293
	  /* size_t is unsigned, hence this optimisation */
1295
	  /* size_t is unsigned, hence this optimisation */
1294
	  if (width - 1 > sizeof (buf) - 2)
1296
	  if (width - 1 > sizeof (buf) - 2)
Line 1413... Line 1415...
1413
		    {
1415
		    {
1414
		      infcount = 8;
1416
		      infcount = 8;
1415
		      goto fok;
1417
		      goto fok;
1416
		    }
1418
		    }
1417
		  break;
1419
		  break;
1418
		case '.':
-
 
1419
		  if (flags & DPTOK)
-
 
1420
		    {
-
 
1421
		      flags &= ~(SIGNOK | DPTOK);
-
 
1422
		      leading_zeroes = zeroes;
-
 
1423
		      goto fok;
-
 
1424
		    }
-
 
1425
		  break;
-
 
1426
		case 'e':
1420
		case 'e':
1427
		case 'E':
1421
		case 'E':
1428
		  /* no exponent without some digits */
1422
		  /* no exponent without some digits */
1429
		  if ((flags & (NDIGITS | EXPOK)) == EXPOK
1423
		  if ((flags & (NDIGITS | EXPOK)) == EXPOK
1430
		      || ((flags & EXPOK) && zeroes))
1424
		      || ((flags & EXPOK) && zeroes))
Line 1439... Line 1433...
1439
			SIGNOK | NDIGITS;
1433
			SIGNOK | NDIGITS;
1440
		      zeroes = 0;
1434
		      zeroes = 0;
1441
		      goto fok;
1435
		      goto fok;
1442
		    }
1436
		    }
1443
		  break;
1437
		  break;
-
 
1438
		default:
-
 
1439
#ifndef _MB_CAPABLE
-
 
1440
		  if ((unsigned char) c == (unsigned char) decpt[0]
-
 
1441
		      && (flags & DPTOK))
-
 
1442
		    {
-
 
1443
		      flags &= ~(SIGNOK | DPTOK);
-
 
1444
		      leading_zeroes = zeroes;
-
 
1445
		      goto fok;
-
 
1446
		    }
-
 
1447
		  break;
-
 
1448
#else
-
 
1449
		  if (flags & DPTOK)
-
 
1450
		    {
-
 
1451
		      while ((unsigned char) c
-
 
1452
			     == (unsigned char) decpt[decptpos])
-
 
1453
			{
-
 
1454
			  if (decpt[++decptpos] == '\0')
-
 
1455
			    {
-
 
1456
			      /* We read the complete decpt seq. */
-
 
1457
			      flags &= ~(SIGNOK | DPTOK);
-
 
1458
			      leading_zeroes = zeroes;
-
 
1459
			      p = stpncpy (p, decpt, decptpos);
-
 
1460
			      decptpos = 0;
-
 
1461
			      goto fskip;
-
 
1462
			    }
-
 
1463
			  ++nread;
-
 
1464
			  if (--fp->_r > 0)
-
 
1465
			    fp->_p++;
-
 
1466
			  else if (__srefill_r (rptr, fp))
-
 
1467
			    break;		/* EOF */
-
 
1468
			  c = *fp->_p;
-
 
1469
			}
-
 
1470
		      if (decptpos > 0)
-
 
1471
			{
-
 
1472
			  /* We read part of a multibyte decimal point,
-
 
1473
			     but the rest is invalid or we're at EOF,
-
 
1474
			     so back off. */
-
 
1475
			  while (decptpos-- > 0)
-
 
1476
			    {
-
 
1477
			      _ungetc_r (rptr, (unsigned char) decpt[decptpos],
-
 
1478
					 fp);
-
 
1479
			      --nread;
-
 
1480
			    }
-
 
1481
			}
-
 
1482
		    }
-
 
1483
		  break;
-
 
1484
#endif
1444
		}
1485
		}
1445
	      break;
1486
	      break;
1446
	    fok:
1487
	    fok:
1447
	      *p++ = c;
1488
	      *p++ = c;
1448
	    fskip:
1489
	    fskip:
Line 1593... Line 1634...
1593
input_failure:
1634
input_failure:
1594
  /* On read failure, return EOF failure regardless of matches; errno
1635
  /* On read failure, return EOF failure regardless of matches; errno
1595
     should have been set prior to here.  On EOF failure (including
1636
     should have been set prior to here.  On EOF failure (including
1596
     invalid format string), return EOF if no matches yet, else number
1637
     invalid format string), return EOF if no matches yet, else number
1597
     of matches made prior to failure.  */
1638
     of matches made prior to failure.  */
1598
  _funlockfile (fp);
1639
  _newlib_flockfile_exit (fp);
1599
  return nassigned && !(fp->_flags & __SERR) ? nassigned : EOF;
1640
  return nassigned && !(fp->_flags & __SERR) ? nassigned : EOF;
1600
match_failure:
1641
match_failure:
1601
all_done:
1642
all_done:
1602
  /* Return number of matches, which can be 0 on match failure.  */
1643
  /* Return number of matches, which can be 0 on match failure.  */
1603
  _funlockfile (fp);
1644
  _newlib_flockfile_end (fp);
1604
  return nassigned;
1645
  return nassigned;
1605
}
1646
}
Line 1606... Line 1647...
1606
 
1647
 
1607
#ifndef _NO_POS_ARGS
1648
#ifndef _NO_POS_ARGS