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