Mercurial > hg > truffle
comparison src/share/vm/runtime/arguments.cpp @ 11070:6e3634222155
8017611: Auto corrector for mistyped vm options
Summary: The auto corrector for mistyped vm options fuzzy-matches existing flags based on string similarity (Dice's coefficient).
Reviewed-by: kvn, dsamersoff, hseigel, johnc
author | tamao |
---|---|
date | Fri, 28 Jun 2013 20:18:04 -0700 |
parents | c92b74c62d97 |
children | 8b789ce47503 |
comparison
equal
deleted
inserted
replaced
11069:5ea20b3bd249 | 11070:6e3634222155 |
---|---|
847 arg_len = strlen(argname); | 847 arg_len = strlen(argname); |
848 } else { | 848 } else { |
849 arg_len = equal_sign - argname; | 849 arg_len = equal_sign - argname; |
850 } | 850 } |
851 | 851 |
852 Flag* found_flag = Flag::find_flag((char*)argname, arg_len, true); | 852 Flag* found_flag = Flag::find_flag((const char*)argname, arg_len, true); |
853 if (found_flag != NULL) { | 853 if (found_flag != NULL) { |
854 char locked_message_buf[BUFLEN]; | 854 char locked_message_buf[BUFLEN]; |
855 found_flag->get_locked_message(locked_message_buf, BUFLEN); | 855 found_flag->get_locked_message(locked_message_buf, BUFLEN); |
856 if (strlen(locked_message_buf) == 0) { | 856 if (strlen(locked_message_buf) == 0) { |
857 if (found_flag->is_bool() && !has_plus_minus) { | 857 if (found_flag->is_bool() && !has_plus_minus) { |
868 jio_fprintf(defaultStream::error_stream(), "%s", locked_message_buf); | 868 jio_fprintf(defaultStream::error_stream(), "%s", locked_message_buf); |
869 } | 869 } |
870 } else { | 870 } else { |
871 jio_fprintf(defaultStream::error_stream(), | 871 jio_fprintf(defaultStream::error_stream(), |
872 "Unrecognized VM option '%s'\n", argname); | 872 "Unrecognized VM option '%s'\n", argname); |
873 Flag* fuzzy_matched = Flag::fuzzy_match((const char*)argname, arg_len, true); | |
874 if (fuzzy_matched != NULL) { | |
875 jio_fprintf(defaultStream::error_stream(), | |
876 "Did you mean '%s%s%s'?\n", | |
877 (fuzzy_matched->is_bool()) ? "(+/-)" : "", | |
878 fuzzy_matched->name, | |
879 (fuzzy_matched->is_bool()) ? "" : "=<value>"); | |
880 } | |
873 } | 881 } |
874 | 882 |
875 // allow for commandline "commenting out" options like -XX:#+Verbose | 883 // allow for commandline "commenting out" options like -XX:#+Verbose |
876 return arg[0] == '#'; | 884 return arg[0] == '#'; |
877 } | 885 } |