2 * (c) Oleg Puchinin 2006
3 * graycardinalster@gmail.com
10 * February 2006 - comments and strings BUG fixed...
15 bool brace_count (char * d_str
, int * d_count
, bool b_force_block
) // "nice"
19 if (! d_str
|| ! d_count
)
23 if (!strncmp (d_str
, "/*", 2)) {
30 if (strncmp (d_str
, "*/", 2)) {
40 if (!strncmp (d_str
, "//", 2))
43 if (*d_str
== '\"' || *d_str
== '\'') {
44 d_str
= sstrend (d_str
);
45 if (d_str
== NULL
|| *d_str
== 0) {
46 assert (d_str
== NULL
, "HimTeh 4");
47 assert (*d_str
== 0, "HimTeh 5");
62 if (*d_str
== ';' && *d_count
== 0 && !b_force_block
) {
72 void nogui_fdump (struct fdump_param_t
* d_param
)
81 if (!d_array
.from_file (d_param
->d_file_name
))
84 if (d_param
->d_file_output
== NULL
)
87 d_file
= fopen (d_param
->d_file_output
, "w");
92 if (! d_param
->linear
) {
93 for (a
= 0; a
< d_param
->n_trip
; a
++)
94 fprintf (d_file
, "\t");
95 fprintf (d_file
, "//<***>\n");
98 i
= d_param
->d_line
-1;
99 d_size
= d_array
.get_size ();
100 b_in_comment
= false;
102 if (d_array
.get (i
)[0] != '#') {
104 if (!d_param
->linear
) {
105 for (a
= 0; a
< d_param
->n_trip
; a
++)
106 fprintf (d_file
, "\t");
108 fprintf (d_file
, "%s", d_array
.get(i
));
110 if (brace_count (d_array
.get(i
), &d_count
, d_param
->b_force_block
) && !d_count
)
113 if (!d_count
&& ((i
- d_param
->d_line
) > 2) && !d_param
->b_force_block
)
121 fprintf (d_file
, "%s", S
);
122 S
= &S
[strlen (S
)-2];
123 while ((*S
== ' ') || (*S
== '\t'))
129 } while (i
< d_size
);
132 if (!d_param
->linear
) {
133 for (a
= 0; a
< d_param
->n_trip
; a
++)
134 fprintf (d_file
, "\t");
135 fprintf (d_file
, "//</***>\n");
138 if (d_param
->d_file_output
!= NULL
)
141 d_array
.foreach (free
);