2 ** Splint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2003 University of Virginia,
4 ** Massachusetts Institute of Technology
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.
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.
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.
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
28 # include "splintMacros.nf"
33 static void rcfiles_loadFile (FILE *p_rcfile, cstringList *p_passThroughArgs)
34 /*@modifies *p_passThroughArgs, p_rcfile@*/
35 /*@ensures closed p_rcfile@*/ ;
37 bool rcfiles_read (cstring fname, cstringList *passThroughArgs, bool report)
41 if (fileTable_exists (context_fileTable (), fname))
47 message ("Multiple attempts to read options file: %s", fname),
53 FILE *innerf = fileTable_openReadFile (context_fileTable (), fname);
57 fileloc fc = g_currentloc;
58 g_currentloc = fileloc_createRc (fname);
60 displayScan (message ("reading options from %q",
61 fileloc_outputFilename (g_currentloc)));
63 rcfiles_loadFile (innerf, passThroughArgs);
64 fileloc_reallyFree (g_currentloc);
74 message ("Cannot open options file: %s", fname),
83 static void rcfiles_loadFile (/*:open:*/ FILE *rcfile, cstringList *passThroughArgs)
85 /*@ensures closed rcfile@*/
87 char *s = mstring_create (MAX_LINE_LENGTH);
89 cstringList args = cstringList_new ();
91 DPRINTF (("Loading rc file..."));
95 while (reader_readLine (rcfile, s, MAX_LINE_LENGTH) != NULL)
99 DPRINTF (("Line: %s", s));
100 DPRINTF (("args: %s", cstringList_unparse (args)));
102 while (*s == ' ' || *s == '\t')
111 bool escaped = FALSE;
115 /* comment characters */
116 if (c == '#' || c == ';' || c == '\n')
124 while ((c = *s) != '\0')
125 { /* remember to handle spaces and quotes in -D and -U ... */
151 if (c == ' ' || c == '\t' || c == '\n')
153 /*@innerbreak@*/ break;
161 DPRINTF (("Nulling: %c", *s));
164 if (mstring_isEmpty (thisflag))
166 llfatalerror (message ("Missing flag: %s",
167 cstring_fromChars (os)));
171 args = cstringList_add (args, cstring_fromCharsNew (thisflag));
172 DPRINTF (("args: %s", cstringList_unparse (args)));
176 DPRINTF (("Pass through: %s", cstringList_unparse (*passThroughArgs)));
178 while ((c == ' ') || (c == '\t'))
190 DPRINTF (("args: %s", cstringList_unparse (args)));
191 flags_processFlags (FALSE,
192 fileIdList_undefined,
193 fileIdList_undefined,
194 fileIdList_undefined,
195 fileIdList_undefined,
197 cstringList_size (args),
198 cstringList_getElements (args));
199 cstringList_free (args);
200 check (fileTable_closeFile (context_fileTable (), rcfile));