Exemple #1
0
static void init_language(void)
{
    struct locale* lang;
    int i;

    lang = get_or_create_locale("de");
    locale_setstring(lang, "skill::unarmed", "Waffenloser Kampf");
    locale_setstring(lang, "keyword::attack", "ATTACKIERE");
    locale_setstring(lang, "keyword::study", "LERNE");
    locale_setstring(lang, "keyword::tax", "TREIBE");
    locale_setstring(lang, "keyword::loot", "PLUENDERE");
    locale_setstring(lang, "keyword::piracy", "PIRATERIE");
    locale_setstring(lang, "keyword::guard", "BEWACHE");
    locale_setstring(lang, "keyword::move", "NACH");
    locale_setstring(lang, "keyword::message", "BOTSCHAFT");
    locale_setstring(lang, "REGION", "REGION");
    locale_setstring(lang, "east", "O");

    for (i = 0; i < MAXKEYWORDS; ++i) {
        if (!locale_getstring(lang, mkname("keyword", keywords[i])))
            locale_setstring(lang, mkname("keyword", keywords[i]), keywords[i]);
    }
    for (i = 0; i < MAXSKILLS; ++i) {
        if (!locale_getstring(lang, mkname("skill", skillnames[i])))
            locale_setstring(lang, mkname("skill", skillnames[i]), skillnames[i]);
    }
    init_keywords(lang);
    init_skills(lang);
}
Exemple #2
0
void
extract_php (FILE *f,
	     const char *real_filename, const char *logical_filename,
	     flag_context_list_table_ty *flag_table,
	     msgdomain_list_ty *mdlp)
{
  message_list_ty *mlp = mdlp->item[0]->messages;

  fp = f;
  real_file_name = real_filename;
  logical_file_name = xstrdup (logical_filename);
  line_number = 1;

  last_comment_line = -1;
  last_non_comment_line = -1;

  flag_context_list_table = flag_table;

  init_keywords ();

  /* Initial mode is HTML mode, not PHP mode.  */
  skip_html ();

  /* Eat tokens until eof is seen.  When extract_parenthesized returns
     due to an unbalanced closing parenthesis, just restart it.  */
  while (!extract_parenthesized (mlp, null_context, null_context_list_iterator,
				 arglist_parser_alloc (mlp, NULL)))
    ;

  /* Close scanner.  */
  fp = NULL;
  real_file_name = NULL;
  logical_file_name = NULL;
  line_number = 0;
}
Exemple #3
0
void
extract_awk (FILE *f,
             const char *real_filename, const char *logical_filename,
             flag_context_list_table_ty *flag_table,
             msgdomain_list_ty *mdlp)
{
  message_list_ty *mlp = mdlp->item[0]->messages;

  fp = f;
  real_file_name = real_filename;
  logical_file_name = xstrdup (logical_filename);
  line_number = 1;

  last_comment_line = -1;
  last_non_comment_line = -1;

  prefer_division_over_regexp = false;

  flag_context_list_table = flag_table;

  init_keywords ();

  /* Eat tokens until eof is seen.  When extract_parenthesized returns
     due to an unbalanced closing parenthesis, just restart it.  */
  while (!extract_parenthesized (mlp, null_context, null_context_list_iterator,
                                 arglist_parser_alloc (mlp, NULL)))
    ;

  fp = NULL;
  real_file_name = NULL;
  logical_file_name = NULL;
  line_number = 0;
}
Exemple #4
0
int main() {
    char buf[8192], *p;
    int i, n=0;

    init_keywords();

    while (fgets(buf, sizeof buf, stdin) != NULL) {
        p = buf;
        while (isspace(*p))
            p++;
        if (*p == '\0' || strncmp(p, "XXX", 3) == 0)
            continue;
        assert(strchr(p, '\n') != NULL);
        parseline(p);
    }

    for (i=0; i < VAR_SIZE; i++)
        if ((p = variables[i]) != NULL) {
            n++;
            printf("%s\n", p);
            /* A very helpful debugging tool. */
            if (!normalname(p))
                fprintf(stderr, "Unexpected variable name: %s\n", p);
        }
    printf("Saw %d variable names\n", n);

    return 0;
}
Exemple #5
0
		Lexer::Lexer(SourceFile* file)
			:
			line_number_(1)
		{
			file_ = std::unique_ptr<SourceFile>(file);
			init_keywords();
			current_char_ = file_->next_char();
		}
