jrincayc / ucblogo-code

Berkeley Logo interpreter
https://people.eecs.berkeley.edu/~bh/logo.html
GNU General Public License v3.0
187 stars 34 forks source link

ISSUE-134: Fixed issue with LOADPICT if it's called before other turtle commands #135

Closed dmalec closed 2 years ago

dmalec commented 2 years ago

resolves #134

Summary

It looks like the crux of this bug is that the LOADPICT command doesn't call the turtle setup code before loading the graphics file. After adding that block, the code behaves as expected: Screen Shot 2022-06-25 at 2 33 25 PM

Additional Changes

I noticed this issue while working on cleaning up some of the warning messages for issue #20 :

graphics.c: In function ‘restore_palette’:
graphics.c:1196:5: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
     fread(&nslots, sizeof(int), 1, fp);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
graphics.c:1199:2: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
  fread(colors, sizeof(int), 3, fp);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
graphics.c: In function ‘lloadpict’:
graphics.c:2092:2: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
  fread(&rec_idx, sizeof(FIXNUM), 1, fp);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
graphics.c:2099:2: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
  (void)fread(&next, One, 1, fp);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
graphics.c:2130:6: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
      (void)fread(&next, One, 1, fp);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
graphics.c:2148:2: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
  fread(&bg, sizeof(int), 1, fp);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I've included the warning message cleanup specific to this method in this PR; but, I can also split them out into a separate PR if that makes it easier to review.

Test Environment

jrincayc commented 2 years ago

Thank you for fixing this and issue 50 :)

dmalec commented 2 years ago

You're welcome, no worries :)