void callASort(T* buff, size_t size, T*(*asort)(T* buff, size_t n), LPCTSTR fileOut)
{
	T* forSort = duplicateBuff(buff, size);

	T* sortRes = asort(forSort, size);

	if (outputOutput)
		outputBuff(sortRes, size);

	writefile(fileOut, sortRes, size);
	delete[] forSort;
}
示例#2
0
/*********************************
 *                               *
 *    ge_ProcessQuery            *
 *                               *
 *********************************/
static void
ge_ProcessQuery(PE_QUERY query) {

  switch (query.tag) {
  case STRNG :
    st_PrintEntryInfo(st_NameToKey(query.info.query));
    break;
  case ABOUT :
    clearBuff(); 
    appendBuff(CHARITY_CONT_PROMPT "Charity Interpreter version "CHARITY_VERSION " was written by \n"
			    CHARITY_CONT_PROMPT "     Charles Tuckey, \n"
			    CHARITY_CONT_PROMPT "     Peter Vesely and \n"
			    CHARITY_CONT_PROMPT "     Barry Yee \n"
			    CHARITY_CONT_PROMPT "from May to November, 1995.\n");
    outputBuff(stdout);
    break;
  case SHOWCOMB :
    st_PrintEntryInfo(st_NameToKey(query.info.showcomb));
    if (isFunction(query.info.showcomb)) {
      printMsg(MSG, "COMBINATOR DEFN for %s", query.info.showcomb);
      CodeTableShowComb(query.info.showcomb);
    }
    else if (isDatatype(query.info.showcomb)) {
      st_ShowDatatypeCombinators(st_NameToKey(query.info.showcomb));
    }
    else 
      ;   /* do nothing */
    break;
  case DUMPTABLE:
    st_DumpTable();
    break;
  case REPLACE:
    if (gb_ReplaceFunctions)
      printMsg(MSG, "Functions replaced silently.");
    else
      printMsg(MSG, "User prompted to replace functions.");
    printMsg(MSG, "User prompted to replace datatypes.");
    break;
  case INCLUDEDIRS:
    printMsg(MSG,"Search path is %L.",(LIST *)g_strList_IncludeDirs);
    break;
  case SHOWMEM:
    MemDisplayState();
    break;
  case QUERY:
    ge_ShowHelp(QUERY);
    break;
  default: 
    printMsg(FATAL_MSG, "ge_ProcessQuery - Invalid tag (%d)", query.tag);
  }
}
示例#3
0
文件: ioChar.c 项目: dobesv/charity
/**************************
 *                        *
 * appendBuff             *
 *                        *
 **************************/
void 
appendBuff(char *str) {

  int i=0;

  if (str) {
    while (str[i]) {
      if (printBuffPtr == (MaxPrintbuff - 1))  {
	printBuff[++printBuffPtr] = 0;
	outputBuff(stdout);
	clearBuff();
      }
      printBuff[printBuffPtr++] = str[i++];
    }   /*  elihw  */
    printBuff[printBuffPtr] = 0;
  }   /*  fi  */
}
void testsorts()
{
	T* buff = 0;
	size_t size = 0;
	readfile(file2read, buff, size);

	if (outputInput)
		outputBuff(buff, size);

	//callASort(buff, size, bubble_sort, L"C:\\mmm\\4Sort\\bubble_sort.out");
	//callASort(buff, size, insert_sort, L"C:\\mmm\\4Sort\\insert_sort.out");
	//callASort(buff, size, select_sort, L"C:\\mmm\\4Sort\\select_sort.out");
	//callASort(buff, size, merge_sort_iter, L"C:\\mmm\\4Sort\\merge_sort_iter.out");
	//callASort(buff, size, merge_sort_recurs, L"C:\\mmm\\4Sort\\merge_sort_recurs.out");
	callASort(buff, size, quick_sort, L"C:\\mmm\\4Sort\\quick_sort.out");
	//callASort(buff, size, heap_sort, L"C:\\mmm\\4Sort\\heap_sort.out");
	callASort(buff, size, count_sort, L"C:\\mmm\\4Sort\\count_sort.out");
	//callASort(buff, size, radix_sort, L"C:\\mmm\\4Sort\\radix_sort.out");
	//callASort(buff, size, red_black_sort, L"C:\\mmm\\4Sort\\red_black_sort.out");

	delete [] buff;
}
示例#5
0
文件: ioChar.c 项目: dobesv/charity
/**************************
 *                        *
 *    printMsg            *
 *                        *
 **************************/
