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

Diff for /src/usr.bin/tmux/format.c between version 1.188 and 1.189

version 1.188, 2019/03/29 09:33:24 version 1.189, 2019/04/25 18:18:55
Line 904 
Line 904 
         struct environ_entry    *envent;          struct environ_entry    *envent;
         static char              s[64];          static char              s[64];
         struct options_entry    *o;          struct options_entry    *o;
         const char              *found;  
         int                      idx;          int                      idx;
         char                    *copy, *saved;          char                    *found, *saved;
   
         if (~modifiers & FORMAT_TIMESTRING) {          if (~modifiers & FORMAT_TIMESTRING) {
                 o = options_parse_get(global_options, key, &idx, 0);                  o = options_parse_get(global_options, key, &idx, 0);
Line 933 
Line 932 
                                 return (NULL);                                  return (NULL);
                         ctime_r(&fe->t, s);                          ctime_r(&fe->t, s);
                         s[strcspn(s, "\n")] = '\0';                          s[strcspn(s, "\n")] = '\0';
                         found = s;                          found = xstrdup(s);
                         goto found;                          goto found;
                 }                  }
                 if (fe->t != 0) {                  if (fe->t != 0) {
                         xsnprintf(s, sizeof s, "%lld", (long long)fe->t);                          xasprintf(&found, "%lld", (long long)fe->t);
                         found = s;  
                         goto found;                          goto found;
                 }                  }
                 if (fe->value == NULL && fe->cb != NULL) {                  if (fe->value == NULL && fe->cb != NULL) {
Line 946 
Line 944 
                         if (fe->value == NULL)                          if (fe->value == NULL)
                                 fe->value = xstrdup("");                                  fe->value = xstrdup("");
                 }                  }
                 found = fe->value;                  found = xstrdup(fe->value);
                 goto found;                  goto found;
         }          }
   
Line 957 
Line 955 
                 if (envent == NULL)                  if (envent == NULL)
                         envent = environ_find(global_environ, key);                          envent = environ_find(global_environ, key);
                 if (envent != NULL) {                  if (envent != NULL) {
                         found = envent->value;                          found = xstrdup(envent->value);
                         goto found;                          goto found;
                 }                  }
         }          }
Line 967 
Line 965 
 found:  found:
         if (found == NULL)          if (found == NULL)
                 return (NULL);                  return (NULL);
         copy = xstrdup(found);  
         if (modifiers & FORMAT_BASENAME) {          if (modifiers & FORMAT_BASENAME) {
                 saved = copy;                  saved = found;
                 copy = xstrdup(basename(saved));                  found = xstrdup(basename(saved));
                 free(saved);                  free(saved);
         }          }
         if (modifiers & FORMAT_DIRNAME) {          if (modifiers & FORMAT_DIRNAME) {
                 saved = copy;                  saved = found;
                 copy = xstrdup(dirname(saved));                  found = xstrdup(dirname(saved));
                 free(saved);                  free(saved);
         }          }
         if (modifiers & FORMAT_QUOTE) {          if (modifiers & FORMAT_QUOTE) {
                 saved = copy;                  saved = found;
                 copy = xstrdup(format_quote(saved));                  found = xstrdup(format_quote(saved));
                 free(saved);                  free(saved);
         }          }
         return (copy);          return (found);
 }  }
   
 /* Skip until end. */  /* Skip until end. */

Legend:
Removed from v.1.188  
changed lines
  Added in v.1.189