@@ -34,8 +34,18 @@ struct if_expr
3434{
3535 struct if_action
3636 {
37+ enum sign_type
38+ {
39+ S_UNK,
40+
41+ S_EQ,
42+ S_NE,
43+ S_LT,
44+ S_GT,
45+ };
46+
3747 String var;
38- bool equ ;
48+ int sign ;
3949 String value;
4050 String action;
4151 int start;
@@ -68,6 +78,7 @@ struct ac_processor
6878 void try_add (command &c);
6979
7080 void output ();
81+ void output2 ();
7182 void process ();
7283 void process_AC_LANG (command &c);
7384 void process_AC_CHECK_FUNCS (command &c);
@@ -203,10 +214,21 @@ auto parse_conditions(String f)
203214
204215 if_expr::if_action a;
205216 a.var = var;
206- a.equ = sign == " =" ;
207217 a.value = val;
208218 a.start = (int )(m[0 ].first - s.begin ());
209- if (sign != " =" && sign != " !=" ) // TODO: implement '-gt' sign
219+
220+ if (sign == " =" )
221+ a.sign = if_expr::if_action::S_EQ;
222+ else if (sign == " !=" )
223+ a.sign = if_expr::if_action::S_NE;
224+ else if (sign == " -lt" )
225+ a.sign = if_expr::if_action::S_LT;
226+ else if (sign == " -gt" )
227+ a.sign = if_expr::if_action::S_GT;
228+ else
229+ a.sign = if_expr::if_action::S_UNK;
230+
231+ if (a.sign == if_expr::if_action::S_UNK) // TODO: implement other signs (-le, -ge)
210232 std::cerr << " Unknown sign " << sign << " \n " ;
211233 else
212234 {
@@ -229,6 +251,13 @@ void process_configure_ac(const path &p)
229251 proc.output ();
230252}
231253
254+ void process_configure_ac2 (const path &p)
255+ {
256+ ac_processor proc (p);
257+ proc.process ();
258+ proc.output2 ();
259+ }
260+
232261ac_processor::ac_processor (const path &p)
233262{
234263 file = read_file (p);
@@ -240,12 +269,21 @@ ac_processor::ac_processor(const path &p)
240269 conditions = parse_conditions (file);
241270}
242271
272+ void print_checks2 (primitives::CppContext &ctx, const ChecksSet &checks, const String &name);
273+
243274void ac_processor::output ()
244275{
245276 checks.save (root);
246277 std::cout << dump_yaml_config (root);
247278}
248279
280+ void ac_processor::output2 ()
281+ {
282+ primitives::CppContext ctx;
283+ print_checks2 (ctx, checks.checks , " x" );
284+ std::cout << ctx.getText ();
285+ }
286+
249287void prepare_type (String &t)
250288{
251289 if (t == " long_long" )
@@ -341,6 +379,7 @@ void ac_processor::process()
341379 SILENCE (AC_CHECK_FILE);
342380 SILENCE (AC_CHECK_TOOL);
343381 SILENCE (AC_MSG_ERROR);
382+ SILENCE (AC_MSG_FAILURE);
344383 SILENCE (AC_TRY_COMMAND);
345384
346385 // specific checks
@@ -429,6 +468,8 @@ void ac_processor::ifdef_add(command &c)
429468 ; // this is a printer
430469 else if (cmd == " AC_MSG_ERROR" )
431470 ; // this is a printer
471+ else if (cmd == " AC_MSG_FAILURE" )
472+ ; // this is a printer
432473 else if (cmd == " AC_LANG_SOURCE" )
433474 {
434475 auto params = parse_arguments (c.params [0 ].substr (cmd.size () + 1 ));
@@ -457,6 +498,8 @@ void ac_processor::ifdef_add(command &c)
457498 ; // this is a printer
458499 else if (cmd == " AC_MSG_ERROR" )
459500 ; // this is a printer
501+ else if (cmd == " AC_MSG_FAILURE" )
502+ ; // this is a printer
460503 else if (cmd == " AC_DEFINE" )
461504 {
462505 auto params = parse_arguments (c.params [1 ].substr (cmd.size () + 1 ));
@@ -498,9 +541,9 @@ void ac_processor::ifdef_add(command &c)
498541 var = params[0 ];
499542
500543 if (value == act.value )
501- invert = ! act.equ ;
544+ invert = act.sign == if_expr::if_action::S_NE ;
502545 else
503- invert = act.equ ;
546+ invert = act.sign == if_expr::if_action::S_EQ ;
504547 }
505548
506549 if (ifthen.size () > 1 )
@@ -513,9 +556,9 @@ void ac_processor::ifdef_add(command &c)
513556 }
514557
515558 if (value == act.value )
516- invert = act.equ ;
559+ invert = act.sign == if_expr::if_action::S_EQ ;
517560 else
518- invert = ! act.equ ;
561+ invert = act.sign == if_expr::if_action::S_NE ;
519562 }
520563 }
521564 }
@@ -532,6 +575,8 @@ void ac_processor::ifdef_add(command &c)
532575 ; // this is a printer
533576 else if (cmd == " AC_MSG_ERROR" )
534577 ; // this is a printer
578+ else if (cmd == " AC_MSG_FAILURE" )
579+ ; // this is a printer
535580 else if (cmd == " AC_DEFINE" )
536581 {
537582 auto params = parse_arguments (c.params [2 ].substr (cmd.size () + 1 ));
@@ -586,6 +631,8 @@ void ac_processor::try_add(command &c)
586631 ; // this is a printer
587632 else if (cmd == " AC_MSG_ERROR" )
588633 ; // this is a printer
634+ else if (cmd == " AC_MSG_FAILURE" )
635+ ; // this is a printer
589636 else if (cmd == " AC_DEFINE" )
590637 {
591638 auto params = parse_arguments (c.params [2 ].substr (cmd.size () + 1 ));
@@ -714,6 +761,8 @@ void ac_processor::process_AC_CHECK_HEADER(command &c)
714761 ; // this is a printer
715762 else if (cmd == " AC_MSG_ERROR" )
716763 ; // this is a printer
764+ else if (cmd == " AC_MSG_FAILURE" )
765+ ; // this is a printer
717766 else if (cmd == " AC_DEFINE" )
718767 {
719768 auto params = parse_arguments (c.params [1 ].substr (cmd.size () + 1 ));
0 commit comments