Vetting the cargo
Vetting the cargo
Posted Jun 10, 2022 17:58 UTC (Fri) by wtarreau (subscriber, #51152)Parent article: Vetting the cargo
The world is getting more and more concerning: "developer" ... "left-padding" ... "challenging functionality".
Hmmm. I mean, it's significantly below the level of the questions that would be asked to hire a developer. If a developer finds left-padding a "challenging functionality", he's not a developer, he's a "google-search frenetic user" or "coding monkey" or "stackoverflow surfer" or whatever, but not a developer. Seriously. The time it would take to implement safely and suitably is probably lower in any language than the time it takes to read the downloaded lib's doc and make sure it's used correctly.
Hint: snprintf(buf, sizeof buf, "%*s", width, string) will do the job; a one-line for() loop following a call to strlen() would do as well, it's just a matter of taste. It even works in shell, and bash has special constructs that make it easy without printf if needed.
