~ubuntu-branches/ubuntu/natty/linux86/natty

« back to all changes in this revision

Viewing changes to libc/stdio/printf.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-12-07 20:33:39 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20071207203339-uonmnsb2j32kh0sg
Tags: 0.16.17-2ubuntu1
* Merge with Debian; remaining changes:
  - Build elks-libc for lpia.

Show diffs side-by-side

added added

removed removed

Lines of Context:
129
129
 
130
130
#ifdef L_vfprintf
131
131
 
132
 
#ifdef FLOATS
 
132
#ifndef __HAS_NO_FLOATS__
133
133
int (*__fp_print)() = 0;
134
134
#endif
135
135
 
344
344
                           sign, pad, width, preci, buffer_mode);
345
345
            break;
346
346
 
347
 
#if FLOATS
 
347
#ifndef __HAS_NO_FLOATS__
348
348
         case 'e':              /* float */
349
349
         case 'f':
350
350
         case 'g':
378
378
   return (cnt);
379
379
}
380
380
#endif
 
381
 
 
382
#ifdef L_fp_print
 
383
#ifndef __HAS_NO_FLOATS__
 
384
 
 
385
#ifdef __AS386_16__
 
386
#asm
 
387
  loc   1         ! Make sure the pointer is in the correct segment
 
388
auto_func:        ! Label for bcc -M to work.
 
389
  .word ___xfpcvt ! Pointer to the autorun function
 
390
  .text           ! So the function after is also in the correct seg.
 
391
#endasm
 
392
#endif
 
393
 
 
394
#ifdef __AS386_32__
 
395
#asm
 
396
  loc   1         ! Make sure the pointer is in the correct segment
 
397
auto_func:        ! Label for bcc -M to work.
 
398
  .long ___xfpcvt ! Pointer to the autorun function
 
399
  .text           ! So the function after is also in the correct seg.
 
400
#endasm
 
401
#endif
 
402
 
 
403
void
 
404
__fp_print_func(pval, style, preci, ptmp)
 
405
   double * pval;
 
406
   int style;
 
407
   int preci;
 
408
   char * ptmp;
 
409
{
 
410
   int decpt, negative;
 
411
   char * cvt;
 
412
   double val = *pval;
 
413
 
 
414
   if (preci < 0) preci = 6;
 
415
 
 
416
   cvt = fcvt(val, preci, &decpt, &negative);
 
417
   if(negative)
 
418
      *ptmp++ = '-';
 
419
 
 
420
   if (decpt<0) {
 
421
      *ptmp++ = '0';
 
422
      *ptmp++ = '.';
 
423
      while(decpt<0) {
 
424
         *ptmp++ = '0'; decpt++;
 
425
      }
 
426
   }
 
427
 
 
428
   while(*cvt) {
 
429
      *ptmp++ = *cvt++;
 
430
      if (decpt == 1)
 
431
         *ptmp++ = '.';
 
432
      decpt--;
 
433
   }
 
434
 
 
435
   while(decpt > 0) {
 
436
      *ptmp++ = '0';
 
437
      decpt--;
 
438
   }
 
439
}
 
440
 
 
441
void
 
442
__xfpcvt()
 
443
{
 
444
   extern int (*__fp_print)();
 
445
   __fp_print = __fp_print_func;
 
446
}
 
447
 
 
448
#endif
 
449
#endif