📄 trial.c
字号:
/* trial.c */
#define _CRT_SECURE_NO_DEPRECATE
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
#include <string.h>
#include <signal.h>
#include "integer.h"
#include "fun.h"
#include "primes.h"
#define MAXLEN 1000 /* Maximum length of line */
char *progname;
jmp_buf begin;
#ifdef DEBUG
extern long int nettbytes;
#endif
int main(int argc, char ** argv)
{
char *ns;
char *command;
static char quit_str[] = "exit";
static char help_str[] = "help";
int quit;
char *cps,*cpe;
int tty;
INITMPIBANK();
#ifdef UNIX
setlinebuf(stdout);
#endif
#ifdef DEBUG
printf("before testing: nettbytes = %ld\n", nettbytes);
#endif
tty = isatty(0);
progname = argv[0];
init(); /*intall functions in symbol table */
if( argc ==2) {
int i;
char dummy[4096];
for(i=0;i <4095;i++)dummy[i]=0;
strcpy(dummy,argv[1]);
for(i=0;i<strlen(dummy);i++)if(dummy[i] == ';')dummy[i]='\n';
dummy[strlen(argv[1])]='\n';
Parse(dummy);
exit(0);
}
printf("\n");
printf("\t\t\tCALC\n");
printf("\n");
printf("\t\tA NUMBER THEORY CALCULATOR\n");
printf("\t\tK.R.MATTHEWS, 28th September 2007\n\n");
printf("\n");
;
printf("Type exit to quit, help for information:\n");
while (1)
{
setjmp(begin);
quit=0;
if (!(ns = malloc(sizeof(char) * 1000))) {
printf("Not enough memory\n");
exit(-1); /* return failure */
}
if ( !(command=malloc(sizeof(char) *1000))) {
printf("Not enought memory\n");
exit(-1); /* return failure */
}
ns[0]=0;
fflush(stdout);
if (tty)printf("> ");
if (scanf("%999[^\n]", ns) == EOF)break; /* exit on end of file */
strcpy(command,ns);
Flush();
cps=ns;
while(1) {
cpe=cps;
while(*cpe && *cpe!=';')
cpe++;
*cpe='\n';
*(cpe+1)='\0';
if (strncmp(cps, quit_str, 4) == 0){quit=1;break;}
if (strncmp(cps, help_str, 4) == 0){quit=2;break;}
Parse(cps);
strcpy(ns,command);
if(!(*cpe)) break;
cps=cpe+1;
while(*cps && (*cps==' ' || *cps=='\n'))
cps++;
if(!(*cps)) break;
}
if(quit==1) break;
if(quit==2){readme();continue;}
}
clean_symtab();
FREEMPIBANK();
#ifdef DEBUG
/* FREEBANKI(); */
printf("after testing: nettbytes = %ld\n", nettbytes);
#endif
exit(0); /* return success */
}
int execerror(char *s, char *t){
warning(s, t);
longjmp(begin, 0);
}
void warning(char *s, char *t){
if (t)fprintf(stderr, "%s ", t);
fprintf(stderr, "%s\n", s);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -