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

Diff for /src/usr.bin/tmux/arguments.c between version 1.15 and 1.16

version 1.15, 2016/10/11 13:21:59 version 1.16, 2017/01/18 10:00:50
Line 22 
Line 22 
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include <unistd.h>  #include <unistd.h>
   #include <vis.h>
   
 #include "tmux.h"  #include "tmux.h"
   
Line 130 
Line 131 
 args_print(struct args *args)  args_print(struct args *args)
 {  {
         size_t                   len;          size_t                   len;
         char                    *buf;          char                    *buf, *escaped;
         int                      i;          int                      i, flags;
         struct args_entry       *entry;          struct args_entry       *entry;
           static const char        quoted[] = " #\"';$";
   
         len = 1;          len = 1;
         buf = xcalloc(1, len);          buf = xcalloc(1, len);
Line 156 
Line 158 
                         args_print_add(&buf, &len, " -%c ", entry->flag);                          args_print_add(&buf, &len, " -%c ", entry->flag);
                 else                  else
                         args_print_add(&buf, &len, "-%c ", entry->flag);                          args_print_add(&buf, &len, "-%c ", entry->flag);
                 if (strchr(entry->value, ' ') != NULL)  
                         args_print_add(&buf, &len, "\"%s\"", entry->value);                  flags = VIS_OCTAL|VIS_TAB|VIS_NL;
                   if (entry->value[strcspn(entry->value, quoted)] != '\0')
                           flags |= VIS_DQ;
                   stravis(&escaped, entry->value, flags);
                   if (flags & VIS_DQ)
                           args_print_add(&buf, &len, "\"%s\"", escaped);
                 else                  else
                         args_print_add(&buf, &len, "%s", entry->value);                          args_print_add(&buf, &len, "%s", escaped);
                   free(escaped);
         }          }
   
         /* And finally the argument vector. */          /* And finally the argument vector. */
         for (i = 0; i < args->argc; i++) {          for (i = 0; i < args->argc; i++) {
                 if (*buf != '\0')                  if (*buf != '\0')
                         args_print_add(&buf, &len, " ");                          args_print_add(&buf, &len, " ");
                 if (strchr(args->argv[i], ' ') != NULL)  
                         args_print_add(&buf, &len, "\"%s\"", args->argv[i]);                  flags = VIS_OCTAL|VIS_TAB|VIS_NL;
                   if (args->argv[i][strcspn(args->argv[i], quoted)] != '\0')
                           flags |= VIS_DQ;
                   stravis(&escaped, args->argv[i], flags);
                   if (flags & VIS_DQ)
                           args_print_add(&buf, &len, "\"%s\"", escaped);
                 else                  else
                         args_print_add(&buf, &len, "%s", args->argv[i]);                          args_print_add(&buf, &len, "%s", escaped);
                   free(escaped);
         }          }
   
         return (buf);          return (buf);

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16