Changeset abd1c2 in git for Singular/febase.cc
- Timestamp:
- Jun 5, 1998, 11:39:34 AM (26 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- c51762f18dfacf5d060608511226b47283868578
- Parents:
- 757550da97af1df30c4f0816a21fd54dc54c26c0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/febase.cc
r757550 rabd1c2 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: febase.cc,v 1.4 5 1998-06-04 17:20:54 Singular Exp $ */4 /* $Id: febase.cc,v 1.46 1998-06-05 09:39:34 Singular Exp $ */ 5 5 /* 6 6 * ABSTRACT: i/o system … … 46 46 #ifndef MAXPATHLEN 47 47 #define MAXPATHLEN 1024 48 #endif 49 50 #ifndef MAXNAMLEN 51 #define MAXNAMLEN MAXPATHLEN 48 52 #endif 49 53 … … 168 172 169 173 // Return the file search path for singular w.r.t. the following steps: 170 // 1.) SINGULARPATH Env Variable 174 // 1.) SINGULARPATH Env Variable 171 175 // 2.) bindir/LIB 172 176 // 3.) bindir/LIB/VERSION … … 175 179 // 6.) ROOT_DIR/Singular/LIB/ 176 180 // 7.) ROOT_DIR/Singular/LIB/VERSION 177 // 8.) Go through all dirs and remove duplicates dirs resp. 181 // 8.) Go through all dirs and remove duplicates dirs resp. 178 182 // those which do not exist 179 183 static char* feGetSearchPath(const char* bindir) 180 { 184 { 181 185 char *env = NULL, *path, *opath; 182 186 int plength = 0, tmp; 183 187 184 188 #ifdef MSDOS 185 189 env=getenv("SPATH"); … … 196 200 plength += 4*strlen(bindir); 197 201 198 plength += 2*strlen(SINGULAR_ROOT_DIR) 202 plength += 2*strlen(SINGULAR_ROOT_DIR) 199 203 + 3*(strlen(S_VERSION1) + 1) 200 + 24 + 36 + 12 + 6 + 7; 204 + 24 + 36 + 12 + 6 + 7; 201 205 // == 6*/LIB + 4*/Singular + 2*/../.. + for colons + some room to breath 202 206 203 207 opath = (char*) AllocL(plength*sizeof(char)); 204 208 path = opath; 205 209 206 210 if (env != NULL) 207 211 { … … 213 217 *(path +1) = '\0'; 214 218 printf("Got from env var: %s\n", opath); 215 #endif 216 } 217 219 #endif 220 } 221 218 222 if (bindir != NULL) 219 223 { … … 230 234 path += strlen(path); 231 235 } 232 236 233 237 sprintf(path, "%s/Singular/LIB%c%sSingular/LIB/%s", 234 238 SINGULAR_ROOT_DIR, FS_SEP, … … 236 240 #ifdef PATH_DEBUG 237 241 printf("From rootdir: %s\n", path); 238 #endif 242 #endif 239 243 return CleanUpPath(opath); 240 244 } … … 266 270 hlpdir[0]=hlpdir[2]; 267 271 hlpdir[1]=':'; 268 mystrcpy(hlpdir+2,hlpdir+3); 272 mystrcpy(hlpdir+2,hlpdir+3); 269 273 } 270 274 return hlpdir; … … 283 287 printf("Search for singular.hlp\n"); 284 288 #endif 285 289 286 290 if (bindir != NULL) 287 291 { … … 289 293 #ifdef PATH_DEBUG 290 294 printf("trying %s -- %s\n", hlpfile, ( access(hlpfile, R_OK) ? "no" : "yes")); 291 #endif 295 #endif 292 296 if (! access(hlpfile, R_OK)) return feFixFileName(hlpfile); 293 297 … … 295 299 #ifdef PATH_DEBUG 296 300 printf("trying %s -- %s\n", hlpfile, ( access(hlpfile, R_OK) ? "no" : "yes")); 297 #endif 301 #endif 298 302 if (! access(hlpfile, R_OK)) return feFixFileName(hlpfile); 299 303 … … 301 305 #ifdef PATH_DEBUG 302 306 printf("trying %s -- %s\n", hlpfile, ( access(hlpfile, R_OK) ? "no" : "yes")); 303 #endif 307 #endif 304 308 if (! access(hlpfile, R_OK)) return feFixFileName(hlpfile); 305 309 … … 307 311 #ifdef PATH_DEBUG 308 312 printf("trying %s -- %s\n", hlpfile, ( access(hlpfile, R_OK) ? "no" : "yes")); 309 #endif 313 #endif 310 314 if (! access(hlpfile, R_OK)) return feFixFileName(hlpfile); 311 315 … … 313 317 #ifdef PATH_DEBUG 314 318 printf("trying %s -- %s\n", hlpfile, ( access(hlpfile, R_OK) ? "no" : "yes")); 315 #endif 319 #endif 316 320 if (! access(hlpfile, R_OK)) return feFixFileName(hlpfile); 317 321 … … 319 323 #ifdef PATH_DEBUG 320 324 printf("trying %s -- %s\n", hlpfile, ( access(hlpfile, R_OK) ? "no" : "yes")); 321 #endif 325 #endif 322 326 if (! access(hlpfile, R_OK)) return feFixFileName(hlpfile); 323 327 } … … 344 348 sprintf(infoprog, "%s/%s", SINGULAR_BIN_DIR, INFOPROG); 345 349 if (! access(infoprog, X_OK)) return mstrdup(infoprog); 346 350 347 351 #ifdef HAVE_INFO 348 352 sprintf(infoprog, "%s", HAVE_INFO); … … 354 358 } 355 359 360 #ifdef WINNT 361 // add utility function of Cygwin32: 362 extern "C" int posix_path_list_p (const char *path); 363 #endif 364 365 void feExpandPath(char *dir) 366 { 367 char *path=getenv("PATH"); 368 char buf[MAXNAMLEN]; 369 if (path==NULL) 370 { 371 strcpy(buf,dir); 372 } 373 else 374 { 375 #ifdef WINNT 376 char path_delim = posix_path_list_p (path) ? ':' : ';'; 377 #else 378 char path_delim=FS_SEP; 379 #endif 380 sprintf(buf,"%s%c%s",path,path_delim,dir); 381 } 382 setenv("PATH",buf,1); 383 } 356 384 // 357 385 // public routines … … 360 388 { 361 389 feArgv0 = mstrdup(argv0); 390 #ifdef WINNT 391 feExtendPath(feGetBinDir()); // can only be called after setting feArgv0 392 feExtendPath(SINGULAR_BIN_DIR); 393 #endif 362 394 } 363 395 … … 404 436 + 100); 405 437 char *infofile = feGetInfoFile(); 406 438 407 439 if (what != NULL && strcmp(what, "index") != 0) 408 440 sprintf(feInfoCall, 409 "%s %s %s Index %s", 410 feGetInfoProgram(), 441 "%s %s %s Index %s", 442 feGetInfoProgram(), 411 443 (*infofile != '\0' ? "-f" : ""), 412 (*infofile != '\0' ? infofile : "Singular"), 444 (*infofile != '\0' ? infofile : "Singular"), 413 445 what); 414 446 else 415 447 sprintf(feInfoCall, 416 "%s %s %s", 417 feGetInfoProgram(), 448 "%s %s %s", 449 feGetInfoProgram(), 418 450 (*infofile != '\0' ? "-f" : ""), 419 451 (*infofile != '\0' ? infofile : "Singular")); … … 421 453 #ifdef PATH_DEBUG 422 454 printf("Info call with: %s \n", feInfoCall); 423 #endif 455 #endif 424 456 return feInfoCall; 425 457 } … … 445 477 #ifdef PATH_DEBUG 446 478 printf("Entered CleanUpPath with: %s\n", path); 447 #endif 479 #endif 448 480 if (path == NULL) return path; 449 481 … … 451 483 char* opath = path; 452 484 char** path_comps; 453 485 454 486 for (; *path != '\0'; path++) 455 487 { 456 488 if (*path == FS_SEP) n_comps++; 457 489 } 458 490 459 491 460 492 path_comps = (char**) AllocL(n_comps*sizeof(char*)); … … 462 494 path=opath; 463 495 i = 1; 464 496 465 497 if (i < n_comps) 466 498 { … … 477 509 } 478 510 } 479 511 480 512 for (i=0; i<n_comps; i++) 481 513 path_comps[i] = CleanUpName(path_comps[i]); … … 486 518 printf("\n"); 487 519 #endif 488 520 489 521 for (i=0; i<n_comps;) 490 522 { … … 492 524 if (access(path_comps[i], X_OK)) 493 525 printf("remove %d:%s -- can not access\n", i, path_comps[i]); 494 #endif 526 #endif 495 527 if ( ! access(path_comps[i], X_OK)) 496 528 { … … 503 535 #ifdef PATH_DEBUG 504 536 printf("remove %d:%s -- equal to %d:%s\n", j, path_comps[j], i, path_comps[i]); 505 #endif 537 #endif 506 538 j = i+1; 507 539 break; 508 540 } 509 541 } 510 if (j == i) 542 if (j == i) 511 543 { 512 544 i++; … … 540 572 { 541 573 char* fn, *s; 542 574 543 575 for (fn = fname; *fn != '\0'; fn++) 544 576 { … … 1064 1096 int i; 1065 1097 BOOLEAN done = FALSE; 1066 1098 1067 1099 for (i=0;;i++) 1068 1100 { … … 1071 1103 if (mode[i] == 'b') done = TRUE; 1072 1104 } 1073 1105 1074 1106 if (! done) 1075 1107 {
Note: See TracChangeset
for help on using the changeset viewer.