2 * (c) Oleg Puchinin 2006
3 * graycardinalster@gmail.com
12 #include "functions.h"
16 extern FILE * d_stream_dbg
;
18 char * d_lpsz_operators
[] = { "if", "else", "for", "while", "do", "switch", "#define",
19 "#include", "#else", "#if", "#elif","typedef", "struct", "class",
20 "case", "return", NULL
};
22 char * d_lpsz_oneopops
[] = {"if", "else", "for", "while", "do", NULL
};
23 char * d_lpsz_mustlined_ops
[] = {"if", "for", "while", "do", NULL
};
24 char * d_lpsz_greenpeace
[] = {"struct",
36 // $ silent_bob --indent
37 void nogui_indent () // "UN-TT" ;)
39 struct tt_state_t
* d_tt_state
;
40 bool b_inmacro
= false;
50 d_tt_state
= CNEW (tt_state_t
, 1);
51 d_tt_state
->d_file_name
= "-";
52 d_ptr
= THE_TT::do_tt_file (d_tt_state
);
55 d_array
.push (d_lpsz_oneopops
);
56 d_must_lined
.push (d_lpsz_mustlined_ops
);
57 d_operators
.push (d_lpsz_operators
);
60 ch
= t_op (&d_ptr
, &d_out
); // t_op on top
68 if (ch
== '\n' && d_ptr
[-1] != '\\') {
69 printf ("%s\n", d_out
);
77 if (d_must_lined
.snfind (d_out
) != -1 && !t_lined
&& !b_inmacro
) {
82 if (ch
!= '\n' && !b_inmacro
) {
83 for (i
= 0; i
< brace_depth
; i
++)
95 if (b_inmacro
&& ch
== '}')
99 if (ch
== '}' && brace_depth
== 0) {
100 if (*d_ptr
== '#' || *d_ptr
== '\n')
101 fputc ('\n', stdout
);
102 else if (*d_ptr
&& *d_ptr
!= ';') {
103 fputc ('\n', stdout
);
104 fputc ('\n', stdout
);
106 else if (*d_ptr
&& *d_ptr
== ';') {
112 fputc ('\n', stdout
);
120 THE_TT::free_tt_state (d_tt_state
);