Page MenuHomeFreeBSD

b64encode: implement -w to wrap lines
ClosedPublic

Authored by pstef on Nov 11 2021, 5:26 PM.
Tags
None
Referenced Files
F80182105: D32944.diff
Thu, Mar 28, 10:33 PM
Unknown Object (File)
Mon, Mar 18, 7:36 PM
Unknown Object (File)
Mon, Mar 18, 7:36 PM
Unknown Object (File)
Mon, Mar 18, 7:36 PM
Unknown Object (File)
Mon, Mar 18, 7:36 PM
Unknown Object (File)
Mon, Mar 18, 7:36 PM
Unknown Object (File)
Mon, Mar 18, 7:36 PM
Unknown Object (File)
Sat, Mar 16, 6:55 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

Lint
Lint Skipped
Unit
Tests Skipped

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

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

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

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

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

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

254

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
239–240

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.