static void izcmds(void) { int x; cmdhash = htmk(256); for (x = 0; x != sizeof(cmds) / sizeof(CMD); ++x) htadd(cmdhash, cmds[x].name, cmds + x); }
void init_gettext(unsigned char *s) { FILE *f; unsigned char buf[1024]; snprintf(buf, sizeof(buf), "%slang/%s.po",JOEDATA,s); if ((f = fopen((char *)buf, "r"))) { /* Try specific language, like en_GB */ gettext_ht = htmk(256); load_po(f); } else if (s[0] && s[1]) { /* Try generic language, like en */ snprintf(buf, sizeof(buf), "%slang/%c%c.po",JOEDATA,s[0],s[1]); if ((f = fopen((char *)buf, "r"))) { gettext_ht = htmk(256); load_po(f); } } }
void init_gettext(const char *s) { FILE *f; char buf[1024]; joe_snprintf_2(buf, SIZEOF(buf), "%slang/%s.po",JOEDATA,s); if ((f = fopen(buf, "r"))) { /* Try specific language, like en_GB */ gettext_ht = htmk(256); load_po(f); } else if (s[0] && s[1]) { /* Try generic language, like en */ joe_snprintf_3(buf, SIZEOF(buf), "%slang/%c%c.po",JOEDATA,s[0],s[1]); if ((f = fopen(buf, "r"))) { gettext_ht = htmk(256); load_po(f); } } }
struct high_syntax *load_syntax_subr(unsigned char *name, unsigned char *subr, struct high_param *params) { struct high_syntax *syntax; /* New syntax table */ /* Find syntax table */ /* Already loaded? */ for (syntax = syntax_list; syntax; syntax = syntax->next) { if (syntax_match(syntax, name, subr, params)) { return syntax; } } /* Create new one */ syntax = joe_malloc(sizeof(struct high_syntax)); syntax->name = zdup(name); syntax->subr = subr ? zdup(subr) : 0; syntax->params = params; syntax->next = syntax_list; syntax->nstates = 0; syntax->color = 0; syntax->states = joe_malloc(sizeof(struct high_state *) * (syntax->szstates = 64)); syntax->ht_states = htmk(syntax->szstates); iz_cmd(&syntax->default_cmd); syntax->default_cmd.reset = 1; syntax->stack_base = 0; syntax_list = syntax; if (load_dfa(syntax)) { /* dump_syntax(syntax); */ return syntax; } else { if (syntax_list == syntax) { syntax_list = syntax_list->next; } else { struct high_syntax *syn; for (syn = syntax_list; syn->next != syntax; syn = syn->next); syn->next = syntax->next; } htrm(syntax->ht_states); joe_free(syntax->name); joe_free(syntax->states); joe_free(syntax); return 0; } }
void parse_options(struct high_syntax *syntax, struct high_cmd *cmd, FILE *f, unsigned char *p, int parsing_strings, unsigned char *name, int line) { unsigned char buf[1024]; unsigned char bf[256]; unsigned char bf1[256]; while (parse_ws(&p, '#'), !parse_ident(&p, bf, sizeof(bf))) { if (!zcmp(bf, USTR "buffer")) { cmd->start_buffering = 1; } else if (!zcmp(bf, USTR "hold")) { cmd->stop_buffering = 1; } else if (!zcmp(bf, USTR "save_c")) { cmd->save_c = 1; } else if (!zcmp(bf, USTR "save_s")) { cmd->save_s = 1; } else if (!zcmp(bf, USTR "recolor")) { parse_ws(&p, '#'); if (!parse_char(&p, '=')) { parse_ws(&p, '#'); if (parse_int(&p, &cmd->recolor)) { i_printf_2((char *)joe_gettext(_("%s %d: Missing value for option\n")), name, line); } } else { i_printf_2((char *)joe_gettext(_("%s %d: Missing value for option\n")), name, line); } } else if (!zcmp(bf, USTR "call")) { parse_ws(&p, '#'); if (!parse_char(&p, '=')) { parse_ws(&p, '#'); if (!parse_char(&p, '.')) { zcpy(bf, syntax->name); goto subr; } else if (parse_ident(&p, bf, sizeof(bf))) { i_printf_2((char *)joe_gettext(_("%s %d: Missing value for option\n")), name, line); } else { if (!parse_char(&p, '.')) { subr: if (parse_ident(&p, bf1, sizeof(bf1))) { i_printf_2((char *)joe_gettext(_("%s %d: Missing subroutine name\n")), name, line); } cmd->call = load_syntax_subr(bf, bf1, parse_params(syntax->params, &p, name, line)); } else { cmd->call = load_syntax_subr(bf, 0, parse_params(syntax->params, &p, name, line)); } } } else { i_printf_2((char *)joe_gettext(_("%s %d: Missing value for option\n")), name, line); } } else if (!zcmp(bf, USTR "return")) { cmd->rtn = 1; } else if (!zcmp(bf, USTR "reset")) { cmd->reset = 1; } else if (!parsing_strings && (!zcmp(bf, USTR "strings") || !zcmp(bf, USTR "istrings"))) { if (bf[0] == 'i') { cmd->ignore = 1; } while (fgets((char *)buf, 1023, f)) { ++line; p = buf; parse_ws(&p, '#'); if (*p) { if (!parse_field(&p, USTR "done")) { break; } if (parse_string(&p, bf, sizeof(bf)) >= 0) { parse_ws(&p, '#'); if (cmd->ignore) { lowerize(bf); } if (!parse_ident(&p, bf1, sizeof(bf1))) { struct high_cmd *kw_cmd = mkcmd(); kw_cmd->noeat = 1; kw_cmd->new_state = find_state(syntax, bf1); if (!zcmp(bf, USTR "&")) { cmd->delim = kw_cmd; } else { if (!cmd->keywords) { cmd->keywords = htmk(64); } htadd(cmd->keywords, zdup(bf), kw_cmd); } parse_options(syntax, kw_cmd, f, p, 1, name, line); } else { i_printf_2((char *)joe_gettext(_("%s %d: Missing state name\n")), name, line); } } else { i_printf_2((char *)joe_gettext(_("%s %d: Missing string\n")), name, line); } } } } else if (!zcmp(bf, USTR "noeat")) { cmd->noeat = 1; } else if (!zcmp(bf, USTR "mark")) { cmd->start_mark = 1; } else if (!zcmp(bf, USTR "markend")) { cmd->stop_mark = 1; } else if (!zcmp(bf, USTR "recolormark")) { cmd->recolor_mark = 1; } else { i_printf_2((char *)joe_gettext(_("%s %d: Unknown option\n")), name, line); } } }