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

Method String

Singular/subexpr.cc:765–1045  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

763}
764
765char * sleftv::String(void *d, BOOLEAN typed, int dim)
766{
767#ifdef SIQ
768 if (rtyp==COMMAND)
769 {
770 ::Print("##command %d\n",((command)data)->op);
771 if (((command)data)->arg1.rtyp!=0)
772 ((command)data)->arg1.Print(NULL,2);
773 if (((command)data)->arg2.rtyp!=0)
774 ((command)data)->arg2.Print(NULL,2);
775 if (((command)data)->arg3.rtyp==0)
776 ((command)data)->arg3.Print(NULL,2);
777 PrintS("##end\n");
778 return omStrDup("");
779 }
780#endif
781 if (d==NULL) d=Data();
782 if (!errorreported)
783 {
784 char *s;
785 int t=Typ();
786 switch (t /*Typ()*/)
787 {
788 case INT_CMD:
789 if (typed)
790 {
791 #if SIZEOF_LONG==8
792 const size_t len=MAX_INT_LEN+17;
793 #else
794 const size_t len=MAX_INT_LEN+7;
795 #endif
796 s=(char*)omAlloc(len);
797 snprintf(s,len,"int(%ld)",(long)d);
798 }
799 else
800 {
801 #if SIZEOF_LONG==8
802 const size_t len=MAX_INT_LEN+12;
803 #else
804 const size_t len=MAX_INT_LEN+2;
805 #endif
806 s=(char*)omAlloc(len);
807 snprintf(s,len,"%ld",(long)d);
808 }
809 return s;
810
811 case STRING_CMD:
812 if (d == NULL)
813 {
814 if (typed) return omStrDup("\"\"");
815 return omStrDup("");
816 }
817 if (typed)
818 {
819 size_t len=strlen((char*) d) + 3;
820 s = (char*) omAlloc(len);
821 snprintf(s,len,"\"%s\"", (char*) d);
822 return s;

Callers

nothing calls this directly

Calls 15

PrintSFunction · 0.85
DataClass · 0.85
pStringFunction · 0.85
nCoeffStringFunction · 0.85
n2StringFunction · 0.85
StringSetSFunction · 0.85
rField_is_GFFunction · 0.85
nfShowMipoFunction · 0.85
StringAppendSFunction · 0.85
StringEndSFunction · 0.85
n_WriteFunction · 0.85
sBucketStringFunction · 0.85

Tested by

no test coverage detected