mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
Some formatting changes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@11371 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
299c88a96b
commit
920c3bef8e
9 changed files with 260 additions and 119 deletions
|
@ -377,30 +377,35 @@
|
|||
{
|
||||
#if TYPE_ORDER == 0
|
||||
return (data) ? @"true" : @"false";
|
||||
#elif TYPE_ORDER == 1
|
||||
return [NSString stringWithFormat: @"%i", (int)data];
|
||||
#else
|
||||
NSString *result = [NSString alloc];
|
||||
|
||||
#if TYPE_ORDER == 1
|
||||
result = [result initWithFormat: @"%i" locale: locale, (int)data];
|
||||
#elif TYPE_ORDER == 2
|
||||
return [NSString stringWithFormat: @"%u", (unsigned int)data];
|
||||
result = [result initWithFormat: @"%u" locale: locale, (unsigned int)data];
|
||||
#elif TYPE_ORDER == 3
|
||||
return [NSString stringWithFormat: @"%hi", (short int)data];
|
||||
result = [result initWithFormat: @"%hi" locale: locale, data];
|
||||
#elif TYPE_ORDER == 4
|
||||
return [NSString stringWithFormat: @"%hu", (unsigned short int)data];
|
||||
result = [result initWithFormat: @"%hu" locale: locale, data];
|
||||
#elif TYPE_ORDER == 5
|
||||
return [NSString stringWithFormat: @"%i", data];
|
||||
result = [result initWithFormat: @"%i" locale: locale, data];
|
||||
#elif TYPE_ORDER == 6
|
||||
return [NSString stringWithFormat: @"%u", data];
|
||||
result = [result initWithFormat: @"%u" locale: locale, data];
|
||||
#elif TYPE_ORDER == 7
|
||||
return [NSString stringWithFormat: @"%li", data];
|
||||
result = [result initWithFormat: @"%li" locale: locale, data];
|
||||
#elif TYPE_ORDER == 8
|
||||
return [NSString stringWithFormat: @"%lu", data];
|
||||
result = [result initWithFormat: @"%lu" locale: locale, data];
|
||||
#elif TYPE_ORDER == 9
|
||||
return [NSString stringWithFormat: @"%lli", data];
|
||||
result = [result initWithFormat: @"%lli" locale: locale, data];
|
||||
#elif TYPE_ORDER == 10
|
||||
return [NSString stringWithFormat: @"%llu", data];
|
||||
result = [result initWithFormat: @"%llu" locale: locale, data];
|
||||
#elif TYPE_ORDER == 11
|
||||
return [NSString stringWithFormat: @"%0.7g", (double)data];
|
||||
result = [result initWithFormat: @"%0.7g" locale: locale, (double)data];
|
||||
#elif TYPE_ORDER == 12
|
||||
return [NSString stringWithFormat: @"%0.16g", data];
|
||||
result = [result initWithFormat: @"%0.16g" locale: locale, data];
|
||||
#endif
|
||||
return AUTORELEASE(result);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -666,11 +666,12 @@ static Class doubleNumberClass;
|
|||
|
||||
- (NSString*) descriptionWithLocale: (NSDictionary*)locale
|
||||
{
|
||||
NSString *result = nil;
|
||||
|
||||
if (GSObjCClass(self) == abstractClass)
|
||||
{
|
||||
[NSException raise: NSInternalInconsistencyException
|
||||
format: @"descriptionWithLocale: for abstract NSNumber"];
|
||||
return nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -680,48 +681,74 @@ static Class doubleNumberClass;
|
|||
{
|
||||
case 0:
|
||||
return [self boolValue] ? @"true" : @"false";
|
||||
break;
|
||||
|
||||
case 1:
|
||||
return [NSString stringWithFormat: @"%i",
|
||||
result = [[NSString alloc] initWithFormat: @"%i" locale: locale,
|
||||
(int)[self charValue]];
|
||||
break;
|
||||
|
||||
case 2:
|
||||
return [NSString stringWithFormat: @"%u",
|
||||
result = [[NSString alloc] initWithFormat: @"%u" locale: locale,
|
||||
(unsigned int)[self unsignedCharValue]];
|
||||
break;
|
||||
|
||||
case 3:
|
||||
return [NSString stringWithFormat: @"%hi",
|
||||
(short int)[self shortValue]];
|
||||
result = [[NSString alloc] initWithFormat: @"%hi" locale: locale,
|
||||
[self shortValue]];
|
||||
break;
|
||||
|
||||
case 4:
|
||||
return [NSString stringWithFormat: @"%hu",
|
||||
(unsigned short int)[self unsignedShortValue]];
|
||||
result = [[NSString alloc] initWithFormat: @"%hu" locale: locale,
|
||||
[self unsignedShortValue]];
|
||||
break;
|
||||
|
||||
case 5:
|
||||
return [NSString stringWithFormat: @"%i",
|
||||
result = [[NSString alloc] initWithFormat: @"%i" locale: locale,
|
||||
[self intValue]];
|
||||
break;
|
||||
|
||||
case 6:
|
||||
return [NSString stringWithFormat: @"%u",
|
||||
result = [[NSString alloc] initWithFormat: @"%u" locale: locale,
|
||||
[self unsignedIntValue]];
|
||||
break;
|
||||
|
||||
case 7:
|
||||
return [NSString stringWithFormat: @"%li",
|
||||
result = [[NSString alloc] initWithFormat: @"%li" locale: locale,
|
||||
[self longValue]];
|
||||
break;
|
||||
|
||||
case 8:
|
||||
return [NSString stringWithFormat: @"%lu",
|
||||
result = [[NSString alloc] initWithFormat: @"%lu" locale: locale,
|
||||
[self unsignedLongValue]];
|
||||
break;
|
||||
|
||||
case 9:
|
||||
return [NSString stringWithFormat: @"%lli",
|
||||
result = [[NSString alloc] initWithFormat: @"%lli" locale: locale,
|
||||
[self longLongValue]];
|
||||
break;
|
||||
|
||||
case 10:
|
||||
return [NSString stringWithFormat: @"%llu",
|
||||
result = [[NSString alloc] initWithFormat: @"%llu" locale: locale,
|
||||
[self unsignedLongLongValue]];
|
||||
break;
|
||||
|
||||
case 11:
|
||||
return [NSString stringWithFormat: @"%0.7g",
|
||||
result = [[NSString alloc] initWithFormat: @"%0.7g" locale: locale,
|
||||
(double)[self floatValue]];
|
||||
break;
|
||||
|
||||
case 12:
|
||||
return [NSString stringWithFormat: @"%0.16g",
|
||||
result = [[NSString alloc] initWithFormat: @"%0.16g" locale: locale,
|
||||
[self doubleValue]];
|
||||
break;
|
||||
|
||||
default:
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"unknown number type value for description"];
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
return AUTORELEASE(result);
|
||||
}
|
||||
|
||||
/* All the rest of these methods must be implemented by a subclass */
|
||||
|
|
|
@ -723,14 +723,13 @@ handle_printf_atsign (FILE *stream,
|
|||
}
|
||||
|
||||
- (id) initWithFormat: (NSString*)format
|
||||
locale: (NSDictionary*)locale
|
||||
locale: (NSDictionary*)locale, ...
|
||||
{
|
||||
va_list ap;
|
||||
/*
|
||||
* Dummy variable 'ap' is unused, but needs to be present because on
|
||||
* some machines we can't just pass a null as a va_list
|
||||
*/
|
||||
va_list ap;
|
||||
va_start(ap, locale);
|
||||
return [self initWithFormat: format locale: locale arguments: ap];
|
||||
va_end(ap);
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithFormat: (NSString*)format
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue