Re: Diff: Function Length Reduction

2021-09-11 Thread Tom Cosgrove
For example, making it look something like this would be better static void inc_buf(SCR *sp, VICMD *vp) { CHAR_T v = vp->buffer; if (v < '1' || v > '8') return; VIP(sp)->sdot.buffer = vp->buffer = ++v; } Thanks Tom On 10/09/2021 22:24, Stuart Henderson wrote: On 202

Re: Diff: Function Length Reduction

2021-09-10 Thread VARIK VALEFOR
STUART HENDERSON: Is any particular aspect of the replacement code bad? Being able to better detect cheesiness in C programs would be nice -- Haskellers are a different breed and need to be taught some things. ;^) Note that OMAR POLO modifies the replacement such that the readability of this re

Re: Diff: Function Length Reduction

2021-09-10 Thread Stuart Henderson
On 2021/09/10 16:39, VARIK VALEFOR wrote: > Is any particular aspect of the replacement code bad? The use of 'magic number' ASCII values obfuscates what the code is doing.

Re: Diff: Function Length Reduction

2021-09-10 Thread Stuart Henderson
On 2021/09/10 00:27, VARIK VALEFOR wrote: > P.S. s/originalBuf/vp->buffer/g I think this is a good demonstration of why sometimes it's better to have longer but simpler code.

Re: Diff: Function Length Reduction

2021-09-10 Thread VARIK VALEFOR
P.S. s/originalBuf/vp->buffer/g The CORRECTED diff is as follows: diff --git a/usr.bin/vi/vi/v_put.c b/usr.bin/vi/vi/v_put.c index 959d4a47698..4e30bc620d3 100644 --- a/usr.bin/vi/vi/v_put.c +++ b/usr.bin/vi/vi/v_put.c @@ -104,35 +104,6 @@ v_put(SCR *sp, VICMD *vp) static void inc_buf(SCR *sp,

Diff: Function Length Reduction

2021-09-09 Thread VARIK VALEFOR
Sir or Madam: The attached diff significantly decreases the length of a function... and potentially increases the readability of this function. Don't stop skankin', Varik "NOT A COMPUTER PROGRAMMER!!!" Valefor diff --git a/usr.bin/vi/vi/v_put.c b/usr.bin/vi/vi/v_put.c index 959d4a47698..4e30bc62