2 ** Splint - annotation-assisted static program checker
3 ** Copyright (C) 1994-2002 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
27 ** Main module for Splint annotation-assisted program checker
33 ** Ensure that WIN32 and _WIN32 are both defined or both undefined.
38 # error "Inconsistent definitions."
42 # error "Inconsistent definitions."
51 # include "splintMacros.nf"
59 # include "scanline.h"
60 # include "lclscanline.h"
61 # include "lclsyntable.h"
62 # include "lcltokentable.h"
63 # include "lslparse.h"
65 # include "syntable.h"
66 # include "tokentable.h"
73 # include "Headers/version.h" /* Visual C++ finds the wrong version.h */
75 # include "cgrammar.h"
80 extern /*@external@*/ int yydebug;
81 static void cleanupFiles (void);
82 static void interrupt (int p_i);
84 static void describeVars (void);
85 static bool specialFlagsHelp (char *p_next);
86 static bool hasShownHerald = FALSE;
87 static char *specFullName (char *p_specfile, /*@out@*/ char **p_inpath)
88 /*@modifies *p_inpath@*/ ;
90 static bool anylcl = FALSE;
91 static clock_t inittime;
93 static fileIdList preprocessFiles (fileIdList, bool)
94 /*@modifies fileSystem@*/ ;
96 static void warnSysFiles(fileIdList p_files) /*@modifies fileSystem@*/;
101 void lslCleanup (void)
102 /*@globals killed g_symtab@*/
103 /*@modifies internalState, g_symtab@*/
106 ** Cleanup all the LCL/LSL.
109 static bool didCleanup = FALSE;
111 llassert (!didCleanup);
116 lsymbol_destroyMod ();
117 LCLSynTableCleanup ();
118 LCLTokenTableCleanup ();
119 LCLScanLineCleanup ();
122 /* clean up LSL parsing */
125 ltokenTableCleanup ();
129 symtable_free (g_symtab);
134 lslProcess (fileIdList lclfiles)
135 /*@globals undef g_currentSpec, undef g_currentSpecName, g_currentloc,
136 undef killed g_symtab; @*/
137 /*@modifies g_currentSpec, g_currentSpecName, g_currentloc, internalState, fileSystem; @*/
140 bool parser_status = FALSE;
141 bool overallStatus = FALSE;
146 context_resetSpecLines ();
148 fileIdList_elements (lclfiles, fid)
150 cstring actualName = cstring_undefined;
151 cstring fname = fileTable_fileName (fid);
153 if (osd_getPath (cstring_fromChars (g_localSpecPath),
154 fname, &actualName) == OSD_FILENOTFOUND)
156 if (mstring_equal (g_localSpecPath, "."))
158 lldiagmsg (message ("Spec file not found: %q", osd_outputPath (fname)));
162 lldiagmsg (message ("Spec file not found: %q (on %s)",
163 osd_outputPath (fname),
164 cstring_fromChars (g_localSpecPath)));
169 inputStream specFile;
171 char *namePtr = actualName;
173 while (*namePtr == '.' && *(namePtr + 1) == CONNECTCHAR)
177 /*@noaccess cstring@*/
179 g_currentSpec = cstring_fromCharsNew (namePtr);
181 specFile = inputStream_create (cstring_copy (g_currentSpec),
182 LCL_EXTENSION, TRUE);
184 llassert (inputStream_isDefined (specFile));
186 g_currentSpecName = specFullName
187 (cstring_toCharsSafe (g_currentSpec),
192 displayScan (message ("reading spec %s", g_currentSpec));
194 /* Open the source file */
196 if (!inputStream_open (specFile))
198 lldiagmsg (message ("Cannot open file: %q",
199 osd_outputPath (inputStream_fileName (specFile))));
200 inputStream_free (specFile);
204 scopeInfo dummy_scope = (scopeInfo) dmalloc (sizeof (*dummy_scope));
205 dummy_scope->kind = SPE_INVALID;
208 LCLScanReset (specFile);
211 ** Minor hacks to allow more than one LCL file to
212 ** be scanned, while keeping initializations
215 symtable_enterScope (g_symtab, dummy_scope);
216 resetImports (cstring_fromChars (g_currentSpecName));
217 context_enterLCLfile ();
218 (void) lclHadNewError ();
220 parser_status = (ylparse () != 0);
221 context_exitLCLfile ();
223 overallStatus = parser_status || lclHadNewError ();
225 if (context_getFlag (FLG_DOLCS))
229 outputLCSFile (path, "%FAILED Output from ",
234 outputLCSFile (path, "%PASSED Output from ",
239 (void) inputStream_close (specFile);
240 inputStream_free (specFile);
242 symtable_exitScope (g_symtab);
245 cstring_free (actualName);
246 } end_fileIdList_elements;
248 /* Can cleanup lsl stuff right away */
252 g_currentSpec = cstring_undefined;
253 g_currentSpecName = NULL;
257 static void handlePassThroughFlag (char *arg)
260 char *quotechar = strchr (curarg, '\"');
263 char *freearg = NULL;
265 while (quotechar != NULL)
267 if (*(quotechar - 1) == '\\')
269 char *tp = quotechar - 2;
280 curarg = quotechar + 1;
281 quotechar = strchr (curarg, '\"');
286 llassert (quotechar != NULL);
288 offset = (quotechar - arg) + 2;
292 arg = cstring_toCharsSafe
293 (message ("%s\"\'%s",
294 cstring_fromChars (arg),
295 cstring_fromChars (quotechar + 1)));
301 arg = cstring_toCharsSafe
302 (message ("%s\'\"%s",
303 cstring_fromChars (arg),
304 cstring_fromChars (quotechar + 1)));
309 curarg = arg + offset;
310 quotechar = strchr (curarg, '\"');
316 voptgenerror (FLG_BADFLAG,
317 message ("Unclosed quote in flag: %s",
318 cstring_fromChars (arg)),
327 ** If the value is surrounded by single quotes ('), remove
328 ** them. This is an artifact of UNIX command line?
331 def = osd_fixDefine (cstring_fromChars (arg + 1));
332 DPRINTF (("Do define: %s", def));
334 DPRINTF (("After define"));
336 } else if (arg[0] == 'U') {
337 cppDoUndefine (cstring_fromChars (arg + 1));
346 void showHerald (void)
348 if (hasShownHerald || context_getFlag (FLG_QUIET))
354 fprintf (g_messagestream, "%s\n\n", SPLINT_VERSION);
355 hasShownHerald = TRUE;
361 ** Disable MSVC++ warning about return value. Methinks humbly splint control
362 ** comments are a mite more legible.
366 # pragma warning (disable:4035)
369 int main (int argc, char *argv[])
371 /*@globals killed undef g_currentloc,
373 undef g_warningstream, g_messagestream, g_errorstream;
375 /*@modifies g_currentloc, fileSystem,
379 /*@globals killed undef g_currentloc,
380 killed g_localSpecPath,
381 killed undef g_currentSpec,
382 killed undef g_currentSpecName,
384 undef g_warningstream, g_messagestream, g_errorstream;
386 /*@modifies g_currentloc, g_localSpecPath, g_currentSpec, g_currentSpecName,
391 bool first_time = TRUE;
393 inputStream sourceFile = inputStream_undefined;
395 fileIdList dercfiles;
396 cstringSList passThroughArgs = cstringSList_undefined;
397 fileIdList cfiles, xfiles, lclfiles, mtfiles;
398 clock_t before, lcltime, libtime, pptime, cptime, rstime;
402 _wildcard (&argc, &argv);
405 g_warningstream = stdout;
406 g_messagestream = stderr;
407 g_errorstream = stderr;
409 (void) signal (SIGINT, interrupt);
410 (void) signal (SIGSEGV, interrupt);
413 clabstract_initMod ();
414 typeIdSet_initMod ();
415 cppReader_initMod ();
420 g_currentloc = fileloc_createBuiltin ();
425 context_setInCommandLine ();
429 help_showAvailableHelp ();
433 /* -help must be the first flag to get help */
434 if (flagcode_isHelpFlag (flags_identifyFlag (cstring_fromChars (argv[1]))))
437 ** Skip first flag and help flag
440 help_processFlags (argc - 2, argv + 2);
448 ** Add include directories from environment.
452 cstring incval = cstring_copy (osd_getEnvironmentVariable (INCLUDEPATH_VAR));
453 cstring oincval = incval;
455 if (cstring_isDefined (incval))
458 ** Each directory on the include path is a system include directory.
461 DPRINTF (("include: %s", incval));
462 context_setString (FLG_SYSTEMDIRS, cstring_copy (incval));
464 while (cstring_isDefined (incval))
467 char *nextsep = strchr (incval, PATH_SEPARATOR);
473 dir = cstring_copy (incval);
475 if (cstring_length (dir) == 0
476 || !isalpha ((int) cstring_firstChar (dir)))
479 ** win32 environment values can have special values,
485 cppAddIncludeDir (dir);
488 *nextsep = PATH_SEPARATOR;
489 incval = cstring_fromChars (nextsep + 1);
497 /*@noaccess cstring@*/
500 else /* 2001-09-09: herbert */
502 /* Put C_INCLUDE_PATH directories in sysdirs */
503 cstring cincval = osd_getEnvironmentVariable (cstring_makeLiteralTemp ("C_INCLUDE_PATH"));
505 if (cstring_isDefined (cincval))
507 context_setString (FLG_SYSTEMDIRS, cstring_copy (cincval));
512 cstring_free (oincval);
516 ** check RCFILE for default flags
520 ** Process command line message formatting flags before reading rc file
524 cstring home = osd_getHomeDir ();
525 cstring fname = cstring_undefined;
526 bool defaultf = TRUE;
529 for (i = 1; i < argc; i++)
534 if (*thisarg == '-' || *thisarg == '+')
536 bool set = (*thisarg == '+');
542 ** Don't report warnings this time
545 opt = flags_identifyFlagQuiet (cstring_fromChars (thisarg));
551 else if (flagcode_isMessageControlFlag (opt))
554 ** Need to set it immediately, so rc file scan is displayed
557 context_userSetFlag (opt, set);
559 if (flagcode_hasArgument (opt))
561 llassert (flagcode_hasString (opt));
565 fname = cstring_fromChars (argv[i]);
566 setStringFlag (opt, fname);
573 ("Flag %s must be followed by a string",
574 flagcode_unparse (opt)),
579 else if (opt == FLG_OPTF)
584 fname = cstring_fromChars (argv[i]);
585 (void) rcfiles_read (fname, &passThroughArgs, TRUE);
589 (cstring_makeLiteral ("Flag f to select options file "
590 "requires an argument"));
594 ; /* wait to process later */
601 if (!nof && defaultf)
604 ** No explicit rc file, first try reading ~/.splintrc
607 if (cstring_isUndefined (fname))
609 if (!cstring_isEmpty (home))
611 bool readhomerc, readaltrc;
612 cstring homename, altname;
614 homename = message ("%s%h%s", home, CONNECTCHAR,
615 cstring_fromChars (RCFILE));
616 readhomerc = rcfiles_read (homename, &passThroughArgs, FALSE);
619 ** Try ~/.splintrc also for historical accuracy
622 altname = message ("%s%h%s", home, CONNECTCHAR,
623 cstring_fromChars (ALTRCFILE));
624 readaltrc = rcfiles_read (altname, &passThroughArgs, FALSE);
626 if (readhomerc && readaltrc)
631 message ("Found both %s and %s files. Using both files, "
632 "but recommend using only %s to avoid confusion.",
633 homename, altname, homename),
637 cstring_free (homename);
638 cstring_free (altname);
643 ** Next, read .splintrc in the current working directory
647 cstring rcname = message ("%s%s",osd_getCurrentDirectory (), cstring_fromChars (RCFILE));
648 cstring altname = message ("%s%s",osd_getCurrentDirectory (), cstring_fromChars (ALTRCFILE));
649 bool readrc, readaltrc;
651 readrc = rcfiles_read (rcname, &passThroughArgs, FALSE);
652 readaltrc = rcfiles_read (altname, &passThroughArgs, FALSE);
654 if (readrc && readaltrc)
656 voptgenerror (FLG_WARNRC,
657 message ("Found both %s and %s files. Using both files, "
658 "but recommend using only %s to avoid confusion.",
659 rcname, altname, rcname),
664 cstring_free (rcname);
665 cstring_free (altname);
671 llassert (fileloc_isBuiltin (g_currentloc));
673 cfiles = fileIdList_create ();
674 xfiles = fileIdList_create ();
675 lclfiles = fileIdList_create ();
676 mtfiles = fileIdList_create ();
678 /* argv[0] is the program name, don't pass it to flags_processFlags */
679 flags_processFlags (TRUE, xfiles, cfiles,
692 context_resetErrors ();
693 context_clearInCommandLine ();
695 anylcl = !fileIdList_isEmpty (lclfiles);
697 if (context_doMerge ())
699 cstring m = context_getMerge ();
701 displayScanOpen (message ("< loading %s ", m));
705 if (!usymtab_existsType (context_getBoolName ()))
712 if (!context_getFlag (FLG_NOLIB) && loadStandardState ())
721 /* setup bool type and constants */
725 fileloc_free (g_currentloc);
726 g_currentloc = fileloc_createBuiltin ();
729 ** Read metastate files (must happen before loading libraries)
732 fileIdList_elements (mtfiles, mtfile)
734 context_setFileId (mtfile);
735 displayScan (message ("processing %s", fileTable_rootFileName (mtfile)));
736 mtreader_readFile (cstring_copy (fileTable_fileName (mtfile)));
737 } end_fileIdList_elements;
744 llfatalerror (cstring_makeLiteral ("This version of Splint does not handle LCL files."));
746 lslProcess (lclfiles);
750 usymtab_initGlobalMarker ();
755 ** call the pre-preprocessor and /lib/cpp to generate appropriate
760 context_setInCommandLine ();
762 DPRINTF (("Pass through: %s", cstringSList_unparse (passThroughArgs)));
764 cstringSList_elements (passThroughArgs, thisarg)
766 handlePassThroughFlag (cstring_toCharsSafe (thisarg));
768 end_cstringSList_elements;
770 cstringSList_free (passThroughArgs);
774 DPRINTF (("Initializing cpp reader!"));
775 cppReader_initialize ();
776 cppReader_saveDefinitions ();
778 context_clearInCommandLine ();
780 if (!context_getFlag (FLG_NOPP))
786 displayScanOpen (cstring_makeLiteral ("preprocessing"));
790 context_setPreprocessing ();
791 dercfiles = preprocessFiles (xfiles, TRUE);
792 tfiles = preprocessFiles (cfiles, FALSE);
793 warnSysFiles(cfiles);
794 dercfiles = fileIdList_append (dercfiles, tfiles);
795 fileIdList_free (tfiles);
797 context_clearPreprocessing ();
799 fileIdList_free (cfiles);
807 dercfiles = fileIdList_append (cfiles, xfiles);
812 ** now, check all the corresponding C files
814 ** (for now these are just <file>.c, but after pre-processing
815 ** will be <tmpprefix>.<file>.c)
820 int nfiles = /*@-unrecog@*/ _fcloseall (); /*@=unrecog@*/
824 llbug (message ("Files unclosed: %d", nfiles));
829 DPRINTF (("Initializing..."));
833 DPRINTF (("Okay..."));
835 fileIdList_elements (dercfiles, fid)
837 sourceFile = inputStream_create (cstring_copy (fileTable_fileName (fid)), C_EXTENSION, TRUE);
838 context_setFileId (fid);
840 /* Open source file */
842 if (inputStream_isUndefined (sourceFile) || (!inputStream_open (sourceFile)))
844 /* previously, this was ignored ?! */
845 llbug (message ("Could not open temp file: %s", fileTable_fileName (fid)));
849 yyin = inputStream_getFile (sourceFile); /*< shared <- only */
851 llassert (yyin != NULL);
853 displayScan (message ("checking %q", osd_outputPath (fileTable_rootFileName (fid))));
856 ** Every time, except the first time, through the loop,
857 ** need to call yyrestart to clean up the parse buffer.
862 (void) yyrestart (yyin);
869 DPRINTF (("Entering..."));
870 context_enterFile ();
872 context_exitCFile ();
874 (void) inputStream_close (sourceFile);
876 } end_fileIdList_elements;
880 /* process any leftover macros */
882 context_processAllMacros ();
884 /* check everything that was specified was defined */
886 /* don't check if no c files were processed ?
887 ** is this correct behaviour?
890 displayScan (cstring_makeLiteral ("global checks"));
894 if (context_getLinesProcessed () > 0)
896 usymtab_allDefined ();
899 if (context_maybeSet (FLG_TOPUNUSED))
901 uentry ue = usymtab_lookupSafe (cstring_makeLiteralTemp ("main"));
903 if (uentry_isValid (ue))
905 uentry_setUsed (ue, fileloc_observeBuiltin ());
911 if (context_maybeSet (FLG_EXPORTLOCAL))
913 usymtab_exportLocal ();
917 if (context_maybeSet (FLG_EXPORTHEADER))
919 usymtab_exportHeader ();
922 if (context_getFlag (FLG_SHOWUSES))
924 usymtab_displayAllUses ();
927 context_checkSuppressCounts ();
929 if (context_doDump ())
931 cstring dump = context_getDump ();
942 if (context_getFlag (FLG_SHOWSUMMARY))
949 bool isQuiet = context_getFlag (FLG_QUIET);
950 cstring specErrors = cstring_undefined;
952 int nspecErrors = lclNumberErrors ();
957 if (context_neednl ())
958 fprintf (g_warningstream, "\n");
963 if (nspecErrors == context_getLCLExpect ())
966 message ("%d spec warning%&, as expected\n ",
971 if (context_getLCLExpect () > 0)
974 message ("%d spec warning%&, expected %d\n ",
976 (int) context_getLCLExpect ());
980 specErrors = message ("%d spec warning%&\n ",
988 if (context_getLCLExpect () > 0)
990 specErrors = message ("No spec warnings, expected %d\n ",
991 (int) context_getLCLExpect ());
997 if (context_anyErrors ())
999 if (context_numErrors () == context_getExpect ())
1002 llmsg (message ("Finished checking --- "
1003 "%s%d code warning%&, as expected",
1004 specErrors, context_numErrors ()));
1009 if (context_getExpect () > 0)
1013 ("Finished checking --- "
1014 "%s%d code warning%&, expected %d",
1015 specErrors, context_numErrors (),
1016 (int) context_getExpect ()));
1026 llmsg (message ("Finished checking --- "
1027 "%s%d code warning%&",
1028 specErrors, context_numErrors ()));
1037 if (context_getExpect () > 0)
1041 ("Finished checking --- "
1042 "%sno code warnings, expected %d",
1044 (int) context_getExpect ()));
1051 if (context_getLinesProcessed () > 0)
1053 if (cstring_isEmpty (specErrors))
1057 llmsg (message ("Finished checking --- no warnings"));
1064 llmsg (message ("Finished checking --- %sno code warnings",
1072 llmsg (message ("Finished checking --- %sno code processed",
1079 cstring_free (specErrors);
1082 if (context_getFlag (FLG_STATS))
1084 clock_t ttime = clock () - before;
1085 int specLines = context_getSpecLinesProcessed ();
1086 cstring specmsg = cstring_undefined;
1092 specmsg = message ("%d spec, ", specLines);
1095 # ifndef CLOCKS_PER_SEC
1096 lldiagmsg (message ("%s%d source lines in %d time steps (steps/sec unknown)\n",
1098 context_getLinesProcessed (),
1101 lldiagmsg (message ("%s%d source lines in %f s.\n",
1103 context_getLinesProcessed (),
1104 (double) ttime / CLOCKS_PER_SEC));
1112 if (context_getFlag (FLG_TIMEDIST))
1114 clock_t ttime = clock () - before;
1118 char *msg = (char *) dmalloc (256 * sizeof (*msg));
1123 "Time distribution (percent): initialize %.2f / lcl %.2f / "
1124 "pre-process %.2f / c check %.2f / finalize %.2f \n",
1125 (100.0 * (double) (libtime - before) / ttime),
1126 (100.0 * (double) (lcltime - libtime) / ttime),
1127 (100.0 * (double) (pptime - lcltime) / ttime),
1128 (100.0 * (double) (cptime - pptime) / ttime),
1129 (100.0 * (double) (rstime - cptime) / ttime));
1134 "Time distribution (percent): initialize %.2f / "
1135 "pre-process %.2f / c check %.2f / finalize %.2f \n",
1136 (100.0 * (double) (libtime - before) / ttime),
1137 (100.0 * (double) (pptime - libtime) / ttime),
1138 (100.0 * (double) (cptime - pptime) / ttime),
1139 (100.0 * (double) (rstime - cptime) / ttime));
1142 llgenindentmsgnoloc (cstring_fromCharsO (msg));
1146 llexit (expsuccess ? LLSUCCESS : LLFAILURE);
1147 BADBRANCHRET (LLFAILURE);
1152 ** Reenable return value warnings.
1154 # pragma warning (default:4035)
1163 fprintf (g_errorstream, "*** Interrupt\n");
1164 llexit (LLINTERRUPT);
1169 /* Cheat when there are parse errors */
1172 fprintf (g_errorstream, "*** Segmentation Violation\n");
1174 /* Don't catch it if fileloc_unparse causes a signal */
1175 (void) signal (SIGSEGV, NULL);
1177 loc = fileloc_unparse (g_currentloc);
1179 fprintf (g_errorstream, "*** Location (not trusted): %s\n",
1180 cstring_toCharsSafe (loc));
1183 fprintf (g_errorstream, "*** Please report bug to %s\n", SPLINT_MAINTAINER);
1187 fprintf (g_errorstream, "*** Signal: %d\n", i);
1189 fprintf (g_errorstream, "*** Location (not trusted): %s\n",
1190 cstring_toCharsSafe (fileloc_unparse (g_currentloc)));
1193 fprintf (g_errorstream, "*** Please report bug to %s ***\n", SPLINT_MAINTAINER);
1201 static bool doneCleanup = FALSE;
1203 /* make sure this is only called once! */
1205 if (doneCleanup) return;
1210 ** Close all open files
1211 ** (There should only be open files, if we exited after a fatal error.)
1214 fileTable_closeAll (context_fileTable ());
1216 if (context_getFlag (FLG_KEEP))
1218 check (fputs ("Temporary files kept:\n", g_messagestream) != EOF);
1219 fileTable_printTemps (context_fileTable ());
1224 int nfiles = /*@-unrecog@*/ _fcloseall (); /*@=unrecog@*/
1228 llbug (message ("Files unclosed: %d", nfiles));
1231 fileTable_cleanup (context_fileTable ());
1238 ** cleans up temp files (if necessary) and exits
1244 DPRINTF (("llexit: %d", status));
1247 if (status == LLFAILURE)
1255 if (status != LLFAILURE)
1257 context_destroyMod ();
1258 exprNode_destroyMod ();
1261 uentry_destroyMod ();
1262 typeIdSet_destroyMod ();
1265 dmalloc_shutdown ();
1269 exit ((status == LLSUCCESS) ? EXIT_SUCCESS : EXIT_FAILURE);
1272 static fileIdList preprocessFiles (fileIdList fl, bool xhfiles)
1273 /*@modifies fileSystem@*/
1275 bool msg = (context_getFlag (FLG_SHOWSCAN) && fileIdList_size (fl) > 10);
1276 int skip = (fileIdList_size (fl) / 5);
1277 int filesprocessed = 0;
1278 fileIdList dfiles = fileIdList_create ();
1280 fileloc_free (g_currentloc);
1281 g_currentloc = fileloc_createBuiltin ();
1283 fileIdList_elements (fl, fid)
1285 cstring ppfname = fileTable_fileName (fid);
1287 if (!(osd_fileIsReadable (ppfname)))
1289 lldiagmsg (message ("Cannot open file: %q", osd_outputPath (ppfname)));
1290 ppfname = cstring_undefined;
1293 if (cstring_isDefined (ppfname))
1295 fileId dfile = fileTable_addCTempFile (context_fileTable (), fid);
1299 llassert (fileTable_isXHFile (context_fileTable (), dfile));
1302 llassert (cstring_isNonEmpty (ppfname));
1306 if ((filesprocessed % skip) == 0)
1308 if (filesprocessed == 0) {
1309 displayScan (cstring_makeLiteral (" "));
1312 displayScan (cstring_makeLiteral ("."));
1318 DPRINTF (("outfile: %s", fileTable_fileName (dfile)));
1320 if (cppProcess (ppfname, fileTable_fileName (dfile)) != 0)
1322 llfatalerror (message ("Preprocessing error for file: %s",
1323 fileTable_rootFileName (fid)));
1326 fileIdList_add (dfiles, dfile);
1328 } end_fileIdList_elements;
1333 /* This should be in an lclUtils.c file... */
1335 char *specFullName (char *specfile, /*@out@*/ char **inpath)
1337 /* extract the path and the specname associated with the given file */
1338 char *specname = (char *) dmalloc (sizeof (*specname)
1339 * (strlen (specfile) + 9));
1340 char *ospecname = specname;
1341 char *path = (char *) dmalloc (sizeof (*path) * (strlen (specfile)));
1345 /* initialized path to empty string or may have accidental garbage */
1348 /*@-mayaliasunique@*/
1349 strcpy (specname, specfile);
1350 /*@=mayaliasunique@*/
1352 /* trim off pathnames in specfile */
1353 size = strlen (specname);
1355 for (i = size_toInt (size) - 1; i >= 0; i--)
1357 if (specname[i] == CONNECTCHAR)
1359 /* strcpy (specname, (char *)specname+i+1); */
1360 for (j = 0; j <= i; j++) /* include '/' */
1362 path[j] = specname[j];
1372 ** also remove .lcl file extension, assume it's the last extension
1376 size = strlen (specname);
1378 for (i = size_toInt (size) - 1; i >= 0; i--)
1380 if (specname[i] == '.')
1390 ** If specname no longer points to the original char,
1391 ** we need to allocate a new pointer and copy the string.
1394 if (specname != ospecname) {
1395 char *rspecname = (char *) dmalloc (sizeof (*rspecname) * (strlen (specname) + 1));
1396 strcpy (rspecname, specname); /* evs 2000-05-16: Bug: was ospecname! */
1405 void warnSysFiles(fileIdList files)
1407 fileIdList_elements (files, file)
1410 if (fileTable_isSystemFile (context_fileTable (), file) )
1412 if (!context_getFlag( FLG_SYSTEMDIRERRORS ) )
1414 voptgenerror (FLG_WARNSYSFILES, message ("Warning %s is a considered a system file. No errors in this file will be reported.", fileTable_rootFileName (file) ), g_currentloc);
1418 end_fileIdList_elements;