acr icon indicating copy to clipboard operation
acr copied to clipboard

Implement SWITCH statements to avoid nested IFEQ/ELSE blocks

Open radare opened this issue 5 years ago • 0 comments

This is taken from r2's configure.acr:

IFEQ USEROSTYPE auto ; {
        IFEQ HOST_OS mingw32_nt-6.2 ; {
                USEROSTYPE = mingw32 ;
        }{
        IFEQ HOST_OS mingw32_nt ; {
                USEROSTYPE = mingw32 ;
        }{
        IFEQ HOST_OS wsl ; {
                USEROSTYPE =  wsl ;
        }{
        IFEQ HOST_OS linux ; {
                USEROSTYPE = gnulinux ;
        }{
        IFEQ HOST_OS gnu ; {
                (( GNU / HURD ))
                USEROSTYPE = gnulinux ;
                HAVE_LIB_DL = 1 ;
                DL_LIBS = -ldl ;
        }{
        IFEQ HOST_OS sunos ; {
                USEROSTYPE = solaris ;
        }{
        IFEQ HOST_OS gnu/kfreebsd ; {
                USEROSTYPE = bsd ;
        }{
        IFEQ HOST_OS netbsd ; {
                USEROSTYPE = bsd ;
        }{
        IFEQ HOST_OS freebsd ; {
                USEROSTYPE = bsd ;
        }{
        IFEQ HOST_OS openbsd ; {
                USEROSTYPE = bsd ;
        }{
        IFEQ HOST_OS darwin ; {
                USEROSTYPE = darwin ;
        } } } } } } } } } } }
}

That can be rewritten to:

SWITCH HOST_OS 
  darwin { USEROSTYPE = darwin; }
  openbsd { USEROSTYPE = bsd; }
  ..
}

radare avatar Jun 21 '20 09:06 radare