72 char* next_str = f->array()->at(i);
73 size_t next_size = strlen(next_str);
74 //Check if there's room left to write next element
75 if (written + next_size > len) {
76 return;
77 }
78 //Actually write element
79 strcat(buf, next_str);
80 written += next_size;
81 //Check if there's room left for the comma
82 if (i < length-1 && len - written > 0) {
83 strcat(buf, ",");
84 }
85 }
86 }
87
88 template <> void DCmdArgument<jlong>::parse_value(const char* str,
89 size_t len, TRAPS) {
90 int scanned = -1;
91 if (str == NULL
92 || sscanf(str, JLONG_FORMAT"%n", &_value, &scanned) != 1
93 || (size_t)scanned != len)
94 {
95 ResourceMark rm;
96
97 char* buf = NEW_RESOURCE_ARRAY(char, len + 1);
98 strncpy(buf, str, len);
99 buf[len] = '\0';
100 Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_IllegalArgumentException(),
101 "Integer parsing error in command argument '%s'. Could not parse: %s.", _name, buf);
102 }
103 }
104
105 template <> void DCmdArgument<jlong>::init_value(TRAPS) {
106 if (has_default()) {
107 this->parse_value(_default_string, strlen(_default_string), THREAD);
108 if (HAS_PENDING_EXCEPTION) {
109 fatal("Default string must be parseable");
110 }
111 } else {
112 set_value(0);
|
72 char* next_str = f->array()->at(i);
73 size_t next_size = strlen(next_str);
74 //Check if there's room left to write next element
75 if (written + next_size > len) {
76 return;
77 }
78 //Actually write element
79 strcat(buf, next_str);
80 written += next_size;
81 //Check if there's room left for the comma
82 if (i < length-1 && len - written > 0) {
83 strcat(buf, ",");
84 }
85 }
86 }
87
88 template <> void DCmdArgument<jlong>::parse_value(const char* str,
89 size_t len, TRAPS) {
90 int scanned = -1;
91 if (str == NULL
92 || sscanf(str, JLONG_FORMAT "%n", &_value, &scanned) != 1
93 || (size_t)scanned != len)
94 {
95 ResourceMark rm;
96
97 char* buf = NEW_RESOURCE_ARRAY(char, len + 1);
98 strncpy(buf, str, len);
99 buf[len] = '\0';
100 Exceptions::fthrow(THREAD_AND_LOCATION, vmSymbols::java_lang_IllegalArgumentException(),
101 "Integer parsing error in command argument '%s'. Could not parse: %s.", _name, buf);
102 }
103 }
104
105 template <> void DCmdArgument<jlong>::init_value(TRAPS) {
106 if (has_default()) {
107 this->parse_value(_default_string, strlen(_default_string), THREAD);
108 if (HAS_PENDING_EXCEPTION) {
109 fatal("Default string must be parseable");
110 }
111 } else {
112 set_value(0);
|