SchemeObjectCreator::SchemeObjectCreator() :
    the_interaction_env_(Environment::get_global_environment()),
    standard_input_(this),
    standard_output_()
{
    // Guard single instances
    the_interaction_env_.protect_from_gc();
    standard_input_.protect_from_gc();
    standard_output_.protect_from_gc();

    init_keywords();
}
Exemple #7
0
// Return the token type of the keyword str. If str is not a keyword,
// then it must be an identifier.
Token_type
lookup_keyword(String str) {
  // If the keyword table is empty, then populate it on the first pass.
  if (keywords.empty())
    init_keywords();

  // Find the given keyword.
  auto i = keywords.find(str);
  if (i != keywords.end())
    return i->second;
  else
    return Identifier_tok;
}
Exemple #8
0
int
load_config (char * file)
{
	if (!conf)
		conf = alloc_config();

	if (!conf)
		return 1;

	/*
	 * internal defaults
	 */
	if (!conf->verbosity)
		conf->verbosity = DEFAULT_VERBOSITY;

	conf->udev = udev_new();
	dm_drv_version(conf->version, TGT_MPATH);
	conf->dev_type = DEV_NONE;
	conf->minio = DEFAULT_MINIO;
	conf->minio_rq = DEFAULT_MINIO_RQ;
	get_sys_max_fds(&conf->max_fds);
	conf->bindings_file = set_default(DEFAULT_BINDINGS_FILE);
	conf->wwids_file = set_default(DEFAULT_WWIDS_FILE);
	conf->bindings_read_only = 0;
	conf->multipath_dir = set_default(DEFAULT_MULTIPATHDIR);
	conf->features = set_default(DEFAULT_FEATURES);
	conf->flush_on_last_del = 0;
	conf->attribute_flags = 0;
	conf->reassign_maps = DEFAULT_REASSIGN_MAPS;
	conf->checkint = DEFAULT_CHECKINT;
	conf->max_checkint = MAX_CHECKINT(conf->checkint);
	conf->fast_io_fail = DEFAULT_FAST_IO_FAIL;
	conf->retain_hwhandler = DEFAULT_RETAIN_HWHANDLER;
	conf->detect_prio = DEFAULT_DETECT_PRIO;

	/*
	 * preload default hwtable
	 */
	if (conf->hwtable == NULL) {
		conf->hwtable = vector_alloc();

		if (!conf->hwtable)
			goto out;
	}
	if (setup_default_hwtable(conf->hwtable))
		goto out;

	/*
	 * read the config file
	 */
	set_current_keywords(&conf->keywords);
	alloc_keywords();
	if (filepresent(file)) {
		int builtin_hwtable_size;

		builtin_hwtable_size = VECTOR_SIZE(conf->hwtable);
		if (init_data(file, init_keywords)) {
			condlog(0, "error parsing config file");
			goto out;
		}
		if (VECTOR_SIZE(conf->hwtable) > builtin_hwtable_size) {
			/*
			 * remove duplica in hwtable. config file
			 * takes precedence over build-in hwtable
			 */
			factorize_hwtable(conf->hwtable, builtin_hwtable_size);
		}

	} else {
		init_keywords();
	}

	/*
	 * fill the voids left in the config file
	 */
	if (conf->blist_devnode == NULL) {
		conf->blist_devnode = vector_alloc();

		if (!conf->blist_devnode)
			goto out;
	}
	if (conf->blist_wwid == NULL) {
		conf->blist_wwid = vector_alloc();

		if (!conf->blist_wwid)
			goto out;
	}
	if (conf->blist_device == NULL) {
		conf->blist_device = vector_alloc();

		if (!conf->blist_device)
			goto out;
	}
	if (setup_default_blist(conf))
		goto out;

	if (conf->elist_devnode == NULL) {
		conf->elist_devnode = vector_alloc();

		if (!conf->elist_devnode)
			goto out;
	}
	if (conf->elist_wwid == NULL) {
		conf->elist_wwid = vector_alloc();

		if (!conf->elist_wwid)
			goto out;
	}

	if (conf->elist_device == NULL) {
		conf->elist_device = vector_alloc();

		if (!conf->elist_device)
			goto out;
	}

	if (conf->mptable == NULL) {
		conf->mptable = vector_alloc();
		if (!conf->mptable)
			goto out;
	}
	if (conf->bindings_file == NULL)
		conf->bindings_file = set_default(DEFAULT_BINDINGS_FILE);

	if (!conf->multipath_dir || !conf->bindings_file ||
	    !conf->wwids_file)
		goto out;

	return 0;
out:
	free_config(conf);
	return 1;
}