static GEN int_read_dec(const char **s) { int nb; GEN y = utoi(number(&nb, s)); if (nb == MAX_DIGITS) y = int_read_more(y, s); return y; }
GEN F2xq_ellcard(GEN a, GEN a6, GEN T) { pari_sp av = avma; long n = F2x_degree(T); GEN q = int2u(n), c; if (typ(a)==t_VECSMALL) { GEN t = F2xq_elltrace_Harley(a6, T); c = addii(q, F2xq_trace(a,T) ? addui(1,t): subui(1,t)); } else if (n==1) { long a4i = lgpol(gel(a,2)), a6i = lgpol(a6); return utoi(a4i? (a6i? 1: 5): 3); } else if (n==2) { GEN a3 = gel(a,1), a4 = gel(a,2), x = polx_F2x(T[1]), x1 = pol1_F2x(T[1]); GEN a613 = F2xq_mul(F2x_add(x1, a6),a3,T), a43= F2xq_mul(a4,a3,T); long f0= F2xq_trace(F2xq_mul(a6,a3,T),T); long f1= F2xq_trace(F2x_add(a43,a613),T); long f2= F2xq_trace(F2x_add(F2xq_mul(a43,x,T),a613),T); long f3= F2xq_trace(F2x_add(F2xq_mul(a43,F2x_add(x,x1),T),a613),T); c = utoi(9-2*(f0+f1+f2+f3)); } else { struct _F2xqE e; long m = (n+1)>>1; GEN q1 = addis(q, 1); GEN v = n==4 ? mkvec4s(13,17,21,25) : odd(n) ? mkvec3(subii(q1,int2u(m)),q1,addii(q1,int2u(m))): mkvec5(subii(q1,int2u(m+1)),subii(q1,int2u(m)),q1, addii(q1,int2u(m)),addii(q1,int2u(m+1))); e.a2=a; e.a6=a6; e.T=T; c = gen_select_order(v,(void*)&e, &F2xqE_group); if (n==4 && equaliu(c, 21)) /* Ambiguous case */ { GEN d = F2xq_powu(polx_F2x(T[1]),3,T), a3 = gel(a,1); e.a6 = F2x_add(a6,F2xq_mul(d,F2xq_sqr(a3,T),T)); /* twist */ c = subui(34, gen_select_order(mkvec2s(13,25),(void*)&e, &F2xqE_group)); } } return gerepileuptoint(av, c); }
int32_t RBDataMap::getInt(const char* key, UErrorCode &status) const { UnicodeString r = this->getString(key, status); if(U_SUCCESS(status)) { return utoi(r); } else { return 0; } }
static GEN int_read(const char **s) { int nb; GEN y; if (isbin(s)) { y = utoi(binnumber(&nb, s)); if (nb == MAX_BDIGITS) y = bin_read_more(y, s); } else if (ishex(s)) { y = utoi(hexnumber(&nb, s)); if (nb == MAX_XDIGITS) y = hex_read_more(y, s); } else { y = int_read_dec(s); } return y; }
static GEN _lift_invd(void *E, GEN V, GEN v, GEN qM, long M) { struct _frob_lift *F = (struct _frob_lift*) E; GEN TM = ZXT_remi2n(F->T, M); GEN x2 = gel(v,2), y2 = gel(v,3), s = gel(v,4), r; GEN Dx = ZX_add(ZX_mul(ZX_Z_add(ZX_shifti(y2, 4), gen_2), s), ZX_shifti(y2, 2)); GEN Dy = ZX_add(ZX_Z_add(ZX_mul(ZX_Z_add(ZX_shifti(x2, 4), utoi(4)), s), gen_1), ZX_shifti(x2, 2)); Dx = FpX_rem(ZX_remi2n(Dx, M), TM, qM); Dy = FpX_rem(ZX_remi2n(Dy, M), TM, qM); r = mkvec3(Dy, Dx, TM); return gen_Z2X_Dixon(r, V, M, E, _frob_lin, _frob_lins, _frob_invls); }
HL_PRIM vdynamic *hl_parse_int( vbyte *bytes, int pos, int len ) { uchar *c = (uchar*)(bytes + pos), *end = NULL; int h; if( len >= 2 && c[0] == '0' && (c[1] == 'x' || c[1] == 'X') ) { h = 0; c += 2; while( *c ) { uchar k = *c++; if( k >= '0' && k <= '9' ) h = (h << 4) | (k - '0'); else if( k >= 'A' && k <= 'F' ) h = (h << 4) | ((k - 'A') + 10); else if( k >= 'a' && k <= 'f' ) h = (h << 4) | ((k - 'a') + 10); else return NULL; } return hl_make_dyn(&h,&hlt_i32); } h = utoi(c,&end); return c == end ? NULL : hl_make_dyn(&h,&hlt_i32); }
const int32_t* RBDataMap::getIntArray(int32_t& count, const char* key, UErrorCode &status) const { const ResourceBundle *r = getItem(key, status); if(U_SUCCESS(status)) { int32_t i = 0; count = r->getSize(); if(count <= 0) { return NULL; } int32_t *result = new int32_t[count]; UnicodeString stringRes; for(i = 0; i<count; i++) { stringRes = r->getStringEx(i, status); result[i] = utoi(stringRes); } return result; } else { return NULL; } }
/* [L:K] = ell^k; return 1 if L/K is locally cyclotomic at ell, 0 otherwise */ long rnfislocalcyclo(GEN rnf) { pari_sp av = avma; GEN K, L, S, SK, TK, SLs, SL2, TL, ell; ulong ll; long i, j, k, lk, lSK; checkrnf(rnf); lk = rnf_get_degree(rnf); if (lk == 1) return 1; k = uisprimepower(lk, &ll); if (!k) pari_err_IMPL("rnfislocalcyclo for non-l-extensions"); ell = utoi(ll); K = rnf_get_nf(rnf); L = rnf_build_nfabs(rnf, nf_get_prec(K)); S = rnfidealprimedec(rnf, ell); SK = gel(S,1); SLs = gel(S,2); SL2 = shallowconcat1(SLs); TK = padicfact(K, SK, 100); lSK = lg(SK); TL = padicfact(L, SL2, 100); for (i = 1; i < lSK; i++) { long eK = etilde(K, gel(SK,i), gel(TK,i)); GEN SL = gel(SLs,i); long lSL = lg(SL); for (j = 1; j < lSL; j++) { long iS = gen_search(SL2, gel(SL,j), 0, (void*)&cmp_prime_over_p, &cmp_nodata); long eL = etilde(L, gel(SL,j), gel(TL,iS)); if (dvdui(eL/eK, ell)) { avma = av; return 0; } } }; avma = av; return 1; }
static textconfig text_configure(paragraph *source) { textconfig ret; paragraph *p; int n; /* * Non-negotiables. */ ret.bullet.next = NULL; ret.bullet.alt = NULL; ret.bullet.type = word_Normal; ret.atitle.just_numbers = FALSE; /* ignored */ ret.atitle.number_at_all = TRUE; /* ignored */ /* * Defaults. */ ret.indent = 7; ret.indent_code = 2; ret.listindentbefore = 1; ret.listindentafter = 3; ret.width = 68; ret.atitle.align = CENTRE; ret.atitle.underline = L"\x2550\0=\0\0"; ret.achapter.align = LEFT; ret.achapter.just_numbers = FALSE; ret.achapter.number_at_all = TRUE; ret.achapter.number_suffix = L": "; ret.achapter.underline = L"\x203E\0-\0\0"; ret.nasect = 1; ret.asect = snewn(ret.nasect, alignstruct); ret.asect[0].align = LEFTPLUS; ret.asect[0].just_numbers = TRUE; ret.asect[0].number_at_all = TRUE; ret.asect[0].number_suffix = L" "; ret.asect[0].underline = L"\0"; ret.include_version_id = TRUE; ret.indent_preambles = FALSE; ret.bullet.text = L"\x2022\0-\0\0"; ret.rule = L"\x2500\0-\0\0"; ret.filename = dupstr("output.txt"); ret.startemph = L"_\0_\0\0"; ret.endemph = uadv(ret.startemph); ret.startstrong = L"*\0*\0\0"; ret.endstrong = uadv(ret.startstrong); ret.listsuffix = L"."; ret.charset = CS_ASCII; /* * Default quote characters are Unicode matched single quotes, * falling back to the TeXlike `'. */ ret.lquote = L"\x2018\0\x2019\0`\0'\0\0"; ret.rquote = uadv(ret.lquote); /* * Two-pass configuration so that we can pick up global config * (e.g. `quotes') before having it overridden by specific * config (`text-quotes'), irrespective of the order in which * they occur. */ for (p = source; p; p = p->next) { if (p->type == para_Config) { if (!ustricmp(p->keyword, L"quotes")) { if (*uadv(p->keyword) && *uadv(uadv(p->keyword))) { ret.lquote = uadv(p->keyword); ret.rquote = uadv(ret.lquote); } } } } for (p = source; p; p = p->next) { if (p->type == para_Config) { if (!ustricmp(p->keyword, L"text-indent")) { ret.indent = utoi(uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"text-charset")) { ret.charset = charset_from_ustr(&p->fpos, uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"text-filename")) { sfree(ret.filename); ret.filename = dupstr(adv(p->origkeyword)); } else if (!ustricmp(p->keyword, L"text-indent-code")) { ret.indent_code = utoi(uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"text-width")) { ret.width = utoi(uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"text-list-indent")) { ret.listindentbefore = utoi(uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"text-listitem-indent")) { ret.listindentafter = utoi(uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"text-chapter-align")) { ret.achapter.align = utoalign(uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"text-chapter-underline")) { ret.achapter.underline = uadv(p->keyword); } else if (!ustricmp(p->keyword, L"text-chapter-numeric")) { ret.achapter.just_numbers = utob(uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"text-chapter-shownumber")) { ret.achapter.number_at_all = utob(uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"text-chapter-suffix")) { ret.achapter.number_suffix = uadv(p->keyword); } else if (!ustricmp(p->keyword, L"text-section-align")) { wchar_t *q = uadv(p->keyword); int n = 0; if (uisdigit(*q)) { n = utoi(q); q = uadv(q); } if (n >= ret.nasect) { int i; ret.asect = sresize(ret.asect, n+1, alignstruct); for (i = ret.nasect; i <= n; i++) ret.asect[i] = ret.asect[ret.nasect-1]; ret.nasect = n+1; } ret.asect[n].align = utoalign(q); } else if (!ustricmp(p->keyword, L"text-section-underline")) { wchar_t *q = uadv(p->keyword); int n = 0; if (uisdigit(*q)) { n = utoi(q); q = uadv(q); } if (n >= ret.nasect) { int i; ret.asect = sresize(ret.asect, n+1, alignstruct); for (i = ret.nasect; i <= n; i++) ret.asect[i] = ret.asect[ret.nasect-1]; ret.nasect = n+1; } ret.asect[n].underline = q; } else if (!ustricmp(p->keyword, L"text-section-numeric")) { wchar_t *q = uadv(p->keyword); int n = 0; if (uisdigit(*q)) { n = utoi(q); q = uadv(q); } if (n >= ret.nasect) { int i; ret.asect = sresize(ret.asect, n+1, alignstruct); for (i = ret.nasect; i <= n; i++) ret.asect[i] = ret.asect[ret.nasect-1]; ret.nasect = n+1; } ret.asect[n].just_numbers = utob(q); } else if (!ustricmp(p->keyword, L"text-section-shownumber")) { wchar_t *q = uadv(p->keyword); int n = 0; if (uisdigit(*q)) { n = utoi(q); q = uadv(q); } if (n >= ret.nasect) { int i; ret.asect = sresize(ret.asect, n+1, alignstruct); for (i = ret.nasect; i <= n; i++) ret.asect[i] = ret.asect[ret.nasect-1]; ret.nasect = n+1; } ret.asect[n].number_at_all = utob(q); } else if (!ustricmp(p->keyword, L"text-section-suffix")) { wchar_t *q = uadv(p->keyword); int n = 0; if (uisdigit(*q)) { n = utoi(q); q = uadv(q); } if (n >= ret.nasect) { int i; ret.asect = sresize(ret.asect, n+1, alignstruct); for (i = ret.nasect; i <= n; i++) { ret.asect[i] = ret.asect[ret.nasect-1]; } ret.nasect = n+1; } ret.asect[n].number_suffix = q; } else if (!ustricmp(p->keyword, L"text-title-align")) { ret.atitle.align = utoalign(uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"text-title-underline")) { ret.atitle.underline = uadv(p->keyword); } else if (!ustricmp(p->keyword, L"text-versionid")) { ret.include_version_id = utob(uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"text-indent-preamble")) { ret.indent_preambles = utob(uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"text-bullet")) { ret.bullet.text = uadv(p->keyword); } else if (!ustricmp(p->keyword, L"text-rule")) { ret.rule = uadv(p->keyword); } else if (!ustricmp(p->keyword, L"text-list-suffix")) { ret.listsuffix = uadv(p->keyword); } else if (!ustricmp(p->keyword, L"text-emphasis")) { if (*uadv(p->keyword) && *uadv(uadv(p->keyword))) { ret.startemph = uadv(p->keyword); ret.endemph = uadv(ret.startemph); } } else if (!ustricmp(p->keyword, L"text-strong")) { if (*uadv(p->keyword) && *uadv(uadv(p->keyword))) { ret.startstrong = uadv(p->keyword); ret.endstrong = uadv(ret.startstrong); } } else if (!ustricmp(p->keyword, L"text-quotes")) { if (*uadv(p->keyword) && *uadv(uadv(p->keyword))) { ret.lquote = uadv(p->keyword); ret.rquote = uadv(ret.lquote); } } } } /* * Now process fallbacks on quote characters, underlines, the * rule character, the emphasis characters, and bullets. */ while (*uadv(ret.rquote) && *uadv(uadv(ret.rquote)) && (!cvt_ok(ret.charset, ret.lquote) || !cvt_ok(ret.charset, ret.rquote))) { ret.lquote = uadv(ret.rquote); ret.rquote = uadv(ret.lquote); } while (*uadv(ret.endemph) && *uadv(uadv(ret.endemph)) && (!cvt_ok(ret.charset, ret.startemph) || !cvt_ok(ret.charset, ret.endemph))) { ret.startemph = uadv(ret.endemph); ret.endemph = uadv(ret.startemph); } while (*uadv(ret.endstrong) && *uadv(uadv(ret.endstrong)) && (!cvt_ok(ret.charset, ret.startstrong) || !cvt_ok(ret.charset, ret.endstrong))) { ret.startstrong = uadv(ret.endstrong); ret.endstrong = uadv(ret.startstrong); } while (*ret.atitle.underline && *uadv(ret.atitle.underline) && !cvt_ok(ret.charset, ret.atitle.underline)) ret.atitle.underline = uadv(ret.atitle.underline); while (*ret.achapter.underline && *uadv(ret.achapter.underline) && !cvt_ok(ret.charset, ret.achapter.underline)) ret.achapter.underline = uadv(ret.achapter.underline); for (n = 0; n < ret.nasect; n++) { while (*ret.asect[n].underline && *uadv(ret.asect[n].underline) && !cvt_ok(ret.charset, ret.asect[n].underline)) ret.asect[n].underline = uadv(ret.asect[n].underline); } while (*ret.bullet.text && *uadv(ret.bullet.text) && !cvt_ok(ret.charset, ret.bullet.text)) ret.bullet.text = uadv(ret.bullet.text); while (*ret.rule && *uadv(ret.rule) && !cvt_ok(ret.charset, ret.rule)) ret.rule = uadv(ret.rule); return ret; }
static infoconfig info_configure(paragraph *source) { infoconfig ret; paragraph *p; /* * Defaults. */ ret.filename = dupstr("output.info"); ret.maxfilesize = 64 << 10; ret.charset = CS_ASCII; ret.width = 70; ret.listindentbefore = 1; ret.listindentafter = 3; ret.indent_code = 2; ret.index_width = 40; ret.listsuffix = L"."; ret.bullet = L"\x2022\0-\0\0"; ret.rule = L"\x2500\0-\0\0"; ret.startemph = L"_\0_\0\0"; ret.endemph = uadv(ret.startemph); ret.lquote = L"\x2018\0\x2019\0`\0'\0\0"; ret.rquote = uadv(ret.lquote); ret.sectsuffix = L": "; ret.underline = L"\x203E\0-\0\0"; ret.index_text = L"Index"; /* * Two-pass configuration so that we can pick up global config * (e.g. `quotes') before having it overridden by specific * config (`info-quotes'), irrespective of the order in which * they occur. */ for (p = source; p; p = p->next) { if (p->type == para_Config) { if (!ustricmp(p->keyword, L"quotes")) { if (*uadv(p->keyword) && *uadv(uadv(p->keyword))) { ret.lquote = uadv(p->keyword); ret.rquote = uadv(ret.lquote); } } else if (!ustricmp(p->keyword, L"index")) { ret.index_text = uadv(p->keyword); } } } for (p = source; p; p = p->next) { if (p->type == para_Config) { if (!ustricmp(p->keyword, L"info-filename")) { sfree(ret.filename); ret.filename = dupstr(adv(p->origkeyword)); } else if (!ustricmp(p->keyword, L"info-charset")) { ret.charset = charset_from_ustr(&p->fpos, uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"info-max-file-size")) { ret.maxfilesize = utoi(uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"info-width")) { ret.width = utoi(uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"info-indent-code")) { ret.indent_code = utoi(uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"info-index-width")) { ret.index_width = utoi(uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"info-list-indent")) { ret.listindentbefore = utoi(uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"info-listitem-indent")) { ret.listindentafter = utoi(uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"info-section-suffix")) { ret.sectsuffix = uadv(p->keyword); } else if (!ustricmp(p->keyword, L"info-underline")) { ret.underline = uadv(p->keyword); } else if (!ustricmp(p->keyword, L"info-bullet")) { ret.bullet = uadv(p->keyword); } else if (!ustricmp(p->keyword, L"info-rule")) { ret.rule = uadv(p->keyword); } else if (!ustricmp(p->keyword, L"info-list-suffix")) { ret.listsuffix = uadv(p->keyword); } else if (!ustricmp(p->keyword, L"info-emphasis")) { if (*uadv(p->keyword) && *uadv(uadv(p->keyword))) { ret.startemph = uadv(p->keyword); ret.endemph = uadv(ret.startemph); } } else if (!ustricmp(p->keyword, L"info-quotes")) { if (*uadv(p->keyword) && *uadv(uadv(p->keyword))) { ret.lquote = uadv(p->keyword); ret.rquote = uadv(ret.lquote); } } } } /* * Now process fallbacks on quote characters, underlines, the * rule character, the emphasis characters, and bullets. */ while (*uadv(ret.rquote) && *uadv(uadv(ret.rquote)) && (!cvt_ok(ret.charset, ret.lquote) || !cvt_ok(ret.charset, ret.rquote))) { ret.lquote = uadv(ret.rquote); ret.rquote = uadv(ret.lquote); } while (*uadv(ret.endemph) && *uadv(uadv(ret.endemph)) && (!cvt_ok(ret.charset, ret.startemph) || !cvt_ok(ret.charset, ret.endemph))) { ret.startemph = uadv(ret.endemph); ret.endemph = uadv(ret.startemph); } while (*ret.underline && *uadv(ret.underline) && !cvt_ok(ret.charset, ret.underline)) ret.underline = uadv(ret.underline); while (*ret.bullet && *uadv(ret.bullet) && !cvt_ok(ret.charset, ret.bullet)) ret.bullet = uadv(ret.bullet); while (*ret.rule && *uadv(ret.rule) && !cvt_ok(ret.charset, ret.rule)) ret.rule = uadv(ret.rule); return ret; }
static manconfig man_configure(paragraph *source) { paragraph *p; manconfig ret; /* * Defaults. */ ret.th = NULL; ret.headnumbers = FALSE; ret.mindepth = 0; ret.filename = dupstr("output.1"); ret.charset = CS_ASCII; ret.bullet = L"\x2022\0o\0\0"; ret.rule = L"\x2500\0-\0\0"; ret.lquote = L"\x2018\0\x2019\0\"\0\"\0\0"; ret.rquote = uadv(ret.lquote); /* * Two-pass configuration so that we can pick up global config * (e.g. `quotes') before having it overridden by specific * config (`man-quotes'), irrespective of the order in which * they occur. */ for (p = source; p; p = p->next) { if (p->type == para_Config) { if (!ustricmp(p->keyword, L"quotes")) { if (*uadv(p->keyword) && *uadv(uadv(p->keyword))) { ret.lquote = uadv(p->keyword); ret.rquote = uadv(ret.lquote); } } } } for (p = source; p; p = p->next) { if (p->type == para_Config) { if (!ustricmp(p->keyword, L"man-identity")) { wchar_t *wp, *ep; wp = uadv(p->keyword); ep = wp; while (*ep) ep = uadv(ep); sfree(ret.th); ret.th = snewn(ep - wp + 1, wchar_t); memcpy(ret.th, wp, (ep - wp + 1) * sizeof(wchar_t)); } else if (!ustricmp(p->keyword, L"man-charset")) { ret.charset = charset_from_ustr(&p->fpos, uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"man-headnumbers")) { ret.headnumbers = utob(uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"man-mindepth")) { ret.mindepth = utoi(uadv(p->keyword)); } else if (!ustricmp(p->keyword, L"man-filename")) { sfree(ret.filename); ret.filename = dupstr(adv(p->origkeyword)); } else if (!ustricmp(p->keyword, L"man-bullet")) { ret.bullet = uadv(p->keyword); } else if (!ustricmp(p->keyword, L"man-rule")) { ret.rule = uadv(p->keyword); } else if (!ustricmp(p->keyword, L"man-quotes")) { if (*uadv(p->keyword) && *uadv(uadv(p->keyword))) { ret.lquote = uadv(p->keyword); ret.rquote = uadv(ret.lquote); } } }