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

New sprintf implementation #7612

Draft
wants to merge 41 commits into
base: master
Choose a base branch
from
Draft

New sprintf implementation #7612

wants to merge 41 commits into from

Commits on Oct 14, 2021

  1. Beginnings of a new sprintf parser/interpreter.

    The goal of this new design is to make it much simpler to modify
    and update when we find a bug or have to add a new identifier.  A
    secondary longer goal is to decouple processing of the format string
    from the generation of the final string when executing sprintf.  The
    value of this decoupling is we can push the format parsing phase into
    the sprintf callsite so we only have to process the format once.  In
    fact once we get to that point we can potentially just bytecode generate
    the string building piece.
    
    The current point of this work is we can completely parse the format
    string into a sequence of tokens.  It is done sans bugs or decisions to
    add/change any fields based on work on the interpreter.
    
    At this point to use it you need to set the env var SPRINTF=anything
    to enable new runtime and it will only work with %i, %d, and %u.
    
    Future work will be to keep adding new directives but not be trying
    very hard to make one method process to many directives.  In the case
    of the three (i,d,u) 'i' is an alias of 'd' and 'u' processes unsigned
    values a little differently when setting up the value.   Any more complexity
    and u would have been its own method.
    enebo committed Oct 14, 2021
    Configuration menu
    Copy the full SHA
    78944ef View commit details
    Browse the repository at this point in the history
  2. Remove extra printlns

    enebo committed Oct 14, 2021
    Configuration menu
    Copy the full SHA
    0ddff4d View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    762f06d View commit details
    Browse the repository at this point in the history
  4. Make spec:ruby:fast run again

    enebo committed Oct 14, 2021
    Configuration menu
    Copy the full SHA
    289b71a View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    978dcc5 View commit details
    Browse the repository at this point in the history
  6. Sketchy fix for %%d -> %d for printf

    May need to unit test byteListUpto but for now this passes more tests.
    enebo committed Oct 14, 2021
    Configuration menu
    Copy the full SHA
    ef223bb View commit details
    Browse the repository at this point in the history
  7. %.5d was not zero padding

    enebo committed Oct 14, 2021
    Configuration menu
    Copy the full SHA
    25abce1 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    09dccb9 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    e09cce9 View commit details
    Browse the repository at this point in the history
  10. Dual using token.width is confusing. Just make another field.

    indexed args in sprintf were still also using that index as its
    width.
    enebo committed Oct 14, 2021
    Configuration menu
    Copy the full SHA
    e4b287d View commit details
    Browse the repository at this point in the history
  11. Allow <name> to accept additional formatting.

    getArg will now get named parameters.
    enebo committed Oct 14, 2021
    Configuration menu
    Copy the full SHA
    03b3eab View commit details
    Browse the repository at this point in the history

Commits on Oct 15, 2021

  1. Implement %bBoxX.

    enebo committed Oct 15, 2021
    Configuration menu
    Copy the full SHA
    b9af53e View commit details
    Browse the repository at this point in the history
  2. Change some visibility on token fields.

    Implement argument errors for mixed format specifiers.
    enebo committed Oct 15, 2021
    Configuration menu
    Copy the full SHA
    98fa357 View commit details
    Browse the repository at this point in the history

Commits on Oct 17, 2021

  1. Fix assumed ordering of indexed arguments.

    The parser assumed width and arg index would occur in the same order:
    
      %*1$2$d
    
    but it can also be:
    
      %2$*1$d
    
    I also changed some naming.
    enebo committed Oct 17, 2021
    Configuration menu
    Copy the full SHA
    785d657 View commit details
    Browse the repository at this point in the history
  2. Made mistake in last commit in naming.

    I fixed another incompatibility and realized hasWidth is the right
    name.  This commit also fixed asking for next arg if hasWidth for
    an unnumbered format field.
    enebo committed Oct 17, 2021
    Configuration menu
    Copy the full SHA
    0b44a2a View commit details
    Browse the repository at this point in the history
  3. Fix first long-standing bug in spec/ruby for sprintf.

    %#o with a negative values does not prefix with a '0'.  Strange but true.
    enebo committed Oct 17, 2021
    Configuration menu
    Copy the full SHA
    03f2102 View commit details
    Browse the repository at this point in the history
  4. Fix another long standing problem. mixed error now thrown.

    "%*10d" is mixing numbered '*' with 10d unnumbered.
    enebo committed Oct 17, 2021
    Configuration menu
    Copy the full SHA
    25125b2 View commit details
    Browse the repository at this point in the history

