uchess icon indicating copy to clipboard operation
uchess copied to clipboard

fix: prevent panic on negative count input strings.Repeat() fixes #7

Open jfkw opened this issue 2 years ago • 5 comments

On pawn promotion e.g. g8=Q, function pkg/util.getCapturedPieces() calculates an incorrect negative count of the promoted piece e.g. Q=-1. Using this negative count as subsequent input will cause strings.Repeat() to panic.

Add a func nonNegative() which returns an int value not less than zero and wrap the calculations of captured pieces to ensure valid input to strings.Repeat().

jfkw avatar Mar 26 '23 23:03 jfkw

Acknowledging receipt of your PR. Thanks! I will take a look soon and get this merged assuming that everything looks good.

tmountain avatar Mar 28 '23 00:03 tmountain

Pushed a small change to eliminate the else branch in nonNegative(int). If you have any changes you would prefer, e.g. a different name for nonNegative(int), I'm happy to make those adjustments before review.

jfkw avatar Apr 21 '23 01:04 jfkw

Thanks, I know it's taking some time to get this merged, but I'm looking over the codebase as a whole, and I want to add better documentation and testing, so that's slowing down the next release. Truthfully, I need to review the logic on captured pieces fully and make sure I have that documented. Anyway, I appreciate the contribution, and rest assured, I will get the fix applied sometime soon.

tmountain avatar Apr 21 '23 11:04 tmountain

@tmountain not trying to be annoying, but I just found out about uchess and it looks exactly what I want:

  • CLI
  • Written in a compiled language
  • Nice, easy config
  • Only important features no feature "creep"

So I am just asking openly here: Is this something I should package now (for Void Linux) or should I wait for your refactor/update?

Thanks and have a good one!

Anachron avatar Jun 13 '23 12:06 Anachron

Hi, you're not annoying me. I know it's taken forever for me to push an update. The project is still active, and I will do my best to package up a new release soon. I apologize for the delay, and I'll do my best to get something out the door within a week or two.

tmountain avatar Jun 13 '23 14:06 tmountain