Diff for /embedaddon/readline/colors.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2014/07/30 08:16:45 version 1.1.1.2, 2021/03/17 01:01:01
Line 2 Line 2
   
    Modified by Chet Ramey for Readline.     Modified by Chet Ramey for Readline.
   
   Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012 Free Software Foundation,   Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012, 2015, 2017, 2019
   Inc.   Free Software Foundation, Inc.
   
    This program is free software: you can redistribute it and/or modify     This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by     it under the terms of the GNU General Public License as published by
Line 32 Line 32
   
 #include "rlconf.h"  #include "rlconf.h"
   
   #if defined __TANDEM
   #  define _XOPEN_SOURCE_EXTENDED 1
   #  define _TANDEM_SOURCE 1
   #  include <sys/types.h>
   #  include <sys/stat.h>
   #endif
   
 #include <stdio.h>  #include <stdio.h>
   
 #include "posixstat.h" // stat related macros (S_ISREG, ...)  #include "posixstat.h" // stat related macros (S_ISREG, ...)
 #include <fcntl.h> // S_ISUID  #include <fcntl.h> // S_ISUID
   
   #ifndef S_ISDIR
   #  define       S_ISDIR(m)      (((m) & S_IFMT) == S_IFDIR)
   #endif
   
 // strlen()  // strlen()
 #if defined (HAVE_STRING_H)  #if defined (HAVE_STRING_H)
 #  include <string.h>  #  include <string.h>
Line 66  COLOR_EXT_TYPE *_rl_color_ext_list = 0; Line 77  COLOR_EXT_TYPE *_rl_color_ext_list = 0;
   
 /* Output a color indicator (which may contain nulls).  */  /* Output a color indicator (which may contain nulls).  */
 void  void
_rl_put_indicator (const struct bin_str *ind) {_rl_put_indicator (const struct bin_str *ind)
 {
   fwrite (ind->string, ind->len, 1, rl_outstream);    fwrite (ind->string, ind->len, 1, rl_outstream);
 }  }
   
Line 98  _rl_set_normal_color (void) Line 110  _rl_set_normal_color (void)
     }      }
 }  }
   
   bool
   _rl_print_prefix_color (void)
   {
     struct bin_str *s;
   
     /* What do we want to use for the prefix? Let's try cyan first, see colors.h */
     s = &_rl_color_indicator[C_PREFIX];
     if (s->string != NULL)
       {
         if (is_colored (C_NORM))
           restore_default_color ();
         _rl_put_indicator (&_rl_color_indicator[C_LEFT]);
         _rl_put_indicator (s);
         _rl_put_indicator (&_rl_color_indicator[C_RIGHT]);
         return 0;
       }
     else
       return 1;
   }
     
 /* Returns whether any color sequence was printed. */  /* Returns whether any color sequence was printed. */
 bool  bool
_rl_print_color_indicator (char *f)_rl_print_color_indicator (const char *f)
 {  {
   enum indicator_no colored_filetype;    enum indicator_no colored_filetype;
   COLOR_EXT_TYPE *ext;  /* Color extension */    COLOR_EXT_TYPE *ext;  /* Color extension */
Line 108  _rl_print_color_indicator (char *f) Line 140  _rl_print_color_indicator (char *f)
   
   const char* name;    const char* name;
   char *filename;    char *filename;
  struct stat astat;  struct stat astat, linkstat;
   mode_t mode;    mode_t mode;
  int linkok;  int linkok;   /* 1 == ok, 0 == dangling symlink, -1 == missing */
 
   int stat_ok;    int stat_ok;
   
   name = f;    name = f;
Line 130  _rl_print_color_indicator (char *f) Line 161  _rl_print_color_indicator (char *f)
 #else  #else
   stat_ok = stat(name, &astat);    stat_ok = stat(name, &astat);
 #endif  #endif
  if( stat_ok == 0 ) {  if (stat_ok == 0)
    mode = astat.st_mode;    {
    linkok = 1; //f->linkok;      mode = astat.st_mode;
  }#if defined (HAVE_LSTAT)
       if (S_ISLNK (mode))
         {
           linkok = stat (name, &linkstat) == 0;
           if (linkok && strncmp (_rl_color_indicator[C_LINK].string, "target", 6) == 0)
             mode = linkstat.st_mode;
         }
       else
 #endif
         linkok = 1;
     }
   else    else
     linkok = -1;      linkok = -1;
   
Line 141  _rl_print_color_indicator (char *f) Line 182  _rl_print_color_indicator (char *f)
   
   if (linkok == -1 && _rl_color_indicator[C_MISSING].string != NULL)    if (linkok == -1 && _rl_color_indicator[C_MISSING].string != NULL)
     colored_filetype = C_MISSING;      colored_filetype = C_MISSING;
     else if (linkok == 0 && _rl_color_indicator[C_ORPHAN].string != NULL)
       colored_filetype = C_ORPHAN;        /* dangling symlink */
   else if(stat_ok != 0)    else if(stat_ok != 0)
     {      {
       static enum indicator_no filetype_indicator[] = FILETYPE_INDICATORS;        static enum indicator_no filetype_indicator[] = FILETYPE_INDICATORS;
Line 152  _rl_print_color_indicator (char *f) Line 195  _rl_print_color_indicator (char *f)
         {          {
           colored_filetype = C_FILE;            colored_filetype = C_FILE;
   
   #if defined (S_ISUID)
           if ((mode & S_ISUID) != 0 && is_colored (C_SETUID))            if ((mode & S_ISUID) != 0 && is_colored (C_SETUID))
             colored_filetype = C_SETUID;              colored_filetype = C_SETUID;
          else if ((mode & S_ISGID) != 0 && is_colored (C_SETGID))          else
 #endif
 #if defined (S_ISGID)
           if ((mode & S_ISGID) != 0 && is_colored (C_SETGID))
             colored_filetype = C_SETGID;              colored_filetype = C_SETGID;
          else if (is_colored (C_CAP) && 0) //f->has_capability)          else
 #endif
           if (is_colored (C_CAP) && 0) //f->has_capability)
             colored_filetype = C_CAP;              colored_filetype = C_CAP;
           else if ((mode & S_IXUGO) != 0 && is_colored (C_EXEC))            else if ((mode & S_IXUGO) != 0 && is_colored (C_EXEC))
             colored_filetype = C_EXEC;              colored_filetype = C_EXEC;
Line 180  _rl_print_color_indicator (char *f) Line 229  _rl_print_color_indicator (char *f)
             colored_filetype = C_STICKY;              colored_filetype = C_STICKY;
 #endif  #endif
         }          }
   #if defined (S_ISLNK)
       else if (S_ISLNK (mode))        else if (S_ISLNK (mode))
        colored_filetype = ((linkok == 0        colored_filetype = C_LINK;
                 && (!strncmp (_rl_color_indicator[C_LINK].string, "target", 6)#endif
                     || _rl_color_indicator[C_ORPHAN].string)) 
                ? C_ORPHAN : C_LINK); 
       else if (S_ISFIFO (mode))        else if (S_ISFIFO (mode))
         colored_filetype = C_FIFO;          colored_filetype = C_FIFO;
   #if defined (S_ISSOCK)
       else if (S_ISSOCK (mode))        else if (S_ISSOCK (mode))
         colored_filetype = C_SOCK;          colored_filetype = C_SOCK;
   #endif
       else if (S_ISBLK (mode))        else if (S_ISBLK (mode))
         colored_filetype = C_BLK;          colored_filetype = C_BLK;
       else if (S_ISCHR (mode))        else if (S_ISCHR (mode))

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>