-
Notifications
You must be signed in to change notification settings - Fork 254
lib/string/README: Add guidelines for using strings #1338
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
f6c228a to
d6d127b
Compare
ikerexxe
left a comment
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.
Thank you for putting this together, it is a great step forward in understanding all existing functions and the roadmap you are proposing.
I added several comments inline, but I have some more general comments.
I miss a table of contents or some explanation for what each category does. My proposal would be to use the following:
- ctype/: Character classification functions
- memset/: Memory zeroing utilities
- strchr/: Character search and counting
- strcmp/: String comparison with various modes
- strdup/: Memory duplication utilities
- strcpy/: Safe string copying variants
- sprintf/: Formatted string creation
- strspn/: String span operations
- strtok/: String tokenization utilities
Furthermore, I find it somewhat difficult to understand the functions that begin with Like *(3), since in most cases I need to first check man *(3) and then return to this document to understand the difference. Perhaps it is just me, or perhaps there are other people who have difficulty retaining this type of information and changing the context. I really do not know.
Those titles sound good (I'll amend some a little bit). But I'd prefer to not write a table of contents explicitly, $ cat lib/string/README | grep '^\S'
General guidelines:
===================
- If there's an upper-case macro that wraps a function, use the macro
- x*() functions wrap a function of the same name without the 'x'.
- strn*() functions are forbidden for use with strings. Consider strn
Forbidden libc functions:
=========================
<stdio.h>
<string.h>
Specific guidelines:
====================
ctype/
memset/
strchr/
strcmp/
strdup/
strcpy/
sprintf/
strspn/
strtok/
strftime.hMaybe I could add the information after the directory name.
With that, I essentially mean that those are libc functions. You don't need to read the manual page, as you'll usually remember what the libc functions do, I expect. |
cc66977 to
374c8fc
Compare
|
I've significantly reworded the document. Please re-check. Here's the "summary" that you can get now with grep(1): |
374c8fc to
5616a0b
Compare
That sounds good! I believe this information will be useful to other developers.
For some I do, for others I wish. |
5616a0b to
cd11ed9
Compare
|
We have corrected a few errors, and I believe this has improved the comprehensibility of the documentation. Since @hallyn and I requested this documentation, I would like to wait for an initial review from him before continuing with my own. |
Feel free to continue with your review while we wait for @hallyn . |
|
On Mon, Sep 15, 2025 at 05:04:03AM -0700, Alejandro Colomar wrote:
alejandro-colomar left a comment (shadow-maint/shadow#1338)
> We have corrected a few errors, and I believe this has improved the comprehensibility of the documentation.
>
> Since @hallyn and I requested this documentation, I would like to wait for an initial review from him before continuing with my own.
Feel free to continue with your review while we wait for @hallyn .
I'll take a look this week.
|
|
gnulib has adopted some of these APIs:
We're discussing the adoption of some more. |
|
Thanks, @alejandro-colomar , this looks great. |
Suggested-by: Iker Pedrosa <ipedrosa@redhat.com> Suggested-by: Serge Hallyn <serge@hallyn.com> Suggested-by: Evgeny Grin (Karlson2k) <k2k@drgrin.dev> Suggested-by: Lukas Slebodnik <lslebodn@fedoraproject.org> Signed-off-by: Alejandro Colomar <alx@kernel.org>
cd11ed9 to
09c2912
Compare
ikerexxe
left a comment
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.
I think we did a good job with the initial revisions because I can see that everything is fine in this latest one. Thank you for your excellent work!
Suggested-by: @ikerexxe
Suggested-by: @hallyn
Suggested-by: @Karlson2k
Suggested-by: @lslebodn
Here, I've covered also some of the functions I haven't added yet.
v2
v3
v3b
v4
v5