dpatel      02/09/17 15:54:20

  Modified:    gcc      toplev.c genindex.h genindex.c cpplib.c c-lex.c
  Log:
  Using #line directive in source, user can force GCC to assume another
  name for the current input file being processed. Untill now indexer
  did not know about this trick.
  
  Revision  Changes    Path
  1.156     +6 -0      gcc3/gcc/toplev.c
  
  Index: toplev.c
  ===================================================================
  RCS file: /cvs/Darwin/gcc3/gcc/toplev.c,v
  retrieving revision 1.155
  retrieving revision 1.156
  diff -u -r1.155 -r1.156
  --- toplev.c  2002/09/10 20:53:29     1.155
  +++ toplev.c  2002/09/17 22:54:18     1.156
  @@ -2271,6 +2271,9 @@
     fs->next = input_file_stack;
     input_file_stack = fs;
     input_file_stack_tick++;
  +  /* APPLE LOCAL indexing dpatel */
  +  if (flag_gen_index_original)
  +    push_cur_index_filename (input_filename);
   }
   
   /* Pop the top entry off the stack of presently open source files.
  @@ -2291,6 +2294,9 @@
       abort ();
     input_filename = input_file_stack->name;
     lineno = input_file_stack->line;
  +  /* APPLE LOCAL indexing dpatel */
  +  if (flag_gen_index_original)
  +    pop_cur_index_filename ();
   }
   
   /* Compile an entire translation unit.  Write a file of assembly
  
  
  
  1.14      +4 -0      gcc3/gcc/genindex.h
  
  Index: genindex.h
  ===================================================================
  RCS file: /cvs/Darwin/gcc3/gcc/genindex.h,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- genindex.h        2002/06/06 19:41:33     1.13
  +++ genindex.h        2002/09/17 22:54:19     1.14
  @@ -28,6 +28,10 @@
   void write_indexed_header_list           PARAMS ((void));
   struct indexed_header * add_index_header_name PARAMS ((char *));
   struct indexed_header * add_index_header PARAMS ((char *, time_t));
  +void push_cur_index_filename             PARAMS ((char *));
  +void pop_cur_index_filename              PARAMS ((void));
  +void add_dup_header_name                 PARAMS ((char *, char *));
  +
   void free_indexed_header_list            PARAMS ((void));
   int process_header_indexing              PARAMS ((char *, int));
   /* Update header status.  */
  
  
  
  1.19      +145 -9    gcc3/gcc/genindex.c
  
  Index: genindex.c
  ===================================================================
  RCS file: /cvs/Darwin/gcc3/gcc/genindex.c,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- genindex.c        2002/08/08 03:19:52     1.18
  +++ genindex.c        2002/09/17 22:54:19     1.19
  @@ -72,6 +72,15 @@
   int begin_header_count = 0;
   char **begin_header_stack = NULL; 
   
  +struct idx_file_stack 
  +{
  +  char *name;          /* file name */
  +  struct idx_file_stack *next;
  +};
  +/* Stack to keep track of the current file being indexed */
  +static struct idx_file_stack *cur_index_filename = NULL;
  +#define CUR_INDEX_FILENAME (cur_index_filename ? cur_index_filename->name: NULL)
  +
   /* Indexed header list.  */
   int flag_check_indexed_header_list = 0;
   char *index_header_list_filename = 0;
  @@ -79,6 +88,14 @@
   {
     struct indexed_header *next;
     char *name;
  +
  +  struct idx_file_stack *dup_name;  
  +                    /* duplicate name 
  +                          People do strange things. Sometimes 
  +                       they change name of input file during 
  +                       compilation by using line markers.  
  +                       Not saved on the disk.  */
  +
     time_t timestamp;    /* time of last data modification. */
   
     int timestamp_status;/* Flag to indicate valid timestamp for the 
  @@ -104,7 +121,6 @@
   
   static struct indexed_header *indexed_header_list = NULL;
   
  -
   /* Static function prototypes */
   static void allocate_begin_header_stack   PARAMS ((void));
   static void reallocate_begin_header_stack PARAMS ((void));
  @@ -113,6 +129,12 @@
   static void maybe_flush_index_buffer      PARAMS ((int));
   static void allocate_index_buffer         PARAMS ((void));
   static char * absolute_path_name          PARAMS ((char *));
  +static int is_dup_name                    PARAMS ((struct idx_file_stack *, char 
*));
  +static void free_idx_file_stack           PARAMS (( struct idx_file_stack *));
  +static struct idx_file_stack * push_idx_file_stack 
  +                                          PARAMS (( struct idx_file_stack *, char 
*));
  +static struct idx_file_stack * pop_idx_file_stack            
  +                                          PARAMS (( struct idx_file_stack *));
   
   /* Establish socket connection to put the indexing information.  */
   int 
  @@ -148,12 +170,6 @@
   void
   init_gen_indexing ()
   {
  -#if 0
  -  /* Turn OFF indexing, until further testing with new PB is done.  */
  -  flag_gen_index = 0;
  -  flag_gen_index_original = 0;
  -  return;
  -#endif
   
     if (flag_debug_gen_index)
       {
  @@ -611,6 +627,7 @@
     if (!h)
       return NULL;
   
  +  h->dup_name = NULL;
     h->name = (char *) xmalloc (sizeof (char) * (strlen (str) + 1));
     if (!h->name)
       return NULL;
  @@ -628,6 +645,58 @@
     return h;
   }
   
  +/* Remember name of file being indexed right now.  
  +   Push it on the stack.  */
  +void
  +push_cur_index_filename (name)
  +     char *name;
  +{
  +  cur_index_filename = push_idx_file_stack (cur_index_filename, name);
  +}
  +
  +/* Pop current index file from the stack.  */
  +void
  +pop_cur_index_filename ()
  +{
  +  cur_index_filename = pop_idx_file_stack (cur_index_filename);
  +}
  +
  +/* Add duplicate name for index_header.  */
  +void
  +add_dup_header_name (orig_name, sname)
  +     char *orig_name; 
  +     char *sname;  /* another name */
  +{
  +  struct indexed_header *cursor;
  +  if (!sname || !orig_name)
  +    return;
  +
  +  /* Find original header and add another name for it.  */
  +  for (cursor = indexed_header_list;
  +       cursor != NULL; 
  +       cursor = cursor->next)
  +    {
  +      if (!strcmp (cursor->name, CUR_INDEX_FILENAME))
  +     cursor->dup_name = push_idx_file_stack (cursor->dup_name, sname);
  +    }
  +}
  +
  +/* Return 1, if name 'n' is in the list of
  +   duplicate name 'd'.  */
  +static int
  +is_dup_name (struct idx_file_stack *d, char *n)
  +{
  +  struct idx_file_stack *cursor;
  +  if (!d || !n)
  +    return 0;  /* Not found */
  +
  +  for (cursor = d; cursor != NULL; cursor = cursor->next)
  +    if (cursor->name && !strcmp (cursor->name, n))
  +      return 1; /* Found! */
  +
  +  return 0;  /* Not found */
  +}
  +
   void
   print_indexed_header_list ()
   {
  @@ -658,6 +727,22 @@
          count++;
       }
   }
  +/* Free the duplicate header name list.  */
  +void
  +free_idx_file_stack (list)
  +     struct idx_file_stack *list;
  +{
  +  struct idx_file_stack *cursor;
  +  struct idx_file_stack *next_cursor;
  +  cursor = next_cursor = list;
  +  for (; next_cursor != NULL; )
  +    {
  +      next_cursor = cursor->next;
  +      free (cursor->name);
  +      free (cursor);
  +    }
  +}
  +
   /* Free the indexed header list.  */
   void
   free_indexed_header_list ()
  @@ -670,8 +755,11 @@
         next_cursor = cursor->next;
         free (cursor->name);
         free (cursor);
  +      free_idx_file_stack (cursor->dup_name);
       }
   
  +  while (cur_index_filename)
  +    cur_index_filename = pop_idx_file_stack (cur_index_filename);
     return;
   }
   
  @@ -777,7 +865,9 @@
               }
           }
        if (skip_index_generation == 0 && recursion_depth == 0)
  -       flag_gen_index = 1;
  +       {
  +         flag_gen_index = 1;
  +       }
        else if (skip_index_generation < 0)
          {
            warning("Invalid skip header index count.");
  @@ -897,7 +987,11 @@
   
     for (cursor = indexed_header_list; cursor != NULL; cursor = cursor->next)
       {
  -      if (!strcmp (cursor->name, name))
  +      if (!strcmp (cursor->name, name)
  +       || (cursor->dup_name 
  +           && CUR_INDEX_FILENAME 
  +           && !strcmp (CUR_INDEX_FILENAME, cursor->name)
  +           && is_dup_name (cursor->dup_name, name)))
           {
             if (cursor->timestamp_status == INDEX_TIMESTAMP_VALID)
               {
  @@ -951,3 +1045,45 @@
   {
     index_language = l;
   }
  +
  +/* Push 'name' in 'stack' */
  +/* Allocate new memory */
  +static struct idx_file_stack *
  +push_idx_file_stack (stack, name)
  +     struct idx_file_stack *stack;
  +     char *name;
  +{
  +  struct idx_file_stack *n;
  +
  +  /* Allocate new entry */
  +  n = (struct idx_file_stack *) xmalloc (sizeof (struct idx_file_stack));
  +  n->name = absolute_path_name (name);
  +  
  +  /* push */
  +  if (stack)
  +    n->next = stack;
  +  else
  +    n->next = NULL;
  +  stack = n;
  +
  +  return stack;
  +}
  +
  +/* Pop top entry from the stack and free it */
  +static struct idx_file_stack *
  +pop_idx_file_stack (stack)
  +     struct idx_file_stack *stack;
  +{
  +  struct idx_file_stack *n = stack;
  +
  +  if (stack)
  +    stack = n->next;
  +
  +  if (n)
  +    {
  +      free (n->name);
  +      free (n);
  +    }
  +  return stack;
  +}
  +
  
  
  
  1.41      +5 -1      gcc3/gcc/cpplib.c
  
  Index: cpplib.c
  ===================================================================
  RCS file: /cvs/Darwin/gcc3/gcc/cpplib.c,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- cpplib.c  2002/08/26 05:39:32     1.40
  +++ cpplib.c  2002/09/17 22:54:19     1.41
  @@ -926,10 +926,14 @@
              strcat (apath, "/");
              strcat (apath, new_file);
              gen_indexing_header ((char *) apath);
  +           push_cur_index_filename (apath);
              free (apath);
            }
          else 
  -         gen_indexing_header ((char *) new_file);
  +         {
  +           gen_indexing_header ((char *) new_file);
  +           push_cur_index_filename (new_file);
  +         }
          flag_gen_index_header = 0;
          process_header_indexing ((char *) new_file, PB_INDEX_BEGIN);
        }
  
  
  
  1.42      +4 -0      gcc3/gcc/c-lex.c
  
  Index: c-lex.c
  ===================================================================
  RCS file: /cvs/Darwin/gcc3/gcc/c-lex.c,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- c-lex.c   2002/09/02 03:45:49     1.41
  +++ c-lex.c   2002/09/17 22:54:19     1.42
  @@ -307,6 +307,10 @@
         
         (*debug_hooks->end_source_file) (to_line);
       }
  +  /* APPLE LOCAL begin indexing dpatel */
  +  else if (flag_gen_index && new_map->reason == LC_RENAME)
  +    add_dup_header_name (input_filename, new_map->to_file);
  +  /* APPLE LOCAL end indexing dpatel */
   
     update_header_times (new_map->to_file);
     in_system_header = new_map->sysp != 0;
  
  
  


Reply via email to