/** Set the game language to the specified one. */ void language_set(gint index) { #ifdef DEBUG printf("language_set\n"); #endif gchar buf[SMALL], buf2[SMALL]; gchar *dir; GPtrArray *codes = misc_separate_strings(const_str("string_language_codes")); if(index > 0) strcpy(buf, (gchar*)g_ptr_array_index(codes, index - 1)); else strcpy(buf, ""); if(strcmp(buf, opt_str("string_opt_language_code")) != 0 || window.main == NULL) { #ifndef MAC_BUILD dir = g_get_current_dir(); sprintf(buf2, "%s%slocale", dir, G_DIR_SEPARATOR_S); #else dir = file_get_mac_resource_path("locale"); strcpy(buf2, dir); #endif g_free(dir); #ifdef ENABLE_NLS if(g_file_test(buf2, G_FILE_TEST_EXISTS)) { bindtextdomain (GETTEXT_PACKAGE, buf2); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); } #endif g_setenv ("LANGUAGE", buf, TRUE); opt_set_str("string_opt_language_code", buf); { extern int _nl_msg_cat_cntr; ++_nl_msg_cat_cntr; } if(window.main != NULL) { window_destroy(&window.main); window_create(WINDOW_MAIN); on_button_back_to_main_clicked(NULL, NULL); } } lg_commentary_load_commentary_file_from_option(); news_load_news_file_from_option(); free_gchar_array(&codes); }
static void set_default_opts(void) { opt_set_int("rt-stats", 0); opt_set_int("rt_trace_en", 0); opt_set_int("dump-llvm", 0); opt_set_int("optimise", 1); opt_set_int("native", 0); opt_set_int("bootstrap", 0); opt_set_int("cover", 0); opt_set_int("stop-delta", 1000); opt_set_int("unit-test", 0); opt_set_int("prefer-explicit", 0); opt_set_int("make-deps-only", 0); opt_set_int("make-posix", 0); opt_set_str("work-name", "work"); opt_set_str("dump-vcode", NULL); opt_set_int("relax", 0); }
int main(int argc, char **argv) { term_init(); set_default_opts(); if (getenv("NVC_GDB") != NULL) register_gdb_signal_handlers(); else register_trace_signal_handlers(); atexit(fbuf_cleanup); static struct option long_options[] = { { "help", no_argument, 0, 'h' }, { "version", no_argument, 0, 'v' }, { "work", required_argument, 0, 'w' }, { "dump", no_argument, 0, 'd' }, { "codegen", no_argument, 0, 'c' }, { "make", no_argument, 0, 'm' }, { "std", required_argument, 0, 's' }, { 0, 0, 0, 0 } }; int c, index = 0; const char *spec = "aehrvL:"; while ((c = getopt_long(argc, argv, spec, long_options, &index)) != -1) { switch (c) { case 0: // Set a flag break; case 'h': usage(); exit(EXIT_SUCCESS); case 'v': printf("%s\n%s\n", version_string, copy_string); exit(EXIT_SUCCESS); case 'w': opt_set_str("work-name", optarg); break; case 'L': lib_add_search_path(optarg); break; case 's': set_standard(parse_standard(optarg)); break; case 'a': case 'e': case 'd': case 'r': case 'c': case 'm': // Subcommand options are parsed later argc -= (optind - 1); argv += (optind - 1); goto getopt_out; case '?': // getopt_long already printed an error message exit(EXIT_FAILURE); default: abort(); } } getopt_out: switch (c) { case 'a': return analyse(argc, argv); case 'e': return elaborate(argc, argv); case 'r': return run(argc, argv); case 'd': return dump_cmd(argc, argv); case 'c': return codegen(argc, argv); case 'm': return make_cmd(argc, argv); default: fprintf(stderr, "%s: missing command\n", PACKAGE); return EXIT_FAILURE; } }