Changeset f4edee in git
- Timestamp:
- Aug 13, 1999, 1:21:44 PM (25 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- e0c1011389506713adc137a01e7cb3051d1ac59d
- Parents:
- 9fa15ad44663bb926f22bf8c03d6a601739127a3
- Location:
- Singular
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/ChangeLog
r9fa15a rf4edee 1 Fri Aug 13 13:20:01 MET DST 1999 hannes 2 * made fe_fgets_stdin an function pointer instead of a macro 3 ( febase.cc febase.h feread.cc misc.cc sing_mp.cc tesths.cc) 4 1 5 Thu Aug 12 12:57:49 MET DST 1999 hannes 2 6 * integrated "spectrum" by Stefan Endrass, inactive by default -
Singular/febase.cc
r9fa15a rf4edee 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: febase.cc,v 1.7 8 1999-08-05 11:28:02 obachmanExp $ */4 /* $Id: febase.cc,v 1.79 1999-08-13 11:21:42 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: i/o system … … 60 60 ;} 61 61 BOOLEAN errorreported = FALSE; 62 BOOLEAN feBatch = FALSE;63 62 char * feErrors=NULL; 64 63 int feErrorsLen=0; … … 261 260 { 262 261 #ifdef HAVE_MPSR 263 if (fe Batch)262 if (fe_fgets_stdin==fe_fgets_dummy) 264 263 { 265 264 if (feErrors==NULL) -
Singular/febase.h
r9fa15a rf4edee 4 4 * Computer Algebra System SINGULAR * 5 5 ****************************************/ 6 /* $Id: febase.h,v 1.3 4 1999-08-06 14:06:38 obachmanExp $ */6 /* $Id: febase.h,v 1.35 1999-08-13 11:21:43 Singular Exp $ */ 7 7 /* 8 8 * ABSTRACT: basic i/o … … 67 67 #endif 68 68 extern BOOLEAN errorreported; 69 extern BOOLEAN fe_use_fgets;70 extern BOOLEAN feBatch;71 69 extern BOOLEAN feProt; 72 70 extern BOOLEAN feWarn; … … 173 171 #else 174 172 #define PrintTCL(A,B,C) Print("TCL-Err:%s",C) 175 #endif 176 #endif 173 #endif /* HAVE_TCL */ 174 #endif /* __MWERKS__ */ 177 175 178 176 char * StringAppend(char *fmt, ...); … … 229 227 230 228 /* feread.cc: */ 231 #ifdef HAVE_FEREAD 232 //void fe_set_input_mode (void); 233 //void fe_temp_set (void); 234 //void fe_temp_reset (void); 235 char * fe_fgets_stdin(char *pr,char *s, int size); 236 #else 237 #ifdef HAVE_READLINE 238 void fe_set_input_mode (void); 239 void fe_reset_input_mode (void); 240 char * fe_fgets_stdin_rl(char *pr,char *s, int size); 241 #define fe_fgets_stdin(p,A,B) fe_fgets_stdin_rl(p,A,B) 242 #else 243 #define fe_fgets_stdin(p,A,B) fgets(A,B,stdin) 229 230 /* the interface for reading: */ 231 extern char * (*fe_fgets_stdin)(char *pr,char *s, int size); 232 233 /* possible implementations: */ 234 235 /* readline, linked in: */ 236 char * fe_fgets_stdin_rl(char *pr,char *s, int size); 237 238 /* emulated readline: */ 239 char * fe_fgets_stdin_emu(char *pr,char *s, int size); 240 241 /* fgets: */ 242 char * fe_fgets(char *pr,char *s, int size); 243 244 #ifdef HAVE_TCL 245 /* tcl: */ 246 char * fe_fgets_tcl(char *pr,char *s, int size); 244 247 #endif 245 #endif 246 #endif /* ifndef __MWERKS__ */ 248 249 /* dummy (for batch mode): */ 250 char * fe_fgets_dummy(char *pr,char *s, int size); 251 252 #endif /* c++ only */ 247 253 248 254 /* everything in between calls to these procedures is printed into a string -
Singular/feread.cc
r9fa15a rf4edee 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: feread.cc,v 1.2 0 1998-10-29 13:15:14Singular Exp $ */4 /* $Id: feread.cc,v 1.21 1999-08-13 11:21:43 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: input from ttys, simulating fgets … … 17 17 18 18 19 static char * fe_fgets_stdin_init(char *pr,char *s, int size); 20 char * (*fe_fgets_stdin)(char *pr,char *s, int size) 21 = fe_fgets_stdin_init; 19 22 #if defined(HAVE_READLINE) && !defined(HAVE_FEREAD) 20 23 #include <unistd.h> … … 52 55 #include "ipshell.h" 53 56 54 BOOLEAN fe_use_fgets=FALSE;57 char * fe_fgets_stdin_rl(char *pr,char *s, int size); 55 58 56 59 … … 112 115 } 113 116 114 void fe_set_input_mode(void) 115 { 117 void fe_reset_input_mode (void) 118 { 119 char *p = getenv("SINGULARHIST"); 120 if (p != NULL) 121 { 122 if(history_total_bytes()!=0) 123 write_history (p); 124 } 125 } 126 127 char * fe_fgets_stdin_rl(char *pr,char *s, int size) 128 { 129 if (!BVERBOSE(V_PROMPT)) 130 { 131 pr=""; 132 } 133 mflush(); 134 135 char *line; 136 line = readline (pr); 137 138 if (line==NULL) 139 return NULL; 140 141 if (*line!='\0') 142 { 143 add_history (line); 144 } 145 int l=strlen(line); 146 if (l>=size-1) 147 { 148 strncpy(s,line,size); 149 } 150 else 151 { 152 strncpy(s,line,l); 153 s[l]='\n'; 154 s[l+1]='\0'; 155 } 156 free (line); 157 158 return s; 159 } 160 #endif 161 /*--------------------------------------------------------------*/ 162 #if !defined(HAVE_READLINE) && defined(HAVE_FEREAD) 163 extern "C" { 164 char * fe_fgets_stdin_fe(char *pr,char *s, int size); 165 } 166 char * fe_fgets_stdin_emu(char *pr,char *s, int size) 167 { 168 if (!BVERBOSE(V_PROMPT)) 169 { 170 pr=""; 171 } 172 mflush(); 173 return fe_fgets_stdin_fe(pr,s,size); 174 } 175 #endif 176 177 static char * fe_fgets_stdin_init(char *pr,char *s, int size) 178 { 179 #if defined(HAVE_READLINE) && !defined(HAVE_FEREAD) 116 180 /* Allow conditional parsing of the ~/.inputrc file. */ 117 181 rl_readline_name = "Singular"; … … 119 183 rl_attempted_completion_function = (CPPFunction *)singular_completion; 120 184 121 if(!fe_use_fgets) 122 { 123 124 /* set the output stream */ 125 if(!isatty(STDOUT_FILENO)) 126 { 127 #ifdef atarist 128 rl_outstream = fopen( "/dev/tty", "w" ); 129 #else 130 rl_outstream = fopen( ttyname(fileno(stdin)), "w" ); 131 #endif 132 } 133 134 /* try to read a history */ 135 using_history(); 136 char *p = getenv("SINGULARHIST"); 137 if (p != NULL) 138 { 139 read_history (p); 140 } 141 } 142 } 143 144 void fe_reset_input_mode (void) 145 { 185 /* set the output stream */ 186 if(!isatty(STDOUT_FILENO)) 187 { 188 #ifdef atarist 189 rl_outstream = fopen( "/dev/tty", "w" ); 190 #else 191 rl_outstream = fopen( ttyname(fileno(stdin)), "w" ); 192 #endif 193 } 194 195 /* try to read a history */ 196 using_history(); 146 197 char *p = getenv("SINGULARHIST"); 147 198 if (p != NULL) 148 199 { 149 if(!feBatch && !fe_use_fgets && (history_total_bytes()!=0)) 150 write_history (p); 151 } 152 } 153 154 char * fe_fgets_stdin_rl(char *pr,char *s, int size) 155 { 156 if (feBatch) 157 return NULL; 158 if(fe_use_fgets) 159 { 160 #ifdef HAVE_TCL 161 if (tclmode) 162 { 163 if(currRing!=NULL) PrintTCLS('P',pr); 164 else PrintTCLS('U',pr); 165 } 166 else 167 #endif 168 if (BVERBOSE(V_PROMPT)) 169 { 170 PrintS(pr); 171 } 172 mflush(); 173 return fgets(s,size,stdin); 174 } 175 176 if (!BVERBOSE(V_PROMPT)) 177 { 178 pr=""; 179 } 180 mflush(); 181 182 char *line; 183 line = readline (pr); 184 185 if (line==NULL) 186 return NULL; 187 188 if (*line!='\0') 189 { 190 add_history (line); 191 } 192 int l=strlen(line); 193 if (l>=size-1) 194 { 195 strncpy(s,line,size); 196 } 197 else 198 { 199 strncpy(s,line,l); 200 s[l]='\n'; 201 s[l+1]='\0'; 202 } 203 free (line); 204 205 return s; 206 } 207 #endif 208 /*--------------------------------------------------------------*/ 200 read_history (p); 201 } 202 fe_fgets_stdin=fe_fgets_stdin_rl; 203 return(fe_fgets_stdin_rl(pr,s,size)); 204 #endif 209 205 #if !defined(HAVE_READLINE) && defined(HAVE_FEREAD) 210 extern "C" { 211 char * fe_fgets_stdin_fe(char *pr,char *s, int size); 212 } 213 char * fe_fgets_stdin(char *pr,char *s, int size) 214 { 215 if (feBatch) 216 return NULL; 217 if(fe_use_fgets) 218 { 219 #ifdef HAVE_TCL 220 if (tclmode) 221 { 222 if(currRing!=NULL) PrintTCLS('P',pr); 223 else PrintTCLS('U',pr); 224 } 225 else 226 #endif 227 if (BVERBOSE(V_PROMPT)) 228 { 229 PrintS(pr); 230 } 231 mflush(); 232 return fgets(s,size,stdin); 233 } 234 235 if (!BVERBOSE(V_PROMPT)) 236 { 237 pr=""; 238 } 239 mflush(); 240 241 242 return fe_fgets_stdin_fe(pr,s,size); 243 } 244 #endif 206 fe_fgets_stdin=fe_fgets_stdin_emu; 207 return(fe_fgets_stdin_emu(pr,s,size)); 208 #endif 209 } 210 211 /* fgets: */ 212 char * fe_fgets(char *pr,char *s, int size) 213 { 214 if (BVERBOSE(V_PROMPT)) 215 { 216 fprintf(stdout,pr); 217 } 218 mflush(); 219 return fgets(s,size,stdin); 220 } 221 222 #ifdef HAVE_TCL 223 /* tcl: */ 224 char * fe_fgets_tcl(char *pr,char *s, int size) 225 { 226 if(currRing!=NULL) PrintTCLS('P',pr); 227 else PrintTCLS('U',pr); 228 mflush(); 229 return fgets(s,size,stdin); 230 } 231 #endif 232 233 /* dummy (for batch mode): */ 234 char * fe_fgets_dummy(char *pr,char *s, int size) 235 { 236 return NULL; 237 } -
Singular/misc.cc
r9fa15a rf4edee 114 114 #ifdef HAVE_FEREAD 115 115 #ifdef HAVE_ATEXIT 116 fe_reset_input_mode();116 //fe_reset_input_mode(); 117 117 #else 118 fe_reset_input_mode(0,NULL);118 //fe_reset_input_mode(0,NULL); 119 119 #endif 120 120 #else 121 121 #ifdef HAVE_READLINE 122 fe_reset_input_mode();122 //fe_reset_input_mode(); 123 123 #endif 124 124 #endif -
Singular/sing_mp.cc
r9fa15a rf4edee 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: sing_mp.cc,v 1.2 5 1999-08-03 16:33:44 obachmanExp $ */4 /* $Id: sing_mp.cc,v 1.26 1999-08-13 11:21:44 Singular Exp $ */ 5 5 6 6 /* … … 276 276 SI_LINK_SET_RW_OPEN_P(l); 277 277 l->data = (void *) link; 278 fe Batch=TRUE;278 fe_fgets_stdin=fe_fgets_dummy; 279 279 _exit(Batch_ReadEval(slCopy(l))); 280 280 } -
Singular/tesths.cc
r9fa15a rf4edee 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: tesths.cc,v 1.6 7 1999-08-06 14:06:41 obachmanExp $ */4 /* $Id: tesths.cc,v 1.68 1999-08-13 11:21:44 Singular Exp $ */ 5 5 6 6 /* … … 113 113 114 114 // mention only documented options here 115 // or let help string start with // then option is like undocumented 115 // or let help string start with // then option is like undocumented 116 116 static struct sing_option sing_longopts[] = 117 117 { … … 194 194 #ifdef NDEBUG 195 195 && *(sopt->help) != '/' 196 #endif 196 #endif 197 197 ) 198 198 { … … 315 315 case 'b': 316 316 #ifdef HAVE_MPSR 317 fe Batch=TRUE;317 fe_fgets_stdin=fe_fgets_dummy; 318 318 mainSetSingOptionValue(LON_BATCH, (char*) 1); 319 319 break; … … 334 334 case 't': 335 335 #if defined(HAVE_FEREAD) || defined(HAVE_READLINE) 336 fe_ use_fgets=TRUE;336 fe_fgets_stdin=fe_fgets; 337 337 #endif 338 338 mainSetSingOptionValue(LON_NO_TTY, (char*) 1); … … 340 340 341 341 case 'd': 342 343 342 sdb_flags = 1; 343 break; 344 344 345 345 case 'v': … … 356 356 #ifdef HAVE_TCL 357 357 tclmode = TRUE; 358 fe_fgets_stdin=fe_fgets_tcl; 358 359 mainSetSingOptionValue(LON_TCLMODE, (char*) 1); 359 360 verbose|=Sy_bit(V_SHOW_MEM); … … 436 437 // print EmacsDir and InfoFile so that Emacs 437 438 // mode can pcik it up 438 Warn("EmacsDir: %s", (feResource("EmacsDir") != NULL ? 439 feResource("EmacsDir") : "")); 440 Warn("InfoFile: %s", (feResource("InfoFile") != NULL ? 441 feResource("InfoFile") : "")); 442 439 Warn("EmacsDir: %s", (feResource('e' /*"EmacsDir"*/) != NULL ? 440 feResource('e' /*"EmacsDir"*/) : "")); 441 Warn("InfoFile: %s", (feResource('i' /*"InfoFile"*/) != NULL ? 442 feResource('i' /*"InfoFile"*/) : "")); 443 443 } 444 444 else if (strcmp(longopts[option_index].name, LON_NO_RC) == 0) … … 522 522 #endif /* HAVE_NAMESPACES */ 523 523 } 524 if (BVERBOSE(0) && !feBatch)524 if (BVERBOSE(0)) 525 525 { 526 526 printf( … … 542 542 { 543 543 sdb_flags = 0; 544 if (!feBatch)545 {546 544 #ifdef __MWERKS__ 547 545 memcpy(stderr,stdout,sizeof(FILE)); 548 546 #else 549 dup2(1,2); 550 #endif 551 } 547 dup2(1,2); 548 #endif 552 549 } 553 550 slStandardInit(); … … 567 564 errorreported = 0; 568 565 mmMarkInitDBMCB(); 569 #ifndef macintosh570 #if defined(HAVE_READLINE)571 fe_set_input_mode();572 #endif573 #endif574 566 setjmp(si_start_jmpbuf); 575 567 … … 624 616 625 617 /* start shell */ 626 if (fe Batch)618 if (fe_fgets_stdin==fe_fgets_dummy) 627 619 { 628 620 #ifdef HAVE_MPSR
Note: See TracChangeset
for help on using the changeset viewer.