< prev index next >

src/share/vm/runtime/globals.cpp

Print this page

        

*** 473,484 **** // This works for most flags, but there are exceptions. Our longest flag // name right now is UseAdaptiveGenerationSizePolicyAtMajorCollection and // its minor collection buddy. These are 48 characters. We use a buffer of // 10 spaces below to adjust the space between the flag value and the // column of flag type and origin that is printed in the end of the line. ! char spaces[10 + 1] = " "; ! st->print("%9s %-40s = ", _type, _name); if (is_bool()) { st->print("%-20s", get_bool() ? "true" : "false"); } else if (is_int()) { st->print("%-20d", get_int()); --- 473,489 ---- // This works for most flags, but there are exceptions. Our longest flag // name right now is UseAdaptiveGenerationSizePolicyAtMajorCollection and // its minor collection buddy. These are 48 characters. We use a buffer of // 10 spaces below to adjust the space between the flag value and the // column of flag type and origin that is printed in the end of the line. ! ! // Use some named constants to make code more readable. ! char spaces[] = " "; // 10 spaces plus NUL ! const unsigned int maxFlagLen = 50; ! const unsigned int nSpaces = strlen(spaces); ! ! st->print("%9s %-*s = ", _type, maxFlagLen-nSpaces, _name); if (is_bool()) { st->print("%-20s", get_bool() ? "true" : "false"); } else if (is_int()) { st->print("%-20d", get_int());
*** 507,519 **** } st->print("%-20s", cp); } else st->print("%-20s", ""); } ! assert(strlen(_name) < 50, "Flag name is longer than expected"); ! spaces[50 - MAX2((size_t)40, strlen(_name))] = '\0'; st->print("%s", spaces); print_kind_and_origin(st); #ifndef PRODUCT if (withComments) { st->print("%s", _doc); --- 512,527 ---- } st->print("%-20s", cp); } else st->print("%-20s", ""); } ! // Make sure we do not punch a '\0' at a negative char array index. ! unsigned int nameLen = strlen(_name); ! if (nameLen < maxFlagLen) { ! spaces[maxFlagLen - MAX2(maxFlagLen-nSpaces, nameLen)] = '\0'; st->print("%s", spaces); + } print_kind_and_origin(st); #ifndef PRODUCT if (withComments) { st->print("%s", _doc);
< prev index next >