Ejemplo n.º 1
0
void main()
{
 int no[M]={42,23,74,11,65,57,94,36,99,87,70,81,61},i,cnt=0;
clrscr();
/*   for(i=0;i<SIZE;i++)
   {
    printf("Enter no[%d] : ",i+1);
    scanf("%d",&no[i]);
   }*/
   cnt=FindMaxLen(no);
   printf("\nmaxlen:%d",cnt);
   getch();

   for(i=0;i<cnt;i++)
   {
    Radix_Sort(no,i+1);
    disp(arr);
   }
//getch();
}
Ejemplo n.º 2
0
int main(int nargs, char **args)
{
   ATL_arg_t *cmpb, *asmb, *lnkb, *filb, *ap, *rmb=NULL, *rp;
   int bits, lcmp, lasm, llnk, lfil, i, lout=0, CPPONLY;
   char *cmps, *asms, *lnks, *outn;
   #ifdef DEBUG
      fplog = fopen("ATL_CCWRAP.log", "w");
      PrintFlags(nargs, args);
   #endif

   outn = ParseCompFlags(nargs, args, &bits, &filb, &cmpb, &asmb, &lnkb,
                         &CPPONLY);
   if (outn)
      lout = strlen(outn);
/*
 * Now, compile each file to the standard name ATL_tmp#.s using gcc -S
 */
   if (cmpb)
   {
      rp = rmb = NewArg("rm");
      lcmp = FindTotLen(cmpb);
      lfil = FindMaxLen(filb);
      cmps = malloc(lcmp + lfil + 32);
      assert(cmps);
      i = PrintAllArgsToStr(cmpb, cmps);
      if (i != lcmp)
      {
         fprintf(stderr, "ERROR: lcmp=%d, i=%d, strlen=%d, str='%s'\n",
                 lcmp, i, (int)strlen(cmps), cmps);
         #ifdef DEBUG
            fprintf(fplog, "ERROR: lcmp=%d, i=%d, strlen=%d, str='%s'\n",
                    lcmp, i, (int)strlen(cmps), cmps);
            fflush(fplog);
         #endif
         assert(i == lcmp);
      }
      for (i=0,ap=filb; ap; i++, ap = ap->next)
      {
         int k;
         char tmpnam[16];
         sprintf(tmpnam, "ATL_tmp%d.[s,o]", i);
         rp->next = NewArg(tmpnam);
         rp = rp->next;
         if (ap->arg[ap->len-1] == 'S' || CPPONLY)
            k = lcmp + sprintf(cmps+lcmp, "-E -o ATL_tmp%d.s ", i);
         else
            k = lcmp + sprintf(cmps+lcmp, "-S -o ATL_tmp%d.s ", i);
         PrintArgToStr(ap, cmps+k);
         #ifdef DEBUG
            fprintf(fplog, "COMP: %s\n", cmps);
            fflush(fplog);
         #endif
         assert(!system(cmps));
      }
      KillAllArgs(cmpb);
      free(cmps);
/*
 *    If we aren't linking and we have only one file with a specified name,
 *    assemble the .s file to the specified .o file
 */
      lasm = FindTotLen(asmb);
      cmps = malloc(lasm + lfil + 64);
      assert(cmps);
      i = PrintAllArgsToStr(asmb, cmps);
      assert(i == lasm);
      if (!lnkb && !filb->next)
      {
         int k;
         char *sp;
         if (outn)
            sp = outn;
         else
            sp = GetDefObjNam(filb->arg);
         k = lasm + sprintf(cmps+lasm, "-c ATL_tmp0.s");
         if (sp != outn)
            sprintf(cmps+k, " -o %s", sp);
         #ifdef DEBUG
            fprintf(fplog, "ASSEMBLE: %s\n", cmps);
         #endif
         k = system(cmps);
         KillAllArgs(filb);
         KillAllArgs(asmb);
         free(cmps);
         if (sp != outn)
            free(sp);
         return(k);
      }
/*
 *    Now assemble every .s into a .o
 */
      for (i=0,ap=filb; ap; i++, ap = ap->next)
      {
         int k;
         k = lasm + sprintf(cmps+lasm, "-c ATL_tmp%d.s -o ATL_tmp%d.o", i, i);
         #ifdef DEBUG
            fprintf(fplog, "ASSEMBLE: %s\n", cmps);
            fflush(fplog);
         #endif
         assert(!system(cmps));
      }
      KillAllArgs(asmb);
      free(cmps);
   }
/*
 * Now issue link line
 */
   if (lnkb)
   {
/*
 *    Put files back into link line in the order in which they were found
 *    NULL-arg nodes are placeholders for the names.
 */
      for (i=0,ap=filb; ap; i++,ap = ap->next)
      {
         ATL_arg_t *tp;
         for (tp=lnkb; tp && tp->arg; tp = tp->next);
         assert(tp);
         tp->arg = malloc(16);
         assert(tp->arg);
         tp->len = sprintf(tp->arg, "ATL_tmp%d.o", i);
      }
      llnk = FindTotLen(lnkb);
      cmps = malloc(llnk + 1);
      assert(cmps);
      i = PrintAllArgsToStr(lnkb, cmps);
      assert(i == llnk);
      #ifdef DEBUG
         fprintf(fplog, "LINK: '%s'\n", cmps);
         fflush(fplog);
      #endif
      assert(!system(cmps));
      KillAllArgs(lnkb);
      free(cmps);
   }
   KillAllArgs(filb);
/*
 * Now delete the temporary files that we have created
 */
   i = FindTotLen(rmb);
   cmps = malloc(i + 1);
   assert(cmps);
   assert(i == PrintAllArgsToStr(rmb, cmps));
   KillAllArgs(rmb);
   printf("%s\n", cmps);
   system(cmps);
   free(cmps);

   #ifdef DEBUG
      system("cat ATL_CCWRAP.log");
      fclose(fplog);
   #endif
   return(0);
}