-
-
Notifications
You must be signed in to change notification settings - Fork 29
string handling cleanup #540
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
…ispFromNative Removes StrNCpyFromLispToC and the single use of it in LispStringToCString in the BYTESWAP implementation case. Rename StrNCpyFromCToLisp, which does NOT follow "strncpy" semantics, to be MemCpyToLispFromNative, where the types in the name match the types of the arguments, and the semantics (and argument order) are those of the C library "memcpy".
If the Lisp string passed to LispStringToCString were longer than the destination buffer's MaxLen the could would have written the terminating nul past the end of the array. Fixes formatting of LispStringToCString Corrects English grammar in some comments.
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.
Summary of Changes
Hello @nbriggs, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request focuses on cleaning up and modernizing the string handling mechanisms within the Maiko project. My primary goal was to consolidate and improve existing string copy routines, enhance the robustness of Lisp string to C string conversions, and enable the correct printing of indirect Lisp strings in the URaid debugger. These changes aim to improve code clarity, maintainability, and correctness without altering normal program operation.
Highlights
- String Copy Routine Consolidation: I've replaced the
StrNCpyFromCToLisp
andStrNCpyFromLispToC
macros with a single, more robustMemCpyToLispFromNative
macro ininc/locfile.h
. This new macro handles memory copying between native and Lisp memory locations, accounting for potential byte-swapping, and its usage has been updated acrosssrc/dir.c
,src/dsk.c
,src/osmsg.c
, andsrc/ufs.c
. - Lisp String to C String Conversion Refactoring: The
LispStringToCString
macro ininc/locfile.h
has been converted into astatic void
function. This change improves type safety and maintainability, with separate implementations provided for byte-swapped and non-byte-swapped environments, ensuring proper null termination. - Improved Indirect String Printing: I've enhanced the
print_NEWstring
function insrc/kprint.c
to correctly handle indirect Lisp strings. This ensures that displaced array substrings and similar indirect string objects are now properly decoded and printed by the generic object printer, particularly benefiting the URaid debugger. - General Code Cleanup and Modernization: Various minor cleanups were performed, including removing unnecessary header includes (
bin/makefile-tail
,inc/vmemsavedefs.h
,src/kbdsubrs.c
), updating byte count calculations to use defined constants (src/ether_nethub.c
,src/ether_sunos.c
), and refining comments and macro usage for clarity and consistency.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
Warning Gemini is unable to generate a review due to a potential policy violation. |
I successfully built the code of this branch on Linux Mint 22.1 Cinnamon and Medley is working fine. |
Start at cleaning up some of the string handling in Maiko. So far this only eliminates one routine (StrNCpyFromLispToC).
There should be no change in the normal operation of the code, the only new feature is that passing an indirect string (such as generated by a displaced array substring on a string) to URaid will print it correctly as the generic object printer will decode indirect strings.