[BACK]Return to top.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / top

Diff for /src/usr.bin/top/top.c between version 1.97 and 1.98

version 1.97, 2018/11/17 23:10:08 version 1.98, 2018/11/28 22:00:30
Line 74 
Line 74 
   
 extern int      (*proc_compares[])(const void *, const void *);  extern int      (*proc_compares[])(const void *, const void *);
 int order_index;  int order_index;
   int rev_order;
   
 int displays = 0;       /* indicates unspecified */  int displays = 0;       /* indicates unspecified */
 char do_unames = Yes;  char do_unames = Yes;
Line 93 
Line 94 
 char topn_specified = No;  char topn_specified = No;
 #endif  #endif
   
   struct system_info system_info;
   struct statics  statics;
   
 /*  /*
  * these defines enumerate the "strchr"s of the commands in   * these defines enumerate the "strchr"s of the commands in
  * command_chars   * command_chars
Line 129 
Line 133 
         extern char *__progname;          extern char *__progname;
   
         fprintf(stderr,          fprintf(stderr,
             "usage: %s [-1bCHIinqSu] [-d count] [-g string] [-o field] "              "usage: %s [-1bCHIinqSu] [-d count] [-g string] [-o [-]field] "
             "[-p pid] [-s time]\n\t[-U [-]user] [number]\n",              "[-p pid] [-s time]\n\t[-U [-]user] [number]\n",
             __progname);              __progname);
 }  }
   
 static int  static int
   getorder(char *field)
   {
           int i, r = field[0] == '-';
   
           i = string_index(r ? field + 1 : field, statics.order_names);
           if (i != -1)
                   rev_order = r;
   
           return i;
   }
   
   static int
 filteruser(char buf[])  filteruser(char buf[])
 {  {
         const char *errstr;          const char *errstr;
Line 311 
Line 327 
         }          }
 }  }
   
 struct system_info system_info;  
 struct statics  statics;  
   
 int  int
 main(int argc, char *argv[])  main(int argc, char *argv[])
 {  {
Line 381 
Line 394 
   
         /* determine sorting order index, if necessary */          /* determine sorting order index, if necessary */
         if (order_name != NULL) {          if (order_name != NULL) {
                 if ((order_index = string_index(order_name,                  if ((order_index = getorder(order_name)) == -1) {
                     statics.order_names)) == -1) {                          new_message(MT_delayed,
                         char **pp, msg[512];                              " %s: unrecognized sorting order", order_name);
   
                         snprintf(msg, sizeof(msg),  
                             "'%s' is not a recognized sorting order",  
                             order_name);  
                         strlcat(msg, ". Valid are:", sizeof(msg));  
                         pp = statics.order_names;  
                         while (*pp != NULL) {  
                                 strlcat(msg, " ", sizeof(msg));  
                                 strlcat(msg, *pp++, sizeof(msg));  
                         }  
                         new_message(MT_delayed, msg);  
                         order_index = 0;                          order_index = 0;
                 }                  }
         }          }
Line 879 
Line 881 
                         new_message(MT_standout,                          new_message(MT_standout,
                             "Order to sort: ");                              "Order to sort: ");
                         if (readline(tempbuf, sizeof(tempbuf)) > 0) {                          if (readline(tempbuf, sizeof(tempbuf)) > 0) {
                                 if ((i = string_index(tempbuf,                                  if ((i = getorder(tempbuf)) == -1) {
                                     statics.order_names)) == -1) {  
                                         new_message(MT_standout,                                          new_message(MT_standout,
                                             " %s: unrecognized sorting order",                                              " %s: unrecognized sorting order",
                                               tempbuf[0] == '-' ? tempbuf + 1 :
                                             tempbuf);                                              tempbuf);
                                         no_command = Yes;                                          no_command = Yes;
                                 } else                                  } else

Legend:
Removed from v.1.97  
changed lines
  Added in v.1.98