-
-
Couldn't load subscription status.
- Fork 137
Update detab.c (Fixed #43) #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the follow-up and for proposing a change. After our discussion in issue #43, I think this PR still adds complexity without fixing the core problem.
- The exercise requires expanding actual tab characters ('\t') to the next tab stop, not interpreting the two-character sequence "\" + "t".
- Replacing every tab with a fixed 8 spaces is still incorrect mid-line; the number of spaces must depend on the current column.
Suggestion to align with K&R 1.20:
- Track the current column.
- On '\t', output TABSIZE - (col % TABSIZE) spaces and increment col by that amount.
- On '\n', reset col to 0.
- Everything else: emit the character and increment col.
This keeps the solution minimal, correct, and easy to reason about. If you update the PR with this approach (TABSIZE as a macro is fine), I’m happy to re-review.
Uh oh!
There was an error while loading. Please reload this page.
The incorrect solution for exercise 1.20 has been corrected.
For detailed discussion, please refer to the issue #43.