]> andersk Git - splint.git/blob - src/fileloc.c
151d7dddee9e27caa561c865c62208c6049f32bd
[splint.git] / src / fileloc.c
1 /*
2 ** Splint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2002 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 "llbasic.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 static flkind fileId_kind (fileId s)
44 {
45   cstring fname = fileTable_rootFileName (s);
46   
47   if (fileLib_isLCLFile (fname))
48     {
49       return (FL_SPEC);
50     }
51   else if (cstring_equalPrefix (fname, cstring_makeLiteralTemp (SYSTEM_LIBDIR)))
52     {
53       return (FL_STDHDR); 
54     }
55   else
56     {
57       return (FL_NORMAL);
58     }
59 }  
60
61 fileloc
62 fileloc_decColumn (fileloc f, int x)
63 {
64   fileloc ret = fileloc_copy (f);
65
66   llassert (x >= 0);
67
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
77 fileloc
78 fileloc_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
97 void
98 fileloc_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
107 fileloc 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
131 fileloc 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
153 fileloc 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
170 void
171 fileloc_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             {
183               sfree (f);  
184               /*@-branchstate@*/ 
185             } 
186         }
187       else
188         {
189           ; /* Don't free g_currentloc ever! */
190         }
191       /*@=branchstate@*/
192     }
193 }
194
195 void
196 fileloc_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
211 cstring fileloc_getBase (fileloc f)
212 {
213   llassert (fileloc_isDefined (f));
214
215   return (fileTable_fileNameBase (f->fid));
216 }
217
218 bool
219 fileloc_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
227 int
228 fileloc_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
243
244   /* drl 8-11-01 fix what I think is a bug
245      lineno should more important than column number*/
246
247   INTCOMPARERETURN (f1->lineno, f2->lineno);   
248   INTCOMPARERETURN (f1->column, f2->column);
249   
250   return 0;
251 }
252
253 bool
254 fileloc_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
264 bool
265 fileloc_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
282 bool
283 fileloc_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
295 bool
296 fileloc_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
309 bool
310 fileloc_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
317 bool
318 fileloc_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
331 bool
332 fileloc_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           
354           return (cstring_equal (s1, s2)); 
355         }
356     }
357 }
358
359 bool
360 fileloc_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
376 bool 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
388 bool fileloc_isXHFile (fileloc f1)
389 {
390   if (fileloc_isDefined (f1)
391       && !fileloc_isBuiltin (f1)
392       && !fileloc_isExternal (f1))
393     {
394       DPRINTF (("Fileloc is XH: [%p] %s", f1, fileloc_unparse (f1)));
395       return (fileTable_isXHFile (context_fileTable (), f1->fid));
396     }
397   
398   return FALSE;
399 }
400
401 bool
402 fileloc_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
435 fileloc_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
453 fileloc_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
463   if (cstring_equalPrefix (ln, cstring_makeLiteralTemp (SYSTEM_LIBDIR)))
464     {
465       fk = FL_STDLIB;
466     }
467
468   return (fileloc_createPrim (fk, fid, 0, 0));
469 }
470
471 fileloc 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
478 fileloc fileloc_createExternal (void)
479 {
480   /*@i@*/ return (fileloc_getExternal ()); 
481 }
482
483 fileloc 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
495 fileloc fileloc_observeBuiltin ()
496 {
497   /*@-onlytrans@*/ return (fileloc_getBuiltin ()); /*@=onlytrans@*/
498 }
499
500 fileloc 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
512 fileloc
513 fileloc_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
524 fileloc
525 fileloc_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
545 fileloc_createBuiltin ()
546 {
547   return (fileloc_createPrim (FL_BUILTIN, fileId_invalid, 0, 0)); 
548 }
549
550 # ifndef NOLCL
551 /*@only@*/ fileloc
552 fileloc_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
565 static /*@only@*/ fileloc
566 fileloc_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;
574
575   DPRINTF (("Fileloc create: [%p] %s", f, fileloc_unparse (f)));
576   return (f);
577 }
578
579 # ifndef NOLCL
580 /*@only@*/ fileloc
581 fileloc_createSpec (fileId fid, int line, int col)
582 {
583   return (fileloc_createPrim (FL_SPEC, fid, line, col));
584 }
585 # endif
586
587 fileloc fileloc_create (fileId fid, int line, int col)
588 {
589   return (fileloc_createPrim (fileId_kind (fid), fid, line, col));
590 }
591
592 /*@observer@*/ cstring
593 fileloc_filename (fileloc f)
594 {
595   return (fileloc_isDefined (f) ? fileTable_rootFileName (f->fid) : cstring_makeLiteralTemp ("<unknown>"));
596 }
597
598 /*@only@*/ cstring fileloc_outputFilename (fileloc f)
599 {
600   if (fileloc_isDefined (f))
601     {
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         }
610     }
611   else
612     {
613       return cstring_makeLiteral ("<unknown>");
614     }
615 }
616
617 cstring
618 fileloc_unparseFilename (fileloc f)
619 {
620   if (fileloc_isDefined (f))
621     {
622       switch (f->kind)
623         {
624         case FL_LIB:
625           return (message ("load file %q", fileloc_outputFilename (f)));
626         case FL_BUILTIN:
627           return (cstring_makeLiteral ("# builtin #"));
628         case FL_IMPORT:
629           return (message ("import file %q", fileloc_outputFilename (f)));
630         case FL_EXTERNAL:
631           return (cstring_makeLiteral ("<external>"));
632         default: 
633           return (fileloc_outputFilename (f));
634         }
635     }
636   return cstring_undefined;
637 }
638
639 int
640 fileloc_lineno (fileloc f)
641 {
642   return (fileloc_isDefined (f) ? f->lineno : -1);
643 }
644
645 int
646 fileloc_column (fileloc f)
647 {
648   return (fileloc_isDefined (f) ? f->column : -1);
649 }
650
651 /*@only@*/ cstring
652 fileloc_unparse (fileloc f)
653 {
654   static in_funparse = FALSE;
655   bool parenFormat = context_getFlag (FLG_PARENFILEFORMAT); 
656   bool htmlFormat = context_getFlag (FLG_HTMLFILEFORMAT);
657   cstring res = cstring_undefined;
658
659   /* watch out for recursive calls when debugging... */
660   llassert (!in_funparse);
661   in_funparse = TRUE;
662
663   if (fileloc_isDefined (f))
664     {
665        switch (f->kind)
666         {
667         case FL_BUILTIN:
668           {
669             res = cstring_makeLiteral ("Command Line");
670             break;
671           }
672         case FL_IMPORT:
673           if (parenFormat)
674             {
675               res = message ("import file %q(%d)", fileloc_outputFilename (f), f->lineno);
676             }
677           else
678             {
679               res = message ("import file %q:%d", fileloc_outputFilename (f), f->lineno);
680             }
681           break;
682         case FL_PREPROC:
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           }
695         case FL_EXTERNAL:
696           res = cstring_makeLiteral ("<external>");
697           break;
698         default:
699           {
700             cstring fname;
701             
702             if (f->kind == FL_LIB)
703               {
704                 fname = message ("load file %q", fileloc_outputFilename (f));
705
706                 if (!context_getFlag (FLG_SHOWLOADLOC))
707                   {
708                     res = fname;
709                     break;
710                   }
711               }
712             else
713               {
714                 fname = fileloc_outputFilename (f);
715               }
716
717             if (context_getFlag (FLG_SHOWCOL))
718               {
719                 if (fileloc_linenoDefined (f))
720                   {
721                     if (fileloc_columnDefined (f))
722                       {
723                         if (parenFormat)
724                           {
725                             res = message ("%q(%d,%d)", fname, f->lineno, f->column);
726                           }
727                         else
728                           {
729                             res = message ("%q:%d:%d", fname, f->lineno, f->column);
730                           }
731                       }
732                     else
733                       {
734                         if (parenFormat)
735                           {
736                             res = message ("%q(%d)", fname, f->lineno);
737                           }
738                         else
739                           {
740                             res = message ("%q:%d", fname, f->lineno);
741                           }
742                       }
743                   }
744                 else
745                   {
746                     res = fname;
747                     /*@-branchstate@*/ /* spurious warnings reporteded because of break above */
748                   }
749               }
750             else if (fileloc_linenoDefined (f))
751               {
752                 if (parenFormat)
753                   {
754                     res = message ("%q(%d)", fname, f->lineno);
755                   }
756                 else
757                   {
758                     res = message ("%q:%d", fname, f->lineno);
759                   }
760               }
761             else
762               {
763                 res = fname;
764               }
765           }
766         }
767
768        if (htmlFormat && fileloc_linenoDefined (f))
769          {
770            res = message ("<a href=\"#line%d\">%s</a>", f->lineno, res);
771          }
772     }
773   else
774     {
775       res = cstring_makeLiteral ("< Location unknown >");
776     }
777   /*@=branchstate@*/ /*@i2523 this is a spurious warning because of the break */
778   
779   in_funparse = FALSE;
780   return res;
781 }
782
783 /*@only@*/ cstring
784 fileloc_unparseRaw (cstring fname, int lineno)
785 {
786   if (!cstring_isEmpty (fname))
787     {
788       bool parenFormat = context_getFlag (FLG_PARENFILEFORMAT); 
789       
790       if (parenFormat)
791         {
792           return (message ("%q(%d)", osd_outputPath (fname), lineno));
793         }
794       else
795         {
796           return (message ("%q:%d", osd_outputPath (fname), lineno));
797         }
798     }
799   else
800     {
801       return cstring_makeLiteral ("Command Line");
802     }
803 }
804
805 /*@only@*/ cstring
806 fileloc_unparseRawCol (cstring fname, int lineno, int col)
807 {
808   if (!cstring_isEmpty (fname))
809     {
810       if (context_getFlag (FLG_SHOWCOL)) 
811         {
812           bool parenFormat = context_getFlag (FLG_PARENFILEFORMAT); 
813           
814           if (parenFormat)
815             {
816               return (message ("%q(%d,%d)", osd_outputPath (fname), lineno, col));
817             }
818           else
819             {
820               return (message ("%q:%d:%d", osd_outputPath (fname), lineno, col));
821             }
822         }
823       else
824         {
825           return fileloc_unparseRaw (fname, lineno);
826         }
827     }
828   else
829     {
830       return cstring_makeLiteral ("Command Line");
831     }
832 }
833
834 bool fileloc_isSpecialFile (fileloc f)
835 {
836   if (fileloc_isDefined (f) 
837       && fileId_isValid (f->fid))
838     {
839       return (fileTable_isSpecialFile (context_fileTable (), f->fid));
840     }
841   else
842     {
843       return FALSE;
844     }
845 }
846
847 bool fileloc_isHeader (fileloc f)
848 {
849   /* returns true if is not a .c file */
850
851   return (fileloc_isDefined (f) && fileId_isValid (f->fid)
852           && fileId_isHeader (f->fid));
853 }
854
855 bool fileloc_isSpec (fileloc f)
856 {
857   return (fileloc_isDefined (f) && 
858           (f->kind == FL_LIB || f->kind == FL_STDLIB || f->kind == FL_SPEC));
859 }
860
861 bool fileloc_isRealSpec (fileloc f)
862 {
863   return (fileloc_isDefined (f) && (f->kind == FL_SPEC));
864 }
865
866 bool fileloc_isLib (fileloc f)
867 {
868   return (fileloc_isDefined (f) 
869           && (f->kind == FL_LIB || f->kind == FL_STDHDR || f->kind == FL_STDLIB));
870 }
871
872 bool fileloc_isStandardLib (fileloc f)
873 {
874   return (fileloc_isDefined (f) && f->kind == FL_STDLIB);
875 }
876
877 /*@only@*/ cstring fileloc_unparseDirect (fileloc fl)
878 {
879   if (fileloc_isDefined (fl))
880     {
881       return (message ("%d:%d:%d",
882                        /*@access fileId@*/ (int) fl->fid, /*@noaccess fileId@*/
883                        fl->lineno, fl->column));
884     }
885   else
886     {
887       return (cstring_makeLiteral ("<undef>"));
888     }
889 }
890
891 bool fileloc_isUser (fileloc f)
892 {
893   return (fileloc_isDefined (f) 
894           && f->kind == FL_NORMAL);
895 }
896
897
898
899
This page took 0.117898 seconds and 3 git commands to generate.