]> andersk Git - splint.git/blame - src/codeGeneration.c
Added files for the splint.sf.net repository as part of the merge process.
[splint.git] / src / codeGeneration.c
CommitLineData
b1ceadc0 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/*
26** constraintGeneration.c
27*/
28
29# include "splintMacros.nf"
30# include "basic.h"
31
32static /*@only@*/ cstring includes = cstring_undefined;
33
34static void doOutputCode (cstring st, fileloc loc)
35{
36 cstring name, newName;
37 FILE * f;
38
39 if (context_getFlag(FLG_GENERATECODEANDOVERWRITE) )
40 {
41 if (fileloc_canGetName(loc) )
42 {
43 int tmp;
44 name = fileloc_getName(loc);
45
46 newName = cstring_concatChars(name, ".splint.tmp");
47 f = fopen (cstring_toCharsSafe(newName), "a");
48
49 llassertprint(f != NULL, (message("failed to open file %s", newName)
50 ) );
51
52 if (cstring_isDefined(includes) )
53 {
54 fprintf (f, "%s%s", cstring_toCharsSafe(includes),
55 cstring_toCharsSafe(st) );
56
57 cstring_free(includes);
58 includes = cstring_undefined;
59 }
60 else
61 {
62 fprintf (f, "%s", cstring_toCharsSafe(st) );
63 }
64 /*@i999*/ /*these may fail they should be handled more cleanly...
65 */
66 tmp = fflush(f);
67 llassert(tmp == 0 );
68 tmp = fclose (f);
69 llassert( tmp == 0 );
70
71 cstring_free(newName);
72 }
73 else
74 {
75 if (cstring_isUndefined(includes ) )
76 {
77 includes = message ("%s", st);
78 }
79 else
80 {
81 includes = cstring_concatFree1(includes, st);
82 }
83 }
84 }
85 else
86 {
87 fprintf (stderr, "%s", cstring_toCharsSafe(st) );
88 }
89
90}
91
92void outputCode (cstring st)
93{
94 cstring output;
95
96
97 if (!fileloc_isDotH(g_currentloc) && context_getFlag(FLG_GENERATECODE))
98 {
99 // output = message ("/* %s */ \n %s",fileloc_unparse(g_currentloc), st);
100 output = st;
101 doOutputCode (output, g_currentloc);
102 }
103}
104
This page took 0.061268 seconds and 5 git commands to generate.