locutusjs / locutus

Bringing stdlibs of other programming languages to JavaScript for educational purposes

Home Page:https://locutus.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[c/stdio/sprintf] %% consumes an extra arg

paramsiddharth opened this issue · comments

  • Have you checked the guidelines in our Contributing document?

Description

[c/stdio/sprintf] %% consumes an extra arg

When trying to use %% in sprintf to represent a % sign, it consumes an extra value from ...args.

The following examples will explain it better:

  • const str = sprintf('%d%%%d.', 1, 2);
    console.log(str);
    Output: 1%0.
  • const str = sprintf('%s is a %d%% %s %s.', 'Param', 90, 'good', 'boy');
    console.log(str);
    Output: Param is a 90% boy undefined.

If approved, I would like to work on this issue.

@paramsiddharth thank you for reporting the bug. You are free to work on it. I'll then review the fix.

@paramsiddharth do you plan to submit a fix soon? Otherwise I'm ready to prepare one.

@paramsiddharth do you plan to submit a fix soon? Otherwise I'm ready to prepare one.

Yes! Pardon the delay! I'll let you know if I'm stuck. I'll make a PR soon!

@kukawski I just made PR #442 . Please review.

Alright, the patch is now merged. Thanks for spotting the problem and fixing it.