Skip to content

uucore: move printf::memo module to uucore #2777

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

Merged
merged 2 commits into from
Jan 25, 2022

Conversation

jfinkels
Copy link
Collaborator

This pull request moves the printf::memo module to uucore so that it can be used by other programs, not just printf. For example, the -f option to seq requires parsing and formatting numbers according to the same logic as printf (see issue #2616).

I could use some help with this. After this change, I see the following warnings:

warning: struct is never constructed: `Remainder`
  --> src/uucore/src/lib/features/tokenize/num_format/formatters/base_conv/mod.rs:35:12
   |
35 | pub struct Remainder<'a> {
   |            ^^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: struct is never constructed: `DivOut`
  --> src/uucore/src/lib/features/tokenize/num_format/formatters/base_conv/mod.rs:41:12
   |
41 | pub struct DivOut<'a> {
   |            ^^^^^^

warning: function is never used: `arrnum_int_div_step`
  --> src/uucore/src/lib/features/tokenize/num_format/formatters/base_conv/mod.rs:46:8
   |
46 | pub fn arrnum_int_div_step(
   |        ^^^^^^^^^^^^^^^^^^^

warning: function is never used: `unsigned_to_arrnum`
   --> src/uucore/src/lib/features/tokenize/num_format/formatters/base_conv/mod.rs:144:8
    |
144 | pub fn unsigned_to_arrnum(src: u16) -> Vec<u8> {
    |        ^^^^^^^^^^^^^^^^^^

warning: field is never read: `as_num`
  --> src/uucore/src/lib/features/tokenize/num_format/formatters/cninetyninehexfloatf.rs:12:5
   |
12 |     as_num: f64,
   |     ^^^^^^^^^^^

warning: function is never used: `to_hex`
  --> src/uucore/src/lib/features/tokenize/num_format/formatters/cninetyninehexfloatf.rs:94:4
   |
94 | fn to_hex(src: &str, before_decimal: bool) -> String {
   |    ^^^^^^

I believe this is related to the fact that the %a formatting option is not implemented yet. See issue #2776. What do you recommend I do about this?

@jfinkels
Copy link
Collaborator Author

Aha, I see how the previous code dealt with this:

#![allow(dead_code)]

I can just reproduce that #![allow(dead_code)].

@jfinkels jfinkels marked this pull request as ready for review December 31, 2021 03:27
Remove the cli module from the printf crate and move its functions into
the module tokenize::unescaped_text module, the only place they are
used.
Move the `printf::memo` module to `uucore` so that it can be used by
other programs, not just `printf`. For example, the `-f` option to `seq`
requires parsing and formatting numbers according to the same logic as
`printf`.
@sylvestre sylvestre merged commit 5932937 into uutils:main Jan 25, 2022
@jfinkels jfinkels deleted the uucore-printf branch January 29, 2022 01:56
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.

2 participants