nxcomp/src/Loop.cpp: Support NXTransDialog caption / title being pref…#1079
Open
sunweaver wants to merge 1 commit into
Open
nxcomp/src/Loop.cpp: Support NXTransDialog caption / title being pref…#1079sunweaver wants to merge 1 commit into
sunweaver wants to merge 1 commit into
Conversation
c430f1e to
eb8c54a
Compare
eb8c54a to
af91cad
Compare
uli42
reviewed
Jun 30, 2024
uli42
reviewed
Jun 30, 2024
| else | ||
| { | ||
| // Use what gets provided via NX_DIALOG_CAPTIONPREFIX (used in X2Go) | ||
| strncpy(caption, caption_prefix, DEFAULT_STRING_LENGTH-1); |
Member
There was a problem hiding this comment.
this strncpy is different from the one above regarding the number of characters to be copied. While both are technically correct they should at least be unified.
Member
Author
There was a problem hiding this comment.
Can you suggest a clean solution? (You are the C dev... ;-) ).
Member
There was a problem hiding this comment.
str(n)cpy is always tricky. I would do the getenv only once. Then strdup either the result or the default. And free the dupped string at shutdown.
Member
Author
There was a problem hiding this comment.
@uli42 Can you help with this MR and fine-polish it? Your C is so much better than mine.
af91cad to
63adc88
Compare
Member
|
I am currently limited hw-wise. But I think this looks good except that you
use strncpy in two different ways. You should make them identical regarding
the length argument.
I suggest you test and merge it. You can leave this ticket open and I will
revisit eventually.
…On Wed, Nov 20, 2024 at 9:52 PM Mike Gabriel ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In nxcomp/src/Loop.cpp
<#1079 (comment)>
:
> @@ -14731,7 +14731,19 @@ static void handleAlertInLoop()
{
char caption[DEFAULT_STRING_LENGTH];
- strcpy(caption, ALERT_CAPTION_PREFIX);
+ const char* caption_prefix = getenv("NX_DIALOG_CAPTIONPREFIX");
+
+ if (!caption_prefix) {
+ // Use the hard-coded 'NX -' as default.
+ strncpy(caption, ALERT_CAPTION_PREFIX, DEFAULT_STRING_LENGTH);
+ caption[DEFAULT_STRING_LENGTH-1] = '\0';
+ }
+ else
+ {
+ // Use what gets provided via NX_DIALOG_CAPTIONPREFIX (used in X2Go)
+ strncpy(caption, caption_prefix, DEFAULT_STRING_LENGTH-1);
@uli42 <https://github.com/uli42> Can you help with this MR and
fine-polish it? Your C is so much better than mine.
—
Reply to this email directly, view it on GitHub
<#1079 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABQHBZDCBY4MMIX6S6GJGK32BTY75AVCNFSM6AAAAABKDMRZM2VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDINBZGY3TKMBUG4>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
…ixed with a custom prefix string.
63adc88 to
20ddd71
Compare
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
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.
…ixed with a custom prefix string.