Issue 1427 - Generated .di files look ugly and are hard to read #538

Merged
merged 1 commit into from Nov 20, 2012

4 participants

@9rnsr
D Programming Language member

http://d.puremagic.com/issues/show_bug.cgi?id=1427

Use hard tab '\t' for indentation.

@LightBender

I'm working on bringing the DI generation output up to community expectations. Can this be merged? I'd hate to duplicate work.

@LightBender

I did some more more work on this and I can verify that under DMD on Windows when calling the void OutBuffer::write(const void *data, unsigned nbytes) function that DMD throws an Out of Memory exception while compiling Phobos. Also I added a bunch more buf->level changes in addition to what Kenji put in.

My guess is that given the size of Phobos, the number of memory reallocations this code produces that something went wrong somewhere. I removed the second reallocation from this function and everything seems to work as expected.

Note: This is under Windows x64.

The new function is as follows:

void OutBuffer::write(const void *data, unsigned nbytes)
{
char t = '\t';
reserve(nbytes + level);
if (doindent && linehead)
{
if (level)
{
for (size_t i=0; i<level; i++)
{
memcpy(this->data + offset, &t, sizeof(t));
offset++;
}
}
linehead = 0;
}
memcpy(this->data + offset, data, nbytes);
offset += nbytes;
}

@andralex
D Programming Language member

LGTM. Please let's review this and merge it in. @LightBender, how does it (a|e)ffect your work?

@LightBender

@andralex I actually used parts of this merge in my pull. So I will have to re-merge it and fix the errors that crop-up... But this one does not affect output beyond formatting. Also, I have been unable to locate the cause of the phobos test failure in my pull either...

@WalterBright WalterBright merged commit 0c93ce2 into dlang:master Nov 20, 2012

1 check was pending

Details default Pending: 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment