FreeBSD/contrib/gcc/c-incpath.c
/* For each duplicate path in chain HEAD, keep just the first one.
   Remove each path in chain HEAD that also exists in chain SYSTEM.
   Set the NEXT pointer of the last path in the resulting chain to
   JOIN, unless it duplicates JOIN in which case the last path is
   removed.  Return the head of the resulting chain.  Any of HEAD,
   JOIN and SYSTEM can be NULL.  */
For each duplicate path in chain HEAD, keep just the first one.
Remove each path in chain HEAD that also exists in chain SYSTEM.
Set the NEXT pointer of the last path in the resulting chain to
JOIN, unless it duplicates JOIN in which case the last path is
removed.  Return the head of the resulting chain.  Any of HEAD,
JOIN and SYSTEM can be NULL.
For each duplicate path in chain HEAD keep just the first one . Remove each path in chain HEAD that also exists in chain SYSTEM . Set the NEXT pointer of the last path in the resulting chain to JOIN unless it duplicates JOIN in which case the last path is removed . Return the head of the resulting chain . Any of HEAD JOIN and SYSTEM can be NULL .
static struct cpp_dir *
remove_duplicates (cpp_reader *pfile, struct cpp_dir *head,
		   struct cpp_dir *system, struct cpp_dir *join,
		   int verbose)
{
  struct cpp_dir **pcur, *tmp, *cur;
  struct stat st;
  for (pcur = &head; *pcur; )
    {
      int reason = REASON_QUIET;
      cur = *pcur;
      if (stat (cur->name, &st))
	{
	  if (errno != ENOENT)
	    cpp_errno (pfile, CPP_DL_ERROR, cur->name);
	  else
	    {
	      cpp_options *opts = cpp_get_options (pfile);
	      if (opts->warn_missing_include_dirs && cur->user_supplied_p)
		cpp_errno (pfile, CPP_DL_WARNING, cur->name);
	      reason = REASON_NOENT;
	    }
	}
      else if (!S_ISDIR (st.st_mode))
	cpp_error_with_line (pfile, CPP_DL_ERROR, 0, 0,
			     "%s: not a directory", cur->name);
      else
	{
	  INO_T_COPY (cur->ino, st.st_ino);
	  cur->dev  = st.st_dev;
	  reason = REASON_DUP_SYS;
	  for (tmp = system; tmp; tmp = tmp->next)
	   if (INO_T_EQ (tmp->ino, cur->ino) && tmp->dev == cur->dev
	       && cur->construct == tmp->construct)
	      break;
	  if (!tmp)
	    {
	      reason = REASON_DUP;
	      for (tmp = head; tmp != cur; tmp = tmp->next)
	       if (INO_T_EQ (cur->ino, tmp->ino) && cur->dev == tmp->dev
		   && cur->construct == tmp->construct)
		  break;
	      if (tmp == cur
		  && !(cur->next == NULL && join
		       && INO_T_EQ (cur->ino, join->ino)
		      && cur->dev == join->dev
		      && cur->construct == join->construct))
		{
		  pcur = &cur->next;
		  continue;
		}
	    }
	}
      *pcur = cur->next;
      free_path (cur, verbose ? reason: REASON_QUIET);
    }
  *pcur = join;
  return head;
}
static struct cpp_dir * remove_duplicates ( cpp_reader * pfile , struct cpp_dir * head , struct cpp_dir * system , struct cpp_dir * join , int verbose ) { struct cpp_dir * * pcur , * tmp , * cur ; struct stat st ; for ( pcur = & head ; * pcur ; ) { int reason = REASON_QUIET ; cur = * pcur ; if ( stat ( cur -> name , & st ) ) { if ( errno != ENOENT ) cpp_errno ( pfile , CPP_DL_ERROR , cur -> name ) ; else { cpp_options * opts = cpp_get_options ( pfile ) ; if ( opts -> warn_missing_include_dirs && cur -> user_supplied_p ) cpp_errno ( pfile , CPP_DL_WARNING , cur -> name ) ; reason = REASON_NOENT ; } } else if ( ! S_ISDIR ( st . st_mode ) ) cpp_error_with_line ( pfile , CPP_DL_ERROR , 0 , 0 , " " , cur -> name ) ; else { INO_T_COPY ( cur -> ino , st . st_ino ) ; cur -> dev = st . st_dev ; reason = REASON_DUP_SYS ; for ( tmp = system ; tmp ; tmp = tmp -> next ) if ( INO_T_EQ ( tmp -> ino , cur -> ino ) && tmp -> dev == cur -> dev && cur -> construct == tmp -> construct ) break ; if ( ! tmp ) { reason = REASON_DUP ; for ( tmp = head ; tmp != cur ; tmp = tmp -> next ) if ( INO_T_EQ ( cur -> ino , tmp -> ino ) && cur -> dev == tmp -> dev && cur -> construct == tmp -> construct ) break ; if ( tmp == cur && ! ( cur -> next == NULL && join && INO_T_EQ ( cur -> ino , join -> ino ) && cur -> dev == join -> dev && cur -> construct == join -> construct ) ) { pcur = & cur -> next ; continue ; } } } * pcur = cur -> next ; free_path ( cur , verbose ? reason : REASON_QUIET ) ; } * pcur = join ; return head ; }
For each duplicate path in chain HEAD, keep just the first one.
For each duplicate path in chain HEAD keep just the first one .
/* Dirs that don't exist are silently ignored, unless verbose.  */ /* If -Wmissing-include-dirs is given, warn.  */ /* Remove this one if it is in the system chain.  */ /* Duplicate of something earlier in the same chain?  */ /* Last in the chain and duplicate of JOIN?  */ /* Unique, so keep this directory.  */ /* Remove this entry from the chain.  */