Punctuation Removal tweak

I just realised why Punctuation Removal extension isn’t doing what I’d hoped it would. It replaces the apostrophes I want to strip with blank spaces, rather than concatenating what was typed either side of the eliminated apostrophes.

I tried hacking the i6 to do what I want (because it looks like it’s probably uncomplicated) but it’s not elementary if you have no i6 skills (raises hand) as the code is set up to expect a replacement character.

I can think of hacks that would normally work to dance around this, but they’re partly not available to me because I have no player’s snippet to fiddle with, due to extensions I’m using. Plus, why hack when there’s probably a real I6 answer? I’m hoping someone I6y could tweak this inclusion for me to achieve what I’m after. Thanks much.

[ SingleQuoteStripping i;
	for (i = WORDSIZE : i <= (buffer-->0)+(WORDSIZE-1) : i++)	{ 
		if ((buffer->i) == 39) 
		{	buffer->i = ' ';  
	VM_Tokenise(buffer, parse);


So this is untested, since I broke my I7 installation and haven’t been able to fix it yet, but I think this should work.

[ SingleQuoteStripping i offset ;
    offset = 0;
    for(i=WORDSIZE : i+offset<=(buffer-->0)+(WORDSIZE-1) : i++){
        buffer->i = buffer->(i+offset); ! Copy the character back `offset` positions
        if((buffer->i) == 39){ ! 39 is the code for a single quote
            offset++; ! We've removed a character
            i--; ! Go back one, so we'll write over this position again
    (buffer-->0) -= offset; ! buffer-->0 holds the length
    VM_Tokenise(buffer, parse); ! Re-run the tokenizer now that we changed the buffer

I’m sure there’s a cleaner way to do it, but…

Thanks Draconis. Pretty heroic to try to write that without being able to test it.

As is, I couldn’t get it to compile:

Missing operand for “-”
“=” applied to “’-’”
Expected expression with side-effects but found

I wondered if the “-=” was just a typo of “==” so I made that change.

Then it compiled, and I got these results:

“get whale’s” became “get whaless”

“get ‘’ whale’s hat’s” became “get whales hatsat’s”


I think that line has to be:

buffer-->0 = (buffer-->0) - offset; ! buffer-->0 holds the length

I don’t think compound assignment operators (such as +=, -=, and *=) can be used in Inform 6 at all.

Oh yeah, oops, that’s my bad. Inform 6 has -- but not -=. Angstsmurf has it right.

Thank you both, it works!