[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[sc-dev] Re: minor ? - newline character in post window



On Dec 14, 2008, at 3:31 PM, James Harkins wrote:

Document.listener.string.detect({ |ch| ch.ascii < 32 }).ascii
13

$\n.ascii == 10
$\r.ascii == 13

I was trying to parse some output just now and got thrown by this. Anyone know why this is, or if it should be changed? It seems an unnecessary gotcha to me (admitting there could be some secret, valid reason).

OK, it's intentional (below) but the c++ code doesn't answer the question, why?

I've got some other gripes about CollStream that I'll save for later. :)
hjh

void vposttext(const char *str, int length);
void vposttext(const char *str, int length)
{
pthread_mutex_lock(&mainPostBuf.mutex);

if (postfile) {
fwrite(str, length, 1, postfile);
fflush(postfile);
}
for (int i=0; i<length && str[i]; ++i) {
if (((mainPostBuf.wrpos+1) & POSTBUFMASK) == mainPostBuf.rdpos) {
break;
//mainPostBuf.Flush(); CANNOT DO THIS FROM OTHER THAN COCOA'S THREAD!
}

// here -wtf?
if (str[i] == '\n') mainPostBuf.buf[mainPostBuf.wrpos] = '\r';


else mainPostBuf.buf[mainPostBuf.wrpos] = str[i];
mainPostBuf.wrpos = (mainPostBuf.wrpos+1) & POSTBUFMASK;
}
        pthread_mutex_unlock(&mainPostBuf.mutex);
}



: H. James Harkins
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman