1. 24 Aug, 2011 8 commits
  2. 23 Aug, 2011 8 commits
  3. 22 Aug, 2011 3 commits
  4. 16 Aug, 2011 3 commits
  5. 15 Aug, 2011 7 commits
  6. 14 Aug, 2011 2 commits
  7. 13 Aug, 2011 3 commits
    • Douglas Bagnall's avatar
      opt: functions to show integer values with kMGTPE suffixes · bbdf3ef3
      Douglas Bagnall authored
      As with the set_ functions, there are twelve permutations of integer size,
      base, and signedness.  The supported sizes are int, long, and long long.
      
      For example, this:
      
       char buf1[OPT_SHOW_LEN];
       char buf2[OPT_SHOW_LEN];
       unsigned i = 1024000;
       opt_show_uintval_bi(buf1, &i);
       opt_show_uintval_si(buf2, &i);
      
      will put "1000k" in buf1, and "1024k" in buf2.
      
      Unlike the opt_set_ functions, these use unsigned arithmetic for unsigned values.
      
      (32 bit bug using sizeof(suffixes) instead of strlen(suffixes) fixed by Rusty)
      bbdf3ef3
    • Douglas Bagnall's avatar
      opt: incidental comment and whitespace repair · babb2310
      Douglas Bagnall authored
      This comment occurred in a couple of places:
      
       /* Set an integer value, various forms.  Sets to 1 on arg == NULL. */
      
      One instance was clearly spurious, while the other was misleading.
      
      Another resolution to this mismatch would be to add
      "if (arg == NULL){*l = 1; return NULL}" somewhere, but I suspect
      it may have been left out/removed because someone thought better.
      babb2310
    • Douglas Bagnall's avatar
      opt: add integer helpers that accept k, M, G, T, P, E suffixes · af7afcd4
      Douglas Bagnall authored
      These functions come in two flavours: those ending with "_si", which
      have 1000-based interpretations of the suffixes; and those ending with
      "_bi", which use base 1024.  There are versions for signed and
      unsigned int, long, and long long destinations, with tests for all 12
      new functions.  The tests get a bit repetitive, I am afraid.
      
      As an example, if the -x option were using the opt_set_intval_bi
      function, then all of these would do the same thing:
      
      $ foo -x 5M
      $ foo -x $((5 * 1024 * 1024))
      $ foo -x 5242880
      $ foo -x 5120k
      
      quite what that thing is depends on the size of your int -- people
      with 16 bit ints would see an "out of range" error message.
      
      The arithmetic for unsigned variations is actually done using signed
      long long integers, so the maximum possible value is LLONG_MAX, not
      ULLONG_MAX.  This follows the practice of existing functions, and
      avoids tedious work.
      af7afcd4
  8. 01 Aug, 2011 2 commits
  9. 22 Jul, 2011 1 commit
  10. 21 Jul, 2011 3 commits