Skip to content

Remove trailing spaces in hexdump output#219

Merged
avsm merged 4 commits intomirage:masterfrom
emillon:hexdump-formatting
Feb 26, 2019
Merged

Remove trailing spaces in hexdump output#219
avsm merged 4 commits intomirage:masterfrom
emillon:hexdump-formatting

Conversation

@emillon
Copy link
Copy Markdown
Contributor

@emillon emillon commented Feb 1, 2019

Hello,

I added some tests for hexdump_pp.

The formatting seems a bit off to me:

  • there are trailing spaces
  • there is no newline at the end

I believe that the trailing spaces should be removed, but I'm not too sure about the trailing newlines.

Let me know what you think.

@emillon
Copy link
Copy Markdown
Contributor Author

emillon commented Feb 1, 2019

(feature was initially added in #175 where there's some discussion about output)

@avsm
Copy link
Copy Markdown
Member

avsm commented Feb 1, 2019

Lgtm; fixing the trailing spaces and newline sounds good! I just noticed that cstruct doesn't use ocaml-hex from mirage, but the extra dependency probably isnt worth it

@hannesm
Copy link
Copy Markdown
Member

hannesm commented Feb 1, 2019

well, I'd welcome a single to/of_hex -- i.e. Cstruct using the hex library instead of containing the very same code once more... I thought we discussed this somewhere, but I'm unable to find the discussion :/

having said this, I'm ok with these changes - but would appreciate them to be applied to the hex library and that being used here :)

@emillon
Copy link
Copy Markdown
Contributor Author

emillon commented Feb 4, 2019

OK, I'll do the fixes here first and merge the implementations in a separate PR. At the moment, ocaml-hex has a different output format, so that will mean adding a new option over there.

@hannesm
Copy link
Copy Markdown
Member

hannesm commented Feb 4, 2019

@emillon great, thanks!

@emillon emillon changed the title WIP: Add tests for hexdump output Remove trailing spaces in hexdump output Feb 4, 2019
@emillon
Copy link
Copy Markdown
Contributor Author

emillon commented Feb 4, 2019

I removed the spaces and used a vbox instead of forcing a newline.

As for the trailing newline, after trying I don't think it's hexdump_pp's responsibility to add a break at the end.

For example, let's say we're trying to write some text and a hanging hexdump:

Some text 00 01 03....
          11 ....
          3f ....

At the moment there is no trailing newline. But forcing a break will insert spaces (indicated by ):

Some text 00 01 03....
          11 ....
          3f ....
␣␣␣␣␣␣␣␣␣␣

Which makes it impossible to output things like:

Some text 00 01 03....
          11 ....
          3f ....
Something else

So, we can merge this as this already fixes the trailing spaces, and try to think of a better solution once it's merged with hex :)

@avsm
Copy link
Copy Markdown
Member

avsm commented Feb 26, 2019

thanks!

@avsm avsm merged commit bf2f19b into mirage:master Feb 26, 2019
avsm added a commit to avsm/opam-repository that referenced this pull request Feb 26, 2019
…struct-lwt (3.5.0)

CHANGES:

- Remove trailing spaces in hexdump output (mirage/ocaml-cstruct#219 @emillon)
- Add `Cstruct.rev` to allocate a reversed cstruct (mirage/ocaml-cstruct#221 @emillon)
- `Cstruct_unix` now uses the post-OCaml 4.06 `Unix.map_file`
  instead of the deprecated Bigarray `map_file` that was removed
  in OCaml 4.08 (@avsm, see ocaml/ocaml#2263)
- Remove unnecessary `(wrapped false)` in the build system (@avsm)
- Correct ocamldoc to the right `cstruct-ppx` package pointer (@avsm)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants