X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Fmath_hash.C;h=ba5fb5cdccbed8f16d05a12ccbefec7cda996c55;hb=82fa210ea8d38d51aafb131f10d843e27e056429;hp=02f5ac52478ba5a6593897b1eddf8690351fa30e;hpb=dfe1bc44b44903faf77ef454c98c4c3e56c1d5e3;p=lyx.git diff --git a/src/mathed/math_hash.C b/src/mathed/math_hash.C index 02f5ac5247..ba5fb5cdcc 100644 --- a/src/mathed/math_hash.C +++ b/src/mathed/math_hash.C @@ -1,9 +1,9 @@ /* C code produced by gperf version 2.5 (GNU C++ version) */ /* Command-line: gperf -a -p -o -t -G -D keywords */ #include -#include -#include -#include + +#include +#include #include "math_defs.h" #include "math_parser.h" @@ -16,10 +16,11 @@ #define MAX_HASH_VALUE 490 /* maximum key range = 483, duplicates = 40 */ -static unsigned int -hash (register const char *str, register int len) +static +unsigned int +math_hash (register char const *str, register int len) { - static unsigned short asso_values[] = + static unsigned short asso_values[] = { 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, 491, @@ -38,23 +39,24 @@ hash (register const char *str, register int len) return len + asso_values[str[len - 1]] + asso_values[str[0]]; } -static struct latexkeys wordlist[] = +static +latexkeys wordlist[] = { - {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, + {"",0,0}, {"",0,0}, {"",0,0}, {"",0,0}, {"",0,0}, {"",0,0}, {"",0,0}, {"",0,0}, {"setminus", LM_TK_SYM, LM_setminus}, {"ldots", LM_TK_DOTS, LM_ldots}, {"limits", LM_TK_LIMIT, 1 }, - {"stackrel", LM_TK_STACK}, + {"stackrel", LM_TK_STACK, 0}, {"ll", LM_TK_SYM, LM_ll}, - {"label", LM_TK_LABEL}, + {"label", LM_TK_LABEL, 0}, {"lceil", LM_TK_SYM, LM_lceil}, - {"sqrt", LM_TK_SQRT}, + {"sqrt", LM_TK_SQRT, 0}, {"times", LM_TK_SYM, LM_times}, {"subset", LM_TK_SYM, LM_subset}, {"supset", LM_TK_SYM, LM_supset}, {"spadesuit", LM_TK_SYM, LM_spadesuit}, {"Re", LM_TK_SYM, LM_Re}, - {"left", LM_TK_LEFT}, + {"left", LM_TK_LEFT, 0}, {"smile", LM_TK_SYM, LM_smile}, {"exists", LM_TK_SYM, LM_exists}, {"Vert", LM_TK_SYM, LM_Vert}, @@ -65,8 +67,8 @@ static struct latexkeys wordlist[] = {"scriptscriptstyle", LM_TK_STY, LM_ST_SCRIPTSCRIPT}, {"zeta", LM_TK_SYM, LM_zeta}, {"sigma", LM_TK_SYM, LM_sigma}, - {"arccos", LM_TK_FUNC}, - {"sup", LM_TK_FUNCLIM}, + {"arccos", LM_TK_FUNC, 0}, + {"sup", LM_TK_FUNCLIM, 0}, {"sharp", LM_TK_SYM, LM_sharp}, {"sqcup", LM_TK_SYM, LM_sqcup}, {"sqcap", LM_TK_SYM, LM_sqcap}, @@ -79,7 +81,7 @@ static struct latexkeys wordlist[] = {"triangle", LM_TK_SYM, LM_triangle}, {"textstyle", LM_TK_STY, LM_ST_TEXT}, {"tau", LM_TK_SYM, LM_tau}, - {"limsup", LM_TK_FUNCLIM}, + {"limsup", LM_TK_FUNCLIM, 0}, {"partial", LM_TK_SYM, LM_partial}, {"parallel", LM_TK_SYM, LM_parallel}, {"infty", LM_TK_SYM, LM_infty}, @@ -97,7 +99,7 @@ static struct latexkeys wordlist[] = {"eta", LM_TK_SYM, LM_eta}, {"acute", LM_TK_ACCENT, LM_acute}, {"angle", LM_TK_SYM, LM_angle}, - {"exp", LM_TK_FUNC}, + {"exp", LM_TK_FUNC, 0}, {"leftarrow", LM_TK_SYM, LM_leftarrow}, {"prime", LM_TK_SYM, LM_prime}, {"int", LM_TK_BIGSYM, LM_int}, @@ -111,12 +113,12 @@ static struct latexkeys wordlist[] = {"longleftrightarrow", LM_TK_SYM, LM_longleftrightarrow}, {"alpha", LM_TK_SYM, LM_alpha}, {"widehat", LM_TK_WIDE, LM_widehat}, - {"sin", LM_TK_FUNC}, + {"sin", LM_TK_FUNC, 0}, {"asymp", LM_TK_SYM, LM_asymp}, {"nolimits", LM_TK_LIMIT, 0 }, {"perp", LM_TK_MACRO, LM_perp}, {"wedge", LM_TK_SYM, LM_wedge}, - {"ln", LM_TK_FUNC}, + {"ln", LM_TK_FUNC, 0}, {"widetilde", LM_TK_WIDE, LM_widetilde}, {"Omega", LM_TK_SYM, LM_Omega}, {"natural", LM_TK_SYM, LM_natural}, @@ -131,33 +133,33 @@ static struct latexkeys wordlist[] = {"leftharpoondown", LM_TK_SYM, LM_leftharpoondown}, {"wp", LM_TK_SYM, LM_wp}, {"not", LM_TK_ACCENT, LM_not}, - {"tan", LM_TK_FUNC}, + {"tan", LM_TK_FUNC, 0}, {"Theta", LM_TK_SYM, LM_Theta}, {"rceil", LM_TK_SYM, LM_rceil}, {"lfloor", LM_TK_SYM, LM_lfloor}, {"rightleftharpoons", LM_TK_SYM, LM_rightleftharpoons}, - {"cos", LM_TK_FUNC}, - {"sec", LM_TK_FUNC}, + {"cos", LM_TK_FUNC, 0}, + {"sec", LM_TK_FUNC, 0}, {"succ", LM_TK_SYM, LM_succ}, {"cdots", LM_TK_DOTS, LM_cdots}, {"epsilon", LM_TK_SYM, LM_epsilon}, - {"ker", LM_TK_FUNC}, + {"ker", LM_TK_FUNC, 0}, {"nu", LM_TK_SYM, LM_nu}, {"Delta", LM_TK_SYM, LM_Delta}, {"forall", LM_TK_SYM, LM_forall}, - {"liminf", LM_TK_FUNCLIM}, + {"liminf", LM_TK_FUNCLIM, 0}, {"Uparrow", LM_TK_SYM, LM_Uparrow}, {"upsilon", LM_TK_SYM, LM_upsilon}, - {"right", LM_TK_RIGHT}, + {"right", LM_TK_RIGHT, 0}, {"Updownarrow", LM_TK_SYM, LM_Updownarrow}, - {"Pr", LM_TK_FUNCLIM}, + {"Pr", LM_TK_FUNCLIM, 0}, {"nabla", LM_TK_SYM, LM_nabla}, - {"arcsin", LM_TK_FUNC}, - {"arctan", LM_TK_FUNC}, + {"arcsin", LM_TK_FUNC, 0}, + {"arctan", LM_TK_FUNC, 0}, {"flat", LM_TK_SYM, LM_flat}, {"check", LM_TK_ACCENT, LM_check}, {"rangle", LM_TK_SYM, LM_rangle}, - {"cot", LM_TK_FUNC}, + {"cot", LM_TK_FUNC, 0}, {"cdot", LM_TK_SYM, LM_cdot}, {"clubsuit", LM_TK_SYM, LM_clubsuit}, {"in", LM_TK_SYM, LM_in}, @@ -169,9 +171,9 @@ static struct latexkeys wordlist[] = {"models", LM_TK_SYM, LM_models}, {"nearrow", LM_TK_SYM, LM_nearrow}, {"nwarrow", LM_TK_SYM, LM_nwarrow}, - {"max", LM_TK_FUNCLIM}, + {"max", LM_TK_FUNCLIM, 0}, {"Im", LM_TK_SYM, LM_Im}, - {"lim", LM_TK_FUNCLIM}, + {"lim", LM_TK_FUNCLIM, 0}, {"rightharpoonup", LM_TK_SYM, LM_rightharpoonup}, {"mathcal", LM_TK_FONT, LM_TC_CAL}, {"cap", LM_TK_SYM, LM_cap}, @@ -179,7 +181,7 @@ static struct latexkeys wordlist[] = {"prec", LM_TK_SYM, LM_prec}, {"mathnormal", LM_TK_FONT, LM_TC_NORMAL}, {"wr", LM_TK_SYM, LM_wr}, - {"inf", LM_TK_FUNCLIM}, + {"inf", LM_TK_FUNCLIM, 0}, {"bigoplus", LM_TK_BIGSYM, LM_oplus}, {"biguplus", LM_TK_BIGSYM, LM_biguplus}, {"bigotimes", LM_TK_BIGSYM, LM_otimes}, @@ -202,31 +204,31 @@ static struct latexkeys wordlist[] = {"bot", LM_TK_SYM, LM_bot}, {"bullet", LM_TK_SYM, LM_bullet}, {"bigodot", LM_TK_BIGSYM, LM_bigodot}, - {"sinh", LM_TK_FUNC}, + {"sinh", LM_TK_FUNC, 0}, {"jmath", LM_TK_SYM, LM_jmath}, {"mp", LM_TK_SYM, LM_mp}, {"pm", LM_TK_SYM, LM_pm}, - {"nonumber", LM_TK_NONUM}, + {"nonumber", LM_TK_NONUM, 0}, {"breve", LM_TK_ACCENT, LM_breve}, {"bigvee", LM_TK_BIGSYM, LM_vee}, {"bowtie", LM_TK_SYM, LM_bowtie}, {"bigwedge", LM_TK_BIGSYM, LM_wedge}, {"frown", LM_TK_SYM, LM_frown}, {"rightharpoondown", LM_TK_SYM, LM_rightharpoondown}, - {"det", LM_TK_FUNCLIM}, + {"det", LM_TK_FUNCLIM, 0}, {"dot", LM_TK_ACCENT, LM_dot}, {"ddot", LM_TK_ACCENT, LM_ddot}, - {"lg", LM_TK_FUNC}, - {"log", LM_TK_FUNC}, + {"lg", LM_TK_FUNC, 0}, + {"log", LM_TK_FUNC, 0}, {"oplus", LM_TK_SYM, LM_oplus}, {"ominus", LM_TK_SYM, LM_ominus}, {"otimes", LM_TK_SYM, LM_otimes}, {"beta", LM_TK_SYM, LM_beta}, {"diamondsuit", LM_TK_SYM, LM_diamondsuit}, {"rfloor", LM_TK_SYM, LM_rfloor}, - {"end", LM_TK_END}, + {"end", LM_TK_END, 0}, {"hat", LM_TK_ACCENT, LM_hat}, - {"tanh", LM_TK_FUNC}, + {"tanh", LM_TK_FUNC, 0}, {"vdots", LM_TK_DOTS, LM_vdots}, {"bigcap", LM_TK_BIGSYM, LM_cap}, {"bigcup", LM_TK_BIGSYM, LM_cup}, @@ -240,15 +242,15 @@ static struct latexkeys wordlist[] = {"odot", LM_TK_SYM, LM_odot}, {"oint", LM_TK_BIGSYM, LM_oint}, {"grave", LM_TK_ACCENT, LM_grave}, - {"pmod", LM_TK_PMOD}, + {"pmod", LM_TK_PMOD, 0}, {"prod", LM_TK_BIGSYM, LM_prod}, - {"frac", LM_TK_FRAC}, - {"csc", LM_TK_FUNC}, + {"frac", LM_TK_FRAC, 0}, + {"csc", LM_TK_FUNC, 0}, {"circ", LM_TK_SYM, LM_circ}, {"aleph", LM_TK_SYM, LM_aleph}, - {"min", LM_TK_FUNCLIM}, + {"min", LM_TK_FUNCLIM, 0}, {"overline", LM_TK_WIDE, LM_overline}, - {"arg", LM_TK_FUNC}, + {"arg", LM_TK_FUNC, 0}, {"overbrace", LM_TK_WIDE, LM_overbrace}, {"amalg", LM_TK_SYM, LM_amalg}, {"gamma", LM_TK_SYM, LM_gamma}, @@ -258,7 +260,7 @@ static struct latexkeys wordlist[] = {"downarrow", LM_TK_SYM, LM_downarrow}, {"imath", LM_TK_SYM, LM_imath}, {"propto", LM_TK_SYM, LM_propto}, - {"begin", LM_TK_BEGIN}, + {"begin", LM_TK_BEGIN, 0}, {"Lambda", LM_TK_SYM, LM_Lambda}, {"varsigma", LM_TK_SYM, LM_varsigma}, {"vartheta", LM_TK_SYM, LM_vartheta}, @@ -271,7 +273,7 @@ static struct latexkeys wordlist[] = {"bar", LM_TK_ACCENT, LM_bar}, {"varpi", LM_TK_SYM, LM_varpi}, {"varphi", LM_TK_SYM, LM_varphi}, - {"newcommand", LM_TK_NEWCOMMAND }, + {"newcommand", LM_TK_NEWCOMMAND, 0 }, {"overleftarrow", LM_TK_WIDE, LM_overleftarrow}, {"overrightarrow", LM_TK_WIDE, LM_overightarrow}, {"Leftarrow", LM_TK_SYM, LM_Leftarrow}, @@ -287,15 +289,15 @@ static struct latexkeys wordlist[] = {"coprod", LM_TK_BIGSYM, LM_coprod}, {"mathrm", LM_TK_FONT, LM_TC_RM}, {"varepsilon", LM_TK_SYM, LM_varepsilon}, - {"cosh", LM_TK_FUNC}, - {"coth", LM_TK_FUNC}, + {"cosh", LM_TK_FUNC, 0}, + {"coth", LM_TK_FUNC, 0}, {"rho", LM_TK_SYM, LM_rho}, {"cong", LM_TK_SYM, LM_cong}, {"vec", LM_TK_ACCENT, LM_vec}, - {"dim", LM_TK_FUNC}, + {"dim", LM_TK_FUNC, 0}, {"mid", LM_TK_SYM, LM_mid}, - {"hom", LM_TK_FUNC}, - {"bmod", LM_TK_FUNC}, + {"hom", LM_TK_FUNC, 0}, + {"bmod", LM_TK_FUNC, 0}, {"quad", LM_TK_SPACE, LM_quad}, {"doteq", LM_TK_SYM, LM_doteq}, {"qquad", LM_TK_SPACE, LM_qquad}, @@ -303,8 +305,8 @@ static struct latexkeys wordlist[] = {"backslash", LM_TK_SYM, LM_backslash}, {"diamond", LM_TK_SYM, LM_diamond}, {"geq", LM_TK_SYM, LM_geq}, - {"deg", LM_TK_FUNC}, - {"gcd", LM_TK_FUNCLIM}, + {"deg", LM_TK_FUNC, 0}, + {"gcd", LM_TK_FUNCLIM, 0}, {"gg", LM_TK_SYM, LM_gg}, {"div", LM_TK_SYM, LM_div}, {"dashv", LM_TK_SYM, LM_dashv}, @@ -312,7 +314,7 @@ static struct latexkeys wordlist[] = {"vdash", LM_TK_SYM, LM_vdash}, }; -static short lookup[] = +static short lookup[] = { -1, -1, -1, -1, -1, -1, -1, -1, 8, -1, -1, -1, -1, -1, -1, 9, 10, -1, 11, -1, -1, -1, 12, -1, -1, 491, -13, -2, @@ -353,11 +355,11 @@ static short lookup[] = }; struct latexkeys * -in_word_set (register const char *str, register int len) +in_word_set (register char const *str, register int len) { if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) { - register int key = hash (str, len); + register int key = math_hash (str, len); if (key <= MAX_HASH_VALUE && key >= 0) { @@ -392,7 +394,7 @@ latexkeys *lm_get_key_by_id(int t, short tk) latexkeys* l = &wordlist[MIN_HASH_VALUE+TOTAL_KEYWORDS]; latexkeys* base = &wordlist[MIN_HASH_VALUE]; while (--l >= base) { - if (t==l->id && tk==l->token) + if (t == l->id && tk == l->token) return l; } return 0;