char* en_en::getOtherVerb(int v1,int v2,int* adv){ char* adverbs = ""; char t = '1'; if (v1!=0) { FILE* rFile = fopen(DICTIONARY EN_EN_FOLDER "verb_present","r"); gotoline(rFile,v1); fgetc(rFile); t = fgetc(rFile); fclose(rFile); }else { adverbs = getMiddleAdverbs(adv); } char* buf = (char*)calloc(BUFFER_SIZE,sizeof(char)); if (t=='2'){ strcat(buf,getVerbPreAdd(v2)); strcat(buf,"ing "); }else if (t=='3'){ strcat(buf,getVerbPresent(v2,-1,0,1,adverbs)); }else if (t=='1'){ strcat(buf,"to "); strcat(buf,getVerbPresent(v2,-1,0,1,adverbs)); } return buf; }
char en_en::getNounType(int s){ FILE* rFile = fopen(DICTIONARY EN_EN_FOLDER "nouns","r"); gotoline(rFile,s); char t=fgetc(rFile); fclose(rFile); return t; }
/* ARGSUSED */ int compile(int f, int n) { char cprompt[NFILEN], *bufp; struct buffer *bp; struct mgwin *wp; (void)strlcpy(cprompt, compile_last_command, sizeof(cprompt)); if ((bufp = eread("Compile command: ", cprompt, NFILEN, EFDEF | EFNEW | EFCR)) == NULL) return (ABORT); else if (bufp[0] == '\0') return (FALSE); if (savebuffers(f, n) == ABORT) return (ABORT); (void)strlcpy(compile_last_command, bufp, sizeof(compile_last_command)); if ((bp = compile_mode("*compile*", cprompt)) == NULL) return (FALSE); if ((wp = popbuf(bp, WNONE)) == NULL) return (FALSE); curbp = bp; compile_win = curwp = wp; gotoline(FFARG, 0); return (TRUE); }
char* de::getVerbSimple(int v,int f,int s,int st){ if (f<0){ char t=getNounType(s); f=getVerbFormFromSubjectType(s,t); } FILE* rFile=fopen(DICTIONARY DE_FOLDER "verb_simple","r"); gotoline(rFile,v); char* buffer = (char*)malloc(BUFFER_SIZE); fgets(buffer,BUFFER_SIZE-1,rFile); fclose(rFile); char vt=buffer[0]; if (vt == '1') return getVerbPerfekt(v,f,s,st); int i=0; int u=0; while (u<1){ if (buffer[i]=='_') u++; i++; } int a = i; while (u<2){ if (buffer[i]=='\n'){ //Need to conjugate here if (f==2){ buffer[i++]='s'; buffer[i++]='t';} else if (f==6 || f==8 || f==9){ if (buffer[i-1]!='e') buffer[i++]='e'; buffer[i++]='n';} else if (f==7) buffer[i++]='t'; buffer[i]=' '; buffer[i+1]=0; u++; } i++; } return &buffer[a]; }
char* en_en::getVerbPreAdd(int v){ FILE* rFile=fopen(DICTIONARY EN_EN_FOLDER "verb_present","r"); gotoline(rFile,v); char* buffer=(char*)malloc(BUFFER_SIZE); fgets(buffer,BUFFER_SIZE-1,rFile); fclose(rFile); char t=buffer[0]; if (t=='1'){ //Look up second word form int u=0,i=0; while (u<2){ if (buffer[i]=='_') u++; else if (buffer[i]==0) break; else if (buffer[i]=='\n') break; i++; } u=0; while (buffer[i]!='_' && buffer[i]!=0 && buffer[i]!='\n') buffer[u++]=buffer[i++]; buffer[u++]=0; }else if (t=='0'){ char* b=getVerb(v,10,0,1,&blank); int i=0; while (b[i]!=0) i++; //[(space)] [\0] //We are removing the space here, because it is added in getVerb because the function thinks we will just add it straight to the sentence. b[i-1]=0; return b; }else{ int i=0; while(buffer[i]!='_' && buffer[i]!=0 && buffer[i]!='\n') i++; i++; int u=0; while (buffer[i]!='_' && buffer[i]!=0 && buffer[i]!='\n') buffer[u++]=buffer[i++]; //Now follow all the english rules //http://www.oxforddictionaries.com/words/verb-tenses-adding-ed-and-ing //http://www.grammar.cl/Notes/Spelling_ING.htm if (buffer[u-1]=='e' && buffer[u-2]=='i'){ u-=2; buffer[u++]='y'; } else if (buffer[u-1]=='e' && (buffer[u-2]!='e' && buffer[u-2]!='y' && buffer[u-2]!='o')) u-=1; else if (buffer[u-1]=='c'){ buffer[u++]='k'; } else if (!isVowel(buffer[u-3])&&isVowel(buffer[u-2])&&!isVowel(buffer[u-1])&&buffer[u-1]!='x'&&buffer[u-1]!='y'&&buffer[u-1]!='z'&&buffer[u-1]!='w'){ buffer[u]=buffer[u-1]; u++; } buffer[u++]=0; } return buffer; }
/* * Read the file "fname" into the current buffer. Make all of the text * in the buffer go away, after checking for unsaved changes. This is * called by the "read" command, the "visit" command, and the mainline * (for "mg file"). */ int readin(char *fname) { struct mgwin *wp; int status, i, ro = FALSE; PF *ael; /* might be old */ if (bclear(curbp) != TRUE) return (TRUE); /* Clear readonly. May be set by autoexec path */ curbp->b_flag &= ~BFREADONLY; if ((status = insertfile(fname, fname, TRUE)) != TRUE) { ewprintf("File is not readable: %s", fname); return (FALSE); } for (wp = wheadp; wp != NULL; wp = wp->w_wndp) { if (wp->w_bufp == curbp) { if ((fisdir(fname)) != TRUE) { wp->w_dotp = wp->w_linep = bfirstlp(curbp); wp->w_doto = 0; wp->w_markp = NULL; wp->w_marko = 0; } } } /* * Call auto-executing function if we need to. */ if ((ael = find_autoexec(fname)) != NULL) { for (i = 0; ael[i] != NULL; i++) (*ael[i])(0, 1); free(ael); } /* no change */ curbp->b_flag &= ~BFCHG; /* * We need to set the READONLY flag after we insert the file, * unless the file is a directory. */ if (access(fname, W_OK) && errno != ENOENT) ro = TRUE; if (fisdir(fname) == TRUE) ro = TRUE; if (ro == TRUE) curbp->b_flag |= BFREADONLY; if (startrow) { gotoline(FFARG, startrow); startrow = 0; } undo_add_modified(); return (status); }
char* de::getVerbPresent(int v, int f, int s, int st){ if (f<0){ char t=getNounType(s); f=getVerbFormFromSubjectType(s,t); } FILE* rFile=fopen(DICTIONARY DE_FOLDER "verb_present","r"); gotoline(rFile,v); char* buffer = (char*)malloc(BUFFER_SIZE); fgets(buffer,BUFFER_SIZE-1,rFile); fclose(rFile); char vt=buffer[0]; char of=f; if (vt!='0') f=0; int u=0; int i=0; if (vt=='2' && f!=-2) f++; while (u<=f){ char c=buffer[i]; if (c=='_') u++; else if (c=='\n'){ printf("Warning:\nThe form %d doesn't exist for verb %d!\nUsing form 0\n",f,v); return getVerbPresent(v,0,s,0); } i++; } //i should be at the start of form we want //copy form to start of buffer u=0; while (buffer[i]!='_' && buffer[i]!='\n' && buffer[i]!=0){ buffer[u++]=buffer[i++]; } int es=u+1; if(vt=='2'){ while (buffer[i]!='_' && buffer[i]!='\n' && buffer[i]!=0){ i++; } buffer[i]=0; endVerb=&buffer[es]; hasEndVerb=true; } if(vt!='0'){ u--; if (buffer[u]=='n') buffer[u--]=' '; if (buffer[u]!='e') u++; if (of==1) buffer[u++]='e'; else if (of==2){ buffer[u++]='s'; buffer[u++]='t';} else if (of==3 || of==4 || of==5) buffer[u++]='t'; else if (of==6 || of==8 || of==9 || of==0){ buffer[u++]='e'; buffer[u++]='n';} else if (of==7) buffer[u++]='t'; } buffer[u++]=' '; buffer[u++]=0; char* ret=(char*)calloc(BUFFER_SIZE,sizeof(char)); strcat(ret,buffer); return ret; }
char de::getVerbType(int v,int st){ FILE* rFile = NULL; if (st<2){ rFile = fopen(DICTIONARY DE_FOLDER "verb_present","r"); } gotoline(rFile,v); char t=fgetc(rFile); fclose(rFile); return t; }
char de::getPreVerb2(int v1){ FILE* rFile; rFile=fopen(DICTIONARY DE_FOLDER "verb_present","r"); gotoline(rFile,v1); fgetc(rFile); fgetc(rFile); char t = fgetc(rFile); t-='0'; fclose(rFile); return t; }
char* en_en::getConjunction(int conjunction){ FILE* rFile=fopen(DICTIONARY EN_EN_FOLDER "conjunctions","r"); gotoline(rFile,conjunction); char* buf = (char*)calloc(BUFFER_SIZE,sizeof(char)); fgets(buf,BUFFER_SIZE-1,rFile); fclose(rFile); for (int i=0;i<BUFFER_SIZE;i++) { if (buf[i]=='\n') buf[i]=0; } return buf; }
char de::getCaseOfObject(int v,int st){ FILE* rFile = NULL; if (st<10){ rFile=fopen(DICTIONARY DE_FOLDER "verb_present","r"); } gotoline(rFile,verbs[v]); fgetc(rFile); char t=fgetc(rFile); t-='0'; fclose(rFile); if (t==4) t = getCaseOfObject(v+1,st); return t; }
//used when en_en_hasform returns -4 to get the "another noun" int en_en::getNewNoun(int s) { FILE* rFile = fopen(DICTIONARY EN_EN_FOLDER "nouns","r"); gotoline(rFile,s); char t=fgetc(rFile); if (t=='n' || t=='o' || t=='b') return 5; if (t=='m') return 3; if (t=='f') return 4; if (t=='p') return 10; return 1; }
noun* de::getIt(int id){ FILE * rFile = fopen(DICTIONARY DE_FOLDER "nouns" , "r"); gotoline(rFile,id); char st = fgetc(rFile); fclose(rFile); noun * n = new noun; clearNoun(n); n->id=getVerbFormFromSubjectType(id,st); n->num=0; n->plural=false; n->reflex=false; n->useRClause=false; n->usegenitive=false; n->typ=0; return n; }
static void near zuzeile (void) //************************************************************************* // //************************************************************************* { char linstr[12]; int l; linstr[0] = 0; if (inputwin("Goto", "Line:", linstr, 10) != ESC) l = atoi(linstr); if (l > 0) gotoline(l-1, 0); else msgline("Invalid line number"); }
/* * Prompt for which line number we want to go to, then execute gotoline() * with that number as its argument. * * Make sure the bounds are within the file. * * Bound to M-G */ int setline(int f, int n) { char setl[6]; int l; (void)mlreplyt("Go to line: ", setl, 6, 10); l = atoi(setl); /* XXX: This sucks! */ if (l < 1) l = 1; else if (l > curwp->w_bufp->b_lines) l = curwp->w_bufp->b_lines; gotoline(f, l); return (TRUE); }
/** returns number of _ you must reach +1 to get to a specific form of noun returns -2 to add a single 's' character to make the noun a plural returns -1 if the form is not available in this noun (should never be returned unless you do something wrong) returns -4 if the form should be found in another noun **/ int en_en::hasform(int s,int form){ FILE* rFile = fopen (DICTIONARY EN_EN_FOLDER "nouns","r"); if(rFile==NULL) printf("Failed to open file:%s\n",DICTIONARY EN_EN_FOLDER "nouns"); gotoline(rFile,s); char t=fgetc(rFile); fclose(rFile); if (t=='d' && form<4) return form; else if ((t=='m' || t=='f' || t=='n' || t=='b') && form<3) return 0; else if ((t=='m' || t=='f' || t=='n' || t=='b') && form== 4) return -2; else if (t=='o' && form==4) return 1; else if (t=='o' && form<3) return 0; else if (t=='p' && form==4) return 1; else if (t=='p' && form<4) return 0; else if (form==3) return -4; return -1; }
static void near contsearch (void) //************************************************************************* // // Sucht nach 'searchstr' und baut den Bildschirm an der gefundenen // Position neu auf // //************************************************************************* { int count = 0; int slines = e->curline; unsigned sindex = e->readindex; int found = 0; int size = strlen(searchstr); unsigned i = linelength(e->readindex); if (e->curcol > i) i += e->readindex - 1; else i = e->readindex + e->curcol + 1; while (i < e->maxbuf) { while (((buf[i+count] ^ searchstr[count]) & 0x5f) == 0) count++; if (count == size) { found++; break; } count = 0; if (buf[i++] == LF) { slines++; sindex = i; } } if (found) { e->curcol = i-sindex; gotoline(slines, 0); testxoffset(); } else msgline("Pattern not found"); }
char* en_en::getNoun(int s,int form){ int nform = hasform(s,form); //printf("hasform returned %d\n",nform); if (nform>=0) form=nform; else if (nform==-4) return getNoun(getNewNoun(s),form); else if (nform==-2) form=0; else if (nform==-1) { printf("Oh noes! Can't get form for %d,form=%d,nform=-1;\n",s,form); printf("Assmuming you meant form=0\n"); form=0; } FILE* rFile = fopen(DICTIONARY EN_EN_FOLDER "nouns","r"); gotoline(rFile,s); char* buffer = (char*)malloc(BUFFER_SIZE); fgets(buffer,BUFFER_SIZE-1,rFile); form+=1; int u=0,i=0; while (form>u){ if (buffer[i]==0) break; if (buffer[i++]=='_') { u++; } } u=0; while (buffer[i]!='_' && buffer[i]!=0 && buffer[i]!='\n'){ buffer[u++]=buffer[i++];} if (nform==-2) buffer[u++]='s'; buffer[u++]=' '; buffer[u]=0; // puts(buffer); fclose(rFile); return buffer; }
char* de::getVerbPerfekt(int v,int f,int s,int st){ #ifdef DE_AUTOCHANGESIMPLE if (v < 2) return getVerbSimple(v,f,s,st); #endif FILE* rFile=fopen(DICTIONARY DE_FOLDER "verb_pastperfekt","r"); gotoline(rFile,v); char* buffer = (char*)malloc(BUFFER_SIZE); fgets(buffer,BUFFER_SIZE-1,rFile); fclose(rFile); char vt=buffer[0]; //what we do here, is , we save the past participle for later, and return the helper verb, when we need to get the past participle the create sentence() just reads the endVerb variable int i=0; int u=0; while (u<1){ if (buffer[i]=='_') u++; i++; } endVerb=&buffer[i]; hasEndVerb=true; while (u<2){ if (buffer[i]=='\n'){ buffer[i]=' '; buffer[i+1]=0; u++; } i++; } //haben if (vt=='0'){ return getVerbPresent(2,f,s,0); }else if (vt=='1'){ //sein return getVerbPresent(1,f,s,0); } }
int forwsearch(int f, int n) { int status; int wrapt = FALSE, wrapt2 = FALSE; int repl_mode = FALSE; UCS defpat[NPAT]; int search = FALSE; EML eml; /* resolve the repeat count */ if (n == 0) n = 1; if (n < 1) /* search backwards */ FWS_RETURN(0); defpat[0] = '\0'; /* ask the user for the text of a pattern */ while(1){ if (gmode & MDREPLACE) status = srpat("Search", defpat, NPAT, repl_mode); else status = readpattern("Search", TRUE); switch(status){ case TRUE: /* user typed something */ search = TRUE; break; case HELPCH: /* help requested */ if(Pmaster){ VARS_TO_SAVE *saved_state; saved_state = save_pico_state(); (*Pmaster->helper)(Pmaster->search_help, _("Help for Searching"), 1); if(saved_state){ restore_pico_state(saved_state); free_pico_state(saved_state); } } else pico_help(SearchHelpText, _("Help for Searching"), 1); case (CTRL|'L'): /* redraw requested */ pico_refresh(FALSE, 1); update(); break; case (CTRL|'V'): gotoeob(0, 1); mlerase(); FWS_RETURN(TRUE); case (CTRL|'Y'): gotobob(0, 1); mlerase(); FWS_RETURN(TRUE); case (CTRL|'T') : switch(status = readnumpat(_("Search to Line Number : "))){ case -1 : emlwrite(_("Search to Line Number Cancelled"), NULL); FWS_RETURN(FALSE); case 0 : emlwrite(_("Line number must be greater than zero"), NULL); FWS_RETURN(FALSE); case -2 : emlwrite(_("Line number must contain only digits"), NULL); FWS_RETURN(FALSE); case -3 : continue; default : gotoline(0, status); mlerase(); FWS_RETURN(TRUE); } break; case (CTRL|'W'): { LINE *linep = curwp->w_dotp; int offset = curwp->w_doto; gotobop(0, 1); gotobol(0, 1); /* * if we're asked to backup and we're already * */ if((lastflag & CFSRCH) && linep == curwp->w_dotp && offset == curwp->w_doto && !(offset == 0 && lback(linep) == curbp->b_linep)){ backchar(0, 1); gotobop(0, 1); gotobol(0, 1); } } mlerase(); FWS_RETURN(TRUE); case (CTRL|'O'): if(curwp->w_dotp != curbp->b_linep){ gotoeop(0, 1); forwchar(0, 1); } mlerase(); FWS_RETURN(TRUE); case (CTRL|'U'): fillbuf(0, 1); mlerase(); FWS_RETURN(TRUE); case (CTRL|'R'): /* toggle replacement option */ repl_mode = !repl_mode; break; default: if(status == ABORT) emlwrite(_("Search Cancelled"), NULL); else mlerase(); FWS_RETURN(FALSE); } /* replace option is disabled */ if (!(gmode & MDREPLACE)){ ucs4_strncpy(defpat, pat, NPAT); defpat[NPAT-1] = '\0'; break; } else if (search){ /* search now */ ucs4_strncpy(pat, defpat, NPAT); /* remember this search for the future */ pat[NPAT-1] = '\0'; break; } } /* * This code is kind of dumb. What I want is successive C-W 's to * move dot to successive occurences of the pattern. So, if dot is * already sitting at the beginning of the pattern, then we'll move * forward a char before beginning the search. We'll let the * automatic wrapping handle putting the dot back in the right * place... */ status = 0; /* using "status" as int temporarily! */ while(1){ if(defpat[status] == '\0'){ forwchar(0, 1); break; /* find next occurence! */ } if(status + curwp->w_doto >= llength(curwp->w_dotp) || !eq(defpat[status],lgetc(curwp->w_dotp, curwp->w_doto + status).c)) break; /* do nothing! */ status++; } /* search for the pattern */ while (n-- > 0) { if((status = forscan(&wrapt,defpat,NULL,0,PTBEG)) == FALSE) break; } /* and complain if not there */ if (status == FALSE){ char *utf8; UCS x[1]; x[0] = '\0'; utf8 = ucs4_to_utf8_cpystr(defpat ? defpat : x); /* TRANSLATORS: reporting the result of a failed search */ eml.s = utf8; emlwrite(_("\"%s\" not found"), &eml); if(utf8) fs_give((void **) &utf8); } else if((gmode & MDREPLACE) && repl_mode == TRUE){ status = replace_pat(defpat, &wrapt2); /* replace pattern */ if (wrapt == TRUE || wrapt2 == TRUE){ eml.s = (status == ABORT) ? "cancelled but wrapped" : "Wrapped"; emlwrite("Replacement %s", &eml); } } else if(wrapt == TRUE){ emlwrite("Search Wrapped", NULL); } else if(status == TRUE){ emlwrite("", NULL); } FWS_RETURN(status); }
int main( int argc, char *argv[] ) { /* (x,y) position of edit window. x column, y line -> (0,0) at upper left on screen */ unsigned int xCursorPos = 0; unsigned int yCursorPos = 0; unsigned int curmenu = 0x1100; int i; cwsetup( argc, argv ); writestatus( 0 ); writetab( ); splashscreen( ); /* Main program loop */ do { dispstrhgc( " ", wind.col, 2, NORMALATTR ); i = pulled_down_menu( &curmenu, &xCursorPos, &yCursorPos ); if ( filename[0] != '\0' ) { switch ( i ) { case RETKEY: keymain = menu_to_key( curmenu ); break; case ESCKEY: waitkbd( wind.col + xCursorPos, wind.row + yCursorPos ); /* Show blinking cursor */ keymain = readkbd( ); /* If keypressed Get it */ break; default: keymain = i; break; } while ( keymain != ESCKEY ) { if ( ( keymain & 0xff ) >= 32 ) { keymain = changekey( keymain ); if ( insertmode ) { if ( !insert_char( keymain, &xCursorPos, &yCursorPos ) ) { linetoolong( ); } } else { if ( !ovrwrite_char( keymain, &xCursorPos, &yCursorPos ) ) { linetoolong( ); } } refreshline( xCursorPos, yCursorPos ); } else { /* Function Key */ switch ( keymain ) { case PGUPKEY: case CNTRL_R: page_up( ); break; case PGDNKEY: case CNTRL_C: page_down( ); break; case UPKEY: case CNTRL_E: cursor_up( ); break; case DNKEY: case CNTRL_X: cursor_down( yCursorPos ); break; case LEKEY: case CNTRL_S: cursor_left( &xCursorPos ); break; case 0x2301: gobeginblk( &xCursorPos ); break; case 0x2401: goendblk( &xCursorPos ); break; case RIKEY: case CNTRL_D: cursor_right( &xCursorPos, yCursorPos ); break; case CNTRL_W: scroll_up( ); break; case CNTRL_Z: scroll_down( ); break; case CHOMEKEY: top_of_page( ); break; case CPGUPKEY: topfile( &xCursorPos ); break; case CENDKEY: bottom_of_page( ); break; case CPGDNKEY: endfile( &xCursorPos ); break; case DELKEY: case CNTRL_G: delete_char( xCursorPos ); refreshline( xCursorPos, yCursorPos ); changeflag = YES; break; case CNTRL_T: delete_word( xCursorPos ); refreshline( xCursorPos, yCursorPos ); changeflag = YES; break; case CNTRL_Y: delete_line( ); changeflag = YES; break; case CNTRL_M: case RETKEY: if ( insertmode == NO ) { returnkey( &xCursorPos, yCursorPos ); } else { ret_with_ins( &xCursorPos, yCursorPos ); changeflag = YES; } break; case BSKEY: case CNTRL_H: backspace( &xCursorPos ); yCursorPos = findrow( ); refreshline( 0, yCursorPos ); changeflag = YES; break; case INSKEY: case CNTRL_V: insertmode = !insertmode; writeinsmode( ); break; case CNTRL_N: insert_ret( &xCursorPos ); break; case F10KEY: thaimode = !thaimode; writelanguage( ); break; case F1KEY: fontused = 0x00; writeattr( ); break; case F2KEY: fontused = fontused | ITALICATTR; writeattr( ); break; case F3KEY: fontused = fontused | ONELINEATTR; fontused = fontused & 0x7f; writeattr( ); break; case F4KEY: fontused = fontused | TWOLINEATTR; fontused = fontused & 0xfe; writeattr( ); break; case F5KEY: fontused = fontused | BOLDATTR; writeattr( ); break; case F6KEY: fontused = fontused | ENLARGEATTR; writeattr( ); break; case F7KEY: fontused = fontused | SUPERATTR; if ( ( fontused & SUBATTR ) == SUBATTR ) { fontused = fontused ^ SUBATTR; } writeattr( ); break; case F8KEY: fontused = fontused | SUBATTR; if ( ( fontused & SUPERATTR ) == SUPERATTR ) { fontused = fontused ^ SUPERATTR; } writeattr( ); break; case F9KEY: manualwrap( &xCursorPos, &yCursorPos ); break; case ALTM: editmacro( ); break; case TABKEY: case CNTRL_I: movetotab( &xCursorPos, yCursorPos ); break; case CNTRL_K: blockcommand( &xCursorPos ); break; case 0x1401: blkcmd( 'p', &xCursorPos ); break; case 0x6101: blkcmd( 'b', &xCursorPos ); break; case 0x6201: blkcmd( 'k', &xCursorPos ); break; case 0x6301: blkcmd( 'c', &xCursorPos ); break; case 0x6401: blkcmd( 'y', &xCursorPos ); break; case 0x6501: blkcmd( 'v', &xCursorPos ); break; case 0x6601: blkcmd( 'r', &xCursorPos ); break; case 0x6701: blkcmd( 'w', &xCursorPos ); break; case 0x6801: blkcmd( 'h', &xCursorPos ); break; case CNTRL_O: onscreen( xCursorPos, yCursorPos ); break; case 0x7101: doonscrn( 'l', xCursorPos, yCursorPos ); break; case 0x7201: doonscrn( 'r', xCursorPos, yCursorPos ); break; case 0x7301: doonscrn( 'i', xCursorPos, yCursorPos ); break; case 0x7401: doonscrn( 'n', xCursorPos, yCursorPos ); break; case 0x7501: doonscrn( 'c', xCursorPos, yCursorPos ); break; case 0x7601: doonscrn( 'p', xCursorPos, yCursorPos ); break; case 0x7701: doonscrn( 'x', xCursorPos, yCursorPos ); break; case CNTRL_Q: quick( &xCursorPos, &yCursorPos ); break; case 0x3501: deltoendline( xCursorPos, yCursorPos ); break; case 0x8111: inscntrl( CNTRL_W, xCursorPos, yCursorPos ); break; case 0x8211: inscntrl( CNTRL_S, xCursorPos, yCursorPos ); break; case 0x8311: inscntrl( CNTRL_R, xCursorPos, yCursorPos ); break; case 0x8411: inscntrl( CNTRL_B, xCursorPos, yCursorPos ); break; case 0x8511: inscntrl( CNTRL_E, xCursorPos, yCursorPos ); break; case 0x8611: inscntrl( CNTRL_T, xCursorPos, yCursorPos ); break; case 0x8711: inscntrl( CNTRL_V, xCursorPos, yCursorPos ); break; case CNTRL_P: printcntrl( xCursorPos, yCursorPos ); break; case HOMEKEY: home( &xCursorPos ); break; case ENDKEY: endline( &xCursorPos ); break; case CLEKEY: case CNTRL_A: backword( &xCursorPos ); break; case CRIKEY: case CNTRL_F: nextword( &xCursorPos, yCursorPos ); break; case CNTRL_L: if ( source[0] != '\0' ) { if ( replaceflag == NO ) { if ( searchfwd( &xCursorPos, &yCursorPos ) == NO ) { wordnotfound( ); } } else { if ( searchreplace( &xCursorPos, &yCursorPos ) == NO ) { wordnotfound( ); } } } break; case CNTRL_B: reform( ); break; case ALTP: gotopage( ); break; case CNTRL_J: case ALTL: gotoline( ); break; case 0x5101: searching( &xCursorPos, &yCursorPos ); break; case 0x5201: replacing( &xCursorPos, &yCursorPos ); break; case 0x8501: loadtoline( curline->text ); refreshline( 0, yCursorPos ); break; case CF1KEY: insertmacro( ¯o[0][0], &xCursorPos, &yCursorPos ); break; case CF2KEY: insertmacro( ¯o[1][0], &xCursorPos, &yCursorPos ); break; case CF3KEY: insertmacro( ¯o[2][0], &xCursorPos, &yCursorPos ); break; case CF4KEY: insertmacro( ¯o[3][0], &xCursorPos, &yCursorPos ); break; case CF5KEY: insertmacro( ¯o[4][0], &xCursorPos, &yCursorPos ); break; case CF6KEY: insertmacro( ¯o[5][0], &xCursorPos, &yCursorPos ); break; case CF7KEY: insertmacro( ¯o[6][0], &xCursorPos, &yCursorPos ); break; case CF8KEY: insertmacro( ¯o[7][0], &xCursorPos, &yCursorPos ); break; case CF9KEY: insertmacro( ¯o[8][0], &xCursorPos, &yCursorPos ); break; case CF10KEY: insertmacro( ¯o[9][0], &xCursorPos, &yCursorPos ); break; case AF2KEY: inscntrl( ITALICCODE, xCursorPos, yCursorPos ); break; case AF3KEY: inscntrl( ONELINECODE, xCursorPos, yCursorPos ); break; case AF4KEY: inscntrl( TWOLINECODE, xCursorPos, yCursorPos ); break; case AF5KEY: inscntrl( BOLDCODE, xCursorPos, yCursorPos ); break; case AF6KEY: inscntrl( ENLARGECODE, xCursorPos, yCursorPos ); break; case AF7KEY: inscntrl( SUPERCODE, xCursorPos, yCursorPos ); break; case AF8KEY: inscntrl( SUBCODE, xCursorPos, yCursorPos ); break; #ifdef WANT_TO_USE_GRAPH case ALTG: insertgraph( ); break; case ALTD: deletegraph( ); break; #endif case ALTX: quitprog = YES; keymain = ESCKEY; break; default: if ( ( alt_char_map( keymain ) ) != -1 ) { keymain = alt_char_map( keymain ); if ( insertmode ) { if ( !insert_char( keymain, &xCursorPos, &yCursorPos ) ) { linetoolong( ); } } else { if ( !ovrwrite_char( keymain, &xCursorPos, &yCursorPos ) ) { linetoolong( ); } } refreshline( xCursorPos, yCursorPos ); } break; } /* switch ( keymain ) */ } adjustcol( &xCursorPos ); while ( ( yCursorPos = findrow( ) ) > ( wind.width - 1 ) ) { storeline( curline ); curline = curline->previous; loadtoline( curline->text ); lineno--; } if ( !keypressed( ) ) { if ( !pagecomplete ) { showpage( ); } if ( !keypressed( ) ) { writecolno( firstcol + xCursorPos ); dispstrhgc( " ", wind.col, 2, NORMALATTR ); if ( !keypressed( ) ) { writepageline( ); } } } if ( quitprog != YES ) { waitkbd( wind.col + xCursorPos, wind.row + yCursorPos ); keymain = readkbd( ); dispkey( keymain ); } } /* while */ } else { /* if filename[0] != '\0' */ errorsound( ); } } while ( !quitprog ); if ( changeflag ) { blockmsg( 5 ); dispstrhgc( "ÂѧäÁèä´é¨Ñ´à¡çºá¿éÁ¢éÍÁÙÅ µéͧ¡ÒèѴà¡çºËÃ×ÍäÁè (Y/N)?", ( 16 + center_factor ) + 7, 5, REVERSEATTR ); keymain = 0; while ( ( keymain != 'n' ) && ( keymain != 'N' ) && ( keymain != 'y' ) && ( keymain != 'Y' ) ) { keymain = ebioskey( 0 ) & 0xff; if ( ( keymain == 'y' ) || ( keymain == 'Y' ) ) { writeblk( filename, sentinel->next, 0, sentinel->previous, MAXCOL ); } } } settext( ); return 0; }
/* * Read the file "fname" into the current buffer. Make all of the text * in the buffer go away, after checking for unsaved changes. This is * called by the "read" command, the "visit" command, and the mainline * (for "mg file"). */ int readin(char *fname) { struct mgwin *wp; struct stat statbuf; int status, ro = FALSE; char dp[NFILEN]; /* might be old */ if (bclear(curbp) != TRUE) return (TRUE); /* Clear readonly. May be set by autoexec path */ curbp->b_flag &= ~BFREADONLY; if ((status = insertfile(fname, fname, TRUE)) != TRUE) { dobeep(); ewprintf("File is not readable: %s", fname); return (FALSE); } for (wp = wheadp; wp != NULL; wp = wp->w_wndp) { if (wp->w_bufp == curbp) { wp->w_dotp = wp->w_linep = bfirstlp(curbp); wp->w_doto = 0; wp->w_markp = NULL; wp->w_marko = 0; } } /* no change */ curbp->b_flag &= ~BFCHG; /* * Set the buffer READONLY flag if any of following are true: * 1. file is a directory. * 2. file is read-only. * 3. file doesn't exist and directory is read-only. */ if (fisdir(fname) == TRUE) { ro = TRUE; } else if ((access(fname, W_OK) == -1)) { if (errno != ENOENT) { ro = TRUE; } else if (errno == ENOENT) { (void)xdirname(dp, fname, sizeof(dp)); (void)strlcat(dp, "/", sizeof(dp)); /* Missing directory; keep buffer rw, like emacs */ if (stat(dp, &statbuf) == -1 && errno == ENOENT) { if (eyorn("Missing directory, create") == TRUE) (void)do_makedir(dp); } else if (access(dp, W_OK) == -1 && errno == EACCES) { ewprintf("File not found and directory" " write-protected"); ro = TRUE; } } } if (ro == TRUE) curbp->b_flag |= BFREADONLY; if (startrow) { gotoline(FFARG, startrow); startrow = 0; } undo_add_modified(); return (status); }
int main(int argc, char **argv) { int c = -1; /* command character */ int f; /* default flag */ int n; /* numeric repeat count */ int mflag; /* negative flag on repeat */ struct buffer *bp; /* temp buffer pointer */ int firstfile; /* first file flag */ int carg; /* current arg to scan */ int startflag; /* startup executed flag */ struct buffer *firstbp = NULL; /* ptr to first buffer in cmd line */ int basec; /* c stripped of meta character */ int viewflag; /* are we starting in view mode? */ int gotoflag; /* do we need to goto a line at start? */ int gline = 0; /* if so, what line? */ int searchflag; /* Do we need to search at start? */ int saveflag; /* temp store for lastflag */ int errflag; /* C error processing? */ char bname[NBUFN]; /* buffer name of file to read */ #if CRYPT int cryptflag; /* encrypting on the way in? */ char ekey[NPAT]; /* startup encryption key */ #endif int newc; #if PKCODE & VMS (void) umask(-1); /* Use old protection (this is at wrong place). */ #endif #if PKCODE & BSD sleep(1); /* Time for window manager. */ #endif #if UNIX #ifdef SIGWINCH signal(SIGWINCH, sizesignal); #endif #endif if (argc == 2) { if (strcmp(argv[1], "--help") == 0) { usage(EXIT_FAILURE); } if (strcmp(argv[1], "--version") == 0) { version(); exit(EXIT_SUCCESS); } } /* Initialize the editor. */ vtinit(); /* Display */ edinit("main"); /* Buffers, windows */ varinit(); /* user variables */ viewflag = FALSE; /* view mode defaults off in command line */ gotoflag = FALSE; /* set to off to begin with */ searchflag = FALSE; /* set to off to begin with */ firstfile = TRUE; /* no file to edit yet */ startflag = FALSE; /* startup file not executed yet */ errflag = FALSE; /* not doing C error parsing */ #if CRYPT cryptflag = FALSE; /* no encryption by default */ #endif /* Parse the command line */ for (carg = 1; carg < argc; ++carg) { /* Process Switches */ #if PKCODE if (argv[carg][0] == '+') { gotoflag = TRUE; gline = atoi(&argv[carg][1]); } else #endif if (argv[carg][0] == '-') { switch (argv[carg][1]) { /* Process Startup macroes */ case 'a': /* process error file */ case 'A': errflag = TRUE; break; case 'e': /* -e for Edit file */ case 'E': viewflag = FALSE; break; case 'g': /* -g for initial goto */ case 'G': gotoflag = TRUE; gline = atoi(&argv[carg][2]); break; #if CRYPT case 'k': /* -k<key> for code key */ case 'K': cryptflag = TRUE; strcpy(ekey, &argv[carg][2]); break; #endif #if PKCODE case 'n': /* -n accept null chars */ case 'N': nullflag = TRUE; break; #endif case 'r': /* -r restrictive use */ case 'R': restflag = TRUE; break; case 's': /* -s for initial search string */ case 'S': searchflag = TRUE; strncpy(pat, &argv[carg][2], NPAT); break; case 'v': /* -v for View File */ case 'V': viewflag = TRUE; break; default: /* unknown switch */ /* ignore this for now */ break; } } else if (argv[carg][0] == '@') { /* Process Startup macroes */ if (startup(&argv[carg][1]) == TRUE) /* don't execute emacs.rc */ startflag = TRUE; } else { /* Process an input file */ /* set up a buffer for this file */ makename(bname, argv[carg]); unqname(bname); /* set this to inactive */ bp = bfind(bname, TRUE, 0); strcpy(bp->b_fname, argv[carg]); bp->b_active = FALSE; if (firstfile) { firstbp = bp; firstfile = FALSE; } /* set the modes appropriatly */ if (viewflag) bp->b_mode |= MDVIEW; #if CRYPT if (cryptflag) { bp->b_mode |= MDCRYPT; myencrypt((char *) NULL, 0); myencrypt(ekey, strlen(ekey)); strncpy(bp->b_key, ekey, NPAT); } #endif } } #if UNIX signal(SIGHUP, emergencyexit); signal(SIGTERM, emergencyexit); #endif /* if we are C error parsing... run it! */ if (errflag) { if (startup("error.cmd") == TRUE) startflag = TRUE; } /* if invoked with no other startup files, run the system startup file here */ if (startflag == FALSE) { startup(""); startflag = TRUE; } discmd = TRUE; /* P.K. */ /* if there are any files to read, read the first one! */ bp = bfind("main", FALSE, 0); if (firstfile == FALSE && (gflags & GFREAD)) { swbuffer(firstbp); zotbuf(bp); } else bp->b_mode |= gmode; /* Deal with startup gotos and searches */ if (gotoflag && searchflag) { update(FALSE); mlwrite("(Can not search and goto at the same time!)"); } else if (gotoflag) { if (gotoline(TRUE, gline) == FALSE) { update(FALSE); mlwrite("(Bogus goto argument)"); } } else if (searchflag) { if (forwhunt(FALSE, 0) == FALSE) update(FALSE); } /* Setup to process commands. */ lastflag = 0; /* Fake last flags. */ loop: /* Execute the "command" macro...normally null. */ saveflag = lastflag; /* Preserve lastflag through this. */ execute(META | SPEC | 'C', FALSE, 1); lastflag = saveflag; #if TYPEAH && PKCODE if (typahead()) { newc = getcmd(); update(FALSE); do { fn_t execfunc; if (c == newc && (execfunc = getbind(c)) != NULL && execfunc != insert_newline && execfunc != insert_tab) newc = getcmd(); else break; } while (typahead()); c = newc; } else { update(FALSE); c = getcmd(); } #else /* Fix up the screen */ update(FALSE); /* get the next command from the keyboard */ c = getcmd(); #endif /* if there is something on the command line, clear it */ if (mpresf != FALSE) { mlerase(); update(FALSE); #if CLRMSG if (c == ' ') /* ITS EMACS does this */ goto loop; #endif } f = FALSE; n = 1; /* do META-# processing if needed */ basec = c & ~META; /* strip meta char off if there */ if ((c & META) && ((basec >= '0' && basec <= '9') || basec == '-')) { f = TRUE; /* there is a # arg */ n = 0; /* start with a zero default */ mflag = 1; /* current minus flag */ c = basec; /* strip the META */ while ((c >= '0' && c <= '9') || (c == '-')) { if (c == '-') { /* already hit a minus or digit? */ if ((mflag == -1) || (n != 0)) break; mflag = -1; } else { n = n * 10 + (c - '0'); } if ((n == 0) && (mflag == -1)) /* lonely - */ mlwrite("Arg:"); else mlwrite("Arg: %d", n * mflag); c = getcmd(); /* get the next key */ } n = n * mflag; /* figure in the sign */ } /* do ^U repeat argument processing */ if (c == reptc) { /* ^U, start argument */ f = TRUE; n = 4; /* with argument of 4 */ mflag = 0; /* that can be discarded. */ mlwrite("Arg: 4"); while (((c = getcmd()) >= '0' && c <= '9') || c == reptc || c == '-') { if (c == reptc) if ((n > 0) == ((n * 4) > 0)) n = n * 4; else n = 1; /* * If dash, and start of argument string, set arg. * to -1. Otherwise, insert it. */ else if (c == '-') { if (mflag) break; n = 0; mflag = -1; } /* * If first digit entered, replace previous argument * with digit and set sign. Otherwise, append to arg. */ else { if (!mflag) { n = 0; mflag = 1; } n = 10 * n + c - '0'; } mlwrite("Arg: %d", (mflag >= 0) ? n : (n ? -n : -1)); } /* * Make arguments preceded by a minus sign negative and change * the special argument "^U -" to an effective "^U -1". */ if (mflag == -1) { if (n == 0) n++; n = -n; } } /* and execute the command */ execute(c, f, n); goto loop; }
/* ARGSUSED */ static int compile_goto_error(int f, int n) { struct buffer *bp; struct mgwin *wp; char *fname, *line, *lp, *ln; int lineno; char *adjf, path[NFILEN]; const char *errstr; struct line *last; compile_win = curwp; compile_buffer = curbp; last = blastlp(compile_buffer); retry: /* last line is compilation result */ if (curwp->w_dotp == last) return (FALSE); if ((line = linetostr(curwp->w_dotp)) == NULL) return (FALSE); lp = line; if ((fname = strsep(&lp, ":")) == NULL || *fname == '\0') goto fail; if ((ln = strsep(&lp, ":")) == NULL || *ln == '\0') goto fail; lineno = (int)strtonum(ln, INT_MIN, INT_MAX, &errstr); if (errstr) goto fail; if (fname && fname[0] != '/') { if (getbufcwd(path, sizeof(path)) == FALSE) goto fail; if (strlcat(path, fname, sizeof(path)) >= sizeof(path)) goto fail; adjf = path; } else { adjf = adjustname(fname, TRUE); } free(line); if (adjf == NULL) return (FALSE); if ((bp = findbuffer(adjf)) == NULL) return (FALSE); if ((wp = popbuf(bp, WNONE)) == NULL) return (FALSE); curbp = bp; curwp = wp; if (bp->b_fname[0] == '\0') readin(adjf); gotoline(FFARG, lineno); return (TRUE); fail: free(line); if (curwp->w_dotp != blastlp(curbp)) { curwp->w_dotp = lforw(curwp->w_dotp); curwp->w_rflag |= WFMOVE; goto retry; } dobeep(); ewprintf("No more hits"); return (FALSE); }
char* en_en::getVerbPresent(int v,int f,int s,int st,char* midadverb){ if (f==-1){ int t=getNounType(s); f=getVerbFormFromSubjectType(t,s); } if (st==1){ FILE* rFile = fopen(DICTIONARY EN_EN_FOLDER "verb_present","r"); gotoline(rFile,v); char* buffer = (char*)malloc(BUFFER_SIZE); fgets(buffer,BUFFER_SIZE-1,rFile); fclose(rFile); char vt=buffer[0]; char of=f; if (vt!='0') f=0; int u=0; int i=0; while (u<=f){ char c=buffer[i]; if (c=='_') u++; else if (c=='\n'){ printf("Warning:\nThe form %d doesn't exist for verb %d!\nUsing form 0\n",f,v); return getVerb(v,0,s,1,midadverb); } i++; } //i should be at the start of form we want //copy form to start of buffer u=0; while (buffer[i]!='_' && buffer[i]!='\n' && buffer[i]!=0){ buffer[u++]=buffer[i++]; } //Now if SIMPLE tense on a regular verb, add conjugation if (vt!='0' && vt!='3' ){ if (of>2 && of<6){ if (buffer[u-1]=='o' || (buffer[u-1]=='s' && buffer[u-2]=='s') || (buffer[u-1]=='h' && buffer[u-2]=='s') || (buffer[u-1]=='h' && buffer[u-2]=='c') || (buffer[u-1]=='z' && buffer[u-2]=='z') || buffer[u-1]=='x') buffer[u++]='e'; buffer[u++]='s'; } } buffer[u++]=' '; buffer[u++]=0; if (neg && (vt=='3' || vt=='0')){ strcat(buffer,negativestmt); } char* ret=(char*)calloc(BUFFER_SIZE,sizeof(char)); strcat(ret,midadverb); if (neg && vt!='3' && vt!='0'){ if (of>2 && of<6) strcat(ret,EN_EN_DOESNOT); else strcat(ret,donot); } strcat(ret,buffer); return ret; } else if (st==0){ char t=getVerbType(v,st); if (t=='4'||t=='3'){ // printf("Can not create progressive tense with type %c verbs!\nUsing simple tense instead.\n",t); return getVerb(v,f,s,1,midadverb); } int bl,il; bl=getVerbLength(1,f,s,1,&blank); char* preadd=getVerbPreAdd(v); il=strlen(preadd); char* gerund=NULL; char* buffer = NULL; if (question==0) { buffer = (char*)calloc(bl+il+5,sizeof(char)); gerund = buffer; } else if (question>0) { buffer = (char*) calloc(bl+1,sizeof(char)); QuestionVerb1 = (char*) calloc(il+5,sizeof(char)); gerund = QuestionVerb1; } strcat(buffer,getVerb(1,f,s,1,&blank)); strcat(buffer,midadverb); strcat(gerund,preadd); strcat(gerund,"ing "); return buffer; } }
/* * Set a variable. * * @var: variable to set. * @value: value to set to. */ int svar(struct variable_description *var, char *value) { int vnum; /* ordinal number of var refrenced */ int vtype; /* type of variable to set */ int status; /* status return */ int c; /* translated character */ char *sp; /* scratch string pointer */ /* simplify the vd structure (we are gonna look at it a lot) */ vnum = var->v_num; vtype = var->v_type; /* and set the appropriate value */ status = TRUE; switch (vtype) { case TKVAR: /* set a user variable */ if (uv[vnum].u_value != NULL) free(uv[vnum].u_value); sp = malloc(strlen(value) + 1); if (sp == NULL) return FALSE; strcpy(sp, value); uv[vnum].u_value = sp; break; case TKENV: /* set an environment variable */ status = TRUE; /* by default */ switch (vnum) { case EVFILLCOL: fillcol = atoi(value); break; case EVPAGELEN: status = newsize(TRUE, atoi(value)); break; case EVCURCOL: status = setccol(atoi(value)); break; case EVCURLINE: status = gotoline(TRUE, atoi(value)); break; case EVRAM: break; case EVFLICKER: flickcode = stol(value); break; case EVCURWIDTH: status = newwidth(TRUE, atoi(value)); break; case EVCBUFNAME: strcpy(curbp->b_bname, value); curwp->w_flag |= WFMODE; break; case EVCFNAME: strcpy(curbp->b_fname, value); curwp->w_flag |= WFMODE; break; case EVSRES: status = TTrez(value); break; case EVDEBUG: macbug = stol(value); break; case EVSTATUS: cmdstatus = stol(value); break; case EVASAVE: gasave = atoi(value); break; case EVACOUNT: gacount = atoi(value); break; case EVLASTKEY: lastkey = atoi(value); break; case EVCURCHAR: ldelchar(1, FALSE); /* delete 1 char */ c = atoi(value); if (c == '\n') lnewline(); else linsert(1, c); backchar(FALSE, 1); break; case EVDISCMD: discmd = stol(value); break; case EVVERSION: break; case EVPROGNAME: break; case EVSEED: seed = atoi(value); break; case EVDISINP: disinp = stol(value); break; case EVWLINE: status = resize(TRUE, atoi(value)); break; case EVCWLINE: status = forwline(TRUE, atoi(value) - getwpos()); break; case EVTARGET: curgoal = atoi(value); thisflag = saveflag; break; case EVSEARCH: strcpy(pat, value); rvstrcpy(tap, pat); #if MAGIC mcclear(); #endif break; case EVREPLACE: strcpy(rpat, value); break; case EVMATCH: break; case EVKILL: break; case EVCMODE: curbp->b_mode = atoi(value); curwp->w_flag |= WFMODE; break; case EVGMODE: gmode = atoi(value); break; case EVTPAUSE: term.t_pause = atoi(value); break; case EVPENDING: break; case EVLWIDTH: break; case EVLINE: putctext(value); case EVGFLAGS: gflags = atoi(value); break; case EVRVAL: break; case EVTAB: tabmask = atoi(value) - 1; if (tabmask != 0x07 && tabmask != 0x03) tabmask = 0x07; curwp->w_flag |= WFHARD; break; case EVOVERLAP: overlap = atoi(value); break; case EVSCROLLCOUNT: scrollcount = atoi(value); break; case EVSCROLL: #if SCROLLCODE if (!stol(value)) term.t_scroll = NULL; #endif break; } break; } return status; }
char* en_en::getVerbPast(int v,int f, int s,bool dr,char* midadverb) { FILE* rFile = fopen(DICTIONARY EN_EN_FOLDER "verb_past","r"); gotoline(rFile,v); char* buffer=(char*)malloc(BUFFER_SIZE); fgets(buffer,BUFFER_SIZE-1,rFile); fclose(rFile); char vt=buffer[0]; //just return preadd + (vt=='2' ? 'd' : 'ed' ) if (vt=='2' || vt=='3') { int el=vt-'1'; char* preadd=getVerbPreAdd(v); int il=strlen(preadd); char* buffer2=(char*)calloc(il+el,sizeof(char)); strcat(buffer2,midadverb); strcat(buffer2,preadd); if (vt=='3') strcat(buffer2,"e"); strcat(buffer2,"d "); // free(buffer); return buffer2; } else if (vt=='1') { int i=1; int f=dr?2:1; int u=0; while (u<f) { if (buffer[i]=='_') u++; if (buffer[i]=='\n') break; i++; } char* buffer2=(char*)calloc(BUFFER_SIZE,sizeof(char)); strcat(buffer2,midadverb); u=strlen(buffer2); while(1){ buffer2[u]=buffer[i]; i++; u++; if(buffer[i]=='\n' || buffer[i]=='_') break; } buffer2[u++]=' '; buffer2[u++]=0; return buffer2; } else if (vt=='0' || vt=='4'){ if (f==-1){ int t=getNounType(s); f=getVerbFormFromSubjectType(t,s); } char of=f; if (dr) f = 0; int u=0; int i=0; while (u<=f){ char c=buffer[i]; if (c=='_') u++; else if (c=='\n'){ printf("Warning:\nThe form %d doesn't exist for verb %d!\nUsing form 0\n",f,v); return getVerb(v,0,s,1,&blank); } i++; } //i should be at the start of form we want //copy form to start of buffer char* buffer2=(char*)calloc(BUFFER_SIZE,sizeof(char)); strcat(buffer2,midadverb); u=strlen(buffer2); while (buffer[i]!='_' && buffer[i]!='\n' && buffer[i]!=0){ buffer2[u++]=buffer[i++]; } buffer2[u++]=' '; buffer2[u++]=0; return buffer2; } else{ printf("ERROR:\n"); } return (char*)"failure in en_en::getVerbPast() "; }