void 
printMsg(MSG_TYPE msgType, char *msg, ...) {

  va_list  ap;
  char        *p,
              *strVal,
               convStr[MAX_MSG_LENGTH],
               text[MAX_MSG_LENGTH];
  int          i=0,
               intVal;
  CT_EXPR     *coreTermLogicExpr;
  ST_TYPE_SIG *typeSigVal;
  ST_TYPE     *st_type;
  LIST        *list;
  CT_VAR_BASE *ctVarBase;

  clearBuff();
  switch (msgType) {
  case MSG :  
  case PROMPT_MSG : 
    break;
  case FATAL_MSG :
    appendBuff("*** FATAL ERROR: ");     break;
  case ERROR_MSG :
    appendBuff("*** ERROR: ");           break;
  case DEBUG_MSG :
    appendBuff("-->DEBUG: ");           break;
  case DELAYEDERROR_MSG :
    appendBuff("*** ERROR: ");       delayedErrorCount++;    break;
  case WARN_MSG :
    appendBuff("WARNING: ");         break;
  default :
    printMsg(FATAL_MSG, "printMesg - Invalid value for MSG_TYPE");
  }

  va_start(ap, msg);

  for (p=msg; *p; p++) {
    if (*p != '%') 
      text[i++] = *p;
    else {
      text[i] = 0;      i=0;
      appendBuff(text);
      switch (*++p) {
      case '%' :
	appendBuff("%");
	break;
      case 'd' :
	intVal = va_arg(ap, int);
	sprintf(convStr,"%d",intVal);
	appendBuff(convStr);
	break;
      case 'r' :
	coreTermLogicExpr = va_arg(ap, CT_EXPR*);
	_showCT_expr(coreTermLogicExpr, 0);
	break;
      case 's' :
	strVal = va_arg(ap, char*);
	appendBuff(strVal);
	break;
      case 't' :
	typeSigVal = va_arg(ap, ST_TYPE_SIG*);
	st_ShowSig(typeSigVal);
	break;
      case 'L' :  /* lists */
	list = va_arg(ap, LIST*);
	showList(list, BFALSE);
	break;
      case 'T' :
	st_type = va_arg(ap, ST_TYPE *);
	st_ShowType(st_type);
	break;
      case 'S' :	/* running out of choices */
	typeSigVal = va_arg(ap, ST_TYPE_SIG*);
	st_ShowTypeSig(typeSigVal);
	break;	
      case 'U' :	/* this is to strip out context variables */
	typeSigVal = va_arg(ap, ST_TYPE_SIG*);
	st_ShowTypeSigLessContext(typeSigVal);
	break;
      case 'V' :
        ctVarBase = va_arg(ap, CT_VAR_BASE*);
        ctShowVarBase(ctVarBase);
        break;
      default :
	printMsg(FATAL_MSG, "Invalid format specifier: %s", p);
      }   /*  hctiws  */
    }   /*  esle  */
  }   /*  rof  */

  text[i] = 0;
  appendBuff(text);     



  switch (msgType) {
  case MSG :
  case WARN_MSG :
  case DEBUG_MSG :
  case DELAYEDERROR_MSG :
    appendBuff("\n");
    outputBuff(stdout);
    break;
  case PROMPT_MSG :
    outputBuff(stdout);
    break;
  case FATAL_MSG :
    appendBuff("\n");
    outputBuff(stdout);
    exit(-1);
    break;
  case ERROR_MSG :
    appendBuff("\n");
    outputBuff(stdout);
    longjmp(topLevelEnv, 1);
    break;
  default :
    appendBuff("\n");
    outputBuff(stdout);
    printMsg(FATAL_MSG, "printMesg - Invalid value for MSG_TYPE");
  }
  

}   /*  end printMsg  */