fgix for problem spotted by Wolfgang

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@39753 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2016-05-13 13:19:22 +00:00
parent d0e1834a37
commit 88cfc7dc17
2 changed files with 57 additions and 15 deletions

View file

@ -2,6 +2,9 @@
* Source/Additions/GSMime.m:
Fix bug encoding very long headers with no whitespace to fold on.
* Source/NSThread.m:
Avoid use of autorelease pool when setting the name of the thread
(fix pointless warnings logs spotted by Wolfgang).
2016-05-06 18:03-EDT Gregory John Casamento <greg.casamento@gmail.com>

View file

@ -1056,25 +1056,65 @@ unregisterActiveThread(NSThread *thread)
- (void) _setName: (NSString *)aName
{
int result = -1;
while (result != 0 && [aName length] > 0)
if ([aName isKindOfClass: [NSString class]])
{
result =
PTHREAD_SETNAME([aName cStringUsingEncoding: NSUTF8StringEncoding]);
if (result != 0)
int i;
char buf[200];
if (YES == [aName getCString: buf
maxLength: sizeof(buf)
encoding: NSUTF8StringEncoding])
{
i = strlen(buf);
}
else
{
/* Too much for buffer ... truncate on a character boundary.
*/
i = sizeof(buf) - 1;
if (buf[i] & 0x80)
{
while (i > 0 && (buf[i] & 0x80))
{
buf[i--] = '\0';
}
}
else
{
buf[i--] = '\0';
}
}
while (i > 0)
{
if (PTHREAD_SETNAME(buf) == 0)
{
break; // Success
}
if (ERANGE == errno)
{
/* Name must be too long ... gnu/linux uses 15 characters
*/
if ([aName length] > 15)
if (i > 15)
{
aName = [aName substringToIndex: 15];
i = 15;
}
else
{
aName = [aName substringToIndex: [aName length] - 1];
i--;
}
/* too long a name ... truncate on a character boundary.
*/
if (buf[i] & 0x80)
{
while (i > 0 && (buf[i] & 0x80))
{
buf[i--] = '\0';
}
}
else
{
buf[i--] = '\0';
}
}
else
@ -1112,13 +1152,12 @@ unregisterActiveThread(NSThread *thread)
/**
* Trampoline function called to launch the thread
*/
static void *nsthreadLauncher(void *thread)
static void *
nsthreadLauncher(void *thread)
{
NSThread *t = (NSThread*)thread;
setThreadForCurrentThread(t);
#if __OBJC_GC__
objc_registerThreadWithCollector();
#endif
NSThread *t = (NSThread*)thread;
setThreadForCurrentThread(t);
/*
* Let observers know a new thread is starting.