MCPcopy Create free account
hub / github.com/alliedmodders/sourcemod / gnprintf

Function gnprintf

core/logic/sprintf.cpp:614–1043  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

612}
613
614bool gnprintf(char *buffer,
615 size_t maxlen,
616 const char *format,
617 IPhraseCollection *pPhrases,
618 void **params,
619 unsigned int numparams,
620 unsigned int &curparam,
621 size_t *pOutLength,
622 const char **pFailPhrase)
623{
624 if (!buffer || !maxlen)
625 {
626 if (pOutLength != NULL)
627 {
628 *pOutLength = 0;
629 }
630 return true;
631 }
632
633 if (numparams > MAX_TRANSLATE_PARAMS)
634 {
635 if (pFailPhrase != NULL)
636 {
637 *pFailPhrase = NULL;
638 }
639 return false;
640 }
641
642 int arg = 0;
643 char *buf_p;
644 char ch;
645 int flags;
646 int width;
647 int prec;
648 int n;
649 char sign;
650 const char *fmt;
651 size_t llen = maxlen - 1;
652
653 buf_p = buffer;
654 fmt = format;
655
656 while (true)
657 {
658 // run through the format string until we hit a '%' or '\0'
659 for (ch = *fmt; llen && ((ch = *fmt) != '\0') && (ch != '%'); fmt++)
660 {
661 *buf_p++ = ch;
662 llen--;
663 }
664 if ((ch == '\0') || (llen <= 0))
665 {
666 goto done;
667 }
668
669 // skip over the '%'
670 fmt++;
671

Callers 2

FormatStringMethod · 0.85
FormatStringMethod · 0.85

Calls 11

AddBinaryFunction · 0.85
AddIntFunction · 0.85
AddUIntFunction · 0.85
AddFloatFunction · 0.85
AddStringFunction · 0.85
AddHexFunction · 0.85
GetServerLanguageMethod · 0.80
GetClientLanguageMethod · 0.80
FindTranslationMethod · 0.80
GetGlobalTargetMethod · 0.45
MaxClientsMethod · 0.45

Tested by

no test coverage detected