Parsing Addresses | Line Editor in C #3

Channel:
Subscribers:
5,840
Published on ● Video Link: https://www.youtube.com/watch?v=KrVUeg9HtzE



Duration: 0:00
305 views
19


Using functions to get the next command line and parse out addresses for that command.
Am also handling ',' and ';' address separators and default values for address 1 and 2.
We can now use some actual ed commands and addresses instead of the fixed "%d,%d%c" sscanf() code!

Errata:
The "s++" for case '+'/'-' means that whitespace separated equations don't quite work right now, such as "$ - 10". You have to use "$-10" or "$ -10" for it to parse correctly.
Adding "while(isblank(*s)) s++ after that "s++" line to skip whitespace between the sign and optional number should fix that.

I deleted the a1 greater than a2 check in next_command(), that should have stayed, the addresses still need to be in ascending order.

The 'i' insert command should set a default address if have_a1 = false, else 'a' append will overwrite the decremented a1 value with the current line number.

The '=' command should also set a default address of '$' if have_a1 = false, forgot to do that also.

I fixed these issues after recording with extra commits, will blame it on the tiredness, like the low volume & mic placement.

Playlist:    • Line Editor (ed clone)  

Git repo:
https://codeberg.org/queso_fuego/lined
https://github.com/queso-fuego/lined

Commit before this video:
git checkout 5e9e5d9d2cac8619e41d4216d3fd3f7d90660d06

Commit after this video:
git checkout 2ee848b763ad6d809c912d4360e17714d59241ce

Links:
https://man.cat-v.org/unix-1st/1/ed
https://pubs.opengroup.org/onlinepubs/9799919799/utilities/ed.html
https://man.openbsd.org/ed.1

Join the Community Discord: https://discord.gg/yKm4T89QFn

Contact: https://queso_fuego.codeberg.page/contact.html
Support: https://queso_fuego.codeberg.page/support.html

00:00:00 intro, add next_command() function
00:07:08 add next_address() function
00:26:19 get addresses in next_command(), handle ,; separators
00:51:29 fix infinite loop
00:57:43 use default addresses in command functions
01:08:20 up next & outro

Music credits:
Beginning 1 - HoliznaCC0
https://holiznacc0.bandcamp.com/track/beginning-1

#texteditor #cprogramming #addresses