Project/Real_code/gnu/coreutils-5.0/src/ls.c
static void
extract_dirs_from_files (const char *dirname, int ignore_dot_and_dot_dot)
{
  register int i, j;

  if (*dirname && LOOP_DETECT)
    {
      /* Insert a marker entry first.  When we dequeue this marker entry,
	 we'll know that DIRNAME has been processed and may be removed
	 from the set of active directories.  */
      queue_directory (NULL, dirname);
    }

  /* Queue the directories last one first, because queueing reverses the
     order.  */
  for (i = files_index - 1; i >= 0; i--)
    if ((files[i].filetype == directory || files[i].filetype == arg_directory)
	&& (!ignore_dot_and_dot_dot
	    || !basename_is_dot_or_dotdot (files[i].name)))
      {
	if (files[i].name[0] == '/' || dirname[0] == 0)
	  {
	    queue_directory (files[i].name, files[i].linkname);
	  }
	else
	  {
	    char *path = path_concat (dirname, files[i].name, NULL);
	    queue_directory (path, files[i].linkname);
	    free (path);
	  }
	if (files[i].filetype == arg_directory)
	  free (files[i].name);
      }

  /* Now delete the directories from the table, compacting all the remaining
     entries.  */

  for (i = 0, j = 0; i < files_index; i++)
    if (files[i].filetype != arg_directory)
      files[j++] = files[i];
  files_index = j;
}
/* Remove any entries from `files' that are for directories,
   and queue them to be listed as directories instead.
   `dirname' is the prefix to prepend to each dirname
   to make it correct relative to ls's working dir.
   If IGNORE_DOT_AND_DOT_DOT is nonzero don't treat `.' and `..' as dirs.
   This is desirable when processing directories recursively.  */
Remove any entries from `files' that are for directories,
and queue them to be listed as directories instead.
`dirname' is the prefix to prepend to each dirname
to make it correct relative to ls's working dir.
If IGNORE_DOT_AND_DOT_DOT is nonzero don't treat `.' and `..' as dirs.
This is desirable when processing directories recursively.
Remove any entries from ` files ' that are for directories and queue them to be listed as directories instead . ` dirname ' is the prefix to prepend to each dirname to make it correct relative to ls ' s working dir . If IGNORE_DOT_AND_DOT_DOT is nonzero don ' t treat ` . ' and ` .. ' as dirs . This is desirable when processing directories recursively .
static void
extract_dirs_from_files (const char *dirname, int ignore_dot_and_dot_dot)
{
  register int i, j;
  if (*dirname && LOOP_DETECT)
    {
      queue_directory (NULL, dirname);
    }
  for (i = files_index - 1; i >= 0; i--)
    if ((files[i].filetype == directory || files[i].filetype == arg_directory)
	&& (!ignore_dot_and_dot_dot
	    || !basename_is_dot_or_dotdot (files[i].name)))
      {
	if (files[i].name[0] == '/' || dirname[0] == 0)
	  {
	    queue_directory (files[i].name, files[i].linkname);
	  }
	else
	  {
	    char *path = path_concat (dirname, files[i].name, NULL);
	    queue_directory (path, files[i].linkname);
	    free (path);
	  }
	if (files[i].filetype == arg_directory)
	  free (files[i].name);
      }
  for (i = 0, j = 0; i < files_index; i++)
    if (files[i].filetype != arg_directory)
      files[j++] = files[i];
  files_index = j;
}
static void extract_dirs_from_files ( const char * dirname , int ignore_dot_and_dot_dot ) { register int i , j ; if ( * dirname && LOOP_DETECT ) { queue_directory ( NULL , dirname ) ; } for ( i = files_index - 1 ; i >= 0 ; i -- ) if ( ( files [ i ] . filetype == directory || files [ i ] . filetype == arg_directory ) && ( ! ignore_dot_and_dot_dot || ! basename_is_dot_or_dotdot ( files [ i ] . name ) ) ) { if ( files [ i ] . name [ 0 ] == ' ' || dirname [ 0 ] == 0 ) { queue_directory ( files [ i ] . name , files [ i ] . linkname ) ; } else { char * path = path_concat ( dirname , files [ i ] . name , NULL ) ; queue_directory ( path , files [ i ] . linkname ) ; free ( path ) ; } if ( files [ i ] . filetype == arg_directory ) free ( files [ i ] . name ) ; } for ( i = 0 , j = 0 ; i < files_index ; i ++ ) if ( files [ i ] . filetype != arg_directory ) files [ j ++ ] = files [ i ] ; files_index = j ; }
Remove any entries from `files' that are for directories,
and queue them to be listed as directories instead.
Remove any entries from ` files ' that are for directories and queue them to be listed as directories instead .
/* Insert a marker entry first.  When we dequeue this marker entry,
	 we'll know that DIRNAME has been processed and may be removed
	 from the set of active directories.  */ /* Queue the directories last one first, because queueing reverses the
     order.  */ /* Now delete the directories from the table, compacting all the remaining
     entries.  */