Commits on Oct 19, 2021

  1. Fix most remaining issues in test:mri except a single oddity involing…

    … succ.
    
    Lots of random fixes to the sprintf parser.  A grab bag of smaller fixes.
    enebo committed Oct 19, 2021
    Configuration menu
    Copy the full SHA
    2e7042e View commit details
    Browse the repository at this point in the history
  2. Fix last precision issues?

    Telling between explictly supplied precision and an argument provided one
    is still messy but it should be working now.  I will try and circle back
    to simplify FormatToken since the other two (index, width) are not as
    complex.
    
    Also removed dead parameter in processDigits.
    enebo committed Oct 19, 2021
    Configuration menu
    Copy the full SHA
    c4a9b42 View commit details
    Browse the repository at this point in the history
  3. Another fix for precision.

    %5.0d was zero padding and asking for an extra argument before this change.
    enebo committed Oct 19, 2021
    Configuration menu
    Copy the full SHA
    e45beef View commit details
    Browse the repository at this point in the history

Commits on Oct 22, 2021

  1. Reverse SPRINTF env to run new sprintf it unset.

    We now pass more specs and tests with new code and we also want
    to see mistakes made with the new code during CI runs.
    enebo committed Oct 22, 2021
    Configuration menu
    Copy the full SHA
    210c522 View commit details
    Browse the repository at this point in the history

Commits on Oct 24, 2021

  1. "%1" was an infinite loop

    enebo committed Oct 24, 2021
    Configuration menu
    Copy the full SHA
    34854aa View commit details
    Browse the repository at this point in the history
  2. Some more literal '%' cases

    enebo committed Oct 24, 2021
    Configuration menu
    Copy the full SHA
    9d1a38a View commit details
    Browse the repository at this point in the history
  3. Fixes '%+.2d' zero padding

    enebo committed Oct 24, 2021
    Configuration menu
    Copy the full SHA
    39c73c7 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    fb6e223 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    5dc668c View commit details
    Browse the repository at this point in the history

Commits on Oct 25, 2021

  1. Configuration menu
    Copy the full SHA
    4b1a9d9 View commit details
    Browse the repository at this point in the history

Commits on Oct 26, 2021

  1. Configuration menu
    Copy the full SHA
    396cd98 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    95f5fd2 View commit details
    Browse the repository at this point in the history

Commits on Nov 5, 2021

  1. Configuration menu
    Copy the full SHA
    a67836f View commit details
    Browse the repository at this point in the history

Commits on Nov 18, 2021

  1. Configuration menu
    Copy the full SHA
    70deb32 View commit details
    Browse the repository at this point in the history
  2. new_sprintf WIP: support for %c failing tests

    Fails two specs and one mri test
    
    Modified:
    core/src/main/java/org/jruby/util/SprintfParser.java
    PurityLake authored and enebo committed Nov 18, 2021
    Configuration menu
    Copy the full SHA
    37f2374 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    44a34c3 View commit details
    Browse the repository at this point in the history
  4. new_sprintf WIP: added support for %s

    According to local tests just one test fail
    PurityLake authored and enebo committed Nov 18, 2021
    Configuration menu
    Copy the full SHA
    15e976f View commit details
    Browse the repository at this point in the history
  5. Land %c/%p support

    enebo committed Nov 18, 2021
    Configuration menu
    Copy the full SHA
    6afdae9 View commit details
    Browse the repository at this point in the history

Commits on Nov 23, 2021

  1. Explicit width can mark rightpad at parse time.

    This unfortunately does not mean it still does not need to check it
    in the case of '*' but it makes sense to make the token as known as
    possible.
    enebo committed Nov 23, 2021
    Configuration menu
    Copy the full SHA
    411d3ad View commit details
    Browse the repository at this point in the history

Commits on Dec 2, 2021

  1. Configuration menu
    Copy the full SHA
    73116ae View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0298a8e View commit details
    Browse the repository at this point in the history

Commits on Dec 3, 2021

  1. Configuration menu
    Copy the full SHA
    754a32f View commit details
    Browse the repository at this point in the history

Commits on Dec 17, 2021

  1. Configuration menu
    Copy the full SHA
    dd6e128 View commit details
    Browse the repository at this point in the history
  2. Remove last known %d error

    enebo committed Dec 17, 2021
    Configuration menu
    Copy the full SHA
    049d4ee View commit details
    Browse the repository at this point in the history