sourcemod icon indicating copy to clipboard operation
sourcemod copied to clipboard

[Bug]: When using "%0[width]d" to format a negative integer, the minus sign is placed incorrectly

Open F1F88 opened this issue 6 months ago • 0 comments

Prerequisites

  • [x] I have checked that my issue doesn't exist yet in the issue tracker

Operating System and Version

Windows 11 24H2

Game / AppID and Version

NMRIH version 1.14.2

SourceMod Version

1.12.0-git7197

Metamod:Source Version

1.12.0-git1219

Version Verification

  • [x] I have updated SourceMod to the latest version and the issue persists
  • [x] I have updated SourceMod to the latest snapshot and the issue persists
  • [x] I have updated Metamod:Source to the latest snapshot and the issue persists

Updated SourceMod Version

1.13.0-git7241

Updated Metamod:Source Version

2.0.0-1350

Description

When using "%0[width]d" to format a negative integer, the minus sign is formatted before the integer value but after the filler '0'.

Steps to Reproduce

#include <sourcemod>

public void OnPluginStart()
{
    PrintToServer("Int: (%d)", -123);
    PrintToServer("Int: (%7d)", -123);
    PrintToServer("Int: (%07d)", -123);
    PrintToServer("Int: (%-07d)", -123);
}

Relevant Log Output

Expected Output:

Int: (-123)
Int: (   -123)
Int: (-000123)
Int: (-123000)

Actual Output:

Int: (-123)
Int: (   -123)
Int: (000-123)
Int: (-123000)

F1F88 avatar May 31 '25 22:05 F1F88