MCPcopy Create free account
hub / github.com/Singular/Singular / feSprintf

Function feSprintf

resources/feResource.cc:653–700  ·  view source on GitHub ↗

* * feSprintf * *****************************************************************/

Source from the content-addressed store, hash-verified

651 *
652 *****************************************************************/
653static char* feSprintf(char* s, const char* fmt, int warn)
654{
655 char* s_in = s;
656 if (fmt == NULL) return NULL;
657
658 while (*fmt != '\0')
659 {
660 *s = *fmt;
661
662 if (*fmt == '%' && *(fmt + 1) != '\0')
663 {
664 fmt++;
665 char* r = feResource(*fmt, warn);
666 if (r != NULL)
667 {
668 strcpy(s, r);
669 s += strlen(r) - 1;
670 }
671 else
672 {
673 s++;
674 *s = *fmt;
675 }
676 }
677 else if (*fmt == '$' && *(fmt + 1) != '\0')
678 {
679 fmt++;
680 char* v = s + 1;
681 while (*fmt == '_' ||
682 (*fmt >= 'A' && *fmt <= 'Z') ||
683 (*fmt >= 'a' && *fmt <= 'z'))
684 {
685 *v = *fmt;
686 v++;
687 fmt++;
688 }
689 fmt--;
690 *v = '\0';
691 v = getenv(s + 1);
692 if (v != NULL) strcpy(s, v);
693 s += strlen(s) - 1;
694 }
695 s++;
696 fmt++;
697 }
698 *s = '\0';
699 return s_in;
700}
701

Callers 2

feResourceDefaultFunction · 0.85
feInitResourceFunction · 0.85

Calls 1

feResourceFunction · 0.85

Tested by

no test coverage detected