microsoft/Terminal

Don't printf wstring_views by copying them into wstrings; use `%.*s`!

Open

#4.027 geöffnet am 19. Dez. 2019

Auf GitHub ansehen
 (0 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)C++ (3.212 Forks)batch import
Area-CodeHealthHelp WantedIssue-TaskProduct-ConhostProduct-Terminal

Repository-Metriken

Stars
 (35.764 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 27T 19h) (24 gemergte PRs in 30 T)

Beschreibung

StringCchPrintf and--since C99--printf support a specifier that indicates that a string is counted:

auto size = /* ... */;
auto data = /* ... */;
printf("%.*s", size, data);

The .* suggests that printf should consume one register-width argument to determine how many characters the string that follows contains instead of waiting for a null terminator.

Contributor Guide