Changeset 2792 for branches/libc-0.6/src


Ignore:
Timestamp:
Aug 27, 2006, 8:31:48 PM (19 years ago)
Author:
bird
Message:

Implemented the new length modifiers for *scanf. Adjusted the length modifier implementation for *printf. Fixes #113.

Location:
branches/libc-0.6/src/emx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/ChangeLog.LIBC

    r2786 r2792  
    552006-08-27: knut st. osmundsen <[email protected]>
    66    - libc:
     7
     8
    79        o Fixed problems with fork() and module loading/unloading. Fixes #76.
    810        o Fixed atexit() and on_exit() problem with callbacks in unloaded DLLs. Fixes #103.
  • branches/libc-0.6/src/emx/src/lib/io/_input.c

    r2090 r2792  
    44#include <stdio.h>
    55#include <stdlib.h>
     6
    67#include <stdarg.h>
    78#include <string.h>
     
    1617#define TRUE    1
    1718
     19
     20
     21
     22
    1823/* This structure holds the local variables of _input() which are
    1924   passed to the functions called by _input(). */
     
    2833  int collected;                /* Number of characters collected */
    2934  size_t more_size;             /* Size of the above */
    30   char size;                    /* Size (0, 'h', 'l' or 'L') */
     35  ') */
    3136  char width_given;             /* A field width has been given */
    3237  unsigned char ungetc_count;   /* stream's _ungetc_count prior to get0() */
     
    192197
    193198
     199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
     222
     223
     224
     225
     226
    194227static void inp_str (ilocal *v, unsigned char *dst)
    195228{
     
    197230
    198231  c = skip (v);
    199   if (v->status != OK) return;
     232  if (v->status != OK)
     233    return;
    200234  while (c != EOF && !isspace (c))
    201235    {
     
    211245  make_unread (v, c);
    212246}
     247
     248
     249
     250
     251
     252
     253
     254
     255
     256
     257
     258
     259
     260
     261
     262
     263
     264
     265
     266
     267
     268
     269
     270
     271
     272
     273
    213274
    214275
     
    372433      switch (v->size)
    373434        {
    374         case 'L':
    375           *(long long *)dst = n;
    376           break;
    377435        case 'h':
    378436          *(short *)dst = n;
     437
     438
     439
     440
     441
     442
     443
     444
     445
     446
     447
     448
     449
     450
     451
     452
     453
     454
     455
     456
     457
    379458          break;
    380459        default:
     
    659738                v->width_given = TRUE;
    660739            }
    661           if (*format == 'h' || *format == 'l' || *format == 'L')
    662             v->size = *format++;
     740          if (   *format == 'h' || *format == 'l' || *format == 'L'
     741              || *format == 'j' || *format == 'z' || *format == 't'
     742              || *format == 'q' || *format == 'Z' )
     743            {
     744              v->size = *format++;
     745              if (v->size == 'l' && *format == 'l')
     746                {
     747                  v->size = SIZE_LL; ++format;
     748                }
     749              else if (v->size == 'h' && *format == 'h')
     750                {
     751                  v->size = SIZE_HH; ++format;
     752                }
     753            }
    663754          f = *format;
    664755          switch (f)
    665756            {
    666             case 'c':
    667               if (assign)
    668                 dst = va_arg (arg_ptr, char *);
    669               inp_char (v, dst);
    670               break;
    671 
    672757            case '[':
    673758              if (assign)
     
    676761              break;
    677762
     763
     764
     765
     766
     767
     768
     769
     770
     771
     772
     773
     774
     775
     776
     777
    678778            case 's':
    679               if (assign)
    680                 dst = va_arg (arg_ptr, char *);
    681               inp_str (v, dst);
    682               break;
     779              if (v->size != 'l' && v->size == 'L')
     780                {
     781                  if (assign)
     782                    dst = va_arg (arg_ptr, char *);
     783                  inp_str (v, dst);
     784                  break;
     785                }
     786              /* fall thru */
     787            case 'S':
     788                if (assign)
     789                  dst = va_arg (arg_ptr, wchar_t *);
     790                inp_wstr (v, dst);
     791                break;
    683792
    684793            case 'f':
     
    713822                switch (v->size)
    714823                  {
    715                   case 'L':
    716                     dst = va_arg (arg_ptr, long long *);
     824                  case :
     825                    dst = va_arg (arg_ptr, *);
    717826                    break;
    718827                  case 'h':
    719828                    dst = va_arg (arg_ptr, short *);
     829
     830
     831
     832
     833
     834
     835
     836
     837
     838
     839
     840
     841
     842
     843
     844
     845
     846
    720847                    break;
    721848                  default:
     
    730857                switch (v->size)
    731858                  {
    732                   case 'L':
    733                     *(va_arg (arg_ptr, long long *)) = v->chars;
     859                  case :
     860                    *(va_arg (arg_ptr, *)) = v->chars;
    734861                    break;
    735862                  case 'h':
    736863                    *(va_arg (arg_ptr, short *)) = v->chars;
     864
     865
     866
     867
     868
     869
     870
     871
     872
     873
     874
     875
     876
     877
     878
    737879                    break;
    738880                  default:
  • branches/libc-0.6/src/emx/src/lib/io/_output.c

    r2160 r2792  
    55#include <stdlib.h>
    66#include <stdarg.h>
     7
    78#include <string.h>
    89#include <math.h>
     
    2122#define SIZE_HH         (('h' << 8) | 'h')
    2223#define SIZE_LL         (('l' << 8) | 'l')
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
    2372
    2473#define DEFAULT_PREC    6
     
    369418
    370419
    371 static int cvt_hex_32 (olocal *v, unsigned n, char x)
     420static int cvt_hex_32 (olocal *v, u n, char x)
    372421{
    373422  char buf[9];
     
    378427
    379428
    380 static int cvt_hex_64 (olocal *v, unsigned long long n, char x)
     429static int cvt_hex_64 (olocal *v, u n, char x)
    381430{
    382431  char buf[17];
     
    401450
    402451
    403 static int cvt_oct_32 (olocal *v, unsigned n)
     452static int cvt_oct_32 (olocal *v, u n)
    404453{
    405454  char buf[12];
     
    410459
    411460
    412 static int cvt_oct_64 (olocal *v, unsigned long long n)
     461static int cvt_oct_64 (olocal *v, u n)
    413462{
    414463  char buf[23];
     
    419468
    420469
    421 static int cvt_dec_32 (olocal *v, unsigned n, int is_signed, int is_neg)
     470static int cvt_dec_32 (olocal *v, u n, int is_signed, int is_neg)
    422471{
    423472  char buf[11];
     
    428477
    429478
    430 static int cvt_dec_64 (olocal *v, unsigned long long n, int is_signed,
    431                        int is_neg)
     479static int cvt_dec_64 (olocal *v, uint64_t n, int is_signed, int is_neg)
    432480{
    433481  char buf[21];
     
    905953                size = SIZE_HH; ++format;
    906954              }
    907             else if (size == 'q' || size == 'j')
    908                 size = SIZE_LL;
    909             else if (size == 'z' || size == 'Z' || size == 't')
    910                 size = 'l';
    911955          }
    912956
     
    919963
    920964          case 'n':
    921             if (size == SIZE_LL || size == 'L')
    922               {
    923                 long long *ptr = va_arg (arg_ptr, long long *);
     965            if ()
     966              {
     967                *);
    924968                *ptr = v.count;
    925969              }
    926             else if (size == 'h')
    927               {
    928                 short *ptr = va_arg (arg_ptr, short *);
     970            else if ()
     971              {
     972                t *);
    929973                *ptr = v.count;
    930974              }
    931             else if (size == SIZE_HH)
    932               {
    933                 char *ptr = va_arg (arg_ptr, char *);
     975            else if ()
     976              {
     977                *);
    934978                *ptr = v.count;
    935979              }
    936             else
    937               {
    938                 int *ptr = va_arg (arg_ptr, int *);
     980            else
     981              {
     982                intt *);
    939983                *ptr = v.count;
    940984              }
     
    9751019          case 'd':
    9761020          case 'i':
    977             if (size == SIZE_LL || size == 'L')
    978               {
    979                 long long n = va_arg (arg_ptr, long long);
     1021            if ()
     1022              {
     1023                );
    9801024                if (n < 0)
    9811025                  CHECK (cvt_dec_64 (&v, -n, TRUE, TRUE));
     
    9851029            else
    9861030              {
    987                 int n = va_arg (arg_ptr, int);
     1031                intt);
    9881032                if (size == 'h')
    9891033                  n = (short)n;
     
    9981042
    9991043          case 'u':
    1000             if (size == SIZE_LL || size == 'L')
    1001               CHECK (cvt_dec_64 (&v, va_arg (arg_ptr, unsigned long long),
    1002                                  FALSE, FALSE));
     1044            if (IS_SIZE_64BIT (size))
     1045              CHECK (cvt_dec_64 (&v, va_arg (arg_ptr, uint64_t), FALSE, FALSE));
    10031046            else
    10041047              {
    1005                 unsigned n = va_arg (arg_ptr, unsigned);
     1048                u);
    10061049                if (size == 'h')
    10071050                  n = (unsigned short)n;
     
    10141057          case 'p':
    10151058            v.hash = TRUE;
    1016             CHECK (cvt_hex_32 (&v, va_arg (arg_ptr, unsigned), 'x'));
     1059            if (sizeof(uintptr_t) == sizeof(uint64_t))
     1060                CHECK (cvt_hex_64 (&v, va_arg (arg_ptr, uintptr_t), 'x'));
     1061            else
     1062                CHECK (cvt_hex_32 (&v, va_arg (arg_ptr, uintptr_t), 'x'));
    10171063            break;
    10181064
    10191065          case 'x':
    10201066          case 'X':
    1021             if (size == SIZE_LL || size == 'L')
    1022               CHECK (cvt_hex_64 (&v, va_arg (arg_ptr, unsigned long long),
     1067            if ()
     1068              CHECK (cvt_hex_64 (&v, va_arg (arg_ptr, u),
    10231069                                 *format));
    10241070            else
    10251071              {
    1026                 unsigned n = va_arg (arg_ptr, unsigned);
     1072                u);
    10271073                if (size == 'h')
    10281074                  n = (unsigned short)n;
     
    10341080
    10351081          case 'o':
    1036             if (size == SIZE_LL || size == 'L')
    1037               CHECK (cvt_oct_64 (&v, va_arg (arg_ptr, unsigned long long)));
     1082            if ()
     1083              CHECK (cvt_oct_64 (&v, va_arg (arg_ptr, u)));
    10381084            else
    10391085              {
    1040                 unsigned n = va_arg (arg_ptr, unsigned);
     1086                u);
    10411087                if (size == 'h')
    10421088                  n = (unsigned short)n;
Note: See TracChangeset for help on using the changeset viewer.