chrisosaurus / dodo

scriptable in place file editor
MIT License
4 stars 1 forks source link

dodo line manipulation #6

Open chrisosaurus opened 9 years ago

chrisosaurus commented 9 years ago

Currently dodo has 2 unimplemented functions parse_line and eval_line

A decision needs to be made on whether or not dodo should support line operations.

Any such operations cannot consume more of the file than needed to process any line instructions as dodo must always be able to operate efficiently on large files (a 16G postgres dump is my current example).

The implementation isn't too complex; when dodo is given the instruction l10 to goto line 10 dodo can keep stepping through the file (in chunks to reduce the overhead of frequent reads) counting \n characters until it has seen 9 and then step 1 character past (so at to be at the start of line 10).

If dodo never finds a line 10 then it is an error (similar to a failed expect).

chrisosaurus commented 9 years ago

My thinking here is that I do want to be able to say 'goto line 10' (l10) and have dodo behave correctly for this.

A 'small' (1024?) buffer with an fread and counting \n should be sufficient as a naive first attempt.

chrisosaurus commented 9 years ago

I will be too busy for a while.

phillid commented 8 years ago

I have this tentatively written (locally), I'll do some more testing and tidying before submitting.