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