Changeset 30637f in git for Singular/febase.cc
- Timestamp:
- Apr 30, 1997, 7:08:40 PM (27 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- 22d79069af63dd10b93e136d82bb339faa6c28d9
- Parents:
- 6d3ffecde9449bcf2b3a7cceb254992ea1ef9e43
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/febase.cc
r6d3ffec r30637f 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: febase.cc,v 1.1 2 1997-04-30 15:25:27Singular Exp $ */4 /* $Id: febase.cc,v 1.13 1997-04-30 17:08:40 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: i/o system, handling of 'voices' … … 37 37 class Voices 38 38 { 39 private: 40 void Init() 41 { 42 memset(this,0,sizeof(*this)); 43 v_lineno = 1; 44 } 39 45 public: 40 46 int v_lineno; // lineno, to restore in recursion … … 50 56 51 57 void Next(); 52 Voices() { v_lineno = 1; }58 Voices() { Init(); } 53 59 Voices * VFile(char* fname); 54 60 Voices * Buffer(char* buf, int t); … … 113 119 */ 114 120 115 /*2 fopen, but use 'SINGULARPATH' from environment and SINGULARDATADIR 121 /*2 122 * fopen, but use 'SINGULARPATH' from environment and SINGULARDATADIR 116 123 * as set by configure 117 * */124 */ 118 125 #ifdef macintosh 119 126 # define FS_SEP ',' … … 141 148 { 142 149 if (where!=NULL) strcpy(where,path); 143 if ((*mode=='a') ||(*mode=='w') || (path[0]==DIR_SEP)||(path[0]=='.')) 144 return fopen(path,mode); 150 FILE * f=fopen(path,mode); 151 if ((*mode=='a') ||(*mode=='w') || (path[0]==DIR_SEP)||(path[0]=='.') 152 ||(f!=NULL)) 153 return f; 145 154 char found = 0; 146 FILE * f=NULL;147 155 #ifdef MSDOS 148 156 char *env=getenv("SPATH"); … … 189 197 if (where!=NULL) strcpy(s/*where*/,path); 190 198 f=fopen(path,mode); 191 } 199 } 192 200 #ifndef macintosh 193 201 if (f==NULL) … … 207 215 } 208 216 strcpy(ss,SINGULAR_DATADIR); 209 strcat(s s, DIR_SEPP);217 strcat(s, DIR_SEPP); 210 218 strcat(ss,path); 211 219 f=fopen(ss,mode); … … 271 279 v_echo = si_echo; 272 280 fileVoice = voice; 273 yylineno = v_lineno =1;281 yylineno = 1; 274 282 if (files==NULL) 275 283 { … … 313 321 314 322 currentVoice = &FileAttribs[voice]; 323 currentVoice->Init(); 315 324 } 316 325 … … 455 464 int exitFile() 456 465 { 457 /*4 first check for valid buffer type*/ 458 for (int i=voice; i>0; i--) 459 { 460 if (FileAttribs[i].typ == 0) break; 461 if (FileAttribs[i].typ == BT_file) 462 { 463 while ((BT_file != currentVoice->typ) 464 && (voice > 0)) 465 { 466 exitVoice(); 467 } 468 exitVoice(); 469 } 470 } 466 int oldswitch; 467 468 while ((voice > 0) && (inputswitch > 0)) 469 { 470 exitVoice(); 471 } 472 // now we have left all if-, else-, while-, for-, proc-levels 473 // inside this file; 474 // if the file is the terminal (inputswitch == 0) and 475 // voice >0, so return 1 else return 0 476 // (used for EXIT_CMD in CNTRLC-C-handling) 477 oldswitch = inputswitch; 478 exitVoice(); 479 #ifdef SIC 480 return 1; 481 #else 482 if ((oldswitch)||(myynest<0)) return 0; 483 else return 1; 484 #endif 471 485 } 472 486 … … 587 601 void I_FEbase(void) 588 602 { 589 currentVoice=FileAttribs[0].VFile("STDIN"); 590 //FileAttribs[0].files = yyin = stdin; 591 //FileAttribs[0].filename = mstrdup("STDIN"); 592 //yylineno = 1; 593 //currentVoice = &FileAttribs[0]; 603 currentVoice = FileAttribs[0].VFile("STDIN"); 594 604 } 595 605
Note: See TracChangeset
for help on using the changeset viewer.