Changeset 98123a in git


Ignore:
Timestamp:
Sep 12, 2016, 6:48:06 PM (8 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
6de4f47c2595122ae8162280a8ac90eefcfce27c
Parents:
da4b3223efff0b797045aad67f6bce7fe3596550
Message:
system("sort",<list>)
Location:
Singular
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Singular/extra.cc

    rda4b32 r98123a  
    38053805    else
    38063806#endif
     3807/*==================== sort =================*/
     3808    if(strcmp(sys_cmd,"sort")==0)
     3809    {
     3810      extern BOOLEAN jjSORTLIST(leftv,leftv);
     3811      if (h->Typ()==LIST_CMD)
     3812        return jjSORTLIST(res,h);
     3813      else
     3814        return TRUE;
     3815    }
     3816    else
    38073817/*==================== Error =================*/
    38083818      Werror( "(extended) system(\"%s\",...) %s", sys_cmd, feNotImplemented );
  • Singular/iparith.cc

    rda4b32 r98123a  
    82048204        //Print("test %s\n",Tok2Cmdname(dA1[i].arg));
    82058205        if ((dA1[i].valid_for & NO_CONVERSION)==0)
    8206         {
     8206        {
    82078207          if ((ai=iiTestConvert(at,dA1[i].arg,dConvertTypes))!=0)
    82088208          {
     
    83878387      {
    83888388        if ((dA3[i].valid_for & NO_CONVERSION)==0)
    8389         {
     8389        {
    83908390          if ((ai=iiTestConvert(at,dA3[i].arg1,dConvertTypes))!=0)
    83918391          {
     
    91529152        tmp.Copy(v);
    91539153        bo=iiExprArith2TabIntern(&res_l->m[i],&c->m[i],CHINREM_CMD,&tmp,TRUE,dArith2+tab_pos,c->m[i].rtyp,tmp.rtyp,dConvertTypes);
    9154         tmp.CleanUp();
     9154        tmp.CleanUp();
    91559155        if (bo) { Werror("chinrem failed for list entry %d",i+1); break;}
    91569156      }
     
    93139313  return bo;
    93149314}
     9315// --------------------------------------------------------------------
     9316static int jjCOMPARE_ALL(const void * aa, const void * bb)
     9317{
     9318  leftv a=(leftv)aa;
     9319  int at=a->Typ();
     9320  leftv b=(leftv)bb;
     9321  int bt=b->Typ();;
     9322  if (at < bt) return -1;
     9323  if (at > bt) return 1;
     9324  int tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,'<');
     9325  sleftv tmp;
     9326  memset(&tmp,0,sizeof(sleftv));
     9327  iiOp='<';
     9328  BOOLEAN bo=iiExprArith2TabIntern(&tmp,a,'<',b,FALSE,dArith2+tab_pos,at,bt,dConvertTypes);
     9329  if (bo)
     9330  {
     9331    Werror(" no `<` for %s",Tok2Cmdname(at));
     9332    return -1;
     9333  }
     9334  else if (tmp.data==NULL) /* not < */
     9335  {
     9336    iiOp=EQUAL_EQUAL;
     9337    tab_pos=iiTabIndex(dArithTab2,JJTAB2LEN,EQUAL_EQUAL);
     9338    bo=iiExprArith2TabIntern(&tmp,a,EQUAL_EQUAL,b,FALSE,dArith2+tab_pos,at,bt,dConvertTypes);
     9339    if (bo)
     9340    {
     9341      Werror(" no `==` for %s",Tok2Cmdname(at));
     9342      return -1;
     9343    }
     9344    else if (tmp.data==NULL) /* not <,== */ return 1;
     9345    else return 0;
     9346  }
     9347  else return -1;
     9348}
     9349BOOLEAN jjSORTLIST(leftv, leftv arg)
     9350{
     9351  lists l=(lists)arg->Data();
     9352  if (l->nr>0)
     9353  {
     9354    qsort(l->m,l->nr+1,sizeof(sleftv),jjCOMPARE_ALL);
     9355  }
     9356  return FALSE;
     9357}
Note: See TracChangeset for help on using the changeset viewer.