bug-global
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] move some code into condition_macro


From: Shigio Yamaguchi
Subject: Re: [PATCH] move some code into condition_macro
Date: Wed, 19 Mar 2003 22:04:11 +0900

Fixed with the following modification.
Two code is logically equal, I think.

        if (cc == SYMBOL && strcmp(token, "defined") != 0
            && (dflag
                ? (defined(token)
                   ? target == REF
                   : target == SYM)
                : target == SYM))
                PUT(token, lineno, sp);

                |
                v

        if (cc == SYMBOL && strcmp(token, "defined") != 0) {
                if (target == REF) {
                        if (dflag && defined(token))
                                PUT(token, lineno, sp);
                } else if (target == SYM)
                        if (!dflag || !defined(token))
                                PUT(token, lineno, sp);
                }
        }

Thank you!

> Index: gctags/C.c
> ===================================================================
> RCS file: /cvsroot/global/global/gctags/C.c,v
> retrieving revision 1.23
> diff -u -r1.23 C.c
> --- gctags/C.c        5 Mar 2003 16:04:12 -0000       1.23
> +++ gctags/C.c        9 Mar 2003 23:06:23 -0000
> @@ -45,7 +45,7 @@
>  #include "token.h"
>  
>  static       int     function_definition(int);
> -static       void    condition_macro(int);
> +static       void    condition_macro(int, int);
>  static       int     seems_datatype(const char *);
>  static       void    inittable();
>  static       int     reserved(char *);
> @@ -257,17 +257,7 @@
>               case CP_ELIF:
>               case CP_ELSE:
>               case CP_ENDIF:
> -                     condition_macro(cc);
> -                     while ((c = nexttoken(interested, reserved)) != EOF && 
c != '\n') {
> -                             if (!strcmp(token, "defined"))
> -                                     continue;
> -                             if (c == SYMBOL
> -                                 && (dflag
> -                                     ? ((target == REF && defined(token))
> -                                        || (target == SYM && !defined(token)
))
> -                                     : target == SYM))
> -                                     PUT(token, lineno, sp);
> -                     }
> +                     condition_macro(cc, target);
>                       break;
>               case CP_SHARP:          /* ## */
>                       (void)nexttoken(interested, reserved);
> @@ -333,7 +323,7 @@
>                                               case CP_ELIF:
>                                               case CP_ELSE:
>                                               case CP_ENDIF:
> -                                                     condition_macro(c);
> +                                                     condition_macro(c, targ
et);
>                                                       continue;
>                                               default:
>                                                       break;
> @@ -393,7 +383,7 @@
>                                       case CP_ELIF:
>                                       case CP_ELSE:
>                                       case CP_ENDIF:
> -                                             condition_macro(c);
> +                                             condition_macro(c, target);
>                                               continue;
>                                       default:
>                                               break;
> @@ -467,7 +457,7 @@
>               case CP_ELIF:
>               case CP_ELSE:
>               case CP_ENDIF:
> -                     condition_macro(c);
> +                     condition_macro(c, target);
>                       continue;
>               default:
>                       break;
> @@ -498,7 +488,7 @@
>               case CP_ELIF:
>               case CP_ELSE:
>               case CP_ENDIF:
> -                     condition_macro(c);
> +                     condition_macro(c, target);
>                       continue;
>               default:
>                       break;
> @@ -536,10 +526,12 @@
>   * condition_macro: 
>   *
>   *   i)      cc      token
> + *   i)      target  current target
>   */
>  static void
> -condition_macro(cc)
> +condition_macro(cc, target)
>       int     cc;
> +     int     target;
>  {
>       cur = &stack[piflevel];
>       if (cc == CP_IFDEF || cc == CP_IFNDEF || cc == CP_IF) {
> @@ -584,6 +576,15 @@
>                               level = cur->end;
>                       }
>               }
> +     }
> +     while ((cc = nexttoken(NULL, reserved)) != EOF && cc != '\n') {
> +             if (cc == SYMBOL && strcmp(token, "defined") != 0
> +                 && (dflag
> +                     ? (defined(token)
> +                        ? target == REF
> +                        : target == SYM)
> +                     : target == SYM))
> +                     PUT(token, lineno, sp);
>       }
>  }
>  /*
> Index: gctags/Cpp.c
> ===================================================================
> RCS file: /cvsroot/global/global/gctags/Cpp.c,v
> retrieving revision 1.21
> diff -u -r1.21 Cpp.c
> --- gctags/Cpp.c      5 Mar 2003 16:04:12 -0000       1.21
> +++ gctags/Cpp.c      9 Mar 2003 23:06:23 -0000
> @@ -47,7 +47,7 @@
>  
>  static       int     function_definition(int);
>  static  int     seems_datatype(const char *);
> -static       void    condition_macro(int);
> +static       void    condition_macro(int, int);
>  static       void    inittable();
>  static       int     reserved(char *);
>  
> @@ -259,17 +259,7 @@
>               case CP_ELIF:
>               case CP_ELSE:
>               case CP_ENDIF:
> -                     condition_macro(cc);
> -                     while ((c = nexttoken(interested, reserved)) != EOF && 
c != '\n') {
> -                             if (!strcmp(token, "defined"))
> -                                     continue;
> -                             if (c == SYMBOL
> -                                 && (dflag
> -                                     ? ((target == REF && defined(token))
> -                                        || (target == SYM && !defined(token)
))
> -                                     : target == SYM))
> -                                     PUT(token, lineno, sp);
> -                     }
> +                     condition_macro(cc, target);
>                       break;
>               case CP_SHARP:          /* ## */
>                       (void)nexttoken(interested, reserved);
> @@ -379,7 +369,7 @@
>                                               case CP_ELIF:
>                                               case CP_ELSE:
>                                               case CP_ENDIF:
> -                                                     condition_macro(c);
> +                                                     condition_macro(c, targ
et);
>                                                       continue;
>                                               default:
>                                                       break;
> @@ -439,7 +429,7 @@
>                                       case CP_ELIF:
>                                       case CP_ELSE:
>                                       case CP_ENDIF:
> -                                             condition_macro(c);
> +                                             condition_macro(c, target);
>                                               continue;
>                                       default:
>                                               break;
> @@ -513,7 +503,7 @@
>               case CP_ELIF:
>               case CP_ELSE:
>               case CP_ENDIF:
> -                     condition_macro(c);
> +                     condition_macro(c, target);
>                       continue;
>               default:
>                       break;
> @@ -548,7 +538,7 @@
>               case CP_ELIF:
>               case CP_ELSE:
>               case CP_ENDIF:
> -                     condition_macro(c);
> +                     condition_macro(c, target);
>                       continue;
>               default:
>                       break;
> @@ -585,10 +575,12 @@
>   * condition_macro: 
>   *
>   *   i)      cc      token
> + *   i)      target  current target
>   */
>  static void
> -condition_macro(cc)
> +condition_macro(cc, target)
>       int     cc;
> +     int     target;
>  {
>       cur = &pifstack[piflevel];
>       if (cc == CP_IFDEF || cc == CP_IFNDEF || cc == CP_IF) {
> @@ -633,6 +625,15 @@
>                               level = cur->end;
>                       }
>               }
> +     }
> +     while ((cc = nexttoken(NULL, reserved)) != EOF && cc != '\n') {
> +             if (cc == SYMBOL && strcmp(token, "defined") != 0
> +                 && (dflag
> +                     ? (defined(token)
> +                        ? target == REF
> +                        : target == SYM)
> +                     : target == SYM))
> +                     PUT(token, lineno, sp);
>       }
>  }
>  /*
> 
> ----
> Hideki IWAMOTO  address@hidden
> 
> 
> _______________________________________________
> Bug-global mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/bug-global
> 
> 
--
Shigio Yamaguchi <address@hidden> - Tama Communications Corporation
PGP fingerprint: D1CB 0B89 B346 4AB6 5663  C4B6 3CA5 BBB3 57BE DDA3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]