]> andersk Git - splint.git/blame - src/fileloc.c
Committed to enable merge.
[splint.git] / src / fileloc.c
CommitLineData
616915dd 1/*
11db3170 2** Splint - annotation-assisted static program checker
77d37419 3** Copyright (C) 1994-2002 University of Virginia,
616915dd 4** Massachusetts Institute of Technology
5**
6** This program is free software; you can redistribute it and/or modify it
7** under the terms of the GNU General Public License as published by the
8** Free Software Foundation; either version 2 of the License, or (at your
9** option) any later version.
10**
11** This program is distributed in the hope that it will be useful, but
12** WITHOUT ANY WARRANTY; without even the implied warranty of
13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14** General Public License for more details.
15**
16** The GNU General Public License is available from http://www.gnu.org/ or
17** the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18** MA 02111-1307, USA.
19**
155af98d 20** For information on splint: info@splint.org
21** To report a bug: splint-bug@splint.org
11db3170 22** For more information: http://www.splint.org
616915dd 23*/
24/*
25** fileloc.c
26*/
27/*
28 * Modified by Herbert 04/19/97:
29 * - added new include file portab.h.
30 * - added new private function fileloc_filenameForCpp() to handle
31 * filenames belonging to "#line" statements for OS/2 and MSDOS. It
32 * gets called by fileloc_lineMarker() and fileloc_previousLineMarker()
33 * instead of fileloc_unparseFilename().
34 */
35
1b8ae690 36# include "splintMacros.nf"
616915dd 37# include "llbasic.h"
53a89507 38# include "osd.h"
616915dd 39# include "portab.h"
40
41static /*@only@*/ fileloc fileloc_createPrim (flkind p_kind, fileId p_fid, int p_line, int p_col);
42
43static flkind fileId_kind (fileId s)
44{
4dd72714 45 cstring fname = fileTable_rootFileName (s);
616915dd 46
28bf4b0b 47 if (fileLib_isLCLFile (fname))
616915dd 48 {
49 return (FL_SPEC);
50 }
68de3f33 51 else if (cstring_equalPrefix (fname, cstring_makeLiteralTemp (SYSTEM_LIBDIR)))
616915dd 52 {
53 return (FL_STDHDR);
54 }
55 else
56 {
57 return (FL_NORMAL);
58 }
59}
60
61fileloc
62fileloc_decColumn (fileloc f, int x)
63{
64 fileloc ret = fileloc_copy (f);
68de3f33 65
abd7f895 66 llassert (x >= 0);
67
616915dd 68 if (x > 0 && fileloc_isDefined (ret))
69 {
70 llassertprint (ret->column > x, ("decColumn: %d", x));
71 ret->column -= x;
72 }
73
74 return ret;
75}
76
77fileloc
78fileloc_noColumn (fileloc f)
79{
80 if (fileloc_isDefined (f))
81 {
82 fileloc ret = fileloc_copy (f);
83
84 if (fileloc_isDefined (ret))
85 {
86 ret->column = 0;
87 }
88
89 return ret;
90 }
91 else
92 {
93 return fileloc_undefined;
94 }
95}
96
97void
98fileloc_subColumn (fileloc f, int x)
99{
100 if (x > 0 && fileloc_isDefined (f))
101 {
102 llassert (f->column > x);
103 f->column -= x;
104 }
105}
106
107fileloc fileloc_copy (fileloc f)
108{
109 if (fileloc_isDefined (f))
110 {
111 if (fileloc_isBuiltin (f) || fileloc_isExternal (f))
112 {
113 /*
114 ** Legitimate (spurious) errors reported since no copy
115 ** is made.
116 */
117
118 /*@i3@*/ return f; /* No copy is necessary. */
119 }
120 else
121 {
122 return (fileloc_createPrim (f->kind, f->fid, f->lineno, f->column));
123 }
124 }
125 else
126 {
127 return fileloc_undefined;
128 }
129}
130
131fileloc fileloc_update (/*@only@*/ fileloc old, fileloc fnew)
132{
133 if (fileloc_isUndefined (fnew))
134 {
135 fileloc_free (old);
136 return fileloc_undefined;
137 }
138 else if (fileloc_isUndefined (old) || fileloc_isBuiltin (old) || fileloc_isExternal (old))
139 {
140 return (fileloc_copy (fnew));
141 }
142 else
143 {
144 old->kind = fnew->kind;
145 old->fid = fnew->fid;
146 old->lineno = fnew->lineno;
147 old->column = fnew->column;
148
149 return old;
150 }
151}
152
153fileloc fileloc_updateFileId (/*@only@*/ fileloc old, fileId s)
154{
155 if (fileloc_isUndefined (old) || fileloc_isBuiltin (old) || fileloc_isExternal (old))
156 {
157 return (fileloc_create (s, 1, 1));
158 }
159 else
160 {
161 old->kind = fileId_kind (s);
162 old->fid = s;
163 old->lineno = 1;
164 old->column = 1;
165
166 return old;
167 }
168}
169
170void
171fileloc_free (/*@only@*/ fileloc f)
172{
173 if (fileloc_isDefined (f))
174 {
175 if (f != g_currentloc)
176 {
177 if (fileloc_isBuiltin (f) || fileloc_isExternal (f))
178 {
179 ; /* don't free */
180 }
181 else
182 {
ccf0a4a8 183 sfree (f);
616915dd 184 /*@-branchstate@*/
185 }
186 }
187 else
188 {
ccf0a4a8 189 ; /* Don't free g_currentloc ever! */
190 }
616915dd 191 /*@=branchstate@*/
192 }
193}
194
195void
196fileloc_reallyFree (/*@only@*/ fileloc f)
197{
198 if (fileloc_isDefined (f))
199 {
200 if (fileloc_isBuiltin (f) || fileloc_isExternal (f))
201 {
202 ; /* don't free */
203 }
204 else
205 {
206 sfree (f);
207 /*@-branchstate@*/ } /*@=branchstate@*/
208 }
209}
210
211cstring fileloc_getBase (fileloc f)
212{
213 llassert (fileloc_isDefined (f));
214
4dd72714 215 return (fileTable_fileNameBase (f->fid));
616915dd 216}
217
218bool
219fileloc_equal (fileloc f1, fileloc f2)
220{
221 return ((f1 == f2)
222 || (fileloc_isDefined (f1) && fileloc_isDefined (f2)
223 && ((f1->column == f2->column) &&
224 (f1->lineno == f2->lineno) && fileloc_sameFile (f1, f2))));
225}
226
227int
228fileloc_compare (fileloc f1, fileloc f2)
229{
230 if (fileloc_isUndefined (f1))
231 {
232 if (fileloc_isUndefined (f2)) return 0;
233 return -1;
234 }
235
236 if (fileloc_isUndefined (f2))
237 return 1;
238
239 /*@access fileId@*/
240 INTCOMPARERETURN (f1->fid, f2->fid);
241 /*@noaccess fileId@*/
242
f4ec8018 243
244 /* drl 8-11-01 fix what I think is a bug
b7e84605 245 lineno should more important than column number*/
246
247 INTCOMPARERETURN (f1->lineno, f2->lineno);
f4ec8018 248 INTCOMPARERETURN (f1->column, f2->column);
249
616915dd 250 return 0;
251}
252
253bool
254fileloc_withinLines (fileloc f1, fileloc f2, int n)
255{
256
257 return (fileloc_isDefined (f1) &&
258 fileloc_isDefined (f2) &&
259 ((f2->lineno <= f1->lineno + n)
260 && (f2->lineno >= f1->lineno)
261 && fileloc_sameFile (f1, f2)));
262}
263
264bool
265fileloc_lessthan (fileloc f1, fileloc f2)
266{
267 /*@access fileId*/
268 return ((fileloc_isDefined (f1) && fileloc_isDefined (f2))
269 && ((f1->fid < f2->fid)
270 || ((f1->fid == f2->fid)
271 && ((f1->lineno < f2->lineno)
272 || ((f1->lineno == f2->lineno)
273 && (f1->column < f2->column))))));
274 /*@noaccess fileId*/
275}
276
277/*
278** returns true if f1 and f2 are different files,
279** or f1 is before f2 in same file
280*/
281
282bool
283fileloc_notAfter (fileloc f1, fileloc f2)
284{
285 /*@access fileId*/
286 return ((fileloc_isDefined (f1) && fileloc_isDefined (f2))
287 && ((f1->fid != f2->fid)
288 || ((f1->lineno < f2->lineno)
289 || ((f1->lineno == f2->lineno)
290 && (f1->column <= f2->column)))));
291 /*@noaccess fileId@*/
292}
293
294# ifndef NOLCL
295bool
296fileloc_isStandardLibrary (fileloc f)
297{
298 cstring s = fileloc_getBase (f);
299
300 return (cstring_equalLit (s, LLSTDLIBS_NAME)
301 || cstring_equalLit (s, LLSTRICTLIBS_NAME)
302 || cstring_equalLit (s, LLUNIXLIBS_NAME)
303 || cstring_equalLit (s, LLUNIXSTRICTLIBS_NAME)
304 || cstring_equalLit (s, LLPOSIXSTRICTLIBS_NAME)
305 || cstring_equalLit (s, LLPOSIXLIBS_NAME));
306}
307# endif
308
28bf4b0b 309bool
310fileloc_sameFileAndLine (fileloc f1, fileloc f2)
311{
312 return (fileloc_sameFile (f1, f2)
313 && (fileloc_isDefined (f1) && fileloc_isDefined (f2)
314 && f1->lineno == f2->lineno));
315}
316
616915dd 317bool
318fileloc_sameFile (fileloc f1, fileloc f2)
319{
320 if ((fileloc_isUndefined (f1) || (fileloc_isUndefined (f2))
321 || (fileloc_isLib (f1)) || (fileloc_isLib (f2))))
322 {
323 return FALSE;
324 }
325 else
326 {
327 return (fileId_equal (f1->fid, f2->fid));
328 }
329}
330
331bool
332fileloc_sameModule (fileloc f1, fileloc f2)
333{
334 if (fileloc_isUndefined (f1))
335 {
336 return (fileloc_isUndefined (f2));
337 }
338 else if (fileloc_isUndefined (f2))
339 {
340 return (FALSE);
341 }
342 else
343 {
344 if (fileloc_isBuiltin (f1) || fileloc_isBuiltin (f2)
345 || fileloc_isExternal (f1) || fileloc_isExternal (f2))
346 {
347 return fileloc_sameFile (f1, f2);
348 }
349 else
350 {
351 cstring s1 = fileloc_getBase (f1);
352 cstring s2 = fileloc_getBase (f2);
353
2cecdaff 354 return (cstring_equal (s1, s2));
616915dd 355 }
356 }
357}
358
359bool
360fileloc_sameBaseFile (fileloc f1, fileloc f2)
361{
362 if (fileloc_isUndefined (f1))
363 {
364 return (fileloc_isUndefined (f2));
365 }
366 else if (fileloc_isUndefined (f2))
367 {
368 return (FALSE);
369 }
370 else
371 {
372 return (fileId_baseEqual (f1->fid, f2->fid));
373 }
374}
375
376bool fileloc_isSystemFile (fileloc f1)
377{
378 if (fileloc_isDefined (f1)
379 && !fileloc_isBuiltin (f1)
380 && !fileloc_isExternal (f1))
381 {
382 return (fileTable_isSystemFile (context_fileTable (), f1->fid));
383 }
384
385 return FALSE;
386}
387
28bf4b0b 388bool fileloc_isXHFile (fileloc f1)
389{
390 if (fileloc_isDefined (f1)
391 && !fileloc_isBuiltin (f1)
392 && !fileloc_isExternal (f1))
393 {
ccf0a4a8 394 DPRINTF (("Fileloc is XH: [%p] %s", f1, fileloc_unparse (f1)));
28bf4b0b 395 return (fileTable_isXHFile (context_fileTable (), f1->fid));
396 }
397
398 return FALSE;
399}
400
616915dd 401bool
402fileloc_almostSameFile (fileloc f1, fileloc f2)
403{
404 if ((fileloc_isUndefined (f1) || (fileloc_isUndefined (f2))
405 || (fileloc_isLib (f1)) || (fileloc_isLib (f2))))
406 {
407 return FALSE;
408 }
409 else
410 {
411 if (fileId_baseEqual (f1->fid, f2->fid))
412 {
413 return TRUE;
414 }
415 else if (fileTable_isSystemFile (context_fileTable (), f1->fid)
416 || fileTable_isSystemFile (context_fileTable (), f2->fid))
417 {
418 return TRUE;
419 }
420 else if (fileTable_isSpecialFile (context_fileTable (), f1->fid)
421 || fileTable_isSpecialFile (context_fileTable (), f2->fid))
422 {
423 return (cstring_equal (fileloc_getBase (f1),
424 fileloc_getBase (f2)));
425 }
426 else
427 {
428 return FALSE;
429 }
430 }
431}
432
433# ifndef NOLCL
434/*@only@*/ fileloc
435fileloc_fromTok (ltoken t)
436{
437 cstring fname = ltoken_fileName (t);
438 fileId fid = fileTable_lookup (context_fileTable (), fname);
439 fileloc fl;
440
441 if (!fileId_isValid (fid))
442 {
443 fid = fileTable_addLCLFile (context_fileTable (), fname);
444 }
445
446 fl = fileloc_create (fid, (int) ltoken_getLine (t), (int) ltoken_getCol (t));
447
448 return (fl);
449}
450# endif
451
452/*@only@*/ fileloc
453fileloc_createLib (cstring ln)
454{
455 flkind fk = FL_LIB;
456 fileId fid = fileTable_lookup (context_fileTable (), ln);
457
458 if (!fileId_isValid (fid))
459 {
460 fid = fileTable_addLibraryFile (context_fileTable (), ln);
461 }
462
68de3f33 463 if (cstring_equalPrefix (ln, cstring_makeLiteralTemp (SYSTEM_LIBDIR)))
616915dd 464 {
465 fk = FL_STDLIB;
466 }
467
468 return (fileloc_createPrim (fk, fid, 0, 0));
469}
470
471fileloc fileloc_createRc (cstring name)
472{
473 fileId fid = fileTable_addFile (context_fileTable (), name);
474
475 return (fileloc_createPrim (FL_RC, fid, 0, 0));
476}
477
478fileloc fileloc_createExternal (void)
479{
480 /*@i@*/ return (fileloc_getExternal ());
481}
482
483fileloc fileloc_getExternal (void)
484{
485 static /*@owned@*/ fileloc res = fileloc_undefined;
486
487 if (res == fileloc_undefined)
488 {
489 res = fileloc_createPrim (FL_EXTERNAL, fileId_invalid, 0, 0);
490 }
491
492 return res;
493}
494
495fileloc fileloc_observeBuiltin ()
496{
497 /*@-onlytrans@*/ return (fileloc_getBuiltin ()); /*@=onlytrans@*/
498}
499
500fileloc fileloc_getBuiltin ()
501{
502 static /*@owned@*/ fileloc res = fileloc_undefined;
503
504 if (res == fileloc_undefined)
505 {
506 res = fileloc_createPrim (FL_BUILTIN, fileId_invalid, 0, 0);
507 }
508
509 return res;
510}
511
512fileloc
513fileloc_makePreproc (fileloc loc)
514{
515 if (fileloc_isDefined (loc))
516 {
517 return (fileloc_createPrim (FL_PREPROC, loc->fid,
518 loc->lineno, loc->column));
519 }
520
521 return (fileloc_createPrim (FL_PREPROC, fileId_invalid, 0, 0));
522}
523
524fileloc
525fileloc_makePreprocPrevious (fileloc loc)
526{
527 if (fileloc_isDefined (loc))
528 {
529 if (loc->lineno > 1)
530 {
531 return (fileloc_createPrim (FL_PREPROC, loc->fid,
532 loc->lineno - 1, 0));
533 }
534 else
535 {
536 return (fileloc_createPrim (FL_PREPROC, loc->fid,
537 loc->lineno, 0));
538 }
539 }
540
541 return (fileloc_createPrim (FL_PREPROC, fileId_invalid, 0, 0));
542}
543
544/*@only@*/ fileloc
545fileloc_createBuiltin ()
546{
547 return (fileloc_createPrim (FL_BUILTIN, fileId_invalid, 0, 0));
548}
549
550# ifndef NOLCL
551/*@only@*/ fileloc
552fileloc_createImport (cstring fname, int lineno)
553{
554 fileId fid = fileTable_lookup (context_fileTable (), fname);
555
556 if (!fileId_isValid (fid))
557 {
558 fid = fileTable_addImportFile (context_fileTable (), fname);
559 }
560
561 return (fileloc_createPrim (FL_IMPORT, fid, lineno, 0));
562}
563# endif
564
565static /*@only@*/ fileloc
566fileloc_createPrim (flkind kind, fileId fid, int line, int col)
567{
568 fileloc f = (fileloc) dmalloc (sizeof (*f));
569
570 f->kind = kind;
571 f->fid = fid;
572 f->lineno = line;
573 f->column = col;
28bf4b0b 574
ccf0a4a8 575 DPRINTF (("Fileloc create: [%p] %s", f, fileloc_unparse (f)));
616915dd 576 return (f);
577}
578
579# ifndef NOLCL
580/*@only@*/ fileloc
581fileloc_createSpec (fileId fid, int line, int col)
582{
583 return (fileloc_createPrim (FL_SPEC, fid, line, col));
584}
585# endif
586
587fileloc fileloc_create (fileId fid, int line, int col)
588{
589 return (fileloc_createPrim (fileId_kind (fid), fid, line, col));
590}
591
592/*@observer@*/ cstring
593fileloc_filename (fileloc f)
594{
4dd72714 595 return (fileloc_isDefined (f) ? fileTable_rootFileName (f->fid) : cstring_makeLiteralTemp ("<unknown>"));
53a89507 596}
597
598/*@only@*/ cstring fileloc_outputFilename (fileloc f)
599{
600 if (fileloc_isDefined (f))
601 {
140c27a8 602 if (fileId_isValid (f->fid))
603 {
604 return osd_outputPath (fileTable_rootFileName (f->fid));
605 }
606 else
607 {
608 return cstring_makeLiteral ("<invalid>");
609 }
53a89507 610 }
611 else
612 {
613 return cstring_makeLiteral ("<unknown>");
614 }
616915dd 615}
616
617cstring
618fileloc_unparseFilename (fileloc f)
619{
620 if (fileloc_isDefined (f))
621 {
622 switch (f->kind)
623 {
624 case FL_LIB:
53a89507 625 return (message ("load file %q", fileloc_outputFilename (f)));
616915dd 626 case FL_BUILTIN:
627 return (cstring_makeLiteral ("# builtin #"));
628 case FL_IMPORT:
53a89507 629 return (message ("import file %q", fileloc_outputFilename (f)));
616915dd 630 case FL_EXTERNAL:
631 return (cstring_makeLiteral ("<external>"));
632 default:
53a89507 633 return (fileloc_outputFilename (f));
616915dd 634 }
635 }
636 return cstring_undefined;
637}
638
639int
640fileloc_lineno (fileloc f)
641{
642 return (fileloc_isDefined (f) ? f->lineno : -1);
643}
644
645int
646fileloc_column (fileloc f)
647{
648 return (fileloc_isDefined (f) ? f->column : -1);
649}
650
651/*@only@*/ cstring
652fileloc_unparse (fileloc f)
653{
140c27a8 654 static in_funparse = FALSE;
616915dd 655 bool parenFormat = context_getFlag (FLG_PARENFILEFORMAT);
01a8227e 656 bool htmlFormat = context_getFlag (FLG_HTMLFILEFORMAT);
657 cstring res = cstring_undefined;
616915dd 658
140c27a8 659 /* watch out for recursive calls when debugging... */
660 llassert (!in_funparse);
661 in_funparse = TRUE;
662
616915dd 663 if (fileloc_isDefined (f))
664 {
28bf4b0b 665 switch (f->kind)
616915dd 666 {
616915dd 667 case FL_BUILTIN:
140c27a8 668 {
669 res = cstring_makeLiteral ("Command Line");
670 break;
671 }
616915dd 672 case FL_IMPORT:
673 if (parenFormat)
674 {
01a8227e 675 res = message ("import file %q(%d)", fileloc_outputFilename (f), f->lineno);
616915dd 676 }
677 else
678 {
01a8227e 679 res = message ("import file %q:%d", fileloc_outputFilename (f), f->lineno);
616915dd 680 }
01a8227e 681 break;
616915dd 682 case FL_PREPROC:
01a8227e 683 {
684 if (parenFormat)
685 {
686 res = message ("%q(%d)", fileloc_outputFilename (f), f->lineno);
687 }
688 else
689 {
690 res = message ("%q:%d", fileloc_outputFilename (f), f->lineno);
691 }
692
693 break;
694 }
616915dd 695 case FL_EXTERNAL:
01a8227e 696 res = cstring_makeLiteral ("<external>");
697 break;
616915dd 698 default:
28bf4b0b 699 {
700 cstring fname;
53a89507 701
28bf4b0b 702 if (f->kind == FL_LIB)
703 {
53a89507 704 fname = message ("load file %q", fileloc_outputFilename (f));
28bf4b0b 705 }
706 else
707 {
53a89507 708 fname = fileloc_outputFilename (f);
28bf4b0b 709 }
710
711 if (context_getFlag (FLG_SHOWCOL))
712 {
713 if (fileloc_linenoDefined (f))
714 {
715 if (fileloc_columnDefined (f))
716 {
717 if (parenFormat)
718 {
01a8227e 719 res = message ("%q(%d,%d)", fname, f->lineno, f->column);
28bf4b0b 720 }
721 else
722 {
01a8227e 723 res = message ("%q:%d:%d", fname, f->lineno, f->column);
28bf4b0b 724 }
725 }
726 else
727 {
728 if (parenFormat)
729 {
01a8227e 730 res = message ("%q(%d)", fname, f->lineno);
28bf4b0b 731 }
732 else
733 {
01a8227e 734 res = message ("%q:%d", fname, f->lineno);
28bf4b0b 735 }
736 }
737 }
01a8227e 738 else
739 {
740 res = fname;
741 }
28bf4b0b 742 }
743 else if (fileloc_linenoDefined (f))
744 {
745 if (parenFormat)
746 {
01a8227e 747 res = message ("%q(%d)", fname, f->lineno);
28bf4b0b 748 }
749 else
750 {
01a8227e 751 res = message ("%q:%d", fname, f->lineno);
28bf4b0b 752 }
753 }
754 else
755 {
01a8227e 756 res = fname;
28bf4b0b 757 }
758 }
616915dd 759 }
28bf4b0b 760
01a8227e 761 if (htmlFormat && fileloc_linenoDefined (f))
762 {
763 res = message ("<a href=\"#line%d\">%s</a>", f->lineno, res);
764 }
765 }
766 else
767 {
768 res = cstring_makeLiteral ("< Location unknown >");
769 }
140c27a8 770
771 in_funparse = FALSE;
01a8227e 772 return res;
616915dd 773}
774
775/*@only@*/ cstring
776fileloc_unparseRaw (cstring fname, int lineno)
777{
dadc0519 778 if (!cstring_isEmpty (fname))
616915dd 779 {
dadc0519 780 bool parenFormat = context_getFlag (FLG_PARENFILEFORMAT);
781
782 if (parenFormat)
783 {
784 return (message ("%q(%d)", osd_outputPath (fname), lineno));
785 }
786 else
787 {
788 return (message ("%q:%d", osd_outputPath (fname), lineno));
789 }
616915dd 790 }
791 else
792 {
dadc0519 793 return cstring_makeLiteral ("Command Line");
616915dd 794 }
795}
796
797/*@only@*/ cstring
798fileloc_unparseRawCol (cstring fname, int lineno, int col)
799{
dadc0519 800 if (!cstring_isEmpty (fname))
616915dd 801 {
dadc0519 802 if (context_getFlag (FLG_SHOWCOL))
616915dd 803 {
dadc0519 804 bool parenFormat = context_getFlag (FLG_PARENFILEFORMAT);
805
806 if (parenFormat)
807 {
808 return (message ("%q(%d,%d)", osd_outputPath (fname), lineno, col));
809 }
810 else
811 {
812 return (message ("%q:%d:%d", osd_outputPath (fname), lineno, col));
813 }
616915dd 814 }
815 else
816 {
dadc0519 817 return fileloc_unparseRaw (fname, lineno);
616915dd 818 }
819 }
820 else
821 {
dadc0519 822 return cstring_makeLiteral ("Command Line");
616915dd 823 }
824}
825
826bool fileloc_isSpecialFile (fileloc f)
827{
828 if (fileloc_isDefined (f)
829 && fileId_isValid (f->fid))
830 {
831 return (fileTable_isSpecialFile (context_fileTable (), f->fid));
832 }
833 else
834 {
835 return FALSE;
836 }
837}
838
839bool fileloc_isHeader (fileloc f)
840{
841 /* returns true if is not a .c file */
842
843 return (fileloc_isDefined (f) && fileId_isValid (f->fid)
844 && fileId_isHeader (f->fid));
845}
846
847bool fileloc_isSpec (fileloc f)
848{
849 return (fileloc_isDefined (f) &&
850 (f->kind == FL_LIB || f->kind == FL_STDLIB || f->kind == FL_SPEC));
851}
852
853bool fileloc_isRealSpec (fileloc f)
854{
855 return (fileloc_isDefined (f) && (f->kind == FL_SPEC));
856}
857
616915dd 858bool fileloc_isLib (fileloc f)
859{
860 return (fileloc_isDefined (f)
861 && (f->kind == FL_LIB || f->kind == FL_STDHDR || f->kind == FL_STDLIB));
862}
863
864bool fileloc_isStandardLib (fileloc f)
865{
866 return (fileloc_isDefined (f) && f->kind == FL_STDLIB);
867}
868
869/*@only@*/ cstring fileloc_unparseDirect (fileloc fl)
870{
871 if (fileloc_isDefined (fl))
872 {
873 return (message ("%d:%d:%d",
874 /*@access fileId@*/ (int) fl->fid, /*@noaccess fileId@*/
875 fl->lineno, fl->column));
876 }
877 else
878 {
879 return (cstring_makeLiteral ("<undef>"));
880 }
881}
882
883bool fileloc_isUser (fileloc f)
884{
885 return (fileloc_isDefined (f)
886 && f->kind == FL_NORMAL);
887}
888
889
890
891
This page took 0.186006 seconds and 5 git commands to generate.