bugGNU nano - Bugs: bug #52340, nano cannot build with -std=c89...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #52340: nano cannot build with -std=c89 due to mixed declarations and code

Submitter:  David Lawrence Ramsey <dolorous>
Submitted:  Sun 05 Nov 2017 06:27:16 PM UTC
   
 
Severity:  2 - Minor Status:  Wont Fix
Assigned to:  None Open/Closed:  Closed

Jump to the original submission

Tue 07 Nov 2017 05:07:10 PM UTC, comment #6: 

I have opted for fuzzying twelve messages, which are in fact six double messages that are all very similar, so it doesn't require much translator time.  I've also included the things that don't affect translatable strings, but have left out the debug stuff, as I don't care about that.

The other translatable strings will be left for the overnext release.

Thanks for the patch.

Benno Schulenberg <bens>
Group administrator
Mon 06 Nov 2017 09:06:32 PM UTC, comment #5: 

Well then, how about if I cut it down to the one known problem?  The attached patch just displays numreplaced as signed, since it's ssize_t, and casts it to long instead of using the z modifier.  That's only two fuzzed messages: "Replaced %ld occurrence"
and "Replaced %ld occurrences".

(file #42338)

David Lawrence Ramsey <dolorous>
Group Member
Mon 06 Nov 2017 08:24:18 PM UTC, comment #4: 

Hmm...  That's a bit more than a handful.  There are already six fuzzies and seven new strings.

Benno Schulenberg <bens>
Group administrator
Mon 06 Nov 2017 01:32:10 PM UTC, comment #3: 

The list of translated strings is relatively short: 16.

"Read %lu line (Converted from DOS and Mac format)"
"Read %lu lines (Converted from DOS and Mac format)"
"Read %lu line (Converted from Mac format)"
"Read %lu lines (Converted from Mac format)"
"Read %lu line (Converted from DOS format)"
"Read %lu lines (Converted from DOS format)"
"Read %lu line"
"Read %lu lines"
"Wrote %lu line"
"Wrote %lu lines"
"Error in %s on line %lu: "
"Replaced %lu occurrence"
"Replaced %lu occurrences"
"%sWords: %lu  Lines: %ld  Chars: %lu"
"Internal error: can't match line %ld.  Please save your work."
"line %ld/%ld (%d%%), col %lu/%lu (%d%%), char %lu/%lu (%d%%)"

I've done a search and replace for all the relevant strings (casts to long and unsigned long are uncommon enough), and the attached patch should do it.  There are some untranslated debug messages that the patch updates as well, and numreplaced is properly displayed as signed instead of unsigned, since it's ssize_t.

(file #42334)

David Lawrence Ramsey <dolorous>
Group Member
Sun 05 Nov 2017 08:10:29 PM UTC, comment #2: 

Well, I've moved some declarations earlier because I wanted to be able to build nano on Haiku, which by default uses a pedantic gcc-2.95.  I even submitted a patch for gnulib so Haiku could compile the glob module, but a few weeks later that change was undone, so it seems that the battle for C89 compatibility is lost.

But since then I have learnt how to select a more modern compiler on Haiku, so these mixed declarations are not a problem any more.  I don't really like them, but... if it saves lines of code, and if it clearly is a separate block of code... let it pass.

(Which strings would be fuzzied by starting to use %z?  If it's just a handful, I think we can do that.  There are some new strings, so there will have to be a pre1 anyway.)

Benno Schulenberg <bens>
Group administrator
Sun 05 Nov 2017 06:30:08 PM UTC, comment #1: 

The attached patch against git c16e79b fixes the build errors (but not the warnings).

(file #42332)

David Lawrence Ramsey <dolorous>
Group Member
Sun 05 Nov 2017 06:27:16 PM UTC, original submission:  

As of current git (c16e79b), nano cannot build with C89 compatibility, due to a few places that mix declarations and code; since mixed declarations and code have been fixed before, I'm assuming this is a problem.

(There are also C89 warnings about the unsupported j modifier in printf, but there seems to be no other way to print an intmax_t type.  Note that all the casting of size_t and ssize_t to unsigned long and long in some other printf() calls is done to avoid a similar problem with the z modifier that's supposed to be used for size_t types, but which is unsupported in C89; whether this is a problem or not, changing the printf()s to use the z modifier would mean fuzzing some of the translations, which I'm not sure would be desirable.)

David Lawrence Ramsey <dolorous>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bens (Posted a comment)
  • -email is unavailable- added by dolorous (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-11-13 bens Open/ClosedOpen Closed
    2017-11-06 dolorous Attached File- Added 0001-replace-properly-display-numreplaced-as-signed-since.patch, #42338
    2017-11-06 dolorous Attached File- Added 0001-tweaks-use-printf-s-z-modifier-for-ssize_t-size_t.patch, #42334
    2017-11-05 bens Severity3 - Normal 2 - Minor
        StatusNone Wont Fix
    2017-11-05 dolorous Attached File- Added 0001-tweaks-fix-mixed-declarations-and-code.patch, #42332

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code