ruby / ruby/strscan

Character position setter / rewind

Open
#122 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
88
Forks
50
Avg merge
2d 3h
Merged PRs (30d)
2

Description

I'm implementing look-behind in a parser library based on strscan; currently the only way to rewind the character position is this:

            pos = @str.charpos - nchars
            @str.reset
            @str.getch while @str.charpos < pos

which is not the most efficient it could be, with per-character roundtrips to the native extension and back to Ruby… Would be a lot nicer to have a setter for the character position and not just the byte one.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing strscan's native extension and the existing byte-position setter, then inspect how character positions are represented alongside byte positions. Add coverage for setting and rewinding the character position, and consider the requested behavior complete when callers can rewind without per-character Ruby/native roundtrips.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, ruby
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.