-
Notifications
You must be signed in to change notification settings - Fork 255
Add strtcat[_a](), and use it instead of its pattern #1334
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
Draft
alejandro-colomar
wants to merge
13
commits into
shadow-maint:master
Choose a base branch
from
alejandro-colomar:strtcat
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+354
−386
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d5a6502 to
7954162
Compare
ae41236 to
72e5645
Compare
72e5645 to
7700f0f
Compare
bf41463 to
b1906df
Compare
5c3dce3 to
14f6665
Compare
9d2fd39 to
2b97b7d
Compare
9ea22bd to
0202824
Compare
…attern Signed-off-by: Alejandro Colomar <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
2d2211b to
9e302ce
Compare
vsnprintf(3) returns an int. By using ssize_t, which is also signed, we avoid the need for a cast. Cc: Serge Hallyn <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
There's nothing better that can be done. Cc: Serge Hallyn <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
Make them report truncation via errno and NULL. Instead of having three possible returns (a pointer to the NUL byte, the end of the array, or NULL), reduce it to two possible ones: one for success, and one for error. Use errno, which is a common way to signal the specific error, and thus treat truncation as any other error. This simplifies error handling after these calls. Also, if one misuses a pointer after truncation, the results are better if the pointer is NULL: the program will easily abort. If we returned 'end', the program could more easily produce a buffer overrun. Suggested-by: Douglas McIlroy <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
In the case of [v]snprintf_(), anticipate the rename in the next commit. Signed-off-by: Alejandro Colomar <[email protected]>
For consistency with strTcpy(), call it sTprintf(). Signed-off-by: Alejandro Colomar <[email protected]>
The old name was too complex, and is inconsistent with all other sprintf(3)-based APIs having just one letter for differentiation. This allows breaking less lines. The original name was chosen for differentiation with the buggy Plan9 API seprint(2). However, 9front (the current fork where Plan9 is mainly developed) has acknowledged the bug. There's still no decision on fixing the bug or not, due to the age of their code base, and the projects depending on their library. It is under consideration inventing something like a seprint2(2) in 9front for replacement of seprint(2), but there's no decision yet either. Considering that 9front acknowledges their bug, and that they *may* release a fixed API with a similar name, we may as well claim that our seprintf() is also a fixed version of Plan9's seprint(2). It has a different name, after all (we terminate in 'f'). This commit was partially scripted with $ find * -type f \ | xargs grep -l stpeprintf \ | xargs sed -i 's/stpeprintf/seprintf/g'; Signed-off-by: Alejandro Colomar <[email protected]>
Reported-by: Christopher Bazley <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
9e302ce to
9b4e3e3
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Queued after:
Revisions:
v1b
v2
v2b
v2c
v2d
v3
s/STRTCAT/strtcat_a/v3b
v3c
v3d
v3c
v3d
v3e
v3f
v3g
v3h
v3i
v3j
v3k
v3l
v3m
v3n