def check_fortran_mangling(conf):
    subr = """
      subroutine foobar()
      return
      end
      subroutine foo_bar()
      return
      end
"""
    main_tmpl = """
      int %s() { return 1; }
"""
    prog_tmpl = """
      void %(foobar)s(void);
      void %(foo_bar)s(void);
      int main() {
      %(foobar)s();
      %(foo_bar)s();
      return 0;
      }
"""

    conf.start_message("Checking fortran mangling scheme")
    old = {}
    for k in ["F77_LINKFLAGS", "LIBS", "LIBDIR"]:
        old[k] = copy.deepcopy(conf.env[k])
    try:
        mangling_lib = "check_fc_mangling_lib"
        ret = conf.builders["fortran"].try_static_library(mangling_lib, subr)
        if ret:
            if conf.env[FC_DUMMY_MAIN] is not None:
                main = conf.env["FC_DUMMY_MAIN"] % main_tmpl
            else:
                main = ""
            conf.env["LIBS"].insert(0, mangling_lib)
            libdir = conf.last_task.outputs[-1].parent.abspath()
            conf.env["LIBDIR"].insert(0, libdir)

            for u, du, case in mangling_generator():
                names = {"foobar": mangle_func("foobar", u, du, case),
                         "foo_bar": mangle_func("foo_bar", u, du, case)}
                prog = prog_tmpl % names
                name = "check_fc_mangling_main"
                def _name(u):
                    if u == "_":
                        return "u"
                    else:
                        return "nu"
                name += "_%s_%s_%s" % (_name(u), _name(du), case)
                ret = conf.builders["ctasks"].try_program(name, main + prog)
                if ret:
                    conf.env["FC_MANGLING"] = (u, du, case)
                    conf.end_message("%r %r %r" % (u, du, case))
                    return
            conf.end_message("failed !")
            conf.fail_configuration(None)
        else:
            conf.end_message("failed !")
            conf.fail_configuration(None)

    finally:
        for k in old:
            conf.env[k] = old[k]
dataset/ETHPy150Open cournape/Bento/bento/private/_yaku/yaku/conftests/fconftests.py/check_fortran_mangling/swapped operands of `%`