#include "lclintMacros.nf"#include "llbasic.h"#include "osd.h"#include "llmain.h"#include "portab.h"Go to the source code of this file.
Functions | |
| cstring | fileTable_unparse (fileTable ft) |
| void | fileTable_printTemps (fileTable ft) |
| fileTable | fileTable_create () |
| void | fileTable_noDelete (fileTable ft, cstring name) |
| fileId | fileTable_addFile (fileTable ft, cstring name) |
| fileId | fileTable_addFileOnly (fileTable ft, cstring name) |
| fileId | fileTable_addHeaderFile (fileTable ft, cstring name) |
| bool | fileTable_isHeader (fileTable ft, fileId fid) |
| bool | fileTable_isSystemFile (fileTable ft, fileId fid) |
| bool | fileTable_isSpecialFile (fileTable ft, fileId fid) |
| fileId | fileTable_addLibraryFile (fileTable ft, cstring name) |
| fileId | fileTable_addImportFile (fileTable ft, cstring name) |
| fileId | fileTable_addLCLFile (fileTable ft, cstring name) |
| fileId | fileTable_addMacrosFile (fileTable ft) |
| fileId | fileTable_addCTempFile (fileTable ft, fileId fid) |
| fileId | fileTable_addltemp (fileTable ft) |
| bool | fileTable_exists (fileTable ft, cstring s) |
| fileId | fileTable_lookup (fileTable ft, cstring s) |
| fileId | fileTable_lookupBase (fileTable ft, cstring base) |
| cstring | fileTable_getName (fileTable ft, fileId fid) |
| cstring | fileTable_getRootName (fileTable ft, fileId fid) |
| cstring | fileTable_getNameBase (fileTable ft, fileId fid) |
| bool | fileTable_sameBase (fileTable ft, fileId f1, fileId f2) |
| void | fileTable_cleanup (fileTable ft) |
| void | fileTable_free ( fileTable f) |
|
|
Definition at line 405 of file fileTable.c. 00406 {
00407 # if FALSE
00408 /* Can't control output file name for cl preprocessor */
00409 cstring newname = cstring_concatChars (removeAnyExtension (fileName (fid)), ".i");
00410 # else
00411 cstring newname = cstring_fromChars
00412 (makeTempName (cstring_toCharsSafe (context_tmpdir ()), "cl", ".c"));
00413 # endif
00414
00415 llassert (fileTable_isDefined (ft));
00416
00417 if (!fileId_isValid (ft->elements[fid]->fder))
00418 {
00419 return (fileTable_addFilePrim (ft, newname, TRUE, FILE_NORMAL, fid));
00420 }
00421 else
00422 {
00423 return (fileTable_addFilePrim (ft, newname, TRUE, FILE_NORMAL,
00424 ft->elements[fid]->fder));
00425 }
00426 }
|
|
|
Definition at line 311 of file fileTable.c. Referenced by fileloc_createRc(). 00312 {
00313 /* while (*name == '.' && *(name + 1) == '/') name += 2; */
00314 return (fileTable_addFilePrim (ft, cstring_copy (name),
00315 FALSE, FILE_NORMAL, fileId_invalid));
00316 }
|
|
|
Definition at line 319 of file fileTable.c. 00320 {
00321 return (fileTable_addFilePrim (ft, name, FALSE, FILE_NORMAL, fileId_invalid));
00322 }
|
|
|
Definition at line 325 of file fileTable.c. 00326 {
00327 DPRINTF (("Add header: %s", name));
00328 return (fileTable_addFilePrim (ft, cstring_copy (name), FALSE,
00329 FILE_HEADER, fileId_invalid));
00330 }
|
|
|
Definition at line 377 of file fileTable.c. Referenced by fileloc_createImport(). 00378 {
00379 return (fileTable_addFilePrim (ft, cstring_copy (name),
00380 FALSE, FILE_HEADER, fileId_invalid));
00381 }
|
|
|
Definition at line 384 of file fileTable.c. Referenced by fileloc_fromTok(). 00385 {
00386 return (fileTable_addFilePrim (ft, cstring_copy (name),
00387 FALSE, FILE_HEADER, fileId_invalid));
00388 }
|
|
|
Definition at line 369 of file fileTable.c. Referenced by fileloc_createLib(). 00370 {
00371 return (fileTable_addFilePrim (ft, cstring_copy (name),
00372 FALSE, FILE_HEADER, fileId_invalid));
00373 }
|
|
|
Definition at line 396 of file fileTable.c. 00397 {
00398 cstring newname = cstring_fromChars
00399 (makeTempName (cstring_toCharsSafe (context_tmpdir ()), "lmx", ".llm"));
00400
00401 return (fileTable_addFilePrim (ft, newname, TRUE, FILE_MACROS, fileId_invalid));
00402 }
|
|
|
Definition at line 430 of file fileTable.c. 00431 {
00432 char *newname = makeTempName (cstring_toCharsSafe (context_tmpdir ()),
00433 "ls", ".lsl");
00434 char *onewname;
00435 fileId ret;
00436
00437 if (cstring_hasNonAlphaNumBar (cstring_fromChars (newname)))
00438 {
00439 char *lastpath = (char *)NULL;
00440
00441 if (tmpcounter == 0)
00442 {
00443 lldiagmsg
00444 (message
00445 ("Operating system generates tmp filename containing invalid charater: %s",
00446 cstring_fromChars (newname)));
00447 lldiagmsg (cstring_makeLiteral
00448 ("Try cleaning up the tmp directory. Attempting to continue."));
00449 }
00450
00451 lastpath = strrchr (newname, CONNECTCHAR); /* get the directory */
00452 llassert (lastpath != NULL);
00453 *lastpath = '\0';
00454
00455 onewname = newname;
00456 newname = cstring_toCharsSafe (message ("%s%hlsl%d.lsl",
00457 cstring_fromChars (newname),
00458 CONNECTCHAR,
00459 tmpcounter));
00460 sfree (onewname);
00461 tmpcounter++;
00462 }
00463
00464 /*
00465 ** this is kind of yucky...need to make the result of cstring_fromChars
00466 ** refer to the same storage as its argument. Of course, this loses,
00467 ** since cstring is abstract. Should make it an only?
00468 */
00469
00470 ret = fileTable_addFilePrim (ft, cstring_copy (cstring_fromChars (newname)),
00471 TRUE, FILE_LSLTEMP, fileId_invalid);
00472 sfree (newname);
00473 return (ret);
00474 }
|
|
|
Definition at line 630 of file fileTable.c. 00631 {
00632 int i;
00633 bool msg;
00634 int skip;
00635
00636 llassert (fileTable_isDefined (ft));
00637
00638 msg = ((ft->nentries > 40) && context_getFlag (FLG_SHOWSCAN));
00639 skip = ft->nentries / 10;
00640
00641 if (msg)
00642 {
00643 (void) fflush (g_msgstream);
00644 fprintf (stderr, "< cleaning");
00645 }
00646
00647 for (i = 0; i < ft->nentries; i++)
00648 {
00649 ftentry fe = ft->elements[i];
00650
00651 if (fe->ftemp)
00652 {
00653 /* let's be real careful now, hon! */
00654
00655 /*
00656 ** Make sure it is really a derived file
00657 */
00658
00659 if (fe->ftype == FILE_LSLTEMP || fe->ftype == FILE_NODELETE)
00660 {
00661 ; /* already removed */
00662 }
00663 else if (fileId_isValid (fe->fder))
00664 {
00665 (void) osd_unlink (cstring_toCharsSafe (fe->fname));
00666 }
00667 else if (fe->ftype == FILE_MACROS)
00668 {
00669 (void) osd_unlink (cstring_toCharsSafe (fe->fname));
00670 }
00671 else
00672 {
00673 llbug (message ("Temporary file is not derivative: %s "
00674 "(not deleted)", fe->fname));
00675 }
00676 }
00677 else
00678 {
00679 ;
00680 }
00681
00682 if (msg && ((i % skip) == 0))
00683 {
00684 (void) fflush (g_msgstream);
00685
00686 if (i == 0) {
00687 fprintf (stderr, " ");
00688 } else {
00689 fprintf (stderr, ".");
00690 }
00691
00692 (void) fflush (stderr);
00693 }
00694 }
00695
00696 if (msg)
00697 {
00698 fprintf (stderr, " >\n");
00699 }
00700 }
|
|
|
Definition at line 185 of file fileTable.c. Referenced by context_initMod(). 00186 {
00187 fileTable ft = (fileTable) dmalloc (sizeof (*ft));
00188
00189 ft->nentries = 0;
00190 ft->nspace = FTBASESIZE;
00191 ft->elements = (ftentry *) dmalloc (FTBASESIZE * sizeof (*ft->elements));
00192 ft->htable = hashTable_create (FTHASHSIZE);
00193
00194 return (ft);
00195 }
|
|
|
Definition at line 478 of file fileTable.c. 00479 {
00480 int tindex = fileTable_getIndex (ft, s);
00481
00482 if (tindex == NOT_FOUND)
00483 return FALSE;
00484 else
00485 return TRUE;
00486 }
|
|
|
Definition at line 703 of file fileTable.c. Referenced by context_destroyMod(). 00704 {
00705 int i = 0;
00706
00707 if (f == (fileTable)NULL)
00708 {
00709 return;
00710 }
00711
00712 while ( i < f->nentries )
00713 {
00714 ftentry_free (f->elements[i]);
00715 i++;
00716 }
00717
00718 hashTable_free (f->htable);
00719 sfree (f->elements);
00720 sfree (f);
00721 }
|
|
|
Definition at line 531 of file fileTable.c. 00532 {
00533 if (!fileId_isValid (fid))
00534 {
00535 llcontbug
00536 (message ("fileTable_getName: called with invalid type id: %d", fid));
00537 return cstring_makeLiteralTemp ("<invalid>");
00538 }
00539
00540 llassert (fileTable_isDefined (ft));
00541 return (ft->elements[fid]->fname);
00542 }
|
|
|
Definition at line 573 of file fileTable.c. 00574 {
00575 if (!fileId_isValid (fid))
00576 {
00577 llcontbug (message ("fileTable_getName: called with invalid id: %d", fid));
00578 return cstring_makeLiteralTemp ("<invalid>");
00579 }
00580
00581 if (!fileTable_isDefined (ft))
00582 {
00583 return cstring_makeLiteralTemp ("<no file table>");
00584 }
00585
00586 return (ft->elements[fid]->basename);
00587 }
|
|
|
Definition at line 545 of file fileTable.c. 00546 {
00547 fileId fder;
00548
00549 if (!fileId_isValid (fid))
00550 {
00551 llcontbug (message ("fileTable_getName: called with invalid id: %d", fid));
00552 return cstring_makeLiteralTemp ("<invalid>");
00553 }
00554
00555 if (!fileTable_isDefined (ft))
00556 {
00557 return cstring_makeLiteralTemp ("<no file table>");
00558 }
00559
00560 fder = ft->elements[fid]->fder;
00561
00562 if (fileId_isValid (fder))
00563 {
00564 return (ft->elements[fder]->fname);
00565 }
00566 else
00567 {
00568 return (ft->elements[fid]->fname);
00569 }
00570 }
|
|
|
Definition at line 333 of file fileTable.c. 00334 {
00335 if (fileId_isInvalid (fid))
00336 {
00337 return FALSE;
00338 }
00339
00340 llassert (fileTable_isDefined (ft) && fileTable_inRange (ft, fid));
00341 return (ft->elements[fid]->ftype == FILE_HEADER);
00342 }
|
|
|
Definition at line 357 of file fileTable.c. Referenced by fileloc_almostSameFile(), and fileloc_isSpecialFile(). 00358 {
00359 if (fileId_isInvalid (fid))
00360 {
00361 return FALSE;
00362 }
00363
00364 llassert (fileTable_isDefined (ft) && fileTable_inRange (ft, fid));
00365 return (ft->elements[fid]->fspecial);
00366 }
|
|
|
Definition at line 345 of file fileTable.c. Referenced by fileloc_almostSameFile(), and fileloc_isSystemFile(). 00346 {
00347 if (fileId_isInvalid (fid))
00348 {
00349 return FALSE;
00350 }
00351
00352 llassert (fileTable_isDefined (ft) && fileTable_inRange (ft, fid));
00353 return (ft->elements[fid]->fsystem);
00354 }
|
|
|
Definition at line 489 of file fileTable.c. Referenced by fileTable_noDelete(), fileloc_createImport(), fileloc_createLib(), and fileloc_fromTok(). 00490 {
00491 int tindex = fileTable_getIndex (ft, s);
00492
00493 if (tindex == NOT_FOUND)
00494 {
00495 return fileId_invalid;
00496 }
00497 else
00498 {
00499 return tindex;
00500 }
00501 }
|
|
|
Definition at line 504 of file fileTable.c. 00505 {
00506 int tindex = fileTable_getIndex (ft, base);
00507
00508 if (tindex == NOT_FOUND)
00509 {
00510
00511 return fileId_invalid;
00512 }
00513 else
00514 {
00515 fileId der;
00516
00517 llassert (fileTable_isDefined (ft));
00518
00519 der = ft->elements[tindex]->fder;
00520
00521 if (!fileId_isValid (der))
00522 {
00523 der = tindex;
00524 }
00525
00526 return der;
00527 }
00528 }
|
|
|
Definition at line 236 of file fileTable.c. Referenced by cppProcess(). 00237 {
00238 fileId fid = fileTable_lookup (ft, name);
00239
00240 if (fileId_isValid (fid)) {
00241 llassert (fileTable_isDefined (ft));
00242
00243 ft->elements[fid]->ftype = FILE_NODELETE;
00244 }
00245 }
|
|
|
Definition at line 122 of file fileTable.c. 00123 {
00124 if (fileTable_isDefined (ft))
00125 {
00126 int i;
00127
00128 for (i = 0; i < ft->nentries; i++)
00129 {
00130 if (ft->elements[i]->ftemp)
00131 {
00132 if (fileId_isValid (ft->elements[i]->fder))
00133 {
00134 fprintf (stderr, " %s:1\n\t%s:1\n",
00135 cstring_toCharsSafe (ft->elements[ft->elements[i]->fder]->fname),
00136 cstring_toCharsSafe (ft->elements[i]->fname));
00137 }
00138 else
00139 {
00140 fprintf (stderr, "[no file]\n\t%s:1\n",
00141 cstring_toCharsSafe (ft->elements[i]->fname));
00142 }
00143 }
00144 }
00145 }
00146 }
|
|
|
Definition at line 590 of file fileTable.c. 00591 {
00592 fileId fd1, fd2;
00593
00594 if (!fileId_isValid (f1))
00595 {
00596 return FALSE;
00597 }
00598
00599 if (!fileId_isValid (f2))
00600 {
00601 return FALSE;
00602 }
00603
00604 llassert (fileTable_isDefined (ft));
00605
00606 if (f1 == f2)
00607 {
00608 return TRUE;
00609 }
00610
00611 fd1 = ft->elements[f1]->fder;
00612
00613 if (!fileId_isValid (fd1))
00614 {
00615 fd1 = f1;
00616 }
00617
00618 fd2 = ft->elements[f2]->fder;
00619
00620
00621 if (!fileId_isValid (fd2))
00622 {
00623 fd2 = f2;
00624 }
00625
00626 return (fd1 == fd2);
00627 }
|
|
|
Definition at line 91 of file fileTable.c. 00092 {
00093 cstring s = cstring_undefined;
00094 int i;
00095
00096 if (fileTable_isUndefined (ft))
00097 {
00098 return (cstring_makeLiteral ("<fileTable undefined>"));
00099 }
00100
00101 for (i = 0; i < ft->nentries; i++)
00102 {
00103 if (fileId_isValid (ft->elements[i]->fder))
00104 {
00105 s = message ("%s\n[%d] %s %q %d (%s)",
00106 s, i,
00107 ft->elements[i]->fname,
00108 fileType_unparse (ft->elements[i]->ftype),
00109 ft->elements[i]->fder,
00110 ft->elements[ft->elements[i]->fder]->fname);
00111 }
00112 else
00113 {
00114 s = message ("%s\n[%d] %s %q", s, i, ft->elements[i]->fname,
00115 fileType_unparse (ft->elements[i]->ftype));
00116 }
00117 }
00118
00119 return s;
00120 }
|
1.2.3 written by Dimitri van Heesch,
© 1997-2000