mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
Use unsigned char instead of char.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4657 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
78a8a7a4a3
commit
914ab42dd6
5 changed files with 86 additions and 74 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
Mon Jul 26 21:22:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
|
Fix cStrings to use unsigned char throughout - to avoid problems
|
||||||
|
with character sets other than ascii. Suggested by Kai Henningsen.
|
||||||
|
* Headers/Foundation/NSGCString.h: Use unsigned chars.
|
||||||
|
* Source/NSGCString.m: Use unsigned chars.
|
||||||
|
* Source/GSeq.h: Use unsigned chars.
|
||||||
|
* Source/propList.h: Use unsigned chars.
|
||||||
|
|
||||||
Fri Jul 23 22:20:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
Fri Jul 23 22:20:00 1999 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||||
|
|
||||||
* Source/UnixFileHandle.m: Tidy a little and make sure that
|
* Source/UnixFileHandle.m: Tidy a little and make sure that
|
||||||
|
|
|
@ -36,8 +36,8 @@
|
||||||
|
|
||||||
@interface NSGCString : NSString
|
@interface NSGCString : NSString
|
||||||
{
|
{
|
||||||
char * _contents_chars;
|
unsigned char *_contents_chars;
|
||||||
int _count;
|
unsigned _count;
|
||||||
NSZone *_zone;
|
NSZone *_zone;
|
||||||
unsigned _hash;
|
unsigned _hash;
|
||||||
}
|
}
|
||||||
|
@ -45,11 +45,11 @@
|
||||||
|
|
||||||
@interface NSGMutableCString : NSMutableString
|
@interface NSGMutableCString : NSMutableString
|
||||||
{
|
{
|
||||||
char * _contents_chars;
|
unsigned char * _contents_chars;
|
||||||
int _count;
|
unsigned _count;
|
||||||
NSZone *_zone;
|
NSZone *_zone;
|
||||||
unsigned _hash;
|
unsigned _hash;
|
||||||
int _capacity;
|
unsigned _capacity;
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -275,7 +275,7 @@ typedef struct {
|
||||||
unsigned _lcount = 0; \
|
unsigned _lcount = 0; \
|
||||||
while (_lcount < (R).length) \
|
while (_lcount < (R).length) \
|
||||||
{ \
|
{ \
|
||||||
(B)[_lcount] = (unichar)s->_contents_chars[(R).location + _lcount]; \
|
(B)[_lcount] = (unichar)(unsigned char)s->_contents_chars[(R).location + _lcount]; \
|
||||||
_lcount++; \
|
_lcount++; \
|
||||||
} \
|
} \
|
||||||
} )
|
} )
|
||||||
|
@ -307,7 +307,7 @@ typedef struct {
|
||||||
unsigned _lcount = 0; \
|
unsigned _lcount = 0; \
|
||||||
while (_lcount < (R).length) \
|
while (_lcount < (R).length) \
|
||||||
{ \
|
{ \
|
||||||
(B)[_lcount] = (unichar)o->_contents_chars[(R).location + _lcount]; \
|
(B)[_lcount] = (unichar)(unsigned char)o->_contents_chars[(R).location + _lcount]; \
|
||||||
_lcount++; \
|
_lcount++; \
|
||||||
} \
|
} \
|
||||||
} )
|
} )
|
||||||
|
|
|
@ -76,7 +76,7 @@ static IMP csInitImp; /* designated initialiser for cString */
|
||||||
static IMP msInitImp; /* designated initialiser for mutable */
|
static IMP msInitImp; /* designated initialiser for mutable */
|
||||||
|
|
||||||
@interface NSGMutableCString (GNUDescription)
|
@interface NSGMutableCString (GNUDescription)
|
||||||
- (char*) _extendBy: (unsigned)len;
|
- (unsigned char*) _extendBy: (unsigned)len;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation NSGCString
|
@implementation NSGCString
|
||||||
|
@ -132,7 +132,7 @@ static IMP msInitImp; /* designated initialiser for mutable */
|
||||||
fromZone: (NSZone*)zone
|
fromZone: (NSZone*)zone
|
||||||
{
|
{
|
||||||
_count = length;
|
_count = length;
|
||||||
_contents_chars = byteString;
|
_contents_chars = (unsigned char*)byteString;
|
||||||
_zone = byteString ? zone : 0;
|
_zone = byteString ? zone : 0;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ static IMP msInitImp; /* designated initialiser for mutable */
|
||||||
if (NSShouldRetainWithZone(self, z) == NO)
|
if (NSShouldRetainWithZone(self, z) == NO)
|
||||||
{
|
{
|
||||||
NSGCString *obj;
|
NSGCString *obj;
|
||||||
char *tmp;
|
unsigned char *tmp;
|
||||||
|
|
||||||
obj = (NSGCString*)NSAllocateObject(_fastCls._NSGCString, 0, z);
|
obj = (NSGCString*)NSAllocateObject(_fastCls._NSGCString, 0, z);
|
||||||
if (_count)
|
if (_count)
|
||||||
|
@ -262,7 +262,7 @@ static IMP msInitImp; /* designated initialiser for mutable */
|
||||||
if (NSShouldRetainWithZone(self, z) == NO)
|
if (NSShouldRetainWithZone(self, z) == NO)
|
||||||
{
|
{
|
||||||
NSGCString *obj;
|
NSGCString *obj;
|
||||||
char *tmp;
|
unsigned char *tmp;
|
||||||
|
|
||||||
obj = (NSGCString*)NSAllocateObject(_fastCls._NSGCString, 0, z);
|
obj = (NSGCString*)NSAllocateObject(_fastCls._NSGCString, 0, z);
|
||||||
if (_count)
|
if (_count)
|
||||||
|
@ -331,11 +331,11 @@ static IMP msInitImp; /* designated initialiser for mutable */
|
||||||
|
|
||||||
- (const char *) cString
|
- (const char *) cString
|
||||||
{
|
{
|
||||||
char *r = (char*)_fastMallocBuffer(_count+1);
|
unsigned char *r = (unsigned char*)_fastMallocBuffer(_count+1);
|
||||||
|
|
||||||
memcpy(r, _contents_chars, _count);
|
memcpy(r, _contents_chars, _count);
|
||||||
r[_count] = '\0';
|
r[_count] = '\0';
|
||||||
return r;
|
return (const char*)r;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) getCString: (char*)buffer
|
- (void) getCString: (char*)buffer
|
||||||
|
@ -407,7 +407,7 @@ static IMP msInitImp; /* designated initialiser for mutable */
|
||||||
|
|
||||||
- (void) getCharacters: (unichar*)buffer
|
- (void) getCharacters: (unichar*)buffer
|
||||||
{
|
{
|
||||||
int i;
|
unsigned i;
|
||||||
|
|
||||||
for (i = 0; i < _count; i++)
|
for (i = 0; i < _count; i++)
|
||||||
buffer[i] = chartouni(((unsigned char *)_contents_chars)[i]);
|
buffer[i] = chartouni(((unsigned char *)_contents_chars)[i]);
|
||||||
|
@ -415,7 +415,7 @@ static IMP msInitImp; /* designated initialiser for mutable */
|
||||||
|
|
||||||
- (void) getCharacters: (unichar*)buffer range: (NSRange)aRange
|
- (void) getCharacters: (unichar*)buffer range: (NSRange)aRange
|
||||||
{
|
{
|
||||||
int e, i;
|
unsigned e, i;
|
||||||
|
|
||||||
GS_RANGE_CHECK(aRange, _count);
|
GS_RANGE_CHECK(aRange, _count);
|
||||||
e = aRange.location + aRange.length;
|
e = aRange.location + aRange.length;
|
||||||
|
@ -432,7 +432,8 @@ static IMP msInitImp; /* designated initialiser for mutable */
|
||||||
|
|
||||||
- (NSStringEncoding) fastestEncoding
|
- (NSStringEncoding) fastestEncoding
|
||||||
{
|
{
|
||||||
if(([NSString defaultCStringEncoding]==NSASCIIStringEncoding) || ([NSString defaultCStringEncoding]==NSISOLatin1StringEncoding))
|
if (([NSString defaultCStringEncoding] == NSASCIIStringEncoding)
|
||||||
|
|| ([NSString defaultCStringEncoding] == NSISOLatin1StringEncoding))
|
||||||
return [NSString defaultCStringEncoding];
|
return [NSString defaultCStringEncoding];
|
||||||
else
|
else
|
||||||
return NSUnicodeStringEncoding;
|
return NSUnicodeStringEncoding;
|
||||||
|
@ -543,7 +544,7 @@ static IMP msInitImp; /* designated initialiser for mutable */
|
||||||
{
|
{
|
||||||
unsigned length = [string cStringLength];
|
unsigned length = [string cStringLength];
|
||||||
NSZone *z;
|
NSZone *z;
|
||||||
char *buf;
|
unsigned char *buf;
|
||||||
|
|
||||||
if (length > 0)
|
if (length > 0)
|
||||||
{
|
{
|
||||||
|
@ -576,7 +577,7 @@ static IMP msInitImp; /* designated initialiser for mutable */
|
||||||
|
|
||||||
for (i = 0; i < _count; i++)
|
for (i = 0; i < _count; i++)
|
||||||
{
|
{
|
||||||
char val = _contents_chars[i];
|
unsigned char val = _contents_chars[i];
|
||||||
|
|
||||||
if (isalnum(val))
|
if (isalnum(val))
|
||||||
{
|
{
|
||||||
|
@ -613,8 +614,8 @@ static IMP msInitImp; /* designated initialiser for mutable */
|
||||||
{
|
{
|
||||||
Class c = fastClass(output);
|
Class c = fastClass(output);
|
||||||
NSZone *z = NSDefaultMallocZone();
|
NSZone *z = NSDefaultMallocZone();
|
||||||
char *buf;
|
unsigned char *buf;
|
||||||
char *ptr;
|
unsigned char *ptr;
|
||||||
|
|
||||||
length += 2;
|
length += 2;
|
||||||
if (c == _fastCls._NSGMutableCString)
|
if (c == _fastCls._NSGMutableCString)
|
||||||
|
@ -629,7 +630,7 @@ static IMP msInitImp; /* designated initialiser for mutable */
|
||||||
*ptr++ = '"';
|
*ptr++ = '"';
|
||||||
for (i = 0; i < _count; i++)
|
for (i = 0; i < _count; i++)
|
||||||
{
|
{
|
||||||
char val = _contents_chars[i];
|
unsigned char val = _contents_chars[i];
|
||||||
|
|
||||||
switch (val)
|
switch (val)
|
||||||
{
|
{
|
||||||
|
@ -815,8 +816,9 @@ stringIncrementCountAndMakeHoleAt(NSGMutableCStringStruct *self,
|
||||||
{
|
{
|
||||||
#ifndef STABLE_MEMCPY
|
#ifndef STABLE_MEMCPY
|
||||||
{
|
{
|
||||||
int i;
|
unsigned i = self->_count;
|
||||||
for (i = self->_count; i >= index; i--)
|
|
||||||
|
while (i-- > index)
|
||||||
self->_contents_chars[i+size] = self->_contents_chars[i];
|
self->_contents_chars[i+size] = self->_contents_chars[i];
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -869,7 +871,7 @@ stringDecrementCountAndFillHoleAt(NSGMutableCStringStruct *self,
|
||||||
{
|
{
|
||||||
_count = length;
|
_count = length;
|
||||||
_capacity = length;
|
_capacity = length;
|
||||||
_contents_chars = byteString;
|
_contents_chars = (unsigned char*)byteString;
|
||||||
_zone = byteString ? zone : 0;
|
_zone = byteString ? zone : 0;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
|
@ -901,7 +903,7 @@ stringDecrementCountAndFillHoleAt(NSGMutableCStringStruct *self,
|
||||||
|
|
||||||
- (id) copy
|
- (id) copy
|
||||||
{
|
{
|
||||||
char *tmp;
|
unsigned char *tmp;
|
||||||
NSGCString *obj;
|
NSGCString *obj;
|
||||||
NSZone *z = NSDefaultMallocZone();
|
NSZone *z = NSDefaultMallocZone();
|
||||||
|
|
||||||
|
@ -928,7 +930,7 @@ stringDecrementCountAndFillHoleAt(NSGMutableCStringStruct *self,
|
||||||
|
|
||||||
- (id) copyWithZone: (NSZone*)z
|
- (id) copyWithZone: (NSZone*)z
|
||||||
{
|
{
|
||||||
char *tmp;
|
unsigned char *tmp;
|
||||||
NSGCString *obj;
|
NSGCString *obj;
|
||||||
|
|
||||||
obj = (NSGCString*)NSAllocateObject(_fastCls._NSGCString, 0, z);
|
obj = (NSGCString*)NSAllocateObject(_fastCls._NSGCString, 0, z);
|
||||||
|
@ -1006,7 +1008,8 @@ stringDecrementCountAndFillHoleAt(NSGMutableCStringStruct *self,
|
||||||
- (void) insertString: (NSString*)aString atIndex: (unsigned)index
|
- (void) insertString: (NSString*)aString atIndex: (unsigned)index
|
||||||
{
|
{
|
||||||
unsigned c = [aString cStringLength];
|
unsigned c = [aString cStringLength];
|
||||||
char save;
|
unsigned char save;
|
||||||
|
|
||||||
if (_count + c >= _capacity)
|
if (_count + c >= _capacity)
|
||||||
stringGrowBy((NSGMutableCStringStruct *)self, c);
|
stringGrowBy((NSGMutableCStringStruct *)self, c);
|
||||||
stringIncrementCountAndMakeHoleAt((NSGMutableCStringStruct*)self, index, c);
|
stringIncrementCountAndMakeHoleAt((NSGMutableCStringStruct*)self, index, c);
|
||||||
|
@ -1119,9 +1122,9 @@ stringDecrementCountAndFillHoleAt(NSGMutableCStringStruct *self,
|
||||||
stringDecrementCountAndFillHoleAt((NSGMutableCStringStruct*)self, index, 1);
|
stringDecrementCountAndFillHoleAt((NSGMutableCStringStruct*)self, index, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (char*) _extendBy: (unsigned)len
|
- (unsigned char*) _extendBy: (unsigned)len
|
||||||
{
|
{
|
||||||
char *ptr;
|
unsigned char *ptr;
|
||||||
|
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
stringGrowBy((NSGMutableCStringStruct *)self, len);
|
stringGrowBy((NSGMutableCStringStruct *)self, len);
|
||||||
|
@ -1161,7 +1164,7 @@ stringDecrementCountAndFillHoleAt(NSGMutableCStringStruct *self,
|
||||||
|
|
||||||
- (const char*) cString
|
- (const char*) cString
|
||||||
{
|
{
|
||||||
return _contents_chars;
|
return (const char*) _contents_chars;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) retain
|
- (id) retain
|
||||||
|
@ -1179,12 +1182,12 @@ stringDecrementCountAndFillHoleAt(NSGMutableCStringStruct *self,
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- copy
|
- (id) copy
|
||||||
{
|
{
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- copyWithZone: (NSZone*)z
|
- (id) copyWithZone: (NSZone*)z
|
||||||
{
|
{
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
|
@ -131,7 +131,7 @@ typedef struct {
|
||||||
#if GSPLUNI
|
#if GSPLUNI
|
||||||
const unichar *ptr;
|
const unichar *ptr;
|
||||||
#else
|
#else
|
||||||
const char *ptr;
|
const unsigned char *ptr;
|
||||||
#endif
|
#endif
|
||||||
unsigned end;
|
unsigned end;
|
||||||
unsigned pos;
|
unsigned pos;
|
||||||
|
@ -286,7 +286,7 @@ static inline id parseQuotedString(pldata* pld)
|
||||||
#if GSPLUNI
|
#if GSPLUNI
|
||||||
unichar chars[pld->pos - start - shrink];
|
unichar chars[pld->pos - start - shrink];
|
||||||
#else
|
#else
|
||||||
char chars[pld->pos - start - shrink];
|
unsigned char chars[pld->pos - start - shrink];
|
||||||
#endif
|
#endif
|
||||||
unsigned j;
|
unsigned j;
|
||||||
unsigned k;
|
unsigned k;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue