Skip to content
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

Consistently (don't) split long source file lines #3896

Open
solardiz opened this issue May 7, 2019 · 3 comments
Open

Consistently (don't) split long source file lines #3896

solardiz opened this issue May 7, 2019 · 3 comments

Comments

@solardiz
Copy link
Member

@solardiz solardiz commented May 7, 2019

@jfoug's commit d89568a split a long test vector that's now in openbsdsoftraid_variable_code.h into multiple lines. There are two issues with that:

  1. The split is through use of backslashes inside the string constant, whereas I think it'd be more reliable to close the string on one line and re-open it on the next (and let the compiler concatenate those partial strings) so that the behavior won't depend e.g. on lack of trailing whitespace.

  2. We've since got similarly long other lines into the same source file, which are not split, and even longer lines into other source files. So splitting just that one line makes no sense.

$ egrep -l '^.{4000}' *.[ch] 
agilekeychain_common_plug.c
bks_fmt_plug.c
diskcryptor_common_plug.c
dmg_common_plug.c
keystore_common_plug.c
openbsdsoftraid_variable_code.h
opencl_diskcryptor_aes_fmt_plug.c
opencl_electrum_modern_fmt_plug.c
opencl_pfx_fmt_plug.c
pfx_fmt_plug.c
$ egrep -l '^.{5000}' *.[ch] 
dmg_common_plug.c
keystore_common_plug.c
opencl_electrum_modern_fmt_plug.c
opencl_pfx_fmt_plug.c
pfx_fmt_plug.c

We should probably either un-split that one line or split all similarly long lines (and do it in the more reliable way I suggest above). It also makes sense to first un-split that one line for consistency, and then split all relevant lines in a separate commit/PR.

@magnumripper
Copy link
Member

@magnumripper magnumripper commented May 9, 2019

I opened a PR which currently just unsplit them (I also found such lines in pkzip format).

If we're caring to split all very long lines at all, what would be a sensible limit? 1024, 512, or perhaps 160 characters? The softraid split is something like 1475 character chunks, the pkzip ones merely 181.

@solardiz
Copy link
Member Author

@solardiz solardiz commented May 9, 2019

If we're caring to split all very long lines at all, what would be a sensible limit?

Perhaps no lower, or not much lower, than Jim's split in openbsdsoftraid_variable_code.h was. Maybe 1000 or 2000 or 4000, assuming that a compiler's line length limit is likely a power of 2.

magnumripper added a commit that referenced this issue May 9, 2019
@magnumripper
Copy link
Member

@magnumripper magnumripper commented May 9, 2019

Perhaps we shouldn't close this, but IMHO we can now remove the milestone. Having said that I'll play with some one-liners for doing this automagically.

@magnumripper magnumripper removed this from the 1.9.0-jumbo-1 milestone May 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants