src/share/vm/runtime/arguments.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 8042885 Sdiff src/share/vm/runtime

src/share/vm/runtime/arguments.cpp

Print this page
8042885: java does not take hexadecimal number as vm option


 563     const char* name = entry->d_name;
 564     const char* ext = name + strlen(name) - 4;
 565     bool isJarOrZip = ext > name &&
 566       (os::file_name_strcmp(ext, ".jar") == 0 ||
 567        os::file_name_strcmp(ext, ".zip") == 0);
 568     if (isJarOrZip) {
 569       char* jarpath = NEW_C_HEAP_ARRAY(char, directory_len + 2 + strlen(name), mtInternal);
 570       sprintf(jarpath, "%s%s%s", directory, dir_sep, name);
 571       path = add_to_path(path, jarpath, false);
 572       FREE_C_HEAP_ARRAY(char, jarpath, mtInternal);
 573     }
 574   }
 575   FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
 576   os::closedir(dir);
 577   return path;
 578 }
 579 
 580 // Parses a memory size specification string.
 581 static bool atomull(const char *s, julong* result) {
 582   julong n = 0;
 583   int args_read = sscanf(s, JULONG_FORMAT, &n);









 584   if (args_read != 1) {
 585     return false;
 586   }
 587   while (*s != '\0' && isdigit(*s)) {
 588     s++;
 589   }
 590   // 4705540: illegal if more characters are found after the first non-digit
 591   if (strlen(s) > 1) {
 592     return false;
 593   }
 594   switch (*s) {
 595     case 'T': case 't':
 596       *result = n * G * K;
 597       // Check for overflow.
 598       if (*result/((julong)G * K) != n) return false;
 599       return true;
 600     case 'G': case 'g':
 601       *result = n * G;
 602       if (*result/G != n) return false;
 603       return true;
 604     case 'M': case 'm':
 605       *result = n * M;
 606       if (*result/M != n) return false;
 607       return true;


 761     const char* value = strchr(arg, '=') + 1;
 762     // -XX:Foo:=xxx will reset the string flag to the given value.
 763     if (value[0] == '\0') {
 764       value = NULL;
 765     }
 766     return set_string_flag(name, value, origin);
 767   }
 768 
 769 #define SIGNED_FP_NUMBER_RANGE "[-0123456789.]"
 770 #define SIGNED_NUMBER_RANGE    "[-0123456789]"
 771 #define        NUMBER_RANGE    "[0123456789]"
 772   char value[BUFLEN + 1];
 773   char value2[BUFLEN + 1];
 774   if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_NUMBER_RANGE "." "%" XSTR(BUFLEN) NUMBER_RANGE "%c", name, value, value2, &dummy) == 3) {
 775     // Looks like a floating-point number -- try again with more lenient format string
 776     if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_FP_NUMBER_RANGE "%c", name, value, &dummy) == 2) {
 777       return set_fp_numeric_flag(name, value, origin);
 778     }
 779   }
 780 
 781 #define VALUE_RANGE "[-kmgtKMGT0123456789]"
 782   if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) VALUE_RANGE "%c", name, value, &dummy) == 2) {
 783     return set_numeric_flag(name, value, origin);
 784   }
 785 
 786   return false;
 787 }
 788 
 789 void Arguments::add_string(char*** bldarray, int* count, const char* arg) {
 790   assert(bldarray != NULL, "illegal argument");
 791 
 792   if (arg == NULL) {
 793     return;
 794   }
 795 
 796   int new_count = *count + 1;
 797 
 798   // expand the array and add arg to the last element
 799   if (*bldarray == NULL) {
 800     *bldarray = NEW_C_HEAP_ARRAY(char*, new_count, mtInternal);
 801   } else {




 563     const char* name = entry->d_name;
 564     const char* ext = name + strlen(name) - 4;
 565     bool isJarOrZip = ext > name &&
 566       (os::file_name_strcmp(ext, ".jar") == 0 ||
 567        os::file_name_strcmp(ext, ".zip") == 0);
 568     if (isJarOrZip) {
 569       char* jarpath = NEW_C_HEAP_ARRAY(char, directory_len + 2 + strlen(name), mtInternal);
 570       sprintf(jarpath, "%s%s%s", directory, dir_sep, name);
 571       path = add_to_path(path, jarpath, false);
 572       FREE_C_HEAP_ARRAY(char, jarpath, mtInternal);
 573     }
 574   }
 575   FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
 576   os::closedir(dir);
 577   return path;
 578 }
 579 
 580 // Parses a memory size specification string.
 581 static bool atomull(const char *s, julong* result) {
 582   julong n = 0;
 583   int args_read = 0;
 584   bool is_hex = false;
 585   // Skip leading 0[xX] for hexadecimal 
 586   if (*s =='0' && (*(s+1) == 'x' || *(s+1) == 'X')) {
 587     s += 2;
 588     is_hex = true;
 589     args_read = sscanf(s, JULONG_FORMAT_X, &n);
 590   } else {
 591     args_read = sscanf(s, JULONG_FORMAT, &n);
 592   }
 593   if (args_read != 1) {
 594     return false;
 595   }
 596   while (*s != '\0' && (isdigit(*s) || (is_hex && isxdigit(*s)))) {
 597     s++;
 598   }
 599   // 4705540: illegal if more characters are found after the first non-digit
 600   if (strlen(s) > 1) {
 601     return false;
 602   }
 603   switch (*s) {
 604     case 'T': case 't':
 605       *result = n * G * K;
 606       // Check for overflow.
 607       if (*result/((julong)G * K) != n) return false;
 608       return true;
 609     case 'G': case 'g':
 610       *result = n * G;
 611       if (*result/G != n) return false;
 612       return true;
 613     case 'M': case 'm':
 614       *result = n * M;
 615       if (*result/M != n) return false;
 616       return true;


 770     const char* value = strchr(arg, '=') + 1;
 771     // -XX:Foo:=xxx will reset the string flag to the given value.
 772     if (value[0] == '\0') {
 773       value = NULL;
 774     }
 775     return set_string_flag(name, value, origin);
 776   }
 777 
 778 #define SIGNED_FP_NUMBER_RANGE "[-0123456789.]"
 779 #define SIGNED_NUMBER_RANGE    "[-0123456789]"
 780 #define        NUMBER_RANGE    "[0123456789]"
 781   char value[BUFLEN + 1];
 782   char value2[BUFLEN + 1];
 783   if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_NUMBER_RANGE "." "%" XSTR(BUFLEN) NUMBER_RANGE "%c", name, value, value2, &dummy) == 3) {
 784     // Looks like a floating-point number -- try again with more lenient format string
 785     if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) SIGNED_FP_NUMBER_RANGE "%c", name, value, &dummy) == 2) {
 786       return set_fp_numeric_flag(name, value, origin);
 787     }
 788   }
 789 
 790 #define VALUE_RANGE "[-kmgtxKMGTX0123456789abcdefABCDEF]"
 791   if (sscanf(arg, "%" XSTR(BUFLEN) NAME_RANGE "=" "%" XSTR(BUFLEN) VALUE_RANGE "%c", name, value, &dummy) == 2) {
 792     return set_numeric_flag(name, value, origin);
 793   }
 794 
 795   return false;
 796 }
 797 
 798 void Arguments::add_string(char*** bldarray, int* count, const char* arg) {
 799   assert(bldarray != NULL, "illegal argument");
 800 
 801   if (arg == NULL) {
 802     return;
 803   }
 804 
 805   int new_count = *count + 1;
 806 
 807   // expand the array and add arg to the last element
 808   if (*bldarray == NULL) {
 809     *bldarray = NEW_C_HEAP_ARRAY(char*, new_count, mtInternal);
 810   } else {


src/share/vm/runtime/arguments.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File