-
Notifications
You must be signed in to change notification settings - Fork 127
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
fix mkshort unique #1168
Merged
Merged
fix mkshort unique #1168
Conversation
This file contains 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
1. we were off by one when deciding if we could just concatentate the generated suffix to the name, failing to use the last available character. 2. when attempting to copy the generated suffix to a presumably shortened name, and the generated suffix was longer than the name, the target of the copy was outside the name buffer. In the common case that the rank of size_t was greater than the rank of int, the target was well beyond the end of name, not before as one would expect with signed arithmetic. With the new algorithm when the target length is insufficient to fit both the name and the suffix we will only truncate the name as required to fit the truncated name and the complete suffix in the target length(as opposed to the original length of the name). We fatal if this is not possible. Add a test case to exercise the make unique code.
LGTM
Thanx!
Instead of this suffering (too late) why not just make the the
lenght unsigned? It's never sensible for it to be negative ... or even
really smaller than, oh, "six" or so in practice.
I do agree with your sense of increased fatalism in the code. There are
some cases, mostly pathological, that just plain won't fit. I also later
developed a bad feeling that the code was very English-oriented, but the
feelign wasn't bad enough to include tables of words of the digits in the
top 45 languages.
We should also assert that '.' is never in the blacklist.
I do also, unsurprisignly, agree with your (heroic) efforts to preserve
fidelity for those cases. Those seem spot-on.
For a different spin on all this, peek at shortname.cc , which was never
finished but was my hobby while in flight during the work commute for a
trip or two, before we were even C++, I think. About half the body was this
terrible "test driven design" approach of a table of 2003 (ish) geocache
names and how they'd be reduced to receivers of that era. Then again, as
our own mkshort.cc has become more QString-centric, it's also become less
terrible to look at on its own.
Trivia: in all my geocaching escapades, there were only two cases where I
know there were geocaches I couldn't find because they were lost by
GPSBabel on the way to the receiver. One involved very long geocache names
with a sequence number that wasn't at the end - we collapsed those all into
one and most of the series just wasn't on my hardware. The second I only
caught because I had two _different_ Garmins in my hunting at that time. An
often missed (and the kind of thing you'd approximately never find via
reverse engineering) nuance of the Garmin USB protocol is that on certain
models, if the sent packet is exactly 256 characters (255?) you must insert
a following packet that's basically empty to "push" that one on through,
otherwise it will be lost. So I'd used a shell script that loaded one GPX
file (maybe a merge of a couple...) to my StreetPilot and my GPSMap 60Cx
(60CSx?) and one receiver had a specific point and the other didn't. Took a
serious technology dive to find the truth on that one.
…On Thu, Aug 31, 2023 at 8:12 AM tsteven4 ***@***.***> wrote:
1. we were off by one when deciding if we could just concatenate
the generated suffix to the name, failing to use the last available
character.
2. when attempting to copy the generated suffix to a presumably
shortened name, and the generated suffix was longer than the name,
the target of the copy was outside the name buffer. In the common
case that the rank of size_t was greater than the rank of int, the
target was well beyond the end of name, not before as one would expect
with signed arithmetic.
With the new algorithm when the target length is insufficient to
fit both the name and the suffix we will only truncate the name as
required to fit the truncated name and the complete suffix in the
target length(as opposed to the original length of the name).
We fatal if this is not possible.
Add a test case to exercise the make unique code.
@robertlipe <https://github.com/robertlipe> please verify that the
generated references mkshort6.csv, mkshort5.csv, mkshort4.csv have
generated names as desired.
------------------------------
You can view, comment on, or merge this pull request online at:
#1168
Commit Summary
- e286c7b
<e286c7b>
fix mkshort unique.
- 9cb23ee
<9cb23ee>
fix reference mode.
- 122a735
<122a735>
add notes for future enhancements
- d936a94
<d936a94>
fix testcase cut and paste booboo
File Changes
(8 files <https://github.com/GPSBabel/gpsbabel/pull/1168/files>)
- *M* mkshort.cc
<https://github.com/GPSBabel/gpsbabel/pull/1168/files#diff-f52a7a9b87deb261fda2847180d2f4d7423753bbf22de3a8af530c33ddb7b272>
(49)
- *A* reference/mkshort.csv
<https://github.com/GPSBabel/gpsbabel/pull/1168/files#diff-caea3713b8874e5d24ff078e98159831849eb564317f4b3c553fdcbac2c461b8>
(151)
- *A* reference/mkshort.style
<https://github.com/GPSBabel/gpsbabel/pull/1168/files#diff-24fa103798ffb96cc6d5d0edb136163a6b344d650d05f586d1121f081b4a0c86>
(24)
- *A* reference/mkshort3.log
<https://github.com/GPSBabel/gpsbabel/pull/1168/files#diff-222564face2e1428a82ad1aca9b9dd75ce427a72e3a1ead5d9bee070b9eb4017>
(1)
- *A* reference/mkshort4.csv
<https://github.com/GPSBabel/gpsbabel/pull/1168/files#diff-16587ea7d0414576df19b2e01353965a2816189771cb9a8ac796c9b0c1d0c4e0>
(150)
- *A* reference/mkshort5.csv
<https://github.com/GPSBabel/gpsbabel/pull/1168/files#diff-f3a0b6d130070096f46cbb6e8122b5713ed13b82aa6c4fa62e37aba197a7dc04>
(150)
- *A* reference/mkshort6.csv
<https://github.com/GPSBabel/gpsbabel/pull/1168/files#diff-4a9931921ab1fd3f2a99f996612219d74f7dddc38feb50e02983c49d66698705>
(150)
- *A* testo.d/mkshort.test
<https://github.com/GPSBabel/gpsbabel/pull/1168/files#diff-869f0f3261fa0412ce1dcefa630d9025c7fe00a023fdae97172f3ae31637e926>
(13)
Patch Links:
- https://github.com/GPSBabel/gpsbabel/pull/1168.patch
- https://github.com/GPSBabel/gpsbabel/pull/1168.diff
—
Reply to this email directly, view it on GitHub
<#1168>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AC3VADZSGFQBOSZ65JNW45DXYCEVNANCNFSM6AAAAAA4GB5KMI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
robertlipe
pushed a commit
that referenced
this pull request
Aug 12, 2024
* fix mkshort unique. 1. we were off by one when deciding if we could just concatentate the generated suffix to the name, failing to use the last available character. 2. when attempting to copy the generated suffix to a presumably shortened name, and the generated suffix was longer than the name, the target of the copy was outside the name buffer. In the common case that the rank of size_t was greater than the rank of int, the target was well beyond the end of name, not before as one would expect with signed arithmetic. With the new algorithm when the target length is insufficient to fit both the name and the suffix we will only truncate the name as required to fit the truncated name and the complete suffix in the target length(as opposed to the original length of the name). We fatal if this is not possible. Add a test case to exercise the make unique code. * fix reference mode. * add notes for future enhancements * fix testcase cut and paste booboo * refactor mkshort input from char* to QByteArray.
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.
the generated suffix to the name, failing to use the last available
character.
shortened name, and the generated suffix was longer than the name,
the target of the copy was outside the name buffer. In the common
case that the rank of size_t was greater than the rank of int, the
target was well beyond the end of name, not before as one would expect
with signed arithmetic.
With the new algorithm when the target length is insufficient to
fit both the name and the suffix we will only truncate the name as
required to fit the truncated name and the complete suffix in the
target length(as opposed to the original length of the name).
We fatal if this is not possible.
Add a test case to exercise the make unique code.
@robertlipe please verify that the generated references mkshort6.csv, mkshort5.csv, mkshort4.csv have generated names as desired.