Ignore:
Timestamp:
Apr 27, 2004, 8:39:34 PM (21 years ago)
Author:
bird
Message:

GCC v3.3.3 sources.

Location:
branches/GNU/src/gcc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/gcc

    • Property svn:ignore
      •  

        old new  
        2626configure.vr
        2727configure.vrs
         28dir.info
        2829Makefile
        29 dir.info
        3030lost+found
        3131update.out
  • branches/GNU/src/gcc/libobjc/archive.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    1 /* GNU Objective C Runtime archiving
    2    Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
     1 /* GNU Objective C Runtime archiving
     2   Copyright (C) 1993, 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
    33   Contributed by Kresten Krab Thorup
    44
     
    2929#include "typedstream.h"
    3030#include "encoding.h"
    31 
    32 #ifdef HAVE_STDLIB_H
    3331#include <stdlib.h>
    34 #endif
    35 
    36 extern int fflush(FILE*);
     32
     33extern int fflush (FILE *);
    3734
    3835#define ROUND(V, A) \
    39   ({ typeof(V) __v=(V); typeof(A) __a=(A);  \
    40      __a*((__v+__a-1)/__a); })
    41 
    42 #define PTR2LONG(P) (((char*)(P))-(char*)0)
    43 #define LONG2PTR(L) (((char*)0)+(L))
     36  ({ typeof (V) __v = (V); typeof (A) __a = (A);  \
     37     __a * ((__v + __a - 1)/__a); })
     38
     39#define PTR2LONG(P) (((char *) (P))-(char *) 0)
     40#define LONG2PTR(L) (((char *) 0) + (L))
    4441
    4542/* Declare some functions... */
    4643
    4744static int
    48 objc_read_class (struct objc_typed_stream* stream, Class* class);
    49 
    50 int objc_sizeof_type(const char* type);
     45objc_read_class (struct objc_typed_stream *stream, Class *class);
     46
     47int objc_sizeof_type (const char *type);
    5148
    5249static int
    53 objc_write_use_common (struct objc_typed_stream* stream, unsigned long key);
     50objc_write_use_common (struct objc_typed_stream *stream, unsigned long key);
    5451
    5552static int
    56 objc_write_register_common (struct objc_typed_stream* stream,
     53objc_write_register_common (struct objc_typed_stream *stream,
    5754                            unsigned long key);
    5855
    5956static int
    60 objc_write_class (struct objc_typed_stream* stream,
    61                          struct objc_class* class);
    62 
    63 const char* objc_skip_type (const char* type);
    64 
    65 static void __objc_finish_write_root_object(struct objc_typed_stream*);
    66 static void __objc_finish_read_root_object(struct objc_typed_stream*);
     57objc_write_class (struct objc_typed_stream *stream,
     58                         struct objc_class *class);
     59
     60const char *objc_skip_type (const char *type);
     61
     62static void __objc_finish_write_root_object (struct objc_typed_stream *);
     63static void __objc_finish_read_root_object (struct objc_typed_stream *);
    6764
    6865static __inline__ int
    69 __objc_code_unsigned_char (unsigned char* buf, unsigned char val)
     66__objc_code_unsigned_char (unsigned char *buf, unsigned char val)
    7067{
    7168  if ((val&_B_VALUE) == val)
     
    8380
    8481int
    85 objc_write_unsigned_char (struct objc_typed_stream* stream,
     82objc_write_unsigned_char (struct objc_typed_stream *stream,
    8683                          unsigned char value)
    8784{
    88   unsigned char buf[sizeof (unsigned char)+1];
     85  unsigned char buf[sizeof (unsigned char) + 1];
    8986  int len = __objc_code_unsigned_char (buf, value);
    90   return (*stream->write)(stream->physical, buf, len);
     87  return (*stream->write) (stream->physical, buf, len);
    9188}
    9289
    9390static __inline__ int
    94 __objc_code_char (unsigned char* buf, signed char val)
     91__objc_code_char (unsigned char *buf, signed char val)
    9592{
    9693  if (val >= 0)
     
    105102
    106103int
    107 objc_write_char (struct objc_typed_stream* stream, signed char value)
    108 {
    109   unsigned char buf[sizeof (char)+1];
     104objc_write_char (struct objc_typed_stream *stream, signed char value)
     105{
     106  unsigned char buf[sizeof (char) + 1];
    110107  int len = __objc_code_char (buf, value);
    111   return (*stream->write)(stream->physical, buf, len);
     108  return (*stream->write) (stream->physical, buf, len);
    112109}
    113110
    114111static __inline__ int
    115 __objc_code_unsigned_short (unsigned char* buf, unsigned short val)
     112__objc_code_unsigned_short (unsigned char *buf, unsigned short val)
    116113{
    117114  if ((val&_B_VALUE) == val)
     
    126123      buf[0] = _B_NINT;
    127124
    128       for (c= sizeof(short); c != 0; c -= 1)
    129         if (((val>>(8*(c-1)))%0x100) != 0)
     125      for (c = sizeof (short); c != 0; c -= 1)
     126        if (((val >> (8*(c - 1)))%0x100) != 0)
    130127          break;
    131128
     
    134131      for (b = 1; c != 0; c--, b++)
    135132        {
    136           buf[b] = (val >> (8*(c-1)))%0x100;
     133          buf[b] = (val >> (8*(c - 1)))%0x100;
    137134        }
    138135
     
    142139
    143140int
    144 objc_write_unsigned_short (struct objc_typed_stream* stream,
     141objc_write_unsigned_short (struct objc_typed_stream *stream,
    145142                           unsigned short value)
    146143{
    147   unsigned char buf[sizeof (unsigned short)+1];
     144  unsigned char buf[sizeof (unsigned short) + 1];
    148145  int len = __objc_code_unsigned_short (buf, value);
    149   return (*stream->write)(stream->physical, buf, len);
     146  return (*stream->write) (stream->physical, buf, len);
    150147}
    151148     
    152149static __inline__ int
    153 __objc_code_short (unsigned char* buf, short val)
     150__objc_code_short (unsigned char *buf, short val)
    154151{
    155152  int sign = (val < 0);
     
    161158
    162159int
    163 objc_write_short (struct objc_typed_stream* stream, short value)
    164 {
    165   unsigned char buf[sizeof (short)+1];
     160objc_write_short (struct objc_typed_stream *stream, short value)
     161{
     162  unsigned char buf[sizeof (short) + 1];
    166163  int len = __objc_code_short (buf, value);
    167   return (*stream->write)(stream->physical, buf, len);
     164  return (*stream->write) (stream->physical, buf, len);
    168165}
    169166     
    170167
    171168static __inline__ int
    172 __objc_code_unsigned_int (unsigned char* buf, unsigned int val)
     169__objc_code_unsigned_int (unsigned char *buf, unsigned int val)
    173170{
    174171  if ((val&_B_VALUE) == val)
     
    183180      buf[0] = _B_NINT;
    184181
    185       for (c= sizeof(int); c != 0; c -= 1)
    186         if (((val>>(8*(c-1)))%0x100) != 0)
     182      for (c = sizeof (int); c != 0; c -= 1)
     183        if (((val >> (8*(c - 1)))%0x100) != 0)
    187184          break;
    188185
     
    199196
    200197int
    201 objc_write_unsigned_int (struct objc_typed_stream* stream, unsigned int value)
    202 {
    203   unsigned char buf[sizeof(unsigned int)+1];
     198objc_write_unsigned_int (struct objc_typed_stream *stream, unsigned int value)
     199{
     200  unsigned char buf[sizeof (unsigned int) + 1];
    204201  int len = __objc_code_unsigned_int (buf, value);
    205   return (*stream->write)(stream->physical, buf, len);
     202  return (*stream->write) (stream->physical, buf, len);
    206203}
    207204
    208205static __inline__ int
    209 __objc_code_int (unsigned char* buf, int val)
     206__objc_code_int (unsigned char *buf, int val)
    210207{
    211208  int sign = (val < 0);
     
    217214
    218215int
    219 objc_write_int (struct objc_typed_stream* stream, int value)
    220 {
    221   unsigned char buf[sizeof(int)+1];
     216objc_write_int (struct objc_typed_stream *stream, int value)
     217{
     218  unsigned char buf[sizeof (int) + 1];
    222219  int len = __objc_code_int (buf, value);
    223   return (*stream->write)(stream->physical, buf, len);
     220  return (*stream->write) (stream->physical, buf, len);
    224221}
    225222
    226223static __inline__ int
    227 __objc_code_unsigned_long (unsigned char* buf, unsigned long val)
     224__objc_code_unsigned_long (unsigned char *buf, unsigned long val)
    228225{
    229226  if ((val&_B_VALUE) == val)
     
    238235      buf[0] = _B_NINT;
    239236
    240       for (c= sizeof(long); c != 0; c -= 1)
    241         if (((val>>(8*(c-1)))%0x100) != 0)
     237      for (c = sizeof (long); c != 0; c -= 1)
     238        if (((val >> (8*(c - 1)))%0x100) != 0)
    242239          break;
    243240
     
    246243      for (b = 1; c != 0; c--, b++)
    247244        {
    248           buf[b] = (val >> (8*(c-1)))%0x100;
     245          buf[b] = (val >> (8*(c - 1)))%0x100;
    249246        }
    250247
     
    254251
    255252int
    256 objc_write_unsigned_long (struct objc_typed_stream* stream,
     253objc_write_unsigned_long (struct objc_typed_stream *stream,
    257254                          unsigned long value)
    258255{
    259   unsigned char buf[sizeof(unsigned long)+1];
     256  unsigned char buf[sizeof (unsigned long) + 1];
    260257  int len = __objc_code_unsigned_long (buf, value);
    261   return (*stream->write)(stream->physical, buf, len);
     258  return (*stream->write) (stream->physical, buf, len);
    262259}
    263260
    264261static __inline__ int
    265 __objc_code_long (unsigned char* buf, long val)
     262__objc_code_long (unsigned char *buf, long val)
    266263{
    267264  int sign = (val < 0);
     
    273270
    274271int
    275 objc_write_long (struct objc_typed_stream* stream, long value)
    276 {
    277   unsigned char buf[sizeof(long)+1];
     272objc_write_long (struct objc_typed_stream *stream, long value)
     273{
     274  unsigned char buf[sizeof (long) + 1];
    278275  int len = __objc_code_long (buf, value);
    279   return (*stream->write)(stream->physical, buf, len);
     276  return (*stream->write) (stream->physical, buf, len);
    280277}
    281278
    282279
    283280int
    284 objc_write_string (struct objc_typed_stream* stream,
    285                    const unsigned char* string, unsigned int nbytes)
    286 {
    287   unsigned char buf[sizeof(unsigned int)+1];
     281objc_write_string (struct objc_typed_stream *stream,
     282                   const unsigned char *string, unsigned int nbytes)
     283{
     284  unsigned char buf[sizeof (unsigned int) + 1];
    288285  int len = __objc_code_unsigned_int (buf, nbytes);
    289286 
     
    294291    buf[0] = (buf[0]&_B_VALUE)|_B_NSTR;
    295292
    296   if ((*stream->write)(stream->physical, buf, len) != 0)
    297     return (*stream->write)(stream->physical, string, nbytes);
     293  if ((*stream->write) (stream->physical, buf, len) != 0)
     294    return (*stream->write) (stream->physical, string, nbytes);
    298295  else
    299296    return 0;
     
    301298
    302299int
    303 objc_write_string_atomic (struct objc_typed_stream* stream,
    304                           unsigned char* string, unsigned int nbytes)
     300objc_write_string_atomic (struct objc_typed_stream *stream,
     301                          unsigned char *string, unsigned int nbytes)
    305302{
    306303  unsigned long key;
     
    318315
    319316static int
    320 objc_write_register_common (struct objc_typed_stream* stream,
     317objc_write_register_common (struct objc_typed_stream *stream,
    321318                            unsigned long key)
    322319{
    323320  unsigned char buf[sizeof (unsigned long)+2];
    324   int len = __objc_code_unsigned_long (buf+1, key);
     321  int len = __objc_code_unsigned_long (buf + 1, key);
    325322  if (len == 1)
    326323    {
    327324      buf[0] = _B_RCOMM|0x01;
    328325      buf[1] &= _B_VALUE;
    329       return (*stream->write)(stream->physical, buf, len+1);
     326      return (*stream->write) (stream->physical, buf, len + 1);
    330327    }
    331328  else
    332329    {
    333330      buf[1] = (buf[1]&_B_VALUE)|_B_RCOMM;
    334       return (*stream->write)(stream->physical, buf+1, len);
     331      return (*stream->write) (stream->physical, buf + 1, len);
    335332    }
    336333}
    337334
    338335static int
    339 objc_write_use_common (struct objc_typed_stream* stream, unsigned long key)
     336objc_write_use_common (struct objc_typed_stream *stream, unsigned long key)
    340337{
    341338  unsigned char buf[sizeof (unsigned long)+2];
    342   int len = __objc_code_unsigned_long (buf+1, key);
     339  int len = __objc_code_unsigned_long (buf + 1, key);
    343340  if (len == 1)
    344341    {
    345342      buf[0] = _B_UCOMM|0x01;
    346343      buf[1] &= _B_VALUE;
    347       return (*stream->write)(stream->physical, buf, 2);
     344      return (*stream->write) (stream->physical, buf, 2);
    348345    }
    349346  else
    350347    {
    351348      buf[1] = (buf[1]&_B_VALUE)|_B_UCOMM;
    352       return (*stream->write)(stream->physical, buf+1, len);
     349      return (*stream->write) (stream->physical, buf + 1, len);
    353350    }
    354351}
    355352
    356353static __inline__ int
    357 __objc_write_extension (struct objc_typed_stream* stream, unsigned char code)
     354__objc_write_extension (struct objc_typed_stream *stream, unsigned char code)
    358355{
    359356  if (code <= _B_VALUE)
    360357    {
    361358      unsigned char buf = code|_B_EXT;
    362       return (*stream->write)(stream->physical, &buf, 1);
     359      return (*stream->write) (stream->physical, &buf, 1);
    363360    }
    364361  else
    365362    {
    366       objc_error(nil, OBJC_ERR_BAD_OPCODE,
    367                  "__objc_write_extension: bad opcode %c\n", code);
     363      objc_error (nil, OBJC_ERR_BAD_OPCODE,
     364                  "__objc_write_extension: bad opcode %c\n", code);
    368365      return -1;
    369366    }
     
    371368
    372369__inline__ int
    373 __objc_write_object (struct objc_typed_stream* stream, id object)
     370__objc_write_object (struct objc_typed_stream *stream, id object)
    374371{
    375372  unsigned char buf = '\0';
     
    379376      __objc_write_extension (stream, _BX_OBJECT);
    380377      objc_write_class (stream, object->class_pointer);
    381       (*objc_msg_lookup(object, write_sel))(object, write_sel, stream);
    382       return (*stream->write)(stream->physical, &buf, 1);
     378      (*objc_msg_lookup (object, write_sel)) (object, write_sel, stream);
     379      return (*stream->write) (stream->physical, &buf, 1);
    383380    }
    384381  else
    385     return objc_write_use_common(stream, 0);
     382    return objc_write_use_common (stream, 0);
    386383}
    387384
    388385int
    389 objc_write_object_reference (struct objc_typed_stream* stream, id object)
     386objc_write_object_reference (struct objc_typed_stream *stream, id object)
    390387{
    391388  unsigned long key;
     
    398395
    399396int
    400 objc_write_root_object (struct objc_typed_stream* stream, id object)
     397objc_write_root_object (struct objc_typed_stream *stream, id object)
    401398{
    402399  int len = 0;
     
    408405      stream->writing_root_p = 1;
    409406      __objc_write_extension (stream, _BX_OBJROOT);
    410       if((len = objc_write_object (stream, object)))
    411         __objc_finish_write_root_object(stream);
     407      if ((len = objc_write_object (stream, object)))
     408        __objc_finish_write_root_object (stream);
    412409      stream->writing_root_p = 0;
    413410    }
     
    416413
    417414int
    418 objc_write_object (struct objc_typed_stream* stream, id object)
     415objc_write_object (struct objc_typed_stream *stream, id object)
    419416{
    420417  unsigned long key;
     
    423420
    424421  else if (object == nil)
    425     return objc_write_use_common(stream, 0);
     422    return objc_write_use_common (stream, 0);
    426423
    427424  else
     
    436433
    437434__inline__ int
    438 __objc_write_class (struct objc_typed_stream* stream, struct objc_class* class)
     435__objc_write_class (struct objc_typed_stream *stream, struct objc_class *class)
    439436{
    440437  __objc_write_extension (stream, _BX_CLASS);
    441   objc_write_string_atomic(stream, (char*)class->name,
    442                            strlen((char*)class->name));
     438  objc_write_string_atomic (stream, (char *) class->name,
     439                           strlen ((char *) class->name));
    443440  return objc_write_unsigned_long (stream, class->version);
    444441}
     
    446443
    447444static int
    448 objc_write_class (struct objc_typed_stream* stream,
    449                          struct objc_class* class)
     445objc_write_class (struct objc_typed_stream *stream,
     446                         struct objc_class *class)
    450447{
    451448  unsigned long key;
     
    455452    {
    456453      int length;
    457       hash_add (&stream->stream_table, LONG2PTR(key=PTR2LONG(class)), class);
     454      hash_add (&stream->stream_table, LONG2PTR(key = PTR2LONG(class)), class);
    458455      if ((length = objc_write_register_common (stream, key)))
    459456        return __objc_write_class (stream, class);
     
    464461
    465462__inline__ int
    466 __objc_write_selector (struct objc_typed_stream* stream, SEL selector)
    467 {
    468   const char* sel_name;
     463__objc_write_selector (struct objc_typed_stream *stream, SEL selector)
     464{
     465  const char *sel_name;
    469466  __objc_write_extension (stream, _BX_SEL);
    470467  /* to handle NULL selectors */
     
    476473
    477474int
    478 objc_write_selector (struct objc_typed_stream* stream, SEL selector)
    479 {
    480   const char* sel_name;
     475objc_write_selector (struct objc_typed_stream *stream, SEL selector)
     476{
     477  const char *sel_name;
    481478  unsigned long key;
    482479
     
    492489      int length;
    493490      hash_add (&stream->stream_table,
    494                 LONG2PTR(key=PTR2LONG(sel_name)), (char*)sel_name);
     491                LONG2PTR(key = PTR2LONG(sel_name)), (char *) sel_name);
    495492      if ((length = objc_write_register_common (stream, key)))
    496493        return __objc_write_selector (stream, selector);
     
    506503
    507504__inline__ int
    508 objc_read_char (struct objc_typed_stream* stream, char* val)
     505objc_read_char (struct objc_typed_stream *stream, char *val)
    509506{
    510507  unsigned char buf;
    511508  int len;
    512   len = (*stream->read)(stream->physical, &buf, 1);
     509  len = (*stream->read) (stream->physical, &buf, 1);
    513510  if (len != 0)
    514511    {
     
    518515      else if ((buf & _B_NUMBER) == 1)
    519516        {
    520           len = (*stream->read)(stream->physical, val, 1);
     517          len = (*stream->read) (stream->physical, val, 1);
    521518          if (buf&_B_SIGN)
    522             (*val) = -1*(*val);
     519            (*val) = -1 * (*val);
    523520        }
    524521
    525522      else
    526         objc_error(nil, OBJC_ERR_BAD_DATA,
    527                    "expected 8bit signed int, got %dbit int",
    528                    (int)(buf&_B_NUMBER)*8);
     523        objc_error (nil, OBJC_ERR_BAD_DATA,
     524                    "expected 8bit signed int, got %dbit int",
     525                    (int) (buf&_B_NUMBER)*8);
    529526    }
    530527  return len;
     
    533530
    534531__inline__ int
    535 objc_read_unsigned_char (struct objc_typed_stream* stream, unsigned char* val)
     532objc_read_unsigned_char (struct objc_typed_stream *stream, unsigned char *val)
    536533{
    537534  unsigned char buf;
    538535  int len;
    539   if ((len = (*stream->read)(stream->physical, &buf, 1)))
     536  if ((len = (*stream->read) (stream->physical, &buf, 1)))
    540537    {
    541538      if ((buf & _B_CODE) == _B_SINT)
     
    543540
    544541      else if ((buf & _B_NUMBER) == 1)
    545         len = (*stream->read)(stream->physical, val, 1);
     542        len = (*stream->read) (stream->physical, val, 1);
    546543
    547544      else
    548         objc_error(nil, OBJC_ERR_BAD_DATA,
    549                    "expected 8bit unsigned int, got %dbit int",
    550                    (int)(buf&_B_NUMBER)*8);
     545        objc_error (nil, OBJC_ERR_BAD_DATA,
     546                    "expected 8bit unsigned int, got %dbit int",
     547                    (int) (buf&_B_NUMBER)*8);
    551548    }
    552549  return len;
     
    554551
    555552__inline__ int
    556 objc_read_short (struct objc_typed_stream* stream, short* value)
    557 {
    558   unsigned char buf[sizeof(short)+1];
     553objc_read_short (struct objc_typed_stream *stream, short *value)
     554{
     555  unsigned char buf[sizeof (short) + 1];
    559556  int len;
    560   if ((len = (*stream->read)(stream->physical, buf, 1)))
     557  if ((len = (*stream->read) (stream->physical, buf, 1)))
    561558    {
    562559      if ((buf[0] & _B_CODE) == _B_SINT)
     
    567564          int pos = 1;
    568565          int nbytes = buf[0] & _B_NUMBER;
    569           if (nbytes > sizeof (short))
    570             objc_error(nil, OBJC_ERR_BAD_DATA,
    571                        "expected short, got bigger (%dbits)", nbytes*8);
    572           len = (*stream->read)(stream->physical, buf+1, nbytes);
     566          if (nbytes > (int) sizeof (short))
     567            objc_error (nil, OBJC_ERR_BAD_DATA,
     568                        "expected short, got bigger (%dbits)", nbytes*8);
     569          len = (*stream->read) (stream->physical, buf + 1, nbytes);
    573570          (*value) = 0;
    574571          while (pos <= nbytes)
     
    582579
    583580__inline__ int
    584 objc_read_unsigned_short (struct objc_typed_stream* stream,
    585                           unsigned short* value)
    586 {
    587   unsigned char buf[sizeof(unsigned short)+1];
     581objc_read_unsigned_short (struct objc_typed_stream *stream,
     582                          unsigned short *value)
     583{
     584  unsigned char buf[sizeof (unsigned short) + 1];
    588585  int len;
    589   if ((len = (*stream->read)(stream->physical, buf, 1)))
     586  if ((len = (*stream->read) (stream->physical, buf, 1)))
    590587    {
    591588      if ((buf[0] & _B_CODE) == _B_SINT)
     
    596593          int pos = 1;
    597594          int nbytes = buf[0] & _B_NUMBER;
    598           if (nbytes > sizeof (short))
    599             objc_error(nil, OBJC_ERR_BAD_DATA,
    600                        "expected short, got int or bigger");
    601           len = (*stream->read)(stream->physical, buf+1, nbytes);
     595          if (nbytes > (int) sizeof (short))
     596            objc_error (nil, OBJC_ERR_BAD_DATA,
     597                        "expected short, got int or bigger");
     598          len = (*stream->read) (stream->physical, buf + 1, nbytes);
    602599          (*value) = 0;
    603600          while (pos <= nbytes)
     
    610607
    611608__inline__ int
    612 objc_read_int (struct objc_typed_stream* stream, int* value)
    613 {
    614   unsigned char buf[sizeof(int)+1];
     609objc_read_int (struct objc_typed_stream *stream, int *value)
     610{
     611  unsigned char buf[sizeof (int) + 1];
    615612  int len;
    616   if ((len = (*stream->read)(stream->physical, buf, 1)))
     613  if ((len = (*stream->read) (stream->physical, buf, 1)))
    617614    {
    618615      if ((buf[0] & _B_CODE) == _B_SINT)
     
    623620          int pos = 1;
    624621          int nbytes = buf[0] & _B_NUMBER;
    625           if (nbytes > sizeof (int))
    626             objc_error(nil, OBJC_ERR_BAD_DATA, "expected int, got bigger");
    627           len = (*stream->read)(stream->physical, buf+1, nbytes);
     622          if (nbytes > (int) sizeof (int))
     623            objc_error (nil, OBJC_ERR_BAD_DATA, "expected int, got bigger");
     624          len = (*stream->read) (stream->physical, buf + 1, nbytes);
    628625          (*value) = 0;
    629626          while (pos <= nbytes)
     
    637634
    638635__inline__ int
    639 objc_read_long (struct objc_typed_stream* stream, long* value)
    640 {
    641   unsigned char buf[sizeof(long)+1];
     636objc_read_long (struct objc_typed_stream *stream, long *value)
     637{
     638  unsigned char buf[sizeof (long) + 1];
    642639  int len;
    643   if ((len = (*stream->read)(stream->physical, buf, 1)))
     640  if ((len = (*stream->read) (stream->physical, buf, 1)))
    644641    {
    645642      if ((buf[0] & _B_CODE) == _B_SINT)
     
    650647          int pos = 1;
    651648          int nbytes = buf[0] & _B_NUMBER;
    652           if (nbytes > sizeof (long))
    653             objc_error(nil, OBJC_ERR_BAD_DATA, "expected long, got bigger");
    654           len = (*stream->read)(stream->physical, buf+1, nbytes);
     649          if (nbytes > (int) sizeof (long))
     650            objc_error (nil, OBJC_ERR_BAD_DATA, "expected long, got bigger");
     651          len = (*stream->read) (stream->physical, buf + 1, nbytes);
    655652          (*value) = 0;
    656653          while (pos <= nbytes)
     
    664661
    665662__inline__ int
    666 __objc_read_nbyte_uint (struct objc_typed_stream* stream,
    667                        unsigned int nbytes, unsigned int* val)
    668 {
    669   int len, pos = 0;
    670   unsigned char buf[sizeof(unsigned int)+1];
     663__objc_read_nbyte_uint (struct objc_typed_stream *stream,
     664                        unsigned int nbytes, unsigned int *val)
     665{
     666  int len;
     667  unsigned int pos = 0;
     668  unsigned char buf[sizeof (unsigned int) + 1];
    671669
    672670  if (nbytes > sizeof (int))
    673     objc_error(nil, OBJC_ERR_BAD_DATA, "expected int, got bigger");
    674 
    675   len = (*stream->read)(stream->physical, buf, nbytes);
     671    objc_error (nil, OBJC_ERR_BAD_DATA, "expected int, got bigger");
     672
     673  len = (*stream->read) (stream->physical, buf, nbytes);
    676674  (*val) = 0;
    677675  while (pos < nbytes)
     
    682680
    683681__inline__ int
    684 objc_read_unsigned_int (struct objc_typed_stream* stream,
    685                         unsigned int* value)
    686 {
    687   unsigned char buf[sizeof(unsigned int)+1];
     682objc_read_unsigned_int (struct objc_typed_stream *stream,
     683                        unsigned int *value)
     684{
     685  unsigned char buf[sizeof (unsigned int) + 1];
    688686  int len;
    689   if ((len = (*stream->read)(stream->physical, buf, 1)))
     687  if ((len = (*stream->read) (stream->physical, buf, 1)))
    690688    {
    691689      if ((buf[0] & _B_CODE) == _B_SINT)
     
    700698
    701699int
    702 __objc_read_nbyte_ulong (struct objc_typed_stream* stream,
    703                        unsigned int nbytes, unsigned long* val)
    704 {
    705   int len, pos = 0;
    706   unsigned char buf[sizeof(unsigned long)+1];
     700__objc_read_nbyte_ulong (struct objc_typed_stream *stream,
     701                       unsigned int nbytes, unsigned long *val)
     702{
     703  int len;
     704  unsigned int pos = 0;
     705  unsigned char buf[sizeof (unsigned long) + 1];
    707706
    708707  if (nbytes > sizeof (long))
    709     objc_error(nil, OBJC_ERR_BAD_DATA, "expected long, got bigger");
    710 
    711   len = (*stream->read)(stream->physical, buf, nbytes);
     708    objc_error (nil, OBJC_ERR_BAD_DATA, "expected long, got bigger");
     709
     710  len = (*stream->read) (stream->physical, buf, nbytes);
    712711  (*val) = 0;
    713712  while (pos < nbytes)
     
    718717
    719718__inline__ int
    720 objc_read_unsigned_long (struct objc_typed_stream* stream,
    721                         unsigned long* value)
    722 {
    723   unsigned char buf[sizeof(unsigned long)+1];
     719objc_read_unsigned_long (struct objc_typed_stream *stream,
     720                         unsigned long *value)
     721{
     722  unsigned char buf[sizeof (unsigned long) + 1];
    724723  int len;
    725   if ((len = (*stream->read)(stream->physical, buf, 1)))
     724  if ((len = (*stream->read) (stream->physical, buf, 1)))
    726725    {
    727726      if ((buf[0] & _B_CODE) == _B_SINT)
     
    736735
    737736__inline__ int
    738 objc_read_string (struct objc_typed_stream* stream,
    739                   char** string)
    740 {
    741   unsigned char buf[sizeof(unsigned int)+1];
     737objc_read_string (struct objc_typed_stream *stream,
     738                  char **string)
     739{
     740  unsigned char buf[sizeof (unsigned int) + 1];
    742741  int len;
    743   if ((len = (*stream->read)(stream->physical, buf, 1)))
     742  if ((len = (*stream->read) (stream->physical, buf, 1)))
    744743    {
    745744      unsigned long key = 0;
     
    747746      if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */
    748747        {
    749           len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
    750           len = (*stream->read)(stream->physical, buf, 1);
     748          len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
     749          len = (*stream->read) (stream->physical, buf, 1);
    751750        }
    752751
     
    755754        {
    756755          int length = buf[0]&_B_VALUE;
    757           (*string) = (char*)objc_malloc(length+1);
     756          (*string) = (char*)objc_malloc (length + 1);
    758757          if (key)
    759758            hash_add (&stream->stream_table, LONG2PTR(key), *string);
    760           len = (*stream->read)(stream->physical, *string, length);
     759          len = (*stream->read) (stream->physical, *string, length);
    761760          (*string)[length] = '\0';
    762761        }
     
    766765        {
    767766          char *tmp;
    768           len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
     767          len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
    769768          tmp = hash_value_for_key (stream->stream_table, LONG2PTR (key));
    770           *string = objc_malloc (strlen(tmp) + 1);
     769          *string = objc_malloc (strlen (tmp) + 1);
    771770          strcpy (*string, tmp);
    772771        }
     
    776775        {
    777776          unsigned int nbytes = buf[0]&_B_VALUE;
    778           len = __objc_read_nbyte_uint(stream, nbytes, &nbytes);
     777          len = __objc_read_nbyte_uint (stream, nbytes, &nbytes);
    779778          if (len) {
    780             (*string) = (char*)objc_malloc(nbytes+1);
     779            (*string) = (char*)objc_malloc (nbytes + 1);
    781780            if (key)
    782781              hash_add (&stream->stream_table, LONG2PTR(key), *string);
    783             len = (*stream->read)(stream->physical, *string, nbytes);
     782            len = (*stream->read) (stream->physical, *string, nbytes);
    784783            (*string)[nbytes] = '\0';
    785784          }
     
    788787       
    789788      default:
    790         objc_error(nil, OBJC_ERR_BAD_DATA,
    791                    "expected string, got opcode %c\n", (buf[0]&_B_CODE));
     789        objc_error (nil, OBJC_ERR_BAD_DATA,
     790                    "expected string, got opcode %c\n", (buf[0]&_B_CODE));
    792791      }
    793792    }
     
    798797
    799798int
    800 objc_read_object (struct objc_typed_stream* stream, id* object)
     799objc_read_object (struct objc_typed_stream *stream, id *object)
    801800{
    802801  unsigned char buf[sizeof (unsigned int)];
    803802  int len;
    804   if ((len = (*stream->read)(stream->physical, buf, 1)))
     803  if ((len = (*stream->read) (stream->physical, buf, 1)))
    805804    {
    806805      SEL read_sel = sel_get_any_uid ("read:");
     
    809808      if ((buf[0]&_B_CODE) == _B_RCOMM) /* register common */
    810809        {
    811           len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
    812           len = (*stream->read)(stream->physical, buf, 1);
     810          len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
     811          len = (*stream->read) (stream->physical, buf, 1);
    813812        }
    814813
     
    821820
    822821          /* create instance */
    823           (*object) = class_create_instance(class);
     822          (*object) = class_create_instance (class);
    824823
    825824          /* register? */
     
    829828          /* send -read: */
    830829          if (__objc_responds_to (*object, read_sel))
    831             (*get_imp(class, read_sel))(*object, read_sel, stream);
     830            (*get_imp (class, read_sel)) (*object, read_sel, stream);
    832831
    833832          /* check null-byte */
    834           len = (*stream->read)(stream->physical, buf, 1);
     833          len = (*stream->read) (stream->physical, buf, 1);
    835834          if (buf[0] != '\0')
    836             objc_error(nil, OBJC_ERR_BAD_DATA,
    837                        "expected null-byte, got opcode %c", buf[0]);
     835            objc_error (nil, OBJC_ERR_BAD_DATA,
     836                        "expected null-byte, got opcode %c", buf[0]);
    838837        }
    839838
     
    841840        {
    842841          if (key)
    843             objc_error(nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
    844           len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
     842            objc_error (nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
     843          len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
    845844          (*object) = hash_value_for_key (stream->object_table, LONG2PTR(key));
    846845        }
     
    848847      else if (buf[0] == (_B_EXT | _BX_OBJREF)) /* a forward reference */
    849848        {
    850           struct objc_list* other;
     849          struct objc_list *other;
    851850          len = objc_read_unsigned_long (stream, &key);
    852           other = (struct objc_list*)hash_value_for_key (stream->object_refs,
    853                                                          LONG2PTR(key));
     851          other = (struct objc_list *) hash_value_for_key (stream->object_refs,
     852                                                           LONG2PTR(key));
    854853          hash_add (&stream->object_refs, LONG2PTR(key),
    855                     (void*)list_cons(object, other));
     854                    (void *)list_cons (object, other));
    856855        }
    857856
     
    859858        {
    860859          if (key)
    861             objc_error(nil, OBJC_ERR_BAD_KEY,
    862                        "cannot register root object...");
     860            objc_error (nil, OBJC_ERR_BAD_KEY,
     861                        "cannot register root object...");
    863862          len = objc_read_object (stream, object);
    864863          __objc_finish_read_root_object (stream);
     
    866865
    867866      else
    868         objc_error(nil, OBJC_ERR_BAD_DATA,
    869                    "expected object, got opcode %c", buf[0]);
     867        objc_error (nil, OBJC_ERR_BAD_DATA,
     868                    "expected object, got opcode %c", buf[0]);
    870869    }
    871870  return len;
     
    873872
    874873static int
    875 objc_read_class (struct objc_typed_stream* stream, Class* class)
     874objc_read_class (struct objc_typed_stream *stream, Class *class)
    876875{
    877876  unsigned char buf[sizeof (unsigned int)];
    878877  int len;
    879   if ((len = (*stream->read)(stream->physical, buf, 1)))
     878  if ((len = (*stream->read) (stream->physical, buf, 1)))
    880879    {
    881880      unsigned long key = 0;
     
    883882      if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */
    884883        {
    885           len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
    886           len = (*stream->read)(stream->physical, buf, 1);
     884          len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
     885          len = (*stream->read) (stream->physical, buf, 1);
    887886        }
    888887
    889888      if (buf[0] == (_B_EXT | _BX_CLASS))
    890889        {
    891           char* class_name;
     890          char *class_name;
    892891          unsigned long version;
    893892
    894893          /* get class */
    895894          len = objc_read_string (stream, &class_name);
    896           (*class) = objc_get_class(class_name);
    897           objc_free(class_name);
     895          (*class) = objc_get_class (class_name);
     896          objc_free (class_name);
    898897
    899898          /* register */
     
    901900            hash_add (&stream->stream_table, LONG2PTR(key), *class);
    902901
    903           objc_read_unsigned_long(stream, &version);
    904           hash_add (&stream->class_table, (*class)->name, (void*)version);
     902          objc_read_unsigned_long (stream, &version);
     903          hash_add (&stream->class_table, (*class)->name, (void *)version);
    905904        }
    906905
     
    908907        {
    909908          if (key)
    910             objc_error(nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
    911           len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
    912           (*class) = hash_value_for_key (stream->stream_table, LONG2PTR(key));
    913           if (!*class)
    914             objc_error(nil, OBJC_ERR_BAD_CLASS,
    915                        "cannot find class for key %lu", key);
     909            objc_error (nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
     910          len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
     911          *class = hash_value_for_key (stream->stream_table, LONG2PTR(key));
     912          if (! *class)
     913            objc_error (nil, OBJC_ERR_BAD_CLASS,
     914                        "cannot find class for key %lu", key);
    916915        }
    917916
    918917      else
    919         objc_error(nil, OBJC_ERR_BAD_DATA,
    920                    "expected class, got opcode %c", buf[0]);
     918        objc_error (nil, OBJC_ERR_BAD_DATA,
     919                    "expected class, got opcode %c", buf[0]);
    921920    }
    922921  return len;
     
    924923
    925924int
    926 objc_read_selector (struct objc_typed_stream* stream, SEL* selector)
     925objc_read_selector (struct objc_typed_stream *stream, SEL* selector)
    927926{
    928927  unsigned char buf[sizeof (unsigned int)];
    929928  int len;
    930   if ((len = (*stream->read)(stream->physical, buf, 1)))
     929  if ((len = (*stream->read) (stream->physical, buf, 1)))
    931930    {
    932931      unsigned long key = 0;
     
    934933      if ((buf[0]&_B_CODE) == _B_RCOMM) /* register following */
    935934        {
    936           len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
    937           len = (*stream->read)(stream->physical, buf, 1);
     935          len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
     936          len = (*stream->read) (stream->physical, buf, 1);
    938937        }
    939938
    940939      if (buf[0] == (_B_EXT|_BX_SEL)) /* selector! */
    941940        {
    942           char* selector_name;
     941          char *selector_name;
    943942
    944943          /* get selector */
    945944          len = objc_read_string (stream, &selector_name);
    946945          /* To handle NULL selectors */
    947           if (0 == strlen(selector_name))
     946          if (0 == strlen (selector_name))
    948947            {
    949948              (*selector) = (SEL)0;
     
    951950            }
    952951          else
    953             (*selector) = sel_get_any_uid(selector_name);
    954           objc_free(selector_name);
     952            (*selector) = sel_get_any_uid (selector_name);
     953          objc_free (selector_name);
    955954
    956955          /* register */
    957956          if (key)
    958             hash_add (&stream->stream_table, LONG2PTR(key), (void*)*selector);
     957            hash_add (&stream->stream_table, LONG2PTR(key), (void *) *selector);
    959958        }
    960959
     
    962961        {
    963962          if (key)
    964             objc_error(nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
    965           len = __objc_read_nbyte_ulong(stream, (buf[0] & _B_VALUE), &key);
     963            objc_error (nil, OBJC_ERR_BAD_KEY, "cannot register use upcode...");
     964          len = __objc_read_nbyte_ulong (stream, (buf[0] & _B_VALUE), &key);
    966965          (*selector) = hash_value_for_key (stream->stream_table,
    967966                                            LONG2PTR(key));
     
    969968
    970969      else
    971         objc_error(nil, OBJC_ERR_BAD_DATA,
    972                    "expected selector, got opcode %c", buf[0]);
     970        objc_error (nil, OBJC_ERR_BAD_DATA,
     971                    "expected selector, got opcode %c", buf[0]);
    973972    }
    974973  return len;
     
    985984
    986985int
    987 objc_write_type(TypedStream* stream, const char* type, const void* data)
    988 {
    989   switch(*type) {
     986objc_write_type (TypedStream *stream, const char *type, const void *data)
     987{
     988  switch (*type) {
    990989  case _C_ID:
    991     return objc_write_object (stream, *(id*)data);
     990    return objc_write_object (stream, *(id *) data);
    992991    break;
    993992
    994993  case _C_CLASS:
    995     return objc_write_class (stream, *(Class*)data);
     994    return objc_write_class (stream, *(Class *) data);
    996995    break;
    997996
    998997  case _C_SEL:
    999     return objc_write_selector (stream, *(SEL*)data);
     998    return objc_write_selector (stream, *(SEL *) data);
    1000999    break;
    10011000
    10021001  case _C_CHR:
    1003     return objc_write_char(stream, *(signed char*)data);
     1002    return objc_write_char (stream, *(signed char *) data);
    10041003    break;
    10051004   
    10061005  case _C_UCHR:
    1007     return objc_write_unsigned_char(stream, *(unsigned char*)data);
     1006    return objc_write_unsigned_char (stream, *(unsigned char *) data);
    10081007    break;
    10091008
    10101009  case _C_SHT:
    1011     return objc_write_short(stream, *(short*)data);
     1010    return objc_write_short (stream, *(short *) data);
    10121011    break;
    10131012
    10141013  case _C_USHT:
    1015     return objc_write_unsigned_short(stream, *(unsigned short*)data);
     1014    return objc_write_unsigned_short (stream, *(unsigned short *) data);
    10161015    break;
    10171016
    10181017  case _C_INT:
    1019     return objc_write_int(stream, *(int*)data);
     1018    return objc_write_int (stream, *(int *) data);
    10201019    break;
    10211020
    10221021  case _C_UINT:
    1023     return objc_write_unsigned_int(stream, *(unsigned int*)data);
     1022    return objc_write_unsigned_int (stream, *(unsigned int *) data);
    10241023    break;
    10251024
    10261025  case _C_LNG:
    1027     return objc_write_long(stream, *(long*)data);
     1026    return objc_write_long (stream, *(long *) data);
    10281027    break;
    10291028
    10301029  case _C_ULNG:
    1031     return objc_write_unsigned_long(stream, *(unsigned long*)data);
     1030    return objc_write_unsigned_long (stream, *(unsigned long *) data);
    10321031    break;
    10331032
    10341033  case _C_CHARPTR:
    1035     return objc_write_string (stream, *(char**)data, strlen(*(char**)data));
     1034    return objc_write_string (stream,
     1035                              *(char **) data, strlen (*(char **) data));
    10361036    break;
    10371037
    10381038  case _C_ATOM:
    1039     return objc_write_string_atomic (stream, *(char**)data,
    1040                                      strlen(*(char**)data));
     1039    return objc_write_string_atomic (stream, *(char **) data,
     1040                                     strlen (*(char **) data));
    10411041    break;
    10421042
    10431043  case _C_ARY_B:
    10441044    {
    1045       int len = atoi(type+1);
    1046       while (isdigit(*++type))
     1045      int len = atoi (type + 1);
     1046      while (isdigit ((unsigned char) *++type))
    10471047        ;
    10481048      return objc_write_array (stream, type, len, data);
     
    10601060          align = objc_alignof_type (type);       /* padd to alignment */
    10611061          acc_size += ROUND (acc_size, align);
    1062           objc_write_type (stream, type, ((char*)data)+acc_size);
     1062          objc_write_type (stream, type, ((char *) data) + acc_size);
    10631063          acc_size += objc_sizeof_type (type);   /* add component size */
    10641064          type = objc_skip_typespec (type);      /* skip component */
     
    10691069  default:
    10701070    {
    1071       objc_error(nil, OBJC_ERR_BAD_TYPE,
    1072                  "objc_write_type: cannot parse typespec: %s\n", type);
     1071      objc_error (nil, OBJC_ERR_BAD_TYPE,
     1072                  "objc_write_type: cannot parse typespec: %s\n", type);
    10731073      return 0;
    10741074    }
     
    10841084
    10851085int
    1086 objc_read_type(TypedStream* stream, const char* type, void* data)
     1086objc_read_type(TypedStream *stream, const char *type, void *data)
    10871087{
    10881088  char c;
    1089   switch(c = *type) {
     1089  switch (c = *type) {
    10901090  case _C_ID:
    10911091    return objc_read_object (stream, (id*)data);
     
    11391139  case _C_ARY_B:
    11401140    {
    1141       int len = atoi(type+1);
    1142       while (isdigit(*++type))
     1141      int len = atoi (type + 1);
     1142      while (isdigit ((unsigned char) *++type))
    11431143        ;
    11441144      return objc_read_array (stream, type, len, data);
     
    11651165  default:
    11661166    {
    1167       objc_error(nil, OBJC_ERR_BAD_TYPE,
    1168                  "objc_read_type: cannot parse typespec: %s\n", type);
     1167      objc_error (nil, OBJC_ERR_BAD_TYPE,
     1168                  "objc_read_type: cannot parse typespec: %s\n", type);
    11691169      return 0;
    11701170    }
     
    11831183
    11841184int
    1185 objc_write_types (TypedStream* stream, const char* type, ...)
     1185objc_write_types (TypedStream *stream, const char *type, ...)
    11861186{
    11871187  va_list args;
     
    11931193  for (c = type; *c; c = objc_skip_typespec (c))
    11941194    {
    1195       switch(*c) {
     1195      switch (*c) {
    11961196      case _C_ID:
    11971197        res = objc_write_object (stream, *va_arg (args, id*));
     
    11991199
    12001200      case _C_CLASS:
    1201         res = objc_write_class (stream, *va_arg(args, Class*));
     1201        res = objc_write_class (stream, *va_arg (args, Class*));
    12021202        break;
    12031203
    12041204      case _C_SEL:
    1205         res = objc_write_selector (stream, *va_arg(args, SEL*));
     1205        res = objc_write_selector (stream, *va_arg (args, SEL*));
    12061206        break;
    12071207       
     
    12161216       
    12171217      case _C_SHT:
    1218         res = objc_write_short (stream, *va_arg(args, short*));
     1218        res = objc_write_short (stream, *va_arg (args, short*));
    12191219        break;
    12201220
    12211221      case _C_USHT:
    12221222        res = objc_write_unsigned_short (stream,
    1223                                          *va_arg(args, unsigned short*));
     1223                                         *va_arg (args, unsigned short*));
    12241224        break;
    12251225
    12261226      case _C_INT:
    1227         res = objc_write_int(stream, *va_arg(args, int*));
     1227        res = objc_write_int(stream, *va_arg (args, int*));
    12281228        break;
    12291229       
    12301230      case _C_UINT:
    1231         res = objc_write_unsigned_int(stream, *va_arg(args, unsigned int*));
     1231        res = objc_write_unsigned_int(stream, *va_arg (args, unsigned int*));
    12321232        break;
    12331233
    12341234      case _C_LNG:
    1235         res = objc_write_long(stream, *va_arg(args, long*));
     1235        res = objc_write_long(stream, *va_arg (args, long*));
    12361236        break;
    12371237       
    12381238      case _C_ULNG:
    1239         res = objc_write_unsigned_long(stream, *va_arg(args, unsigned long*));
     1239        res = objc_write_unsigned_long(stream, *va_arg (args, unsigned long*));
    12401240        break;
    12411241
    12421242      case _C_CHARPTR:
    12431243        {
    1244           char** str = va_arg(args, char**);
    1245           res = objc_write_string (stream, *str, strlen(*str));
     1244          char **str = va_arg (args, char **);
     1245          res = objc_write_string (stream, *str, strlen (*str));
    12461246        }
    12471247        break;
     
    12491249      case _C_ATOM:
    12501250        {
    1251           char** str = va_arg(args, char**);
    1252           res = objc_write_string_atomic (stream, *str, strlen(*str));
     1251          char **str = va_arg (args, char **);
     1252          res = objc_write_string_atomic (stream, *str, strlen (*str));
    12531253        }
    12541254        break;
     
    12561256      case _C_ARY_B:
    12571257        {
    1258           int len = atoi(c+1);
    1259           const char* t = c;
    1260           while (isdigit(*++t))
     1258          int len = atoi (c + 1);
     1259          const char *t = c;
     1260          while (isdigit ((unsigned char) *++t))
    12611261            ;
    1262           res = objc_write_array (stream, t, len, va_arg(args, void*));
     1262          res = objc_write_array (stream, t, len, va_arg (args, void *));
    12631263          t = objc_skip_typespec (t);
    12641264          if (*t != _C_ARY_E)
    1265             objc_error(nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t);
     1265            objc_error (nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t);
    12661266        }
    12671267        break;
    12681268       
    12691269      default:
    1270         objc_error(nil, OBJC_ERR_BAD_TYPE,
    1271                    "objc_write_types: cannot parse typespec: %s\n", type);
     1270        objc_error (nil, OBJC_ERR_BAD_TYPE,
     1271                    "objc_write_types: cannot parse typespec: %s\n", type);
    12721272      }
    12731273    }
     
    12831283
    12841284int
    1285 objc_read_types(TypedStream* stream, const char* type, ...)
     1285objc_read_types(TypedStream *stream, const char *type, ...)
    12861286{
    12871287  va_list args;
     
    12891289  int res = 0;
    12901290
    1291   va_start(args, type);
     1291  va_start (args, type);
    12921292
    12931293  for (c = type; *c; c = objc_skip_typespec(c))
    12941294    {
    1295       switch(*c) {
     1295      switch (*c) {
    12961296      case _C_ID:
    1297         res = objc_read_object(stream, va_arg(args, id*));
     1297        res = objc_read_object(stream, va_arg (args, id*));
    12981298        break;
    12991299
    13001300      case _C_CLASS:
    1301         res = objc_read_class(stream, va_arg(args, Class*));
     1301        res = objc_read_class(stream, va_arg (args, Class*));
    13021302        break;
    13031303
    13041304      case _C_SEL:
    1305         res = objc_read_selector(stream, va_arg(args, SEL*));
     1305        res = objc_read_selector(stream, va_arg (args, SEL*));
    13061306        break;
    13071307       
    13081308      case _C_CHR:
    1309         res = objc_read_char(stream, va_arg(args, char*));
     1309        res = objc_read_char(stream, va_arg (args, char*));
    13101310        break;
    13111311       
    13121312      case _C_UCHR:
    1313         res = objc_read_unsigned_char(stream, va_arg(args, unsigned char*));
     1313        res = objc_read_unsigned_char(stream, va_arg (args, unsigned char*));
    13141314        break;
    13151315       
    13161316      case _C_SHT:
    1317         res = objc_read_short(stream, va_arg(args, short*));
     1317        res = objc_read_short(stream, va_arg (args, short*));
    13181318        break;
    13191319
    13201320      case _C_USHT:
    1321         res = objc_read_unsigned_short(stream, va_arg(args, unsigned short*));
     1321        res = objc_read_unsigned_short(stream, va_arg (args, unsigned short*));
    13221322        break;
    13231323
    13241324      case _C_INT:
    1325         res = objc_read_int(stream, va_arg(args, int*));
     1325        res = objc_read_int(stream, va_arg (args, int*));
    13261326        break;
    13271327       
    13281328      case _C_UINT:
    1329         res = objc_read_unsigned_int(stream, va_arg(args, unsigned int*));
     1329        res = objc_read_unsigned_int(stream, va_arg (args, unsigned int*));
    13301330        break;
    13311331
    13321332      case _C_LNG:
    1333         res = objc_read_long(stream, va_arg(args, long*));
     1333        res = objc_read_long(stream, va_arg (args, long*));
    13341334        break;
    13351335       
    13361336      case _C_ULNG:
    1337         res = objc_read_unsigned_long(stream, va_arg(args, unsigned long*));
     1337        res = objc_read_unsigned_long(stream, va_arg (args, unsigned long*));
    13381338        break;
    13391339
     
    13411341      case _C_ATOM:
    13421342        {
    1343           char** str = va_arg(args, char**);
     1343          char **str = va_arg (args, char **);
    13441344          res = objc_read_string (stream, str);
    13451345        }
     
    13481348      case _C_ARY_B:
    13491349        {
    1350           int len = atoi(c+1);
    1351           const char* t = c;
    1352           while (isdigit(*++t))
     1350          int len = atoi (c + 1);
     1351          const char *t = c;
     1352          while (isdigit ((unsigned char) *++t))
    13531353            ;
    1354           res = objc_read_array (stream, t, len, va_arg(args, void*));
     1354          res = objc_read_array (stream, t, len, va_arg (args, void *));
    13551355          t = objc_skip_typespec (t);
    13561356          if (*t != _C_ARY_E)
    1357             objc_error(nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t);
     1357            objc_error (nil, OBJC_ERR_BAD_TYPE, "expected `]', got: %s", t);
    13581358        }
    13591359        break;
    13601360       
    13611361      default:
    1362         objc_error(nil, OBJC_ERR_BAD_TYPE,
    1363                    "objc_read_types: cannot parse typespec: %s\n", type);
     1362        objc_error (nil, OBJC_ERR_BAD_TYPE,
     1363                    "objc_read_types: cannot parse typespec: %s\n", type);
    13641364      }
    13651365    }
    1366   va_end(args);
     1366  va_end (args);
    13671367  return res;
    13681368}
     
    13741374
    13751375int
    1376 objc_write_array (TypedStream* stream, const char* type,
    1377                   int count, const void* data)
     1376objc_write_array (TypedStream *stream, const char *type,
     1377                  int count, const void *data)
    13781378{
    13791379  int off = objc_sizeof_type(type);
    1380   const char* where = data;
     1380  const char *where = data;
    13811381
    13821382  while (count-- > 0)
     
    13961396
    13971397int
    1398 objc_read_array (TypedStream* stream, const char* type,
    1399                  int count, void* data)
     1398objc_read_array (TypedStream *stream, const char *type,
     1399                 int count, void *data)
    14001400{
    14011401  int off = objc_sizeof_type(type);
    1402   char* where = (char*)data;
     1402  char *where = (char*)data;
    14031403
    14041404  while (count-- > 0)
     
    14111411
    14121412static int
    1413 __objc_fread(FILE* file, char* data, int len)
     1413__objc_fread (FILE *file, char *data, int len)
    14141414{
    14151415  return fread(data, len, 1, file);
     
    14171417
    14181418static int
    1419 __objc_fwrite(FILE* file, char* data, int len)
     1419__objc_fwrite (FILE *file, char *data, int len)
    14201420{
    14211421  return fwrite(data, len, 1, file);
     
    14231423
    14241424static int
    1425 __objc_feof(FILE* file)
     1425__objc_feof (FILE *file)
    14261426{
    14271427  return feof(file);
     
    14291429
    14301430static int
    1431 __objc_no_write(FILE* file, char* data, int len)
     1431__objc_no_write (FILE *file __attribute__ ((__unused__)),
     1432                 const char *data __attribute__ ((__unused__)),
     1433                 int len __attribute__ ((__unused__)))
    14321434{
    14331435  objc_error (nil, OBJC_ERR_NO_WRITE, "TypedStream not open for writing");
     
    14361438
    14371439static int
    1438 __objc_no_read(FILE* file, char* data, int len)
     1440__objc_no_read (FILE *file __attribute__ ((__unused__)),
     1441                const char *data __attribute__ ((__unused__)),
     1442                int len __attribute__ ((__unused__)))
    14391443{
    14401444  objc_error (nil, OBJC_ERR_NO_READ, "TypedStream not open for reading");
     
    14431447
    14441448static int
    1445 __objc_read_typed_stream_signature (TypedStream* stream)
     1449__objc_read_typed_stream_signature (TypedStream *stream)
    14461450{
    14471451  char buffer[80];
    14481452  int pos = 0;
    14491453  do
    1450     (*stream->read)(stream->physical, buffer+pos, 1);
     1454    (*stream->read) (stream->physical, buffer+pos, 1);
    14511455  while (buffer[pos++] != '\0')
    14521456    ;
     
    14591463
    14601464static int
    1461 __objc_write_typed_stream_signature (TypedStream* stream)
     1465__objc_write_typed_stream_signature (TypedStream *stream)
    14621466{
    14631467  char buffer[80];
    14641468  sprintf(buffer, "GNU TypedStream %d", OBJC_TYPED_STREAM_VERSION);
    14651469  stream->version = OBJC_TYPED_STREAM_VERSION;
    1466   (*stream->write)(stream->physical, buffer, strlen(buffer)+1);
     1470  (*stream->write) (stream->physical, buffer, strlen (buffer) + 1);
    14671471  return 1;
    14681472}
    14691473
    1470 static void __objc_finish_write_root_object(struct objc_typed_stream* stream)
     1474static void __objc_finish_write_root_object(struct objc_typed_stream *stream)
    14711475{
    14721476  hash_delete (stream->object_table);
     
    14761480}
    14771481
    1478 static void __objc_finish_read_root_object(struct objc_typed_stream* stream)
     1482static void __objc_finish_read_root_object(struct objc_typed_stream *stream)
    14791483{
    14801484  node_ptr node;
     
    14881492       node = hash_next (stream->object_refs, node))
    14891493    {
    1490       struct objc_list* reflist = node->value;
    1491       const void* key = node->key;
     1494      struct objc_list *reflist = node->value;
     1495      const void *key = node->key;
    14921496      id object = hash_value_for_key (stream->object_table, key);
    1493       while(reflist)
    1494         {
    1495           *((id*)reflist->head) = object;
     1497      while (reflist)
     1498        {
     1499          *((id*) reflist->head) = object;
    14961500          if (hash_value_for_key (free_list,reflist) == NULL)
    14971501            hash_add (&free_list,reflist,reflist);
     
    15211525          id object = node->value;
    15221526          if (__objc_responds_to (object, awake_sel))
    1523             (*objc_msg_lookup(object, awake_sel))(object, awake_sel);
     1527            (*objc_msg_lookup (object, awake_sel)) (object, awake_sel);
    15241528        }
    15251529    }
     
    15361540*/
    15371541
    1538 TypedStream*
    1539 objc_open_typed_stream (FILE* physical, int mode)
    1540 {
    1541   TypedStream* s = (TypedStream*)objc_malloc(sizeof(TypedStream));
     1542TypedStream *
     1543objc_open_typed_stream (FILE *physical, int mode)
     1544{
     1545  TypedStream *s = (TypedStream *) objc_malloc (sizeof (TypedStream));
    15421546
    15431547  s->mode = mode;
    15441548  s->physical = physical;
    1545   s->stream_table = hash_new(64,
    1546                              (hash_func_type)hash_ptr,
    1547                              (compare_func_type)compare_ptrs);
    1548   s->object_table = hash_new(64,
    1549                              (hash_func_type)hash_ptr,
    1550                              (compare_func_type)compare_ptrs);
    1551   s->eof = (objc_typed_eof_func)__objc_feof;
    1552   s->flush = (objc_typed_flush_func)fflush;
     1549  s->stream_table = hash_new (64,
     1550                              (hash_func_type) hash_ptr,
     1551                              (compare_func_type) compare_ptrs);
     1552  s->object_table = hash_new (64,
     1553                              (hash_func_type) hash_ptr,
     1554                              (compare_func_type) compare_ptrs);
     1555  s->eof = (objc_typed_eof_func) __objc_feof;
     1556  s->flush = (objc_typed_flush_func) fflush;
    15531557  s->writing_root_p = 0;
    15541558  if (mode == OBJC_READONLY)
    15551559    {
    1556       s->class_table = hash_new(8, (hash_func_type)hash_string,
    1557                                 (compare_func_type)compare_strings);
    1558       s->object_refs = hash_new(8, (hash_func_type)hash_ptr,
    1559                                 (compare_func_type)compare_ptrs);
    1560       s->read = (objc_typed_read_func)__objc_fread;
    1561       s->write = (objc_typed_write_func)__objc_no_write;
     1560      s->class_table = hash_new (8, (hash_func_type) hash_string,
     1561                                 (compare_func_type) compare_strings);
     1562      s->object_refs = hash_new (8, (hash_func_type) hash_ptr,
     1563                                 (compare_func_type) compare_ptrs);
     1564      s->read = (objc_typed_read_func) __objc_fread;
     1565      s->write = (objc_typed_write_func) __objc_no_write;
    15621566      __objc_read_typed_stream_signature (s);
    15631567    }
     
    15661570      s->class_table = 0;
    15671571      s->object_refs = 0;
    1568       s->read = (objc_typed_read_func)__objc_no_read;
    1569       s->write = (objc_typed_write_func)__objc_fwrite;
     1572      s->read = (objc_typed_read_func) __objc_no_read;
     1573      s->write = (objc_typed_write_func) __objc_fwrite;
    15701574      __objc_write_typed_stream_signature (s);
    15711575    }     
     
    15841588
    15851589TypedStream*
    1586 objc_open_typed_stream_for_file (const char* file_name, int mode)
    1587 {
    1588   FILE* file = NULL;
    1589   TypedStream* s;
     1590objc_open_typed_stream_for_file (const char *file_name, int mode)
     1591{
     1592  FILE *file = NULL;
     1593  TypedStream *s;
    15901594
    15911595  if (mode == OBJC_READONLY)
     
    16111615
    16121616void
    1613 objc_close_typed_stream (TypedStream* stream)
     1617objc_close_typed_stream (TypedStream *stream)
    16141618{
    16151619  if (stream->mode == OBJC_READONLY)
     
    16241628
    16251629  if (stream->type == (OBJC_MANAGED_STREAM | OBJC_FILE_STREAM))
    1626     fclose ((FILE*)stream->physical);
     1630    fclose ((FILE *)stream->physical);
    16271631
    16281632  objc_free(stream);
     
    16301634
    16311635BOOL
    1632 objc_end_of_typed_stream (TypedStream* stream)
    1633 {
    1634   return (*stream->eof)(stream->physical);
     1636objc_end_of_typed_stream (TypedStream *stream)
     1637{
     1638  return (*stream->eof) (stream->physical);
    16351639}
    16361640
    16371641void
    1638 objc_flush_typed_stream (TypedStream* stream)
    1639 {
    1640   (*stream->flush)(stream->physical);
     1642objc_flush_typed_stream (TypedStream *stream)
     1643{
     1644  (*stream->flush) (stream->physical);
    16411645}
    16421646
    16431647long
    1644 objc_get_stream_class_version (TypedStream* stream, Class class)
     1648objc_get_stream_class_version (TypedStream *stream, Class class)
    16451649{
    16461650  if (stream->class_table)
Note: See TracChangeset for help on using the changeset viewer.