Re: [PATCH] Refine string and array slice assignments

Philippe Altherr <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel
Message-ID <CAGdYchsQKpmkzrHHU7zk0aERKoE6VS8nZ1HA5j4rJDUZ52ow_A@mail.gmail.com>
>
> Looking at assignstrvalue and setarrvalue side by side is a lot nicer
> now,


Iirc, there are only two differences between the two:

   - For arrays, elements always consist of exactly one char* instance,
   while for strings, if MULTIBYTE is enabled, elements may consist of
   multiple char instances, which requires some extra logic in assignstrvalue
   for the computation of v->end.


   - For strings, the slice [v->start, v->end] must designate a, possibly
   empty, slice of the string v->pm, while for arrays, the slice [v->start,
   v->end] may also be an empty slice whose start is after the end of the
   array v->pm, which requires some extra logic in setarrvalue to populate
   with empty strings the gap between the end of v->pm and the start of the
   slice.

so assuming the code actually works correctly, I like this.
>

One way is to check on GitHub that none of the commits that constitute the
patch
<https://github.com/zsh-users/zsh/compare/master...paltherr:zsh:refine-slice-assignments>
change
any behavior. Another way is to check the logic of the
updated assignstrvalue and setarrvalue which is now relatively
straightforward. I would recommend starting with setarrvalue, which doesn't
have to deal with MULTIBYTE. There are also many tests in
A06assign.ztst that exercise the logic of the two functions.

Philippe
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.