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

Function scanNewstructFromString

Singular/newstruct.cc:725–790  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

723}
724
725static newstruct_desc scanNewstructFromString(const char *s, newstruct_desc res)
726{
727 char *ss=omStrDup(s);
728 char *p=ss;
729 char *start;
730 int t;
731 char c;
732 newstruct_member elem;
733
734 idhdl save_ring=currRingHdl;
735 currRingHdl=(idhdl)1; // fake ring detection
736 loop
737 {
738 // read type:
739 while ((*p!='\0') && (*p<=' ')) p++;
740 start=p;
741 while (isalnum(*p)) p++;
742 *p='\0';
743 IsCmd(start,t);
744 if (t==0)
745 {
746 Werror("unknown type `%s`",start);
747 omFree(ss);
748 omFree(res);
749 currRingHdl=save_ring;
750 return NULL;
751 }
752 if (t==QRING_CMD) t=RING_CMD;
753 else if (NeedShadowRing(t))
754 res->size++; // one additional field for the ring (before the data)
755 //Print("found type %s at real-pos %d",start,res->size);
756 elem=(newstruct_member)omAlloc0(sizeof(*elem));
757 // read name:
758 p++;
759 while ((*p!='\0') && (*p<=' ')) p++;
760 start=p;
761 while (isalnum(*p)) p++;
762 c=*p;
763 *p='\0';
764 elem->typ=t;
765 elem->pos=res->size;
766 if ((*start=='\0') /*empty name*/||(isdigit(*start)))
767 {
768 WerrorS("illegal/empty name for element");
769 goto error_in_newstruct_def;
770 }
771 elem->name=omStrDup(start);
772 //Print(" name:%s\n",start);
773 elem->next=res->member;
774 res->member=elem;
775 res->size++;
776
777 // next ?
778 *p=c;
779 while ((*p!='\0') && (*p<=' ')) p++;
780 if (*p!=',')
781 {
782 if (*p!='\0')

Callers 2

newstructFromStringFunction · 0.85
newstructChildFromStringFunction · 0.85

Calls 5

IsCmdFunction · 0.85
WerrorFunction · 0.85
NeedShadowRingFunction · 0.85
omAlloc0Function · 0.85
WerrorSFunction · 0.85

Tested by

no test coverage detected