Page MenuHomeFreeBSD

b64encode: implement -w to wrap lines
ClosedPublic

Authored by pstef on Nov 11 2021, 5:26 PM.
Tags
None
Referenced Files
F102875195: D32944.diff
Mon, Nov 18, 7:37 AM
Unknown Object (File)
Oct 8 2024, 9:23 PM
Unknown Object (File)
Oct 5 2024, 11:54 AM
Unknown Object (File)
Oct 2 2024, 5:02 PM
Unknown Object (File)
Oct 1 2024, 5:17 PM
Unknown Object (File)
Sep 29 2024, 9:40 PM
Unknown Object (File)
Sep 25 2024, 1:35 PM
Unknown Object (File)
Sep 25 2024, 1:34 PM
Subscribers

Details

Summary

This functionality is present in GNU base64 and I find it useful when I want to generate random, ASCII-clean data of specific width.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

pstef requested review of this revision.Nov 11 2021, 5:26 PM
pstef created this revision.
delphij added inline comments.
usr.bin/uuencode/uuencode.c
106 ↗(On Diff #104241)

It looks like the only reason that arg_to_col exists was to parse the -w argument, and what it does was to strtol(), then perform sanity check of the returned value.

Instead of having a separate function, it would make the code more readable to just use strtol() here with the intermediate _long variable to hold the value, then perform the range check of the returned value and give the feedback here, unless there is plan to have the function used in somewhere else...

159 ↗(On Diff #104241)

Mind adding a comment the reasoning of why 1023 was chosen here? If it was rounddown(BUFSIZE, 3), is it possible to represent that way?

254 ↗(On Diff #104241)

Did you mean optarg_long here? (If so, that would be another reason to just fold the function back into the getopt_long loop...)

Hi, thanks for the review!

usr.bin/uuencode/uuencode.c
106 ↗(On Diff #104241)

A previous version of this patch was like what you describe. But then I rewrote the base64 implementation (D32945) and it will use the arg_to_col() too. The other option is to turn this code into a function as part of D32945 and I wanted it to be minimal and clear.

159 ↗(On Diff #104241)

Good point, I'll recall what the idea was and describe it here.

254 ↗(On Diff #104241)

Good point, I'll use optarg_long here.

Address mistakes, describe the magic buffer length.

Minor style nit, otherwise looks fine.

usr.bin/uuencode/uuencode.c
243–244 ↗(On Diff #105059)

style

This revision is now accepted and ready to land.Apr 16 2022, 5:40 PM
This revision was automatically updated to reflect the committed changes.