Skip to content

Commit

Permalink
Merge pull request #3 from Leont/null-byte
Browse files Browse the repository at this point in the history
Add final null-byte to tokens
  • Loading branch information
hoytech authored Jan 9, 2024
2 parents 7a2941f + cd64e7b commit 246f8b7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Token.xs
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,15 @@ get(ctx)
size_t i, curr;

output = newSVpvn("", 0);
SvGROW(output, ctx->token_length);
SvGROW(output, ctx->token_length + 1);
SvCUR_set(output, ctx->token_length);
outputp = SvPV(output, ctx->token_length);
outputp = SvPV_nolen(output);

for (i=0; i<ctx->token_length; i++) {
while((curr = (get_new_byte(ctx) & ctx->mask)) >= ctx->alphabet_length) ;
outputp[i] = ctx->alphabet[curr];
}
outputp[i] = '\0';

RETVAL = output;

Expand Down

0 comments on commit 246f8b7

Please sign in to comment.