~n-muench/ubuntu/precise/open-vm-tools/open-vm-tools-precise.sid-merge1

« back to all changes in this revision

Viewing changes to lib/misc/strutil.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-12-06 07:45:05 UTC
  • mfrom: (1.1.8 upstream) (2.4.10 sid)
  • Revision ID: james.westby@ubuntu.com-20091206074505-43rp7oejjgp0y2re
Tags: 2009.11.16-210370-1
* Merging upstream version 2009.11.16-210370.
* Moving vmusr plugins from open-vm-tools to open-vm-toolbox (Closes:
  #539282, #557215).
* Correcting plugin location (Closes: #545222, #549044).
* Dropping la files (Closes: #551626).
* Adding open-vm-toolbox lintian overrides.
* Removing test plugin.
* Removing unused plugin symlinks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
490
490
   }
491
491
   if (*rest != '\0') {
492
492
      uint64 shift;
 
493
      Bool suffixOK = TRUE;
493
494
 
494
495
      /*
495
496
       * [kK], [mM], [gG], and [tT] represent kilo, mega, giga, and tera
496
497
       * byte quantities respectively. [bB] represents a singular byte
497
498
       * quantity. [sS] represents a sector quantity. 
498
499
       *
499
 
       * All other suffixes are ignored, which also means a suffix like
500
 
       * "MB" will be treated as 'M'.
 
500
       * For kilo, mega, giga, and tera we're OK with an additional byte
 
501
       * suffix. Otherwise, the presence of an additional suffix is an error.
501
502
       */
502
503
      switch (*rest) {
503
 
      case 's': case 'S':          shift = 9;  break;
504
 
      case 'k': case 'K':          shift = 10; break;
505
 
      case 'm': case 'M':          shift = 20; break;
506
 
      case 'g': case 'G':          shift = 30; break;
507
 
      case 't': case 'T':          shift = 40; break;
508
 
      case 'b': case 'B': default: shift = 0;  break;
509
 
      }
510
 
      quantity *= (double)(1 << shift);
 
504
      case 'b': case 'B': shift = 0;  suffixOK = FALSE; break;
 
505
      case 's': case 'S': shift = 9;  suffixOK = FALSE; break;
 
506
      case 'k': case 'K': shift = 10;                   break;
 
507
      case 'm': case 'M': shift = 20;                   break;
 
508
      case 'g': case 'G': shift = 30;                   break;
 
509
      case 't': case 'T': shift = 40;                   break;
 
510
      default :                                         return FALSE;
 
511
      }
 
512
      switch(*++rest) {
 
513
      case '\0':
 
514
         break;
 
515
      case 'b': case 'B':
 
516
         if (suffixOK && !*++rest) {
 
517
            break;
 
518
         }
 
519
         /* FALLTHRU */
 
520
      default:
 
521
         return FALSE;
 
522
      }
 
523
      quantity *= CONST64U(1) << shift;
511
524
   } else {
512
525
      /*
513
526
       * No suffix, so multiply by the number of bytes per unit as specified
514
527
       * by the caller.
515
528
       */
516
 
 
517
 
      quantity *= (double)bytes;
 
529
      quantity *= bytes;
518
530
   }
519
531
 
520
532
   /*