Conversation
…AP with 3 decimals gmtlib_get_annot_label() used gmt_strrep() to shrink the leading degree field from 3 to 2 digits for latitudes (max 90, vs 360 for longitudes), by replacing every "%3.3d" in the plot format string with "%2.2d". When FORMAT_GEO_MAP requests exactly 3 fractional digits (e.g. "ddd.xxxF"), the fractional-part format is also literally "%3.3d", so gmt_strrep corrupted it too: a latitude fraction of e.g. .024 got padded to only 2 digits and printed as "24" instead of "024", turning "9.024" into "9.24" (i.e. the leading zero after the decimal point was dropped). Only replace the leading degree field (which is always at the start of the format string) instead of every occurrence of "%3.3d" anywhere in the string. Fixes #9154 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
seisman
reviewed
Aug 27, 2026
Member
Author
Trim the multi-line comment explaining the historical bug down to a single line describing the non-obvious WHY of the code as it stands. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Member
|
We need to revise the walls of text produced by the Agents. That is why I think we should not accept PR submitted by them. The "Test Plan" is clearly not needed here. |
joa-quim
approved these changes
Aug 27, 2026
Member
Author
Yes, I agree. |
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.

Summary
Fixes #9154.
gmtlib_get_annot_label()(in gmt_support.c) shrinks the leading degree field of the plot format string from 3 digits to 2 for latitudes (max 90°, vs 360° for longitudes) by doing a text substitution: replace every"%3.3d"in the format string with"%2.2d".The bug: when
FORMAT_GEO_MAPrequests exactly 3 fractional digits (e.g.ddd.xxxF), the fractional-part printf format built for that case is also literally"%3.3d"— same text, unrelated purpose. The blind, whole-stringgmt_strrep()call corrupted that fractional format too, shrinking it from 3 digits to 2. This silently dropped the leading zero of any fraction that happened to be0**(e.g..024became.24), while leaving the value visually plausible (9.020→9.20→ rendered as if only two decimals had been requested).This only manifests for latitudes with exactly 3 fractional digits —
ddd.xxF(2 digits) andddd.xxxxF(4 digits) don't produce the literal string"%3.3d"anywhere else in the format, so they were unaffected. That matches the issue report exactly (3rd panel wrong, 4th panel correct).Fix
Only replace the leading degree field — which is always at position 0 of the format string — instead of replacing every occurrence of
"%3.3d"anywhere in the string.Test plan
FORMAT_GEO_MAP=ddd.xxxF,-Ba0.0001) — before the fix, y-axis annotations read9.24°N, 9.23°N, 9.21°N, ...(2 digits, leading zero dropped); after the fix they correctly read9.024°N, 9.023°N, 9.021°N, ...(3 digits).ddd.xxF/ddd.xxxxF(2 and 4 decimals) were unaffected before and after.ninja gmt(warnings-only, pre-existing and unrelated to this file).doc/scriptsctest suite's-B_geotests;GMT_-B_geo_2fails identically onmasterand on this branch (pre-existing, unrelated font-rendering baseline diff),GMT_-B_geo_1passes on both.Assisted-by: Claude Sonnet 5 (medium effort)