hotspot/src/share/vm/runtime/arguments.cpp
changeset 24458 f0d4da9b062a
parent 24456 8c7933fa5a1f
child 24461 2aa6f773eef8
equal deleted inserted replaced
24457:0e20b36df5c4 24458:f0d4da9b062a
   581 }
   581 }
   582 
   582 
   583 // Parses a memory size specification string.
   583 // Parses a memory size specification string.
   584 static bool atomull(const char *s, julong* result) {
   584 static bool atomull(const char *s, julong* result) {
   585   julong n = 0;
   585   julong n = 0;
   586   int args_read = sscanf(s, JULONG_FORMAT, &n);
   586   int args_read = 0;
       
   587   bool is_hex = false;
       
   588   // Skip leading 0[xX] for hexadecimal
       
   589   if (*s =='0' && (*(s+1) == 'x' || *(s+1) == 'X')) {
       
   590     s += 2;
       
   591     is_hex = true;
       
   592     args_read = sscanf(s, JULONG_FORMAT_X, &n);
       
   593   } else {
       
   594     args_read = sscanf(s, JULONG_FORMAT, &n);
       
   595   }
   587   if (args_read != 1) {
   596   if (args_read != 1) {
   588     return false;
   597     return false;
   589   }
   598   }
   590   while (*s != '\0' && isdigit(*s)) {
   599   while (*s != '\0' && (isdigit(*s) || (is_hex && isxdigit(*s)))) {
   591     s++;
   600     s++;
   592   }
   601   }
   593   // 4705540: illegal if more characters are found after the first non-digit
   602   // 4705540: illegal if more characters are found after the first non-digit
   594   if (strlen(s) > 1) {
   603   if (strlen(s) > 1) {
   595     return false;
   604     return false;
   779     if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_FP_NUMBER_RANGE "%c", name, value, &dummy) == 2) {
   788     if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_FP_NUMBER_RANGE "%c", name, value, &dummy) == 2) {
   780       return set_fp_numeric_flag(name, value, origin);
   789       return set_fp_numeric_flag(name, value, origin);
   781     }
   790     }
   782   }
   791   }
   783 
   792 
   784 #define VALUE_RANGE "[-kmgtKMGT0123456789]"
   793 #define VALUE_RANGE "[-kmgtxKMGTX0123456789abcdefABCDEF]"
   785   if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) VALUE_RANGE "%c", name, value, &dummy) == 2) {
   794   if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) VALUE_RANGE "%c", name, value, &dummy) == 2) {
   786     return set_numeric_flag(name, value, origin);
   795     return set_numeric_flag(name, value, origin);
   787   }
   796   }
   788 
   797 
   789   return false;
   798   return false;