Fixes from dawn

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@4761 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-08-25 14:47:19 +00:00
parent 90f2d8ad55
commit 207ba80b4a
8 changed files with 357 additions and 90 deletions

View file

@ -24,7 +24,7 @@
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/
/* Caveats:
@ -536,10 +536,13 @@ handle_printf_atsign (FILE *stream,
format_to_go = formatter_pos+2;
continue;
}
/* Specifiers from K&R C 2nd ed. */
spec_pos = strpbrk(formatter_pos+1, "dioxXucsfeEgGpn\0");
switch (*spec_pos)
{
#ifndef powerpc
/* FIXME: vsprintf on powerpc apparently advances the arg list
so this doesn't need to be done. Make a more general check
for this */
case 'd': case 'i': case 'o':
case 'x': case 'X': case 'u': case 'c':
va_arg(arg_list, int);
@ -558,8 +561,8 @@ handle_printf_atsign (FILE *stream,
case 'n':
va_arg(arg_list, int*);
break;
#endif /* NOT powerpc */
case '\0':
/* Make sure loop exits on next iteration. */
spec_pos--;
break;
}
@ -1398,8 +1401,21 @@ handle_printf_atsign (FILE *stream,
- (const char*) cString
{
[self subclassResponsibility: _cmd];
return NULL;
NSData *d = [self dataUsingEncoding: _DefaultStringEncoding
allowLossyConversion: NO];
if (d == nil)
{
[NSException raise: NSCharacterConversionException
format: @"unable to convert to cString"];
}
return (const char*)[d bytes];
}
- (const char*) lossyCString
{
NSData *d = [self dataUsingEncoding: _DefaultStringEncoding
allowLossyConversion: YES];
return (const char*)[d bytes];
}
- (unsigned) cStringLength
@ -1551,7 +1567,7 @@ handle_printf_atsign (FILE *stream,
char t;
unsigned char *buff;
buff = (unsigned char*)NSZoneMalloc(NSDefaultMallocZone(), len);
buff = (unsigned char*)NSZoneMalloc(NSDefaultMallocZone(), len+1);
if (!flag)
{
for (count = 0; count < len; count++)
@ -1587,6 +1603,7 @@ handle_printf_atsign (FILE *stream,
}
}
}
buff[count] = '\0';
return [NSData dataWithBytesNoCopy: buff length: count];
}
else if (encoding == NSUnicodeStringEncoding)
@ -2438,7 +2455,7 @@ handle_printf_atsign (FILE *stream,
[NSException raise: NSGenericException
format: @"%@ at line %u", data.err, data.lin];
}
return result;
return AUTORELEASE(result);
}
- (NSDictionary*) propertyListFromStringsFileFormat
@ -2464,7 +2481,7 @@ handle_printf_atsign (FILE *stream,
[NSException raise: NSGenericException
format: @"%@ at line %u", data.err, data.lin];
}
return result;
return AUTORELEASE(result);
}
@end