microsoft/Terminal

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

Ouverte

#4 027 ouverte le 19 déc. 2019

 (0 commentaire) (0 réaction) (0 personne assignée)C++ (9 275 forks)batch import
Area-CodeHealthHelp WantedIssue-TaskProduct-ConhostProduct-Terminal

Métriques du dépôt

Stars
 (103 173 étoiles)
Métriques de merge PR
 (Merge moyen 27j 19h) (24 PRs mergées en 30 j)

Description

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.

Guide contributeur