rem
stringlengths 0
274k
| add
stringlengths 0
169k
| context
stringlengths 9
471k
|
---|---|---|
eltmul(GEN x, GEN y) { return element_mul(static_OBJ, x, y); } | eltmul(void *nf, GEN x, GEN y) { return element_mul((GEN) nf, x, y); } | eltmul(GEN x, GEN y) { return element_mul(static_OBJ, x, y); } |
nf = (GEN)bnf[7]; | rnfisnorminit(GEN T, GEN relpol, int galois){ gpmem_t av = avma; long i, l, drel; GEN prod, S1, S2, gen, cyc, bnf, nf, nfrel, rnfeq, rel, res, k; GEN y = cgetg(9, t_VEC); T = get_bnfpol(T, &bnf, &nf); if (!bnf) bnf = bnfinit0(nf? nf: T, 1, NULL, DEFAULTPREC); if (!nf) nf = checknf(bnf); rnfeq = NULL; /* no reltoabs needed */ if (relpol && !gcmp0(relpol)) { GEN polabs; if (galois == 2 && poldegree(relpol, varn(T))) { /* needs reltoabs */ rnfeq = rnfequation2(bnf, relpol); polabs = (GEN)rnfeq[1]; k = (GEN)rnfeq[3]; } else { long sk; polabs = _rnfequation(bnf, relpol, &sk, NULL); k = stoi(sk); } rel = bnfinit0(polabs, 1, NULL, nfgetprec(nf)); } else { /* over Q */ rel = bnf; k = gzero; relpol = T; T = polx[MAXVARN]; bnf = bnfinit0(T, 2, NULL, 0); } nfrel = checknf(rel); drel = degpol(relpol); if (galois < 0 || galois > 2) err(flagerr, "rnfisnorminit"); if (galois == 2) { GEN P = rnfeq? pol_up(rnfeq, relpol): relpol; galois = nfisgalois(gsubst(nfrel, varn(P), polx[varn(T)]), P); } prod = gun; S1 = S2 = cgetg(1, t_VEC); res = gmael(rel,8,1); cyc = (GEN)res[2]; gen = (GEN)res[3]; l = lg(cyc); for(i=1; i<l; i++) { if (cgcd(smodis((GEN)cyc[i], drel), drel) == 1) break; fa_pr_append(nf,rel,gmael3(gen,i,1,1),&prod,&S1,&S2); } if (!galois) { GEN Ndiscrel = diviiexact((GEN)nfrel[3], gpowgs((GEN)nf[3], drel)); fa_pr_append(nf,rel,absi(Ndiscrel), &prod,&S1,&S2); } y[1] = (long)bnf; y[2] = (long)rel; y[3] = (long)relpol; y[4] = (long)get_theta_abstorel(T, relpol, k); y[5] = (long)prod; y[6] = (long)S1; y[7] = (long)S2; y[8] = lstoi(galois); return gerepilecopy(av, y);} |
|
long r1, degnf, ell, j, i, l; | long ell, i, j, l, r1, degK; | rnfkummersimple(GEN bnr, GEN subgroup, long all){ long r1, degnf, ell, j, i, l; long nbgenclK, lSml2, lSl2, lSp, rc, nbvunit; long lastbid, llistx; GEN polnf,bnf,nf,bid,ideal,arch,cycgen,gell,p1,p2,p3; GEN cyclicK,genK,listgamma,listalpha; GEN Sp,listprSp,vecbeta,matexpo,vunit,id,vecalpha0; GEN munit,vecmunit2,msign,archartif,listx,listal,listg,listgamma0; GEN vecbeta0,vunit_beta,fununits,torsunit; primlist L; bnf = (GEN)bnr[1]; nf = (GEN)bnf[7]; r1 = nf_get_r1(nf); polnf = (GEN)nf[1]; degnf = degpol(polnf); gell = get_gell(bnr,subgroup,all); bid = (GEN)bnr[2]; ideal= gmael(bid,1,1); arch = gmael(bid,1,2); /* this is the conductor */ ell = itos(gell); cyclicK= gmael3(bnf,8,1,2); rc = prank(cyclicK,ell); genK = gmael3(bnf,8,1,3); nbgenclK = lg(genK)-1; listgamma0=cgetg(nbgenclK+1,t_VEC); listgamma=cgetg(nbgenclK+1,t_VEC); vecalpha0=cgetg(rc+1,t_VEC); listalpha=cgetg(rc+1,t_VEC); cycgen = check_and_build_cycgen(bnf); p1 = gmul(gell,ideal); for (i=1; i<=rc; i++) { p3 = basistoalg(nf, idealcoprime(nf,(GEN)genK[i],p1)); p2 = basistoalg(nf, famat_to_nf(nf, (GEN)cycgen[i])); listgamma[i] = listgamma0[i] = linv(p3); vecalpha0[i] = (long)p2; listalpha[i] = lmul(p2, powgi(p3, (GEN)cyclicK[i])); } for ( ; i<=nbgenclK; i++) { long k; p3 = basistoalg(nf, idealcoprime(nf,(GEN)genK[i],p1)); p2 = basistoalg(nf, famat_to_nf(nf, (GEN)cycgen[i])); k = itos(mpinvmod((GEN)cyclicK[i], gell)); p2 = gpowgs(p2,k); listgamma0[i]= (long)p2; listgamma[i] = lmul(p2, gpowgs(p3, k * itos((GEN)cyclicK[i]) - 1)); } i = build_list_Hecke(&L, nf, (GEN)bid[3], ideal, gell, NULL); if (i) return no_sol(all,i); lSml2 = lg(L.Sml2)-1; Sp = concatsp(L.Sm, L.Sml1); lSp = lg(Sp)-1; listprSp = concatsp(L.Sml2, L.Sl); lSl2 = lg(listprSp)-1; vecbeta = cgetg(lSp+1,t_VEC); vecbeta0= cgetg(lSp+1,t_VEC); matexpo = cgetg(lSp+1,t_MAT); for (j=1; j<=lSp; j++) { p1 = isprincipalgenforce(bnf,(GEN)Sp[j]); p2 = basistoalg(nf,(GEN)p1[2]); p1 = (GEN)p1[1]; for (i=1; i<=rc; i++) p2 = gmul(p2, powgi((GEN)listgamma[i], (GEN)p1[i])); p3 = p2; for ( ; i<=nbgenclK; i++) { p2 = gmul(p2, powgi((GEN)listgamma[i], (GEN)p1[i])); p3 = gmul(p3, powgi((GEN)listgamma0[i],(GEN)p1[i])); } matexpo[j] = (long)p1; setlg(p1, rc+1); vecbeta[j] = (long)p2; /* attention, ceci sont les beta modifies */ vecbeta0[j]= (long)p3; } fununits = check_units(bnf,"rnfkummer"); torsunit = gmael3(bnf,8,4,2); listg = gmodulcp(concatsp(fununits,torsunit),polnf); vunit = concatsp(listg, listalpha); vunit_beta = algtobasis(nf, concatsp(vunit, vecbeta)); l = lg(vunit_beta);{ long prec = DEFAULTPREC + ((gexpo(vunit_beta) + gexpo(gmael(nf,5,1))) >> TWOPOTBYTES_IN_LONG); if (nfgetprec(nf) < prec) nf = nfnewprec(nf, prec);} vecmunit2 = cgetg(lSml2+1,t_VEC); id = idmat(degnf); for (i=1; i<=lSl2; i++) { GEN pr = (GEN)listprSp[i]; long e = itos((GEN)pr[3]), z = ell * (e / (ell-1)); if (i <= lSml2) { GEN c; z += 1 - L.ESml2[i]; bid = zidealstarinitgen(nf, idealpows(nf, pr, z+1)); c = cgetg(l,t_MAT); vecmunit2[i] = (long)c; for (j=1; j<l; j++) c[j] = (long)zideallog(nf,(GEN)vunit_beta[j],bid); } id = idealmulpowprime(nf, id, pr, stoi(z)); } nbvunit = lg(vunit)-1; matexpo = concatsp(zeromat(rc,nbvunit), matexpo); archartif = cgetg(r1+1,t_VEC); for (j=1; j<=r1; j++) archartif[j] = un; munit = cgetg(l, t_MAT); msign = cgetg(l, t_MAT); bid = zidealstarinitgen(nf, id); lastbid = prank(gmael(bid,2,2), ell); for (j=1; j<l; j++) { GEN z = (GEN)vunit_beta[j]; p1 = zideallog(nf,z,bid); setlg(p1, lastbid+1); munit[j] = (long)concatsp(p1, (GEN)matexpo[j]); msign[j] = (long)zsigne(nf, z, archartif); } listx = get_listx(arch,msign,munit,vecmunit2,gell,lSp,nbvunit); llistx= lg(listx); listal= cgetg(llistx,t_VEC); listg = concatsp(listg, concatsp(vecalpha0,vecbeta0)); l = lg(listg); for (i=1; i<llistx; i++) { p1 = gun; p2 = (GEN)listx[i]; for (j=1; j<l; j++) p1 = gmul(p1, powgi((GEN)listg[j],(GEN)p2[j])); listal[i] = (long)reducealpha(nf,p1,gell); } /* Now, alpha in listal satisfies all congruences, non-congruences, * x^l - alpha is irreducible, signature and relative disciminant are * correct. Remains to check its norm group. */ if (DEBUGLEVEL) fprintferr("listalpha = %Z\n",listal); p2 = cgetg(1,t_VEC); for (i=1; i<llistx; i++) { p1 = gsub(gpuigs(polx[0],ell), (GEN)listal[i]); if (all || gegal(rnfnormgroup(bnr,p1),subgroup)) p2 = concatsp(p2,p1); } if (all) return p2; switch(lg(p2)-1) { case 0: err(talker,"bug 6: no equation found in kummer"); case 1: break; /* OK */ default:err(talker,"bug 7: more than one equation found in kummer: %Z",p2); } return (GEN)p2[1];} |
polnf = (GEN)nf[1]; degnf = degpol(polnf); | polnf = (GEN)nf[1]; degK = degpol(polnf); | rnfkummersimple(GEN bnr, GEN subgroup, long all){ long r1, degnf, ell, j, i, l; long nbgenclK, lSml2, lSl2, lSp, rc, nbvunit; long lastbid, llistx; GEN polnf,bnf,nf,bid,ideal,arch,cycgen,gell,p1,p2,p3; GEN cyclicK,genK,listgamma,listalpha; GEN Sp,listprSp,vecbeta,matexpo,vunit,id,vecalpha0; GEN munit,vecmunit2,msign,archartif,listx,listal,listg,listgamma0; GEN vecbeta0,vunit_beta,fununits,torsunit; primlist L; bnf = (GEN)bnr[1]; nf = (GEN)bnf[7]; r1 = nf_get_r1(nf); polnf = (GEN)nf[1]; degnf = degpol(polnf); gell = get_gell(bnr,subgroup,all); bid = (GEN)bnr[2]; ideal= gmael(bid,1,1); arch = gmael(bid,1,2); /* this is the conductor */ ell = itos(gell); cyclicK= gmael3(bnf,8,1,2); rc = prank(cyclicK,ell); genK = gmael3(bnf,8,1,3); nbgenclK = lg(genK)-1; listgamma0=cgetg(nbgenclK+1,t_VEC); listgamma=cgetg(nbgenclK+1,t_VEC); vecalpha0=cgetg(rc+1,t_VEC); listalpha=cgetg(rc+1,t_VEC); cycgen = check_and_build_cycgen(bnf); p1 = gmul(gell,ideal); for (i=1; i<=rc; i++) { p3 = basistoalg(nf, idealcoprime(nf,(GEN)genK[i],p1)); p2 = basistoalg(nf, famat_to_nf(nf, (GEN)cycgen[i])); listgamma[i] = listgamma0[i] = linv(p3); vecalpha0[i] = (long)p2; listalpha[i] = lmul(p2, powgi(p3, (GEN)cyclicK[i])); } for ( ; i<=nbgenclK; i++) { long k; p3 = basistoalg(nf, idealcoprime(nf,(GEN)genK[i],p1)); p2 = basistoalg(nf, famat_to_nf(nf, (GEN)cycgen[i])); k = itos(mpinvmod((GEN)cyclicK[i], gell)); p2 = gpowgs(p2,k); listgamma0[i]= (long)p2; listgamma[i] = lmul(p2, gpowgs(p3, k * itos((GEN)cyclicK[i]) - 1)); } i = build_list_Hecke(&L, nf, (GEN)bid[3], ideal, gell, NULL); if (i) return no_sol(all,i); lSml2 = lg(L.Sml2)-1; Sp = concatsp(L.Sm, L.Sml1); lSp = lg(Sp)-1; listprSp = concatsp(L.Sml2, L.Sl); lSl2 = lg(listprSp)-1; vecbeta = cgetg(lSp+1,t_VEC); vecbeta0= cgetg(lSp+1,t_VEC); matexpo = cgetg(lSp+1,t_MAT); for (j=1; j<=lSp; j++) { p1 = isprincipalgenforce(bnf,(GEN)Sp[j]); p2 = basistoalg(nf,(GEN)p1[2]); p1 = (GEN)p1[1]; for (i=1; i<=rc; i++) p2 = gmul(p2, powgi((GEN)listgamma[i], (GEN)p1[i])); p3 = p2; for ( ; i<=nbgenclK; i++) { p2 = gmul(p2, powgi((GEN)listgamma[i], (GEN)p1[i])); p3 = gmul(p3, powgi((GEN)listgamma0[i],(GEN)p1[i])); } matexpo[j] = (long)p1; setlg(p1, rc+1); vecbeta[j] = (long)p2; /* attention, ceci sont les beta modifies */ vecbeta0[j]= (long)p3; } fununits = check_units(bnf,"rnfkummer"); torsunit = gmael3(bnf,8,4,2); listg = gmodulcp(concatsp(fununits,torsunit),polnf); vunit = concatsp(listg, listalpha); vunit_beta = algtobasis(nf, concatsp(vunit, vecbeta)); l = lg(vunit_beta);{ long prec = DEFAULTPREC + ((gexpo(vunit_beta) + gexpo(gmael(nf,5,1))) >> TWOPOTBYTES_IN_LONG); if (nfgetprec(nf) < prec) nf = nfnewprec(nf, prec);} vecmunit2 = cgetg(lSml2+1,t_VEC); id = idmat(degnf); for (i=1; i<=lSl2; i++) { GEN pr = (GEN)listprSp[i]; long e = itos((GEN)pr[3]), z = ell * (e / (ell-1)); if (i <= lSml2) { GEN c; z += 1 - L.ESml2[i]; bid = zidealstarinitgen(nf, idealpows(nf, pr, z+1)); c = cgetg(l,t_MAT); vecmunit2[i] = (long)c; for (j=1; j<l; j++) c[j] = (long)zideallog(nf,(GEN)vunit_beta[j],bid); } id = idealmulpowprime(nf, id, pr, stoi(z)); } nbvunit = lg(vunit)-1; matexpo = concatsp(zeromat(rc,nbvunit), matexpo); archartif = cgetg(r1+1,t_VEC); for (j=1; j<=r1; j++) archartif[j] = un; munit = cgetg(l, t_MAT); msign = cgetg(l, t_MAT); bid = zidealstarinitgen(nf, id); lastbid = prank(gmael(bid,2,2), ell); for (j=1; j<l; j++) { GEN z = (GEN)vunit_beta[j]; p1 = zideallog(nf,z,bid); setlg(p1, lastbid+1); munit[j] = (long)concatsp(p1, (GEN)matexpo[j]); msign[j] = (long)zsigne(nf, z, archartif); } listx = get_listx(arch,msign,munit,vecmunit2,gell,lSp,nbvunit); llistx= lg(listx); listal= cgetg(llistx,t_VEC); listg = concatsp(listg, concatsp(vecalpha0,vecbeta0)); l = lg(listg); for (i=1; i<llistx; i++) { p1 = gun; p2 = (GEN)listx[i]; for (j=1; j<l; j++) p1 = gmul(p1, powgi((GEN)listg[j],(GEN)p2[j])); listal[i] = (long)reducealpha(nf,p1,gell); } /* Now, alpha in listal satisfies all congruences, non-congruences, * x^l - alpha is irreducible, signature and relative disciminant are * correct. Remains to check its norm group. */ if (DEBUGLEVEL) fprintferr("listalpha = %Z\n",listal); p2 = cgetg(1,t_VEC); for (i=1; i<llistx; i++) { p1 = gsub(gpuigs(polx[0],ell), (GEN)listal[i]); if (all || gegal(rnfnormgroup(bnr,p1),subgroup)) p2 = concatsp(p2,p1); } if (all) return p2; switch(lg(p2)-1) { case 0: err(talker,"bug 6: no equation found in kummer"); case 1: break; /* OK */ default:err(talker,"bug 7: more than one equation found in kummer: %Z",p2); } return (GEN)p2[1];} |
id = idmat(degnf); | id = idmat(degK); | rnfkummersimple(GEN bnr, GEN subgroup, long all){ long r1, degnf, ell, j, i, l; long nbgenclK, lSml2, lSl2, lSp, rc, nbvunit; long lastbid, llistx; GEN polnf,bnf,nf,bid,ideal,arch,cycgen,gell,p1,p2,p3; GEN cyclicK,genK,listgamma,listalpha; GEN Sp,listprSp,vecbeta,matexpo,vunit,id,vecalpha0; GEN munit,vecmunit2,msign,archartif,listx,listal,listg,listgamma0; GEN vecbeta0,vunit_beta,fununits,torsunit; primlist L; bnf = (GEN)bnr[1]; nf = (GEN)bnf[7]; r1 = nf_get_r1(nf); polnf = (GEN)nf[1]; degnf = degpol(polnf); gell = get_gell(bnr,subgroup,all); bid = (GEN)bnr[2]; ideal= gmael(bid,1,1); arch = gmael(bid,1,2); /* this is the conductor */ ell = itos(gell); cyclicK= gmael3(bnf,8,1,2); rc = prank(cyclicK,ell); genK = gmael3(bnf,8,1,3); nbgenclK = lg(genK)-1; listgamma0=cgetg(nbgenclK+1,t_VEC); listgamma=cgetg(nbgenclK+1,t_VEC); vecalpha0=cgetg(rc+1,t_VEC); listalpha=cgetg(rc+1,t_VEC); cycgen = check_and_build_cycgen(bnf); p1 = gmul(gell,ideal); for (i=1; i<=rc; i++) { p3 = basistoalg(nf, idealcoprime(nf,(GEN)genK[i],p1)); p2 = basistoalg(nf, famat_to_nf(nf, (GEN)cycgen[i])); listgamma[i] = listgamma0[i] = linv(p3); vecalpha0[i] = (long)p2; listalpha[i] = lmul(p2, powgi(p3, (GEN)cyclicK[i])); } for ( ; i<=nbgenclK; i++) { long k; p3 = basistoalg(nf, idealcoprime(nf,(GEN)genK[i],p1)); p2 = basistoalg(nf, famat_to_nf(nf, (GEN)cycgen[i])); k = itos(mpinvmod((GEN)cyclicK[i], gell)); p2 = gpowgs(p2,k); listgamma0[i]= (long)p2; listgamma[i] = lmul(p2, gpowgs(p3, k * itos((GEN)cyclicK[i]) - 1)); } i = build_list_Hecke(&L, nf, (GEN)bid[3], ideal, gell, NULL); if (i) return no_sol(all,i); lSml2 = lg(L.Sml2)-1; Sp = concatsp(L.Sm, L.Sml1); lSp = lg(Sp)-1; listprSp = concatsp(L.Sml2, L.Sl); lSl2 = lg(listprSp)-1; vecbeta = cgetg(lSp+1,t_VEC); vecbeta0= cgetg(lSp+1,t_VEC); matexpo = cgetg(lSp+1,t_MAT); for (j=1; j<=lSp; j++) { p1 = isprincipalgenforce(bnf,(GEN)Sp[j]); p2 = basistoalg(nf,(GEN)p1[2]); p1 = (GEN)p1[1]; for (i=1; i<=rc; i++) p2 = gmul(p2, powgi((GEN)listgamma[i], (GEN)p1[i])); p3 = p2; for ( ; i<=nbgenclK; i++) { p2 = gmul(p2, powgi((GEN)listgamma[i], (GEN)p1[i])); p3 = gmul(p3, powgi((GEN)listgamma0[i],(GEN)p1[i])); } matexpo[j] = (long)p1; setlg(p1, rc+1); vecbeta[j] = (long)p2; /* attention, ceci sont les beta modifies */ vecbeta0[j]= (long)p3; } fununits = check_units(bnf,"rnfkummer"); torsunit = gmael3(bnf,8,4,2); listg = gmodulcp(concatsp(fununits,torsunit),polnf); vunit = concatsp(listg, listalpha); vunit_beta = algtobasis(nf, concatsp(vunit, vecbeta)); l = lg(vunit_beta);{ long prec = DEFAULTPREC + ((gexpo(vunit_beta) + gexpo(gmael(nf,5,1))) >> TWOPOTBYTES_IN_LONG); if (nfgetprec(nf) < prec) nf = nfnewprec(nf, prec);} vecmunit2 = cgetg(lSml2+1,t_VEC); id = idmat(degnf); for (i=1; i<=lSl2; i++) { GEN pr = (GEN)listprSp[i]; long e = itos((GEN)pr[3]), z = ell * (e / (ell-1)); if (i <= lSml2) { GEN c; z += 1 - L.ESml2[i]; bid = zidealstarinitgen(nf, idealpows(nf, pr, z+1)); c = cgetg(l,t_MAT); vecmunit2[i] = (long)c; for (j=1; j<l; j++) c[j] = (long)zideallog(nf,(GEN)vunit_beta[j],bid); } id = idealmulpowprime(nf, id, pr, stoi(z)); } nbvunit = lg(vunit)-1; matexpo = concatsp(zeromat(rc,nbvunit), matexpo); archartif = cgetg(r1+1,t_VEC); for (j=1; j<=r1; j++) archartif[j] = un; munit = cgetg(l, t_MAT); msign = cgetg(l, t_MAT); bid = zidealstarinitgen(nf, id); lastbid = prank(gmael(bid,2,2), ell); for (j=1; j<l; j++) { GEN z = (GEN)vunit_beta[j]; p1 = zideallog(nf,z,bid); setlg(p1, lastbid+1); munit[j] = (long)concatsp(p1, (GEN)matexpo[j]); msign[j] = (long)zsigne(nf, z, archartif); } listx = get_listx(arch,msign,munit,vecmunit2,gell,lSp,nbvunit); llistx= lg(listx); listal= cgetg(llistx,t_VEC); listg = concatsp(listg, concatsp(vecalpha0,vecbeta0)); l = lg(listg); for (i=1; i<llistx; i++) { p1 = gun; p2 = (GEN)listx[i]; for (j=1; j<l; j++) p1 = gmul(p1, powgi((GEN)listg[j],(GEN)p2[j])); listal[i] = (long)reducealpha(nf,p1,gell); } /* Now, alpha in listal satisfies all congruences, non-congruences, * x^l - alpha is irreducible, signature and relative disciminant are * correct. Remains to check its norm group. */ if (DEBUGLEVEL) fprintferr("listalpha = %Z\n",listal); p2 = cgetg(1,t_VEC); for (i=1; i<llistx; i++) { p1 = gsub(gpuigs(polx[0],ell), (GEN)listal[i]); if (all || gegal(rnfnormgroup(bnr,p1),subgroup)) p2 = concatsp(p2,p1); } if (all) return p2; switch(lg(p2)-1) { case 0: err(talker,"bug 6: no equation found in kummer"); case 1: break; /* OK */ default:err(talker,"bug 7: more than one equation found in kummer: %Z",p2); } return (GEN)p2[1];} |
if (gcmp1((GEN)p1[1])) {tetpil=avma; return gerepile(av,tetpil,gcopy((GEN)p1[2]));} | if (gcmp1((GEN)p1[1])) return gerepilecopy(av,(GEN)p1[2]); | rnfordmax(GEN nf, GEN pol, GEN pr, GEN unnf, GEN id, GEN matId){ long av=avma,tetpil,av1,lim,i,j,k,n,v1,v2,vpol,m,cmpt,sep; GEN p,q,q1,prhall,A,Aa,Aaa,A1,I,R,p1,p2,p3,multab,multabmod,Aainv; GEN pip,baseIp,baseOp,alpha,matprod,alphainv,matC,matG,vecpro,matH; GEN neworder,H,Hid,alphalistinv,alphalist,prhinv; if (DEBUGLEVEL>1) fprintferr(" treating %Z\n",pr); prhall=nfmodprinit(nf,pr); q=cgetg(3,t_VEC); q[1]=(long)pr;q[2]=(long)prhall; p1=rnfdedekind(nf,pol,q); if (gcmp1((GEN)p1[1])) {tetpil=avma; return gerepile(av,tetpil,gcopy((GEN)p1[2]));} sep=itos((GEN)p1[3]); A=gmael(p1,2,1); I=gmael(p1,2,2); n=degpol(pol); vpol=varn(pol); p=(GEN)pr[1]; q=powgi(p,(GEN)pr[4]); pip=(GEN)pr[2]; q1=q; while (cmpis(q1,n)<0) q1=mulii(q1,q); multab=cgetg(n*n+1,t_MAT); for (j=1; j<=n*n; j++) multab[j]=lgetg(n+1,t_COL); prhinv = idealinv(nf,(GEN)prhall[1]); alphalistinv=cgetg(n+1,t_VEC); alphalist=cgetg(n+1,t_VEC); A1=cgetg(n+1,t_MAT); av1=avma; lim=stack_lim(av1,1); for(cmpt=1; ; cmpt++) { if (DEBUGLEVEL>1) { fprintferr(" %ld%s pass\n",cmpt,eng_ord(cmpt)); flusherr(); } for (i=1; i<=n; i++) { if (gegal((GEN)I[i],id)) alphalist[i]=alphalistinv[i]=(long)unnf; else { p1=ideal_two_elt(nf,(GEN)I[i]); v1=gcmp0((GEN)p1[1])? EXP220 : element_val(nf,(GEN)p1[1],pr); v2=element_val(nf,(GEN)p1[2],pr); if (v1>v2) p2=(GEN)p1[2]; else p2=(GEN)p1[1]; alphalist[i]=(long)p2; alphalistinv[i]=(long)element_inv(nf,p2); } } for (j=1; j<=n; j++) { p1=cgetg(n+1,t_COL); A1[j]=(long)p1; for (i=1; i<=n; i++) p1[i] = (long)element_mul(nf,gcoeff(A,i,j),(GEN)alphalist[j]); } Aa=basistoalg(nf,A1); Aainv=lift_intern(ginv(Aa)); Aaa=mat_to_vecpol(Aa,vpol); for (i=1; i<=n; i++) for (j=i; j<=n; j++) { long tp; p1 = lift_intern(gres(gmul((GEN)Aaa[i],(GEN)Aaa[j]), pol)); tp = typ(p1); if (is_scalar_t(tp) || (tp==t_POL && varn(p1)>vpol)) p2 = gmul(p1, (GEN)Aainv[1]); else p2 = gmul(Aainv, pol_to_vec(p1, n)); p3 = algtobasis(nf,p2); for (k=1; k<=n; k++) { coeff(multab,k,(i-1)*n+j) = p3[k]; coeff(multab,k,(j-1)*n+i) = p3[k]; } } R=cgetg(n+1,t_MAT); multabmod = mymod(multab,p); R[1] = matId[1]; for (j=2; j<=n; j++) R[j] = (long) rnfelementid_powmod(nf,multabmod,matId, j,q1,prhall); baseIp = nfkermodpr(nf,R,prhall); baseOp = lift_intern(nfsuppl(nf,baseIp,n,prhall)); alpha=cgetg(n+1,t_MAT); for (j=1; j<lg(baseIp); j++) alpha[j]=baseOp[j]; for ( ; j<=n; j++) { p1=cgetg(n+1,t_COL); alpha[j]=(long)p1; for (i=1; i<=n; i++) p1[i]=(long)element_mul(nf,pip,gcoeff(baseOp,i,j)); } matprod=cgetg(n+1,t_MAT); for (j=1; j<=n; j++) { p1=cgetg(n+1,t_COL); matprod[j]=(long)p1; for (i=1; i<=n; i++) { p2 = rnfelement_mulidmod(nf,multab,unnf, (GEN)alpha[i],j, NULL); for (k=1; k<=n; k++) p2[k] = lmul((GEN)nf[7], (GEN)p2[k]); p1[i] = (long)p2; } } alphainv = lift_intern(ginv(basistoalg(nf,alpha))); matC = cgetg(n+1,t_MAT); for (j=1; j<=n; j++) { p1=cgetg(n*n+1,t_COL); matC[j]=(long)p1; for (i=1; i<=n; i++) { p2 = gmul(alphainv, gcoeff(matprod,i,j)); for (k=1; k<=n; k++) p1[(i-1)*n+k]=(long)nfreducemodpr(nf,algtobasis(nf,(GEN)p2[k]),prhall); } } matG=nfkermodpr(nf,matC,prhall); m=lg(matG)-1; vecpro=cgetg(3,t_VEC); p1=cgetg(n+m+1,t_MAT); vecpro[1]=(long)p1; p2=cgetg(n+m+1,t_VEC); vecpro[2]=(long)p2; for (j=1; j<=m; j++) { p1[j] = llift((GEN)matG[j]); p2[j] = (long)prhinv; } p1 += m; p2 += m; for (j=1; j<=n; j++) { p1[j] = matId[j]; p2[j] = (long)idealmul(nf,(GEN)I[j],(GEN)alphalistinv[j]); } matH=nfhermite(nf,vecpro); p1=algtobasis(nf,gmul(Aa,basistoalg(nf,(GEN)matH[1]))); p2=(GEN)matH[2]; tetpil=avma; neworder=cgetg(3,t_VEC); H=cgetg(n+1,t_MAT); Hid=cgetg(n+1,t_VEC); for (j=1; j<=n; j++) { p3=cgetg(n+1,t_COL); H[j]=(long)p3; for (i=1; i<=n; i++) p3[i]=(long)element_mul(nf,gcoeff(p1,i,j),(GEN)alphalistinv[j]); Hid[j]=(long)idealmul(nf,(GEN)p2[j],(GEN)alphalist[j]); } if (DEBUGLEVEL>3) { fprintferr(" new order:\n"); outerr(H); outerr(Hid); } if (sep == 2 || gegal(I,Hid)) { neworder[1]=(long)H; neworder[2]=(long)Hid; return gerepile(av,tetpil,neworder); } A=H; I=Hid; if (low_stack(lim, stack_lim(av1,1)) || (cmpt & 3) == 0) { GEN *gptr[2]; gptr[0]=&A; gptr[1]=&I; if(DEBUGMEM>1) err(warnmem,"rnfordmax"); gerepilemany(av1,gptr,2); } }} |
borne = gzero; | borne = realzero(prec); | initborne(GEN T, GEN disc, struct galois_borne *gb, long ppp){ ulong ltop = avma, lbot, av2; GEN borne, borneroots, borneabs; int i, j; int n, extra; GEN L, M, z; long prec; prec = 2; for (i = 2; i < lg(T); i++) if (lg(T[i]) > prec) prec = lg(T[i]); L = roots(T, prec); n = lg(L) - 1; for (i = 1; i <= n; i++) { z = (GEN) L[i]; if (signe(z[2])) break; L[i] = z[1]; } M = vandermondeinverse(L, gmul(T, realun(prec)), disc); borne = gzero; for (i = 1; i <= n; i++) { z = gzero; for (j = 1; j <= n; j++) z = gadd(z, gabs(((GEN **) M)[j][i], prec)); if (gcmp(z, borne) > 0) borne = z; } borneroots = gzero; for (i = 1; i <= n; i++) { z = gabs((GEN) L[i], prec); if (gcmp(z, borneroots) > 0) borneroots = z; } borneabs = addsr(1, gpowgs(addsr(n, borneroots), n / ppp)); lbot = avma; borneroots = addsr(1, gmul(borne, borneroots)); av2 = avma; /*We want to reduce the probability of hop. prob=2^(-2-extra) */ extra = itos(mpent (gdiv (glog(mpfact(itos(racine(stoi(n))) + 2), DEFAULTPREC), glog(stoi(2), DEFAULTPREC)))); if (DEBUGLEVEL >= 4) fprintferr("GaloisConj:extra=%d are you happy?\n", extra); borneabs = gmul2n(gmul(borne, borneabs), 2 + extra); gb->valsol = itos(gceil(gdiv(glog(gmul2n(borneroots, 4), prec), glog(gb->l, prec)))); if (DEBUGLEVEL >= 4) fprintferr("GaloisConj:val1=%d\n", gb->valsol); gb->valabs = max(gb->valsol, itos(gceil(gdiv(glog(borneabs, prec), glog(gb->l, prec))))); if (DEBUGLEVEL >= 4) fprintferr("GaloisConj:val2=%d\n", gb->valabs); avma = av2; gb->bornesol = gerepile(ltop, lbot, borneroots); gb->ladicsol = gpowgs(gb->l, gb->valsol); gb->ladicabs = gpowgs(gb->l, gb->valabs);} |
borneroots = gzero; | borneroots = realzero(prec); | initborne(GEN T, GEN disc, struct galois_borne *gb, long ppp){ ulong ltop = avma, lbot, av2; GEN borne, borneroots, borneabs; int i, j; int n, extra; GEN L, M, z; long prec; prec = 2; for (i = 2; i < lg(T); i++) if (lg(T[i]) > prec) prec = lg(T[i]); L = roots(T, prec); n = lg(L) - 1; for (i = 1; i <= n; i++) { z = (GEN) L[i]; if (signe(z[2])) break; L[i] = z[1]; } M = vandermondeinverse(L, gmul(T, realun(prec)), disc); borne = gzero; for (i = 1; i <= n; i++) { z = gzero; for (j = 1; j <= n; j++) z = gadd(z, gabs(((GEN **) M)[j][i], prec)); if (gcmp(z, borne) > 0) borne = z; } borneroots = gzero; for (i = 1; i <= n; i++) { z = gabs((GEN) L[i], prec); if (gcmp(z, borneroots) > 0) borneroots = z; } borneabs = addsr(1, gpowgs(addsr(n, borneroots), n / ppp)); lbot = avma; borneroots = addsr(1, gmul(borne, borneroots)); av2 = avma; /*We want to reduce the probability of hop. prob=2^(-2-extra) */ extra = itos(mpent (gdiv (glog(mpfact(itos(racine(stoi(n))) + 2), DEFAULTPREC), glog(stoi(2), DEFAULTPREC)))); if (DEBUGLEVEL >= 4) fprintferr("GaloisConj:extra=%d are you happy?\n", extra); borneabs = gmul2n(gmul(borne, borneabs), 2 + extra); gb->valsol = itos(gceil(gdiv(glog(gmul2n(borneroots, 4), prec), glog(gb->l, prec)))); if (DEBUGLEVEL >= 4) fprintferr("GaloisConj:val1=%d\n", gb->valsol); gb->valabs = max(gb->valsol, itos(gceil(gdiv(glog(borneabs, prec), glog(gb->l, prec))))); if (DEBUGLEVEL >= 4) fprintferr("GaloisConj:val2=%d\n", gb->valabs); avma = av2; gb->bornesol = gerepile(ltop, lbot, borneroots); gb->ladicsol = gpowgs(gb->l, gb->valsol); gb->ladicabs = gpowgs(gb->l, gb->valabs);} |
pari_sp av=avma,tetpil; long lx,ly,tx=typ(x),i; GEN y,p0,p1,q0,q1,a,b,p2,q2; | pari_sp av = avma; long i, lx, ly, tx = typ(x); GEN p0, p1, q0, q1, a, b, p2, q2; | pnqn(GEN x){ pari_sp av=avma,tetpil; long lx,ly,tx=typ(x),i; GEN y,p0,p1,q0,q1,a,b,p2,q2; if (! is_matvec_t(tx)) err(typeer,"pnqn"); lx=lg(x); if (lx==1) return idmat(2); p0=gen_1; q0=gen_0; if (tx != t_MAT) { p1=(GEN)x[1]; q1=gen_1; for (i=2; i<lx; i++) { a=(GEN)x[i]; p2=gadd(gmul(a,p1),p0); p0=p1; p1=p2; q2=gadd(gmul(a,q1),q0); q0=q1; q1=q2; } } else { ly=lg(x[1]); if (ly==2) { p1=cgetg(lx,t_VEC); for (i=1; i<lx; i++) p1[i]=mael(x,i,1); tetpil=avma; return gerepile(av,tetpil,pnqn(p1)); } if (ly!=3) err(talker,"incorrect size in pnqn"); p1=gcoeff(x,2,1); q1=gcoeff(x,1,1); for (i=2; i<lx; i++) { a=gcoeff(x,2,i); b=gcoeff(x,1,i); p2=gadd(gmul(a,p1),gmul(b,p0)); p0=p1; p1=p2; q2=gadd(gmul(a,q1),gmul(b,q0)); q0=q1; q1=q2; } } tetpil=avma; y=cgetg(3,t_MAT); p2=cgetg(3,t_COL); y[1]=(long)p2; p2[1]=lcopy(p1); p2[2]=lcopy(q1); p2=cgetg(3,t_COL); y[2]=(long)p2; p2[1]=lcopy(p0); p2[2]=lcopy(q0); return gerepile(av,tetpil,y);} |
p1=cgetg(lx,t_VEC); for (i=1; i<lx; i++) p1[i]=mael(x,i,1); tetpil=avma; return gerepile(av,tetpil,pnqn(p1)); | p1 = cgetg(lx,t_VEC); for (i=1; i<lx; i++) p1[i] = mael(x,i,1); return pnqn(p1); | pnqn(GEN x){ pari_sp av=avma,tetpil; long lx,ly,tx=typ(x),i; GEN y,p0,p1,q0,q1,a,b,p2,q2; if (! is_matvec_t(tx)) err(typeer,"pnqn"); lx=lg(x); if (lx==1) return idmat(2); p0=gen_1; q0=gen_0; if (tx != t_MAT) { p1=(GEN)x[1]; q1=gen_1; for (i=2; i<lx; i++) { a=(GEN)x[i]; p2=gadd(gmul(a,p1),p0); p0=p1; p1=p2; q2=gadd(gmul(a,q1),q0); q0=q1; q1=q2; } } else { ly=lg(x[1]); if (ly==2) { p1=cgetg(lx,t_VEC); for (i=1; i<lx; i++) p1[i]=mael(x,i,1); tetpil=avma; return gerepile(av,tetpil,pnqn(p1)); } if (ly!=3) err(talker,"incorrect size in pnqn"); p1=gcoeff(x,2,1); q1=gcoeff(x,1,1); for (i=2; i<lx; i++) { a=gcoeff(x,2,i); b=gcoeff(x,1,i); p2=gadd(gmul(a,p1),gmul(b,p0)); p0=p1; p1=p2; q2=gadd(gmul(a,q1),gmul(b,q0)); q0=q1; q1=q2; } } tetpil=avma; y=cgetg(3,t_MAT); p2=cgetg(3,t_COL); y[1]=(long)p2; p2[1]=lcopy(p1); p2[2]=lcopy(q1); p2=cgetg(3,t_COL); y[2]=(long)p2; p2[1]=lcopy(p0); p2[2]=lcopy(q0); return gerepile(av,tetpil,y);} |
tetpil=avma; y=cgetg(3,t_MAT); p2=cgetg(3,t_COL); y[1]=(long)p2; p2[1]=lcopy(p1); p2[2]=lcopy(q1); p2=cgetg(3,t_COL); y[2]=(long)p2; p2[1]=lcopy(p0); p2[2]=lcopy(q0); return gerepile(av,tetpil,y); | return gerepilecopy(av, mkmat2(mkcol2(p1,q1), mkcol2(p0,q0))); | pnqn(GEN x){ pari_sp av=avma,tetpil; long lx,ly,tx=typ(x),i; GEN y,p0,p1,q0,q1,a,b,p2,q2; if (! is_matvec_t(tx)) err(typeer,"pnqn"); lx=lg(x); if (lx==1) return idmat(2); p0=gen_1; q0=gen_0; if (tx != t_MAT) { p1=(GEN)x[1]; q1=gen_1; for (i=2; i<lx; i++) { a=(GEN)x[i]; p2=gadd(gmul(a,p1),p0); p0=p1; p1=p2; q2=gadd(gmul(a,q1),q0); q0=q1; q1=q2; } } else { ly=lg(x[1]); if (ly==2) { p1=cgetg(lx,t_VEC); for (i=1; i<lx; i++) p1[i]=mael(x,i,1); tetpil=avma; return gerepile(av,tetpil,pnqn(p1)); } if (ly!=3) err(talker,"incorrect size in pnqn"); p1=gcoeff(x,2,1); q1=gcoeff(x,1,1); for (i=2; i<lx; i++) { a=gcoeff(x,2,i); b=gcoeff(x,1,i); p2=gadd(gmul(a,p1),gmul(b,p0)); p0=p1; p1=p2; q2=gadd(gmul(a,q1),gmul(b,q0)); q0=q1; q1=q2; } } tetpil=avma; y=cgetg(3,t_MAT); p2=cgetg(3,t_COL); y[1]=(long)p2; p2[1]=lcopy(p1); p2[2]=lcopy(q1); p2=cgetg(3,t_COL); y[2]=(long)p2; p2[1]=lcopy(p0); p2[2]=lcopy(q0); return gerepile(av,tetpil,y);} |
borne=mulii(binomial(utoipos(d),i),powiu(o,i)); | borne=mulii(binomial(utoipos(d),i),powuu(o,i)); | subcyclo_start(long n, long d, long o, GEN borne, long *ptr_val,long *ptr_l){ pari_sp av; GEN l,le,z; long i; long e,val; if (DEBUGLEVEL >= 1) (void)timer2(); l=utoipos(n+1);e=1; while(!isprime(l)) { l=addis(l,n); e++; } if (DEBUGLEVEL >= 4) fprintferr("Subcyclo: prime l=%Z\n",l); av=avma; if (!borne) { /*Borne utilise': Vecmax(Vec((x+o)^d)=max{binomial(d,i)*o^i ;1<=i<=d} */ i=d-(1+d)/(1+o); borne=mulii(binomial(utoipos(d),i),powiu(o,i)); } if (DEBUGLEVEL >= 4) fprintferr("Subcyclo: borne=%Z\n",borne); val=logint(shifti(borne,2),l,NULL); avma=av; if (DEBUGLEVEL >= 4) fprintferr("Subcyclo: val=%ld\n",val); le=powiu(l,val); z = Fp_pow(gener_Fp(l), utoipos(e), l); z=padicsqrtnlift(gen_1,utoipos(n),z,l,val); if (DEBUGLEVEL >= 1) msgtimer("padicsqrtnlift."); *ptr_val=val; *ptr_l=itos(l); return gmodulcp(z,le);} |
if ( !initialized ) board_serial_init(); for (;;) { READ_UINT16 (DIAG_SLDISR, disr); if (disr & 0x0002) break; } | for (;;) { READ_UINT16 (DIAG_SLDISR, disr); if (disr & 0x0002) break; } | void console_outbyte_polled( int port, char ch){ unsigned short disr; if ( !initialized ) board_serial_init(); for (;;) { READ_UINT16 (DIAG_SLDISR, disr); if (disr & 0x0002) break; } disr = disr & ~0x0002; WRITE_UINT8 (DIAG_TFIFO, (unsigned char) ch); WRITE_UINT16 (DIAG_SLDISR, disr);} |
(rtems_device_minor_number) 0 | (rtems_device_minor_number) 1 | rtems_device_driver console_initialize( rtems_device_major_number major, rtems_device_minor_number minor, void *arg){ int i; rtems_status_code status; /* * Initialise receiver interrupts on both ports */ for (i = 0; i <= 1; i++) { Ring_buffer_Initialize( &Buffer[i] ); ZWRITE(i, 2, SCC_VECTOR); ZWRITE(i, 10, 0); ZWRITE(i, 1, 0x10); /* int on all Rx chars or special condition */ ZWRITE(i, 9, 8); /* master interrupt enable */ } set_vector(C_Receive_ISR, SCC_VECTOR, 1); /* install ISR for ports A and B */ mcchip->vector_base = 0; mcchip->gen_control = 2; /* MIEN */ mcchip->SCC_int_ctl = 0x13; /* SCC IEN, IPL3 */ status = rtems_io_register_name( "/dev/console", major, (rtems_device_minor_number) 0 ); if (status != RTEMS_SUCCESSFUL) rtems_fatal_error_occurred(status); status = rtems_io_register_name( "/dev/tty00", major, (rtems_device_minor_number) 0 ); if (status != RTEMS_SUCCESSFUL) rtems_fatal_error_occurred(status); status = rtems_io_register_name( "/dev/tty01", major, (rtems_device_minor_number) 0 ); if (status != RTEMS_SUCCESSFUL) rtems_fatal_error_occurred(status); return RTEMS_SUCCESSFUL;} |
register rtems_unsigned8 usr; register rtems_unsigned8 uisr; | register uint8_t usr; register uint8_t uisr; | mcfuart_interrupt_handler(rtems_vector_number vec){ mcfuart *uart; register rtems_unsigned8 usr; register rtems_unsigned8 uisr; register int chn; register int bp = 0; /* Find UART descriptor from vector number */ if (int_driven_uart[0].vec == vec) uart = int_driven_uart[0].uart; else if (int_driven_uart[1].vec == vec) uart = int_driven_uart[1].uart; else return; chn = uart->chn; uisr = *MCF5206E_UISR(MBAR, chn); if (uisr & MCF5206E_UISR_DB) { *MCF5206E_UCR(MBAR, chn) = MCF5206E_UCR_MISC_RESET_BRK; } /* Receiving */ while (1) { char buf[32]; usr = *MCF5206E_USR(MBAR,chn); if ((bp < sizeof(buf) - 1) && ((usr & MCF5206E_USR_RXRDY) != 0)) { /* Receive character and handle frame/parity errors */ if (((usr & (MCF5206E_USR_FE | MCF5206E_USR_PE)) != 0) && !(uart->c_iflag & IGNPAR)) { if (uart->c_iflag & PARMRK) { buf[bp++] = 0xff; buf[bp++] = 0x00; } else { buf[bp++] = 0x00; } } else { buf[bp++] = *MCF5206E_URB(MBAR, chn); } /* Reset error condition if any errors has been detected */ if (usr & (MCF5206E_USR_RB | MCF5206E_USR_FE | MCF5206E_USR_PE | MCF5206E_USR_OE)) { *MCF5206E_UCR(MBAR, chn) = MCF5206E_UCR_MISC_RESET_ERR; } } else { if (bp != 0) rtems_termios_enqueue_raw_characters(uart->tty, buf, bp); break; } } /* Transmitting */ while (1) { if ((*MCF5206E_USR(MBAR, chn) & MCF5206E_USR_TXRDY) == 0) break; if (uart->tx_buf != NULL) { if (uart->tx_ptr >= uart->tx_buf_len) { register int dequeue = uart->tx_buf_len; *MCF5206E_UIMR(MBAR, uart->chn) = MCF5206E_UIMR_FFULL; uart->tx_buf = NULL; uart->tx_ptr = uart->tx_buf_len = 0; rtems_termios_dequeue_characters(uart->tty, dequeue); } else { *MCF5206E_UTB(MBAR, chn) = uart->tx_buf[uart->tx_ptr++]; } } else break; }} |
rtems_unsigned32 div; rtems_unsigned32 rate; | uint32_t div; uint32_t rate; | mcfuart_set_baudrate(mcfuart *uart, speed_t baud){ rtems_unsigned32 div; rtems_unsigned32 rate; switch (baud) { case B50: rate = 50; break; case B75: rate = 75; break; case B110: rate = 110; break; case B134: rate = 134; break; case B150: rate = 150; break; case B200: rate = 200; break; case B300: rate = 300; break; case B600: rate = 600; break; case B1200: rate = 1200; break; case B2400: rate = 2400; break; case B4800: rate = 4800; break; case B9600: rate = 9600; break; case B19200: rate = 19200; break; case B38400: rate = 38400; break; case B57600: rate = 57600; break;#ifdef B115200 case B115200: rate = 115200; break;#endif#ifdef B230400 case B230400: rate = 230400; break;#endif default: rate = 9600; break; } div = SYSTEM_CLOCK_FREQUENCY / (rate * 32); *MCF5206E_UBG1(MBAR,uart->chn) = (rtems_unsigned8)((div >> 8) & 0xff); *MCF5206E_UBG2(MBAR,uart->chn) = (rtems_unsigned8)(div & 0xff);} |
*MCF5206E_UBG1(MBAR,uart->chn) = (rtems_unsigned8)((div >> 8) & 0xff); *MCF5206E_UBG2(MBAR,uart->chn) = (rtems_unsigned8)(div & 0xff); | *MCF5206E_UBG1(MBAR,uart->chn) = (uint8_t )((div >> 8) & 0xff); *MCF5206E_UBG2(MBAR,uart->chn) = (uint8_t )(div & 0xff); | mcfuart_set_baudrate(mcfuart *uart, speed_t baud){ rtems_unsigned32 div; rtems_unsigned32 rate; switch (baud) { case B50: rate = 50; break; case B75: rate = 75; break; case B110: rate = 110; break; case B134: rate = 134; break; case B150: rate = 150; break; case B200: rate = 200; break; case B300: rate = 300; break; case B600: rate = 600; break; case B1200: rate = 1200; break; case B2400: rate = 2400; break; case B4800: rate = 4800; break; case B9600: rate = 9600; break; case B19200: rate = 19200; break; case B38400: rate = 38400; break; case B57600: rate = 57600; break;#ifdef B115200 case B115200: rate = 115200; break;#endif#ifdef B230400 case B230400: rate = 230400; break;#endif default: rate = 9600; break; } div = SYSTEM_CLOCK_FREQUENCY / (rate * 32); *MCF5206E_UBG1(MBAR,uart->chn) = (rtems_unsigned8)((div >> 8) & 0xff); *MCF5206E_UBG2(MBAR,uart->chn) = (rtems_unsigned8)(div & 0xff);} |
SERF_DECLARE(apr_pool_t *) serf_request_get_pool(const serf_request_t *request) | SERF_DECLARE(serf_context_t *) serf_context_create(apr_pool_t *pool) | SERF_DECLARE(apr_pool_t *) serf_request_get_pool(const serf_request_t *request){ return request->respool;} |
return request->respool; | serf_context_t *ctx = apr_pcalloc(pool, sizeof(*ctx)); ctx->pool = pool; (void) apr_pollset_create(&ctx->pollset, MAX_CONN, pool, 0); ctx->conns = apr_array_make(pool, 1, sizeof(serf_connection_t *)); return ctx; | SERF_DECLARE(apr_pool_t *) serf_request_get_pool(const serf_request_t *request){ return request->respool;} |
if (minkowski > maxprime()) err(primer1); | if ((ulong)minkowski > maxprime()) err(primer1); | testprime(GEN bnf, long minkowski){ long av = avma, pp,i,nbideal,k,pmax; GEN f,p1,vectpp,fb,dK, nf=checknf(bnf); byteptr delta = diffptr; if (DEBUGLEVEL>1) fprintferr("PHASE 1: check primes to Zimmert bound = %ld\n\n",minkowski); f=(GEN)nf[4]; dK=(GEN)nf[3]; if (!gcmp1(f)) { GEN different = gmael(nf,5,5); if (DEBUGLEVEL>1) fprintferr("**** Testing Different = %Z\n",different); p1 = isprincipalall(bnf,different,nf_FORCE); if (DEBUGLEVEL>1) fprintferr(" is %Z\n",p1); } fb=(GEN)bnf[5]; p1 = gmael(fb, lg(fb)-1, 1); /* largest p in factorbase */ pp = 0; pmax = is_bigint(p1)? VERYBIGINT: itos(p1); if (minkowski > maxprime()) err(primer1); while (pp < minkowski) { pp += *delta++; if (DEBUGLEVEL>1) fprintferr("*** p = %ld\n",pp); vectpp=primedec(bnf,stoi(pp)); nbideal=lg(vectpp)-1; /* loop through all P | p if ramified, all but one otherwise */ if (!smodis(dK,pp)) nbideal++; for (i=1; i<nbideal; i++) { GEN P = (GEN)vectpp[i]; if (DEBUGLEVEL>1) fprintferr(" Testing P = %Z\n",P); if (cmpis(idealnorm(bnf,P), minkowski) < 1) { if (pp <= pmax && (k = tablesearch(fb, P, cmp_prime_ideal))) { if (DEBUGLEVEL>1) fprintferr(" #%ld in factor base\n",k); } else { p1 = isprincipal(bnf,P); if (DEBUGLEVEL>1) fprintferr(" is %Z\n",p1); } } else if (DEBUGLEVEL>1) fprintferr(" Norm(P) > Zimmert bound\n"); } } avma=av; if (DEBUGLEVEL>1) { fprintferr("End of PHASE 1.\n\n"); flusherr(); }} |
GEN p1,matt2, MCcopy, MCshif, M = gmael(nf,5,1), MC = gmael(nf,5,2); long i,j,k,n = min(RU,9); | GEN matt2, MCcopy, MCshif, M = gmael(nf,5,1), MC = gmael(nf,5,2); long i,j,k,n = min(RU,9), N = n*(n+1)/2, ind = 1; | compute_matt2(long RU,GEN nf){ GEN p1,matt2, MCcopy, MCshif, M = gmael(nf,5,1), MC = gmael(nf,5,2); long i,j,k,n = min(RU,9); MCcopy=cgetg(RU+1,t_MAT); MCshif=cgetg(n+1,t_MAT); for (k=1; k<=RU; k++) MCcopy[k]=MC[k]; for (k=1; k<=n; k++) MCshif[k]=lmul2n((GEN)MC[k],20); matt2=cgetg(n+1,t_MAT); for (j=1; j<=n; j++) { p1=cgetg(n+1,t_COL); matt2[j]=(long)p1; MCcopy[j]=MCshif[j]; for (i=1; i<=j; i++) { MCcopy[i]=MCshif[i]; p1[i] = (long)mulmat_real(MCcopy,M); MCcopy[i]=MC[i]; } MCcopy[j]=MC[j]; for ( ; i<=n; i++) p1[i]=zero; } if (DEBUGLEVEL) msgtimer("weighted T2 matrices"); return matt2;} |
matt2=cgetg(n+1,t_MAT); | matt2=cgetg(N+1,t_VEC); | compute_matt2(long RU,GEN nf){ GEN p1,matt2, MCcopy, MCshif, M = gmael(nf,5,1), MC = gmael(nf,5,2); long i,j,k,n = min(RU,9); MCcopy=cgetg(RU+1,t_MAT); MCshif=cgetg(n+1,t_MAT); for (k=1; k<=RU; k++) MCcopy[k]=MC[k]; for (k=1; k<=n; k++) MCshif[k]=lmul2n((GEN)MC[k],20); matt2=cgetg(n+1,t_MAT); for (j=1; j<=n; j++) { p1=cgetg(n+1,t_COL); matt2[j]=(long)p1; MCcopy[j]=MCshif[j]; for (i=1; i<=j; i++) { MCcopy[i]=MCshif[i]; p1[i] = (long)mulmat_real(MCcopy,M); MCcopy[i]=MC[i]; } MCcopy[j]=MC[j]; for ( ; i<=n; i++) p1[i]=zero; } if (DEBUGLEVEL) msgtimer("weighted T2 matrices"); return matt2;} |
p1=cgetg(n+1,t_COL); matt2[j]=(long)p1; | compute_matt2(long RU,GEN nf){ GEN p1,matt2, MCcopy, MCshif, M = gmael(nf,5,1), MC = gmael(nf,5,2); long i,j,k,n = min(RU,9); MCcopy=cgetg(RU+1,t_MAT); MCshif=cgetg(n+1,t_MAT); for (k=1; k<=RU; k++) MCcopy[k]=MC[k]; for (k=1; k<=n; k++) MCshif[k]=lmul2n((GEN)MC[k],20); matt2=cgetg(n+1,t_MAT); for (j=1; j<=n; j++) { p1=cgetg(n+1,t_COL); matt2[j]=(long)p1; MCcopy[j]=MCshif[j]; for (i=1; i<=j; i++) { MCcopy[i]=MCshif[i]; p1[i] = (long)mulmat_real(MCcopy,M); MCcopy[i]=MC[i]; } MCcopy[j]=MC[j]; for ( ; i<=n; i++) p1[i]=zero; } if (DEBUGLEVEL) msgtimer("weighted T2 matrices"); return matt2;} |
|
p1[i] = (long)mulmat_real(MCcopy,M); | matt2[ind++] = (long)mulmat_real(MCcopy,M); | compute_matt2(long RU,GEN nf){ GEN p1,matt2, MCcopy, MCshif, M = gmael(nf,5,1), MC = gmael(nf,5,2); long i,j,k,n = min(RU,9); MCcopy=cgetg(RU+1,t_MAT); MCshif=cgetg(n+1,t_MAT); for (k=1; k<=RU; k++) MCcopy[k]=MC[k]; for (k=1; k<=n; k++) MCshif[k]=lmul2n((GEN)MC[k],20); matt2=cgetg(n+1,t_MAT); for (j=1; j<=n; j++) { p1=cgetg(n+1,t_COL); matt2[j]=(long)p1; MCcopy[j]=MCshif[j]; for (i=1; i<=j; i++) { MCcopy[i]=MCshif[i]; p1[i] = (long)mulmat_real(MCcopy,M); MCcopy[i]=MC[i]; } MCcopy[j]=MC[j]; for ( ; i<=n; i++) p1[i]=zero; } if (DEBUGLEVEL) msgtimer("weighted T2 matrices"); return matt2;} |
for ( ; i<=n; i++) p1[i]=zero; | compute_matt2(long RU,GEN nf){ GEN p1,matt2, MCcopy, MCshif, M = gmael(nf,5,1), MC = gmael(nf,5,2); long i,j,k,n = min(RU,9); MCcopy=cgetg(RU+1,t_MAT); MCshif=cgetg(n+1,t_MAT); for (k=1; k<=RU; k++) MCcopy[k]=MC[k]; for (k=1; k<=n; k++) MCshif[k]=lmul2n((GEN)MC[k],20); matt2=cgetg(n+1,t_MAT); for (j=1; j<=n; j++) { p1=cgetg(n+1,t_COL); matt2[j]=(long)p1; MCcopy[j]=MCshif[j]; for (i=1; i<=j; i++) { MCcopy[i]=MCshif[i]; p1[i] = (long)mulmat_real(MCcopy,M); MCcopy[i]=MC[i]; } MCcopy[j]=MC[j]; for ( ; i<=n; i++) p1[i]=zero; } if (DEBUGLEVEL) msgtimer("weighted T2 matrices"); return matt2;} |
|
while (getDebugChar () != '+'); | while (getAck () != '+'); | putpacket (char *buffer){ int checksum; /* $<packet info>#<checksum> */ do { char *src = buffer; putDebugChar ('$'); checksum = 0; while (*src != '\0') { int runlen = 0; /* Do run length encoding */ while ((src[runlen] == src[0]) && (runlen < 99)) runlen++; if (runlen > 3) { int encode; /* Got a useful amount */ putDebugChar (*src); checksum += *src; putDebugChar ('*'); checksum += '*'; checksum += (encode = (runlen - 4) + ' '); putDebugChar (encode); src += runlen; } else { putDebugChar (*src); checksum += *src; src++; } } putDebugChar ('#'); putDebugChar (highhex (checksum)); putDebugChar (lowhex (checksum)); } while (getDebugChar () != '+');} |
pariputc('\n'); l = lg(g[1]); | l = lg(g[1]); pariputc('\n'); | matbruti(GEN g, pariout_t *T){ long i, j, r, l; void (*print)(GEN, pariout_t *, int); if (typ(g) != t_MAT) { bruti(g,T,1); return; } r=lg(g); if (r==1 || lg(g[1])==1) { pariputs("[;]\n"); return; } pariputc('\n'); l = lg(g[1]); print = (typ(g[1]) == t_VECSMALL)? prints: bruti; for (i=1; i<l; i++) { pariputc('['); for (j=1; j<r; j++) { print(gcoeff(g,i,j),T,1); if (j<r-1) pariputc(' '); } if (i<l-1) pariputs("]\n\n"); else pariputs("]\n"); }} |
puts( "\n\n*** ITRON TASK TEST 3 ***" ); | T_RTSK pk_rtsk; | void ITRON_Init( void ){ ER status; T_CTSK pk_ctsk; puts( "\n\n*** ITRON TASK TEST 3 ***" ); pk_ctsk.exinf = NULL; pk_ctsk.tskatr = TA_HLNG; pk_ctsk.stksz = RTEMS_MINIMUM_STACK_SIZE; pk_ctsk.itskpri = 1; pk_ctsk.task = Preempt_task; status = cre_tsk( PREEMPT_TASK_ID, &pk_ctsk ); directive_failed( status, "cre_tsk of RTEMS_PREEMPT" ); status = sta_tsk( PREEMPT_TASK_ID, 0 ); directive_failed( status, "sta_tsk of RTEMS_PREEMPT" ); puts( "INIT - rot_rdq - yielding processor" ); status = rot_rdq( 1 ); directive_failed( status, "rot_rdq" ); pk_ctsk.itskpri = 3; pk_ctsk.task = Task_1; status = cre_tsk( TA1_ID, &pk_ctsk ); directive_failed( status, "cre_tsk of TA1" ); pk_ctsk.task = Task_2; status = cre_tsk( TA2_ID, &pk_ctsk ); directive_failed( status, "cre_tsk of TA2" ); pk_ctsk.task = Task_3; status = cre_tsk( TA3_ID, &pk_ctsk ); directive_failed( status, "cre_tsk of TA3" ); status = sta_tsk( TA1_ID, 0 ); directive_failed( status, "sta_tsk of TA1" ); status = sta_tsk( TA2_ID, 0 ); directive_failed( status, "sta_tsk of TA2" ); status = sta_tsk( TA3_ID, 0 ); directive_failed( status, "sta_tsk of TA3" ); puts( "INIT - suspending TA2 while middle task on a ready chain" ); status = sus_tsk( TA2_ID ); directive_failed( status, "sus_tsk of TA2" ); status = ter_tsk( TA1_ID ); directive_failed( status, "ter_tsk of TA1" ); status = del_tsk( TA1_ID ); directive_failed( status, "del_tsk of TA1" ); status = ter_tsk( TA2_ID ); directive_failed( status, "ter_tsk of TA2" ); status = ter_tsk( TA3_ID ); directive_failed( status, "ter_tsk of TA3" ); pk_ctsk.itskpri = 1; pk_ctsk.task = Task_1; status = cre_tsk( TA1_ID, &pk_ctsk ); directive_failed( status, "cre_tsk of TA1 at priority 1" ); status = sta_tsk( TA1_ID, 0 ); directive_failed( status, "sta_tsk of TA1" ); status = sta_tsk( TA2_ID, 0 ); directive_failed( status, "sta_tsk of TA2" ); status = sta_tsk( TA3_ID, 0 ); directive_failed( status, "sta_tsk of TA3" ); exd_tsk(); directive_failed( 0, "exd_tsk" );} |
pk_ctsk.itskpri = 1; pk_ctsk.task = Preempt_task; | puts( "\n\n*** ITRON TASK TEST 3 ***" ); puts( "INIT - Create and Start PREEMPT" ); status = chg_pri( TSK_SELF, (PREEMPT_PRIORITY+2) ); directive_failed( status, "chg_pri of SELF" ); | void ITRON_Init( void ){ ER status; T_CTSK pk_ctsk; puts( "\n\n*** ITRON TASK TEST 3 ***" ); pk_ctsk.exinf = NULL; pk_ctsk.tskatr = TA_HLNG; pk_ctsk.stksz = RTEMS_MINIMUM_STACK_SIZE; pk_ctsk.itskpri = 1; pk_ctsk.task = Preempt_task; status = cre_tsk( PREEMPT_TASK_ID, &pk_ctsk ); directive_failed( status, "cre_tsk of RTEMS_PREEMPT" ); status = sta_tsk( PREEMPT_TASK_ID, 0 ); directive_failed( status, "sta_tsk of RTEMS_PREEMPT" ); puts( "INIT - rot_rdq - yielding processor" ); status = rot_rdq( 1 ); directive_failed( status, "rot_rdq" ); pk_ctsk.itskpri = 3; pk_ctsk.task = Task_1; status = cre_tsk( TA1_ID, &pk_ctsk ); directive_failed( status, "cre_tsk of TA1" ); pk_ctsk.task = Task_2; status = cre_tsk( TA2_ID, &pk_ctsk ); directive_failed( status, "cre_tsk of TA2" ); pk_ctsk.task = Task_3; status = cre_tsk( TA3_ID, &pk_ctsk ); directive_failed( status, "cre_tsk of TA3" ); status = sta_tsk( TA1_ID, 0 ); directive_failed( status, "sta_tsk of TA1" ); status = sta_tsk( TA2_ID, 0 ); directive_failed( status, "sta_tsk of TA2" ); status = sta_tsk( TA3_ID, 0 ); directive_failed( status, "sta_tsk of TA3" ); puts( "INIT - suspending TA2 while middle task on a ready chain" ); status = sus_tsk( TA2_ID ); directive_failed( status, "sus_tsk of TA2" ); status = ter_tsk( TA1_ID ); directive_failed( status, "ter_tsk of TA1" ); status = del_tsk( TA1_ID ); directive_failed( status, "del_tsk of TA1" ); status = ter_tsk( TA2_ID ); directive_failed( status, "ter_tsk of TA2" ); status = ter_tsk( TA3_ID ); directive_failed( status, "ter_tsk of TA3" ); pk_ctsk.itskpri = 1; pk_ctsk.task = Task_1; status = cre_tsk( TA1_ID, &pk_ctsk ); directive_failed( status, "cre_tsk of TA1 at priority 1" ); status = sta_tsk( TA1_ID, 0 ); directive_failed( status, "sta_tsk of TA1" ); status = sta_tsk( TA2_ID, 0 ); directive_failed( status, "sta_tsk of TA2" ); status = sta_tsk( TA3_ID, 0 ); directive_failed( status, "sta_tsk of TA3" ); exd_tsk(); directive_failed( 0, "exd_tsk" );} |
directive_failed( 0, "exd_tsk" ); | assert(0); | void ITRON_Init( void ){ ER status; T_CTSK pk_ctsk; puts( "\n\n*** ITRON TASK TEST 3 ***" ); pk_ctsk.exinf = NULL; pk_ctsk.tskatr = TA_HLNG; pk_ctsk.stksz = RTEMS_MINIMUM_STACK_SIZE; pk_ctsk.itskpri = 1; pk_ctsk.task = Preempt_task; status = cre_tsk( PREEMPT_TASK_ID, &pk_ctsk ); directive_failed( status, "cre_tsk of RTEMS_PREEMPT" ); status = sta_tsk( PREEMPT_TASK_ID, 0 ); directive_failed( status, "sta_tsk of RTEMS_PREEMPT" ); puts( "INIT - rot_rdq - yielding processor" ); status = rot_rdq( 1 ); directive_failed( status, "rot_rdq" ); pk_ctsk.itskpri = 3; pk_ctsk.task = Task_1; status = cre_tsk( TA1_ID, &pk_ctsk ); directive_failed( status, "cre_tsk of TA1" ); pk_ctsk.task = Task_2; status = cre_tsk( TA2_ID, &pk_ctsk ); directive_failed( status, "cre_tsk of TA2" ); pk_ctsk.task = Task_3; status = cre_tsk( TA3_ID, &pk_ctsk ); directive_failed( status, "cre_tsk of TA3" ); status = sta_tsk( TA1_ID, 0 ); directive_failed( status, "sta_tsk of TA1" ); status = sta_tsk( TA2_ID, 0 ); directive_failed( status, "sta_tsk of TA2" ); status = sta_tsk( TA3_ID, 0 ); directive_failed( status, "sta_tsk of TA3" ); puts( "INIT - suspending TA2 while middle task on a ready chain" ); status = sus_tsk( TA2_ID ); directive_failed( status, "sus_tsk of TA2" ); status = ter_tsk( TA1_ID ); directive_failed( status, "ter_tsk of TA1" ); status = del_tsk( TA1_ID ); directive_failed( status, "del_tsk of TA1" ); status = ter_tsk( TA2_ID ); directive_failed( status, "ter_tsk of TA2" ); status = ter_tsk( TA3_ID ); directive_failed( status, "ter_tsk of TA3" ); pk_ctsk.itskpri = 1; pk_ctsk.task = Task_1; status = cre_tsk( TA1_ID, &pk_ctsk ); directive_failed( status, "cre_tsk of TA1 at priority 1" ); status = sta_tsk( TA1_ID, 0 ); directive_failed( status, "sta_tsk of TA1" ); status = sta_tsk( TA2_ID, 0 ); directive_failed( status, "sta_tsk of TA2" ); status = sta_tsk( TA3_ID, 0 ); directive_failed( status, "sta_tsk of TA3" ); exd_tsk(); directive_failed( 0, "exd_tsk" );} |
if (!r) err(bugparier, "precision too low in small_norm"); | if (!r) err(bugparier, "small_norm (precision too low)"); | small_norm(RELCACHE_t *cache, FB_t *F, double LOGD, GEN nf,long nbrelpid, GEN invp,GEN L,double LIMC2){ const int maxtry_DEP = 20; const int maxtry_FACT = 500; const double eps = 0.000001; double *y,*z,**q,*v, BOUND; pari_sp av = avma, av1, av2, limpile; long nbsmallnorm, nbfact, j, k, noideal, precbound; long N = degpol(nf[1]), R1 = nf_get_r1(nf), prec = nfgetprec(nf); GEN x, gx, Mlow, M, G, r, Gvec, prvec; REL_t *rel = cache->last; if (DEBUGLEVEL) fprintferr("\n#### Looking for %ld relations (small norms)\n", cache->end - cache->base); gx = NULL; /* gcc -Wall */ nbsmallnorm = nbfact = 0; M = gmael(nf,5,1); G = gmael(nf,5,2); /* LLL reduction produces v0 in I such that * T2(v0) <= (4/3)^((n-1)/2) NI^(2/n) disc(K)^(1/n) * We consider v with T2(v) <= 2 T2(v0) * Hence Nv <= ((4/3)^((n-1)/2) * 2 / n)^(n/2) NI sqrt(disc(K)) */ precbound = 3 + (long)ceil( (N/2. * ((N-1)/2.* log(4./3) + log(2./N)) + log(LIMC2) + LOGD / 2) / (BITS_IN_LONG * log(2.))); /* enough to compute norms */ if (precbound < prec) Mlow = gprec_w(M, precbound); else Mlow = M; prvec = cgetg(3,t_VECSMALL); Gvec = cgetg(3,t_VEC); prvec[1] = MEDDEFAULTPREC; Gvec[1] = (long)gprec_w(G,prvec[1]); prvec[2] = prec; Gvec[2] = (long)G; minim_alloc(N+1, &q, &x, &y, &z, &v); av1 = avma; for (noideal=F->KC; noideal; noideal--) { pari_sp av0 = avma; long nbrelideal = 0, dependent = 0, try_factor = 0; GEN IDEAL, ideal = (GEN)F->LP[noideal]; REL_t *oldrel = rel; if (DEBUGLEVEL>1) fprintferr("\n*** Ideal no %ld: %Z\n", noideal, ideal); ideal = prime_to_ideal(nf,ideal); IDEAL = lllint_ip(ideal,4); /* should be almost T2-reduced */ r = red_ideal(&IDEAL,Gvec,prvec); if (!r) err(bugparier, "precision too low in small_norm"); for (k=1; k<=N; k++) { v[k] = gtodouble(gcoeff(r,k,k)); for (j=1; j<k; j++) q[j][k] = gtodouble(gcoeff(r,j,k)); if (DEBUGLEVEL>3) fprintferr("v[%ld]=%.4g ",k,v[k]); } BOUND = v[2] + v[1] * q[1][2] * q[1][2]; if (BOUND < v[1]) BOUND = v[1]; BOUND *= 2; /* at most twice larger than smallest known vector */ if (DEBUGLEVEL>1) { if (DEBUGLEVEL>3) fprintferr("\n"); fprintferr("BOUND = %.4g\n",BOUND); flusherr(); } BOUND *= 1 + eps; av2=avma; limpile = stack_lim(av2,1); k = N; y[N] = z[N] = 0; x[N] = (long)sqrt(BOUND/v[N]); for(;; x[1]--) { pari_sp av3 = avma; for(;;) /* look for primitive element of small norm, cf minim00 */ { double p; if (k>1) { long l = k-1; z[l] = 0; for (j=k; j<=N; j++) z[l] += q[l][j]*x[j]; p = (double)x[k] + z[k]; y[l] = y[k] + p*p*v[k]; x[l] = (long) floor(sqrt((BOUND-y[l])/v[l])-z[l]); k = l; } for(;;) { p = (double)x[k] + z[k]; if (y[k] + p*p*v[k] <= BOUND) break; k++; x[k]--; } if (k==1) /* element complete */ { if (y[1]<=eps) goto ENDIDEAL; /* skip all scalars: [*,0...0] */ if (ccontent(x)==1) /* primitive */ { gx = gmul_mati_smallvec(IDEAL,x); if (!isnfscalar(gx)) { pari_sp av4 = avma; GEN Nx, xembed = gmul(Mlow, gx); nbsmallnorm++; if (++try_factor > maxtry_FACT) goto ENDIDEAL; Nx = ground( norm_by_embed(R1,xembed) ); setsigne(Nx, 1); if (can_factor(F, nf, NULL, gx, Nx)) { avma = av4; break; } if (DEBUGLEVEL > 1) { fprintferr("."); flusherr(); } } avma = av3; } x[1]--; } } set_fact(++rel, F); /* make sure we get maximal rank first, then allow all relations */ if (rel - cache->base > 1 && rel - cache->base <= F->KC && ! addcolumntomatrix(rel->R,invp,L)) { /* Q-dependent from previous ones: forget it */ free((void*)rel->R); rel--; if (DEBUGLEVEL>1) fprintferr("*"); if (++dependent > maxtry_DEP) break; avma = av3; continue; } rel->m = gclone(gx); rel->ex= NULL; dependent = 0; if (DEBUGLEVEL) { nbfact++; dbg_rel(rel - cache->base, rel->R); } if (rel >= cache->end) goto END; /* we have enough */ if (++nbrelideal == nbrelpid) break; if (low_stack(limpile, stack_lim(av2,1))) { if(DEBUGMEM>1) err(warnmem,"small_norm"); invp = gerepilecopy(av2, invp); } }ENDIDEAL: if (rel == oldrel) avma = av0; else invp = gerepilecopy(av1, invp); if (DEBUGLEVEL>1) msgtimer("for this ideal"); }END: cache->last = rel; avma = av; if (DEBUGLEVEL) { fprintferr("\n"); msgtimer("small norm relations"); fprintferr(" small norms gave %ld relations.\n", cache->last - cache->base); if (nbsmallnorm) fprintferr(" nb. fact./nb. small norm = %ld/%ld = %.3f\n", nbfact,nbsmallnorm,((double)nbfact)/nbsmallnorm); }} |
int i; unsigned long hash,api; PTE pte; | int i; unsigned long hash, api; APte pte; | alreadyMapped(Triv121PgTbl pt, long vsid, unsigned long pi){int i;unsigned long hash,api;PTE pte; if (!pt->size) return 0; if (vsid<0) { vsid=VSID121(pi); pi=PI121(pi); } hash = PTE_HASH1(vsid,pi); api=API(pi); for (i=0, pte=ptegOf(pt,hash); i<PTE_PER_PTEG; i++,pte++) if (pte->v && pte->vsid==vsid && pte->api==api && 0==pte->h) return pte; /* try the secondary hash table */ hash = PTE_HASH2(hash); for (i=0, pte=ptegOf(pt,hash); i<PTE_PER_PTEG; i++,pte++) if (pte->v && pte->vsid==vsid && pte->api==api && 1==pte->h) return pte; return 0;} |
if (vsid<0) { vsid=VSID121(pi); pi=PI121(pi); } | if (TRIV121_121_VSID == vsid) { vsid = VSID121 (pi); pi = PI121 (pi); } else if (TRIV121_SEG_VSID == vsid) { vsid = seg2vsid (pi); pi = PI121 (pi); } | alreadyMapped(Triv121PgTbl pt, long vsid, unsigned long pi){int i;unsigned long hash,api;PTE pte; if (!pt->size) return 0; if (vsid<0) { vsid=VSID121(pi); pi=PI121(pi); } hash = PTE_HASH1(vsid,pi); api=API(pi); for (i=0, pte=ptegOf(pt,hash); i<PTE_PER_PTEG; i++,pte++) if (pte->v && pte->vsid==vsid && pte->api==api && 0==pte->h) return pte; /* try the secondary hash table */ hash = PTE_HASH2(hash); for (i=0, pte=ptegOf(pt,hash); i<PTE_PER_PTEG; i++,pte++) if (pte->v && pte->vsid==vsid && pte->api==api && 1==pte->h) return pte; return 0;} |
if (!m) err(bugparier, "precision too low in random_rel"); | if (!m) err(bugparier, "random_rel (precision too low)"); | random_rel(long phase, RELCACHE_t *cache, FB_t *F, long MAXRELSUP, GEN nf, GEN vecG, GEN L_jideal){ static long jideal, jdir; long i, cptlist, cptzer, nbG, lgsub, jlist = 1; pari_sp av, av1; GEN ideal, IDEAL, m, P, ex; if (phase != 1) { jideal=jdir=1; if (phase < 0) return 0; } if (!F->pow) powFBgen(F, nf, CBUCHG+1); nbG = lg(vecG)-1; lgsub = lg(F->subFB); ex = cgetg(lgsub, t_VECSMALL); cptzer = cptlist = 0; if (DEBUGLEVEL && L_jideal) fprintferr("looking hard for %Z\n",L_jideal); P = NULL; /* gcc -Wall */ for (av = avma;;) { REL_t *rel = cache->last; if (L_jideal && jlist < lg(L_jideal)) { if (++cptlist > 3) { jideal = L_jideal[jlist++]; cptlist = 0; } } else { if (jideal == F->KC) jideal=1; else jideal++; } avma = av; P = prime_to_ideal(nf, (GEN)F->LP[jideal]); ideal = P; do { for (i=1; i<lgsub; i++) { /* reduce mod apparent order */ ex[i] = random_bits(RANDOM_BITS) % F->pow->ord[i]; if (ex[i]) ideal = idealmulh(nf,ideal, gmael(F->pow->id2,i,ex[i])); } } while (ideal == P); /* If ex = 0, try another */ ideal = remove_content(ideal); IDEAL = lllint_ip(ideal, 4); if (phase != 1) jdir = 1; else phase = 2; for (av1 = avma; jdir <= nbG; jdir++, avma = av1) { /* reduce along various directions */ if (DEBUGLEVEL>2) fprintferr("jideal=%ld,jdir=%ld,rand=%ld\n", jideal,jdir,getrand()); m = pseudomin(IDEAL, (GEN)vecG[jdir]); if (!m) err(bugparier, "precision too low in random_rel"); if (!factorgen(F,nf,ideal,m)) { if (DEBUGLEVEL>1) { fprintferr("."); flusherr(); } continue; } /* can factor ideal, record relation */ set_fact(++rel, F); rel->R[jideal]--; for (i=1; i<lgsub; i++) rel->R[ F->subFB[i] ] -= ex[i]; if (already_known(cache, rel)) { /* forget it */ if (DEBUGLEVEL>1) dbg_cancelrel(jideal,jdir,rel->R); free((void*)rel->R); rel--; if (++cptzer > MAXRELSUP) { if (L_jideal) { cptzer -= 10; break; } return 0; } continue; } rel->m = gclone(m); rel->ex = gclone(ex); rel->pow = F->pow; cache->last = rel; if (DEBUGLEVEL) dbg_newrel(cache, jideal, jdir); /* Need more, try next P */ if (rel < cache->end) { cptzer = 0; break; } /* We have found enough. Return */ if (phase) { jdir = 1; if (jideal == F->KC) jideal=1; else jideal++; } if (DEBUGLEVEL>2) { fprintferr("Upon exit: jideal=%ld,jdir=%ld\n",jideal,jdir); if (DEBUGLEVEL > 3 && phase == 0) dbg_outrel(cache); } avma = av; return 1; } }} |
suppressed(ANYARG) {err(talker,"this function has been suppressed");} | suppressed(void) {err(talker,"this function has been suppressed");} | suppressed(ANYARG) {err(talker,"this function has been suppressed");} |
GEN u,S,x,y,z,v,norme1,normax1,borne1,borne2,eps,p1,alpha,norms,dummy; | GEN u,S,x,y,z,v,norme1,normax1,borne1,borne2,eps,p1,alpha,norms; | smallvectors(GEN q, GEN BORNE, long stockmax, FP_chk_fun *CHECK){ long N, n, i, j, k, s, epsbit, prec, checkcnt = 1; pari_sp av, av1, lim; GEN u,S,x,y,z,v,norme1,normax1,borne1,borne2,eps,p1,alpha,norms,dummy; GEN (*check)(void *,GEN) = CHECK? CHECK->f: NULL; void *data = CHECK? CHECK->data: NULL; int skipfirst = CHECK? CHECK->skipfirst: 0; if (DEBUGLEVEL) fprintferr("smallvectors looking for norm <= %Z\n",gprec_w(BORNE,3)); prec = gprecision(q); epsbit = bit_accuracy(prec) >> 1; eps = real2n(-epsbit, 3); alpha = dbltor(0.95); normax1 = gzero; borne1= gadd(BORNE,eps); borne2 = mpmul(borne1,alpha); N = lg(q); n = N-1; v = cgetg(N,t_VEC); dummy = cgetg(1,t_STR); av = avma; lim = stack_lim(av,2); if (check) norms = cgetg(stockmax+1,t_VEC); S = cgetg(stockmax+1,t_VEC); x = cgetg(N,t_COL); y = cgetg(N,t_COL); z = cgetg(N,t_COL); for (i=1; i<N; i++) { v[i] = coeff(q,i,i); x[i]=y[i]=z[i] = zero; } x[n] = lmpent(mpsqrt(gdiv(borne1,(GEN)v[n]))); if (DEBUGLEVEL>3) { fprintferr("\nx[%ld] = %Z\n",n,x[n]); flusherr(); } s = 0; k = n; for(;; x[k] = laddis((GEN)x[k],-1)) /* main */ { do { int fl = 0; if (k > 1) { av1=avma; k--; p1 = mpmul(gcoeff(q,k,k+1),(GEN)x[k+1]); for (j=k+2; j<N; j++) p1 = mpadd(p1, mpmul(gcoeff(q,k,j),(GEN)x[j])); z[k] = (long)gerepileuptoleaf(av1,p1); av1=avma; p1 = gsqr(mpadd((GEN)x[k+1],(GEN)z[k+1])); p1 = mpadd((GEN)y[k+1], mpmul(p1,(GEN)v[k+1])); y[k] = (long)gerepileuptoleaf(av1, p1); /* reject the [x_1,...,x_skipfirst,0,...,0] */ if (k <= skipfirst && !signe(y[skipfirst])) goto END; av1=avma; p1 = mpsub(borne1, (GEN)y[k]); if (signe(p1) < 0) { avma=av1; fl = 1; } else { p1 = mpadd(eps,mpsub(mpsqrt(gdiv(p1,(GEN)v[k])), (GEN)z[k])); x[k] = (long)gerepileuptoleaf(av1,mpent(p1)); } } for(;; x[k] = laddis((GEN)x[k],-1)) { if (!fl) { av1 = avma; /* p1 >= 0 */ p1 = mpmul((GEN)v[k], gsqr(mpadd((GEN)x[k],(GEN)z[k]))); i = mpcmp(mpsub(mpadd(p1,(GEN)y[k]), borne1), gmul2n(p1,-epsbit)); avma = av1; if (i <= 0) break; } k++; fl=0; } if (low_stack(lim, stack_lim(av,2))) { int cnt = 4; if(DEBUGMEM>1) err(warnmem,"smallvectors"); if (stockmax) { /* initialize to dummy values */ GEN T = S; for (i=s+1; i<=stockmax; i++) S[i]=(long)dummy; S = gclone(S); if (isclone(T)) gunclone(T); } if (check) { cnt += 3; for (i=s+1; i<=stockmax; i++) norms[i]=(long)dummy; } gerepileall(av,cnt,&x,&y,&z,&normax1,&borne1,&borne2,&norms); } if (DEBUGLEVEL>3) { if (DEBUGLEVEL>5) fprintferr("%ld ",k); if (k==n) fprintferr("\nx[%ld] = %Z\n",n,x[n]); flusherr(); } } while (k > 1); /* x = 0: we're done */ if (!signe(x[1]) && !signe(y[1])) goto END; av1=avma; p1 = gsqr(mpadd((GEN)x[1],(GEN)z[1])); norme1 = mpadd((GEN)y[1], mpmul(p1, (GEN)v[1])); if (mpcmp(norme1,borne1) > 0) { avma=av1; continue; /* main */ } norme1 = gerepileupto(av1,norme1); if (check) { if (checkcnt < 5 && mpcmp(norme1, borne2) < 0) { if (!check(data,x)) { checkcnt++ ; continue; /* main */} borne1 = mpadd(norme1,eps); borne2 = mpmul(borne1,alpha); s = 0; checkcnt = 0; } } else if (mpcmp(norme1,normax1) > 0) normax1 = norme1; if (++s <= stockmax) { if (check) norms[s] = (long)norme1; S[s] = (long)dummycopy(x); if (s == stockmax) { pari_sp av2 = avma; GEN per; if (!check) goto END; per = sindexsort(norms); if (DEBUGLEVEL) fprintferr("sorting...\n"); for (j=0,i=1; i<=s; i++) { /* let N be the minimal norm so far for x satisfying 'check'. Keep * all elements of norm N */ long k = per[i]; norme1 = (GEN)norms[k]; if (j && mpcmp(norme1, borne1) > 0) break; if (j || check(data,(GEN)S[k])) { if (!j) borne1 = gclone( mpadd(norme1,eps) ); S[++j] = S[k]; } } s = j; if (!j) avma = av2; else { GEN t = borne1; checkcnt = 0; norme1 = mpsub(borne1,eps); for (i=1; i<=s; i++) norms[i] = (long)norme1; borne1 = gcopy(borne1); gunclone(t); borne2 = mpmul(borne1,alpha); } } } }END: if (s < stockmax) stockmax = s; if (check) { GEN per, alph, pols, p; if (DEBUGLEVEL) fprintferr("final sort & check...\n"); s = stockmax; setlg(norms,s+1); per = sindexsort(norms); alph = cgetg(s+1,t_VEC); pols = cgetg(s+1,t_VEC); for (j=0,i=1; i<=s; i++) { long k = per[i]; norme1 = (GEN)norms[k]; if (j && mpcmp(norme1, borne1) > 0) break; if ((p = check(data,(GEN)S[k]))) { if (!j) borne1 = gadd(norme1,eps); j++; pols[j]=(long)p; alph[j]=S[k]; } } u = cgetg(3,t_VEC); setlg(pols,j+1); u[1] = (long)pols; setlg(alph,j+1); u[2] = (long)alph; if (isclone(S)) { u[2] = (long)forcecopy(alph); gunclone(S); } return u; } u = cgetg(4,t_VEC); u[1] = lstoi(s<<1); u[2] = (long)normax1; if (stockmax) { setlg(S,stockmax+1); settyp(S,t_MAT); if (isclone(S)) { p1 = S; S = forcecopy(S); gunclone(p1); } } else S = cgetg(1,t_MAT); u[3] = (long)S; return u;} |
dummy = cgetg(1,t_STR); | smallvectors(GEN q, GEN BORNE, long stockmax, FP_chk_fun *CHECK){ long N, n, i, j, k, s, epsbit, prec, checkcnt = 1; pari_sp av, av1, lim; GEN u,S,x,y,z,v,norme1,normax1,borne1,borne2,eps,p1,alpha,norms,dummy; GEN (*check)(void *,GEN) = CHECK? CHECK->f: NULL; void *data = CHECK? CHECK->data: NULL; int skipfirst = CHECK? CHECK->skipfirst: 0; if (DEBUGLEVEL) fprintferr("smallvectors looking for norm <= %Z\n",gprec_w(BORNE,3)); prec = gprecision(q); epsbit = bit_accuracy(prec) >> 1; eps = real2n(-epsbit, 3); alpha = dbltor(0.95); normax1 = gzero; borne1= gadd(BORNE,eps); borne2 = mpmul(borne1,alpha); N = lg(q); n = N-1; v = cgetg(N,t_VEC); dummy = cgetg(1,t_STR); av = avma; lim = stack_lim(av,2); if (check) norms = cgetg(stockmax+1,t_VEC); S = cgetg(stockmax+1,t_VEC); x = cgetg(N,t_COL); y = cgetg(N,t_COL); z = cgetg(N,t_COL); for (i=1; i<N; i++) { v[i] = coeff(q,i,i); x[i]=y[i]=z[i] = zero; } x[n] = lmpent(mpsqrt(gdiv(borne1,(GEN)v[n]))); if (DEBUGLEVEL>3) { fprintferr("\nx[%ld] = %Z\n",n,x[n]); flusherr(); } s = 0; k = n; for(;; x[k] = laddis((GEN)x[k],-1)) /* main */ { do { int fl = 0; if (k > 1) { av1=avma; k--; p1 = mpmul(gcoeff(q,k,k+1),(GEN)x[k+1]); for (j=k+2; j<N; j++) p1 = mpadd(p1, mpmul(gcoeff(q,k,j),(GEN)x[j])); z[k] = (long)gerepileuptoleaf(av1,p1); av1=avma; p1 = gsqr(mpadd((GEN)x[k+1],(GEN)z[k+1])); p1 = mpadd((GEN)y[k+1], mpmul(p1,(GEN)v[k+1])); y[k] = (long)gerepileuptoleaf(av1, p1); /* reject the [x_1,...,x_skipfirst,0,...,0] */ if (k <= skipfirst && !signe(y[skipfirst])) goto END; av1=avma; p1 = mpsub(borne1, (GEN)y[k]); if (signe(p1) < 0) { avma=av1; fl = 1; } else { p1 = mpadd(eps,mpsub(mpsqrt(gdiv(p1,(GEN)v[k])), (GEN)z[k])); x[k] = (long)gerepileuptoleaf(av1,mpent(p1)); } } for(;; x[k] = laddis((GEN)x[k],-1)) { if (!fl) { av1 = avma; /* p1 >= 0 */ p1 = mpmul((GEN)v[k], gsqr(mpadd((GEN)x[k],(GEN)z[k]))); i = mpcmp(mpsub(mpadd(p1,(GEN)y[k]), borne1), gmul2n(p1,-epsbit)); avma = av1; if (i <= 0) break; } k++; fl=0; } if (low_stack(lim, stack_lim(av,2))) { int cnt = 4; if(DEBUGMEM>1) err(warnmem,"smallvectors"); if (stockmax) { /* initialize to dummy values */ GEN T = S; for (i=s+1; i<=stockmax; i++) S[i]=(long)dummy; S = gclone(S); if (isclone(T)) gunclone(T); } if (check) { cnt += 3; for (i=s+1; i<=stockmax; i++) norms[i]=(long)dummy; } gerepileall(av,cnt,&x,&y,&z,&normax1,&borne1,&borne2,&norms); } if (DEBUGLEVEL>3) { if (DEBUGLEVEL>5) fprintferr("%ld ",k); if (k==n) fprintferr("\nx[%ld] = %Z\n",n,x[n]); flusherr(); } } while (k > 1); /* x = 0: we're done */ if (!signe(x[1]) && !signe(y[1])) goto END; av1=avma; p1 = gsqr(mpadd((GEN)x[1],(GEN)z[1])); norme1 = mpadd((GEN)y[1], mpmul(p1, (GEN)v[1])); if (mpcmp(norme1,borne1) > 0) { avma=av1; continue; /* main */ } norme1 = gerepileupto(av1,norme1); if (check) { if (checkcnt < 5 && mpcmp(norme1, borne2) < 0) { if (!check(data,x)) { checkcnt++ ; continue; /* main */} borne1 = mpadd(norme1,eps); borne2 = mpmul(borne1,alpha); s = 0; checkcnt = 0; } } else if (mpcmp(norme1,normax1) > 0) normax1 = norme1; if (++s <= stockmax) { if (check) norms[s] = (long)norme1; S[s] = (long)dummycopy(x); if (s == stockmax) { pari_sp av2 = avma; GEN per; if (!check) goto END; per = sindexsort(norms); if (DEBUGLEVEL) fprintferr("sorting...\n"); for (j=0,i=1; i<=s; i++) { /* let N be the minimal norm so far for x satisfying 'check'. Keep * all elements of norm N */ long k = per[i]; norme1 = (GEN)norms[k]; if (j && mpcmp(norme1, borne1) > 0) break; if (j || check(data,(GEN)S[k])) { if (!j) borne1 = gclone( mpadd(norme1,eps) ); S[++j] = S[k]; } } s = j; if (!j) avma = av2; else { GEN t = borne1; checkcnt = 0; norme1 = mpsub(borne1,eps); for (i=1; i<=s; i++) norms[i] = (long)norme1; borne1 = gcopy(borne1); gunclone(t); borne2 = mpmul(borne1,alpha); } } } }END: if (s < stockmax) stockmax = s; if (check) { GEN per, alph, pols, p; if (DEBUGLEVEL) fprintferr("final sort & check...\n"); s = stockmax; setlg(norms,s+1); per = sindexsort(norms); alph = cgetg(s+1,t_VEC); pols = cgetg(s+1,t_VEC); for (j=0,i=1; i<=s; i++) { long k = per[i]; norme1 = (GEN)norms[k]; if (j && mpcmp(norme1, borne1) > 0) break; if ((p = check(data,(GEN)S[k]))) { if (!j) borne1 = gadd(norme1,eps); j++; pols[j]=(long)p; alph[j]=S[k]; } } u = cgetg(3,t_VEC); setlg(pols,j+1); u[1] = (long)pols; setlg(alph,j+1); u[2] = (long)alph; if (isclone(S)) { u[2] = (long)forcecopy(alph); gunclone(S); } return u; } u = cgetg(4,t_VEC); u[1] = lstoi(s<<1); u[2] = (long)normax1; if (stockmax) { setlg(S,stockmax+1); settyp(S,t_MAT); if (isclone(S)) { p1 = S; S = forcecopy(S); gunclone(p1); } } else S = cgetg(1,t_MAT); u[3] = (long)S; return u;} |
|
if (stockmax) { GEN T = S; for (i=s+1; i<=stockmax; i++) S[i]=(long)dummy; S = gclone(S); if (isclone(T)) gunclone(T); } | if (stockmax) S = clonefill(S, s, stockmax); | smallvectors(GEN q, GEN BORNE, long stockmax, FP_chk_fun *CHECK){ long N, n, i, j, k, s, epsbit, prec, checkcnt = 1; pari_sp av, av1, lim; GEN u,S,x,y,z,v,norme1,normax1,borne1,borne2,eps,p1,alpha,norms,dummy; GEN (*check)(void *,GEN) = CHECK? CHECK->f: NULL; void *data = CHECK? CHECK->data: NULL; int skipfirst = CHECK? CHECK->skipfirst: 0; if (DEBUGLEVEL) fprintferr("smallvectors looking for norm <= %Z\n",gprec_w(BORNE,3)); prec = gprecision(q); epsbit = bit_accuracy(prec) >> 1; eps = real2n(-epsbit, 3); alpha = dbltor(0.95); normax1 = gzero; borne1= gadd(BORNE,eps); borne2 = mpmul(borne1,alpha); N = lg(q); n = N-1; v = cgetg(N,t_VEC); dummy = cgetg(1,t_STR); av = avma; lim = stack_lim(av,2); if (check) norms = cgetg(stockmax+1,t_VEC); S = cgetg(stockmax+1,t_VEC); x = cgetg(N,t_COL); y = cgetg(N,t_COL); z = cgetg(N,t_COL); for (i=1; i<N; i++) { v[i] = coeff(q,i,i); x[i]=y[i]=z[i] = zero; } x[n] = lmpent(mpsqrt(gdiv(borne1,(GEN)v[n]))); if (DEBUGLEVEL>3) { fprintferr("\nx[%ld] = %Z\n",n,x[n]); flusherr(); } s = 0; k = n; for(;; x[k] = laddis((GEN)x[k],-1)) /* main */ { do { int fl = 0; if (k > 1) { av1=avma; k--; p1 = mpmul(gcoeff(q,k,k+1),(GEN)x[k+1]); for (j=k+2; j<N; j++) p1 = mpadd(p1, mpmul(gcoeff(q,k,j),(GEN)x[j])); z[k] = (long)gerepileuptoleaf(av1,p1); av1=avma; p1 = gsqr(mpadd((GEN)x[k+1],(GEN)z[k+1])); p1 = mpadd((GEN)y[k+1], mpmul(p1,(GEN)v[k+1])); y[k] = (long)gerepileuptoleaf(av1, p1); /* reject the [x_1,...,x_skipfirst,0,...,0] */ if (k <= skipfirst && !signe(y[skipfirst])) goto END; av1=avma; p1 = mpsub(borne1, (GEN)y[k]); if (signe(p1) < 0) { avma=av1; fl = 1; } else { p1 = mpadd(eps,mpsub(mpsqrt(gdiv(p1,(GEN)v[k])), (GEN)z[k])); x[k] = (long)gerepileuptoleaf(av1,mpent(p1)); } } for(;; x[k] = laddis((GEN)x[k],-1)) { if (!fl) { av1 = avma; /* p1 >= 0 */ p1 = mpmul((GEN)v[k], gsqr(mpadd((GEN)x[k],(GEN)z[k]))); i = mpcmp(mpsub(mpadd(p1,(GEN)y[k]), borne1), gmul2n(p1,-epsbit)); avma = av1; if (i <= 0) break; } k++; fl=0; } if (low_stack(lim, stack_lim(av,2))) { int cnt = 4; if(DEBUGMEM>1) err(warnmem,"smallvectors"); if (stockmax) { /* initialize to dummy values */ GEN T = S; for (i=s+1; i<=stockmax; i++) S[i]=(long)dummy; S = gclone(S); if (isclone(T)) gunclone(T); } if (check) { cnt += 3; for (i=s+1; i<=stockmax; i++) norms[i]=(long)dummy; } gerepileall(av,cnt,&x,&y,&z,&normax1,&borne1,&borne2,&norms); } if (DEBUGLEVEL>3) { if (DEBUGLEVEL>5) fprintferr("%ld ",k); if (k==n) fprintferr("\nx[%ld] = %Z\n",n,x[n]); flusherr(); } } while (k > 1); /* x = 0: we're done */ if (!signe(x[1]) && !signe(y[1])) goto END; av1=avma; p1 = gsqr(mpadd((GEN)x[1],(GEN)z[1])); norme1 = mpadd((GEN)y[1], mpmul(p1, (GEN)v[1])); if (mpcmp(norme1,borne1) > 0) { avma=av1; continue; /* main */ } norme1 = gerepileupto(av1,norme1); if (check) { if (checkcnt < 5 && mpcmp(norme1, borne2) < 0) { if (!check(data,x)) { checkcnt++ ; continue; /* main */} borne1 = mpadd(norme1,eps); borne2 = mpmul(borne1,alpha); s = 0; checkcnt = 0; } } else if (mpcmp(norme1,normax1) > 0) normax1 = norme1; if (++s <= stockmax) { if (check) norms[s] = (long)norme1; S[s] = (long)dummycopy(x); if (s == stockmax) { pari_sp av2 = avma; GEN per; if (!check) goto END; per = sindexsort(norms); if (DEBUGLEVEL) fprintferr("sorting...\n"); for (j=0,i=1; i<=s; i++) { /* let N be the minimal norm so far for x satisfying 'check'. Keep * all elements of norm N */ long k = per[i]; norme1 = (GEN)norms[k]; if (j && mpcmp(norme1, borne1) > 0) break; if (j || check(data,(GEN)S[k])) { if (!j) borne1 = gclone( mpadd(norme1,eps) ); S[++j] = S[k]; } } s = j; if (!j) avma = av2; else { GEN t = borne1; checkcnt = 0; norme1 = mpsub(borne1,eps); for (i=1; i<=s; i++) norms[i] = (long)norme1; borne1 = gcopy(borne1); gunclone(t); borne2 = mpmul(borne1,alpha); } } } }END: if (s < stockmax) stockmax = s; if (check) { GEN per, alph, pols, p; if (DEBUGLEVEL) fprintferr("final sort & check...\n"); s = stockmax; setlg(norms,s+1); per = sindexsort(norms); alph = cgetg(s+1,t_VEC); pols = cgetg(s+1,t_VEC); for (j=0,i=1; i<=s; i++) { long k = per[i]; norme1 = (GEN)norms[k]; if (j && mpcmp(norme1, borne1) > 0) break; if ((p = check(data,(GEN)S[k]))) { if (!j) borne1 = gadd(norme1,eps); j++; pols[j]=(long)p; alph[j]=S[k]; } } u = cgetg(3,t_VEC); setlg(pols,j+1); u[1] = (long)pols; setlg(alph,j+1); u[2] = (long)alph; if (isclone(S)) { u[2] = (long)forcecopy(alph); gunclone(S); } return u; } u = cgetg(4,t_VEC); u[1] = lstoi(s<<1); u[2] = (long)normax1; if (stockmax) { setlg(S,stockmax+1); settyp(S,t_MAT); if (isclone(S)) { p1 = S; S = forcecopy(S); gunclone(p1); } } else S = cgetg(1,t_MAT); u[3] = (long)S; return u;} |
{ pari_sp av2 = avma; GEN per; | { GEN per, Sold = S; pari_sp av2; | smallvectors(GEN q, GEN BORNE, long stockmax, FP_chk_fun *CHECK){ long N, n, i, j, k, s, epsbit, prec, checkcnt = 1; pari_sp av, av1, lim; GEN u,S,x,y,z,v,norme1,normax1,borne1,borne2,eps,p1,alpha,norms,dummy; GEN (*check)(void *,GEN) = CHECK? CHECK->f: NULL; void *data = CHECK? CHECK->data: NULL; int skipfirst = CHECK? CHECK->skipfirst: 0; if (DEBUGLEVEL) fprintferr("smallvectors looking for norm <= %Z\n",gprec_w(BORNE,3)); prec = gprecision(q); epsbit = bit_accuracy(prec) >> 1; eps = real2n(-epsbit, 3); alpha = dbltor(0.95); normax1 = gzero; borne1= gadd(BORNE,eps); borne2 = mpmul(borne1,alpha); N = lg(q); n = N-1; v = cgetg(N,t_VEC); dummy = cgetg(1,t_STR); av = avma; lim = stack_lim(av,2); if (check) norms = cgetg(stockmax+1,t_VEC); S = cgetg(stockmax+1,t_VEC); x = cgetg(N,t_COL); y = cgetg(N,t_COL); z = cgetg(N,t_COL); for (i=1; i<N; i++) { v[i] = coeff(q,i,i); x[i]=y[i]=z[i] = zero; } x[n] = lmpent(mpsqrt(gdiv(borne1,(GEN)v[n]))); if (DEBUGLEVEL>3) { fprintferr("\nx[%ld] = %Z\n",n,x[n]); flusherr(); } s = 0; k = n; for(;; x[k] = laddis((GEN)x[k],-1)) /* main */ { do { int fl = 0; if (k > 1) { av1=avma; k--; p1 = mpmul(gcoeff(q,k,k+1),(GEN)x[k+1]); for (j=k+2; j<N; j++) p1 = mpadd(p1, mpmul(gcoeff(q,k,j),(GEN)x[j])); z[k] = (long)gerepileuptoleaf(av1,p1); av1=avma; p1 = gsqr(mpadd((GEN)x[k+1],(GEN)z[k+1])); p1 = mpadd((GEN)y[k+1], mpmul(p1,(GEN)v[k+1])); y[k] = (long)gerepileuptoleaf(av1, p1); /* reject the [x_1,...,x_skipfirst,0,...,0] */ if (k <= skipfirst && !signe(y[skipfirst])) goto END; av1=avma; p1 = mpsub(borne1, (GEN)y[k]); if (signe(p1) < 0) { avma=av1; fl = 1; } else { p1 = mpadd(eps,mpsub(mpsqrt(gdiv(p1,(GEN)v[k])), (GEN)z[k])); x[k] = (long)gerepileuptoleaf(av1,mpent(p1)); } } for(;; x[k] = laddis((GEN)x[k],-1)) { if (!fl) { av1 = avma; /* p1 >= 0 */ p1 = mpmul((GEN)v[k], gsqr(mpadd((GEN)x[k],(GEN)z[k]))); i = mpcmp(mpsub(mpadd(p1,(GEN)y[k]), borne1), gmul2n(p1,-epsbit)); avma = av1; if (i <= 0) break; } k++; fl=0; } if (low_stack(lim, stack_lim(av,2))) { int cnt = 4; if(DEBUGMEM>1) err(warnmem,"smallvectors"); if (stockmax) { /* initialize to dummy values */ GEN T = S; for (i=s+1; i<=stockmax; i++) S[i]=(long)dummy; S = gclone(S); if (isclone(T)) gunclone(T); } if (check) { cnt += 3; for (i=s+1; i<=stockmax; i++) norms[i]=(long)dummy; } gerepileall(av,cnt,&x,&y,&z,&normax1,&borne1,&borne2,&norms); } if (DEBUGLEVEL>3) { if (DEBUGLEVEL>5) fprintferr("%ld ",k); if (k==n) fprintferr("\nx[%ld] = %Z\n",n,x[n]); flusherr(); } } while (k > 1); /* x = 0: we're done */ if (!signe(x[1]) && !signe(y[1])) goto END; av1=avma; p1 = gsqr(mpadd((GEN)x[1],(GEN)z[1])); norme1 = mpadd((GEN)y[1], mpmul(p1, (GEN)v[1])); if (mpcmp(norme1,borne1) > 0) { avma=av1; continue; /* main */ } norme1 = gerepileupto(av1,norme1); if (check) { if (checkcnt < 5 && mpcmp(norme1, borne2) < 0) { if (!check(data,x)) { checkcnt++ ; continue; /* main */} borne1 = mpadd(norme1,eps); borne2 = mpmul(borne1,alpha); s = 0; checkcnt = 0; } } else if (mpcmp(norme1,normax1) > 0) normax1 = norme1; if (++s <= stockmax) { if (check) norms[s] = (long)norme1; S[s] = (long)dummycopy(x); if (s == stockmax) { pari_sp av2 = avma; GEN per; if (!check) goto END; per = sindexsort(norms); if (DEBUGLEVEL) fprintferr("sorting...\n"); for (j=0,i=1; i<=s; i++) { /* let N be the minimal norm so far for x satisfying 'check'. Keep * all elements of norm N */ long k = per[i]; norme1 = (GEN)norms[k]; if (j && mpcmp(norme1, borne1) > 0) break; if (j || check(data,(GEN)S[k])) { if (!j) borne1 = gclone( mpadd(norme1,eps) ); S[++j] = S[k]; } } s = j; if (!j) avma = av2; else { GEN t = borne1; checkcnt = 0; norme1 = mpsub(borne1,eps); for (i=1; i<=s; i++) norms[i] = (long)norme1; borne1 = gcopy(borne1); gunclone(t); borne2 = mpmul(borne1,alpha); } } } }END: if (s < stockmax) stockmax = s; if (check) { GEN per, alph, pols, p; if (DEBUGLEVEL) fprintferr("final sort & check...\n"); s = stockmax; setlg(norms,s+1); per = sindexsort(norms); alph = cgetg(s+1,t_VEC); pols = cgetg(s+1,t_VEC); for (j=0,i=1; i<=s; i++) { long k = per[i]; norme1 = (GEN)norms[k]; if (j && mpcmp(norme1, borne1) > 0) break; if ((p = check(data,(GEN)S[k]))) { if (!j) borne1 = gadd(norme1,eps); j++; pols[j]=(long)p; alph[j]=S[k]; } } u = cgetg(3,t_VEC); setlg(pols,j+1); u[1] = (long)pols; setlg(alph,j+1); u[2] = (long)alph; if (isclone(S)) { u[2] = (long)forcecopy(alph); gunclone(S); } return u; } u = cgetg(4,t_VEC); u[1] = lstoi(s<<1); u[2] = (long)normax1; if (stockmax) { setlg(S,stockmax+1); settyp(S,t_MAT); if (isclone(S)) { p1 = S; S = forcecopy(S); gunclone(p1); } } else S = cgetg(1,t_MAT); u[3] = (long)S; return u;} |
if (j || check(data,(GEN)S[k])) | if (j || check(data,(GEN)Sold[k])) | smallvectors(GEN q, GEN BORNE, long stockmax, FP_chk_fun *CHECK){ long N, n, i, j, k, s, epsbit, prec, checkcnt = 1; pari_sp av, av1, lim; GEN u,S,x,y,z,v,norme1,normax1,borne1,borne2,eps,p1,alpha,norms,dummy; GEN (*check)(void *,GEN) = CHECK? CHECK->f: NULL; void *data = CHECK? CHECK->data: NULL; int skipfirst = CHECK? CHECK->skipfirst: 0; if (DEBUGLEVEL) fprintferr("smallvectors looking for norm <= %Z\n",gprec_w(BORNE,3)); prec = gprecision(q); epsbit = bit_accuracy(prec) >> 1; eps = real2n(-epsbit, 3); alpha = dbltor(0.95); normax1 = gzero; borne1= gadd(BORNE,eps); borne2 = mpmul(borne1,alpha); N = lg(q); n = N-1; v = cgetg(N,t_VEC); dummy = cgetg(1,t_STR); av = avma; lim = stack_lim(av,2); if (check) norms = cgetg(stockmax+1,t_VEC); S = cgetg(stockmax+1,t_VEC); x = cgetg(N,t_COL); y = cgetg(N,t_COL); z = cgetg(N,t_COL); for (i=1; i<N; i++) { v[i] = coeff(q,i,i); x[i]=y[i]=z[i] = zero; } x[n] = lmpent(mpsqrt(gdiv(borne1,(GEN)v[n]))); if (DEBUGLEVEL>3) { fprintferr("\nx[%ld] = %Z\n",n,x[n]); flusherr(); } s = 0; k = n; for(;; x[k] = laddis((GEN)x[k],-1)) /* main */ { do { int fl = 0; if (k > 1) { av1=avma; k--; p1 = mpmul(gcoeff(q,k,k+1),(GEN)x[k+1]); for (j=k+2; j<N; j++) p1 = mpadd(p1, mpmul(gcoeff(q,k,j),(GEN)x[j])); z[k] = (long)gerepileuptoleaf(av1,p1); av1=avma; p1 = gsqr(mpadd((GEN)x[k+1],(GEN)z[k+1])); p1 = mpadd((GEN)y[k+1], mpmul(p1,(GEN)v[k+1])); y[k] = (long)gerepileuptoleaf(av1, p1); /* reject the [x_1,...,x_skipfirst,0,...,0] */ if (k <= skipfirst && !signe(y[skipfirst])) goto END; av1=avma; p1 = mpsub(borne1, (GEN)y[k]); if (signe(p1) < 0) { avma=av1; fl = 1; } else { p1 = mpadd(eps,mpsub(mpsqrt(gdiv(p1,(GEN)v[k])), (GEN)z[k])); x[k] = (long)gerepileuptoleaf(av1,mpent(p1)); } } for(;; x[k] = laddis((GEN)x[k],-1)) { if (!fl) { av1 = avma; /* p1 >= 0 */ p1 = mpmul((GEN)v[k], gsqr(mpadd((GEN)x[k],(GEN)z[k]))); i = mpcmp(mpsub(mpadd(p1,(GEN)y[k]), borne1), gmul2n(p1,-epsbit)); avma = av1; if (i <= 0) break; } k++; fl=0; } if (low_stack(lim, stack_lim(av,2))) { int cnt = 4; if(DEBUGMEM>1) err(warnmem,"smallvectors"); if (stockmax) { /* initialize to dummy values */ GEN T = S; for (i=s+1; i<=stockmax; i++) S[i]=(long)dummy; S = gclone(S); if (isclone(T)) gunclone(T); } if (check) { cnt += 3; for (i=s+1; i<=stockmax; i++) norms[i]=(long)dummy; } gerepileall(av,cnt,&x,&y,&z,&normax1,&borne1,&borne2,&norms); } if (DEBUGLEVEL>3) { if (DEBUGLEVEL>5) fprintferr("%ld ",k); if (k==n) fprintferr("\nx[%ld] = %Z\n",n,x[n]); flusherr(); } } while (k > 1); /* x = 0: we're done */ if (!signe(x[1]) && !signe(y[1])) goto END; av1=avma; p1 = gsqr(mpadd((GEN)x[1],(GEN)z[1])); norme1 = mpadd((GEN)y[1], mpmul(p1, (GEN)v[1])); if (mpcmp(norme1,borne1) > 0) { avma=av1; continue; /* main */ } norme1 = gerepileupto(av1,norme1); if (check) { if (checkcnt < 5 && mpcmp(norme1, borne2) < 0) { if (!check(data,x)) { checkcnt++ ; continue; /* main */} borne1 = mpadd(norme1,eps); borne2 = mpmul(borne1,alpha); s = 0; checkcnt = 0; } } else if (mpcmp(norme1,normax1) > 0) normax1 = norme1; if (++s <= stockmax) { if (check) norms[s] = (long)norme1; S[s] = (long)dummycopy(x); if (s == stockmax) { pari_sp av2 = avma; GEN per; if (!check) goto END; per = sindexsort(norms); if (DEBUGLEVEL) fprintferr("sorting...\n"); for (j=0,i=1; i<=s; i++) { /* let N be the minimal norm so far for x satisfying 'check'. Keep * all elements of norm N */ long k = per[i]; norme1 = (GEN)norms[k]; if (j && mpcmp(norme1, borne1) > 0) break; if (j || check(data,(GEN)S[k])) { if (!j) borne1 = gclone( mpadd(norme1,eps) ); S[++j] = S[k]; } } s = j; if (!j) avma = av2; else { GEN t = borne1; checkcnt = 0; norme1 = mpsub(borne1,eps); for (i=1; i<=s; i++) norms[i] = (long)norme1; borne1 = gcopy(borne1); gunclone(t); borne2 = mpmul(borne1,alpha); } } } }END: if (s < stockmax) stockmax = s; if (check) { GEN per, alph, pols, p; if (DEBUGLEVEL) fprintferr("final sort & check...\n"); s = stockmax; setlg(norms,s+1); per = sindexsort(norms); alph = cgetg(s+1,t_VEC); pols = cgetg(s+1,t_VEC); for (j=0,i=1; i<=s; i++) { long k = per[i]; norme1 = (GEN)norms[k]; if (j && mpcmp(norme1, borne1) > 0) break; if ((p = check(data,(GEN)S[k]))) { if (!j) borne1 = gadd(norme1,eps); j++; pols[j]=(long)p; alph[j]=S[k]; } } u = cgetg(3,t_VEC); setlg(pols,j+1); u[1] = (long)pols; setlg(alph,j+1); u[2] = (long)alph; if (isclone(S)) { u[2] = (long)forcecopy(alph); gunclone(S); } return u; } u = cgetg(4,t_VEC); u[1] = lstoi(s<<1); u[2] = (long)normax1; if (stockmax) { setlg(S,stockmax+1); settyp(S,t_MAT); if (isclone(S)) { p1 = S; S = forcecopy(S); gunclone(p1); } } else S = cgetg(1,t_MAT); u[3] = (long)S; return u;} |
if (!j) borne1 = gclone( mpadd(norme1,eps) ); S[++j] = S[k]; | if (!j) borne1 = mpadd(norme1,eps); S[++j] = Sold[k]; | smallvectors(GEN q, GEN BORNE, long stockmax, FP_chk_fun *CHECK){ long N, n, i, j, k, s, epsbit, prec, checkcnt = 1; pari_sp av, av1, lim; GEN u,S,x,y,z,v,norme1,normax1,borne1,borne2,eps,p1,alpha,norms,dummy; GEN (*check)(void *,GEN) = CHECK? CHECK->f: NULL; void *data = CHECK? CHECK->data: NULL; int skipfirst = CHECK? CHECK->skipfirst: 0; if (DEBUGLEVEL) fprintferr("smallvectors looking for norm <= %Z\n",gprec_w(BORNE,3)); prec = gprecision(q); epsbit = bit_accuracy(prec) >> 1; eps = real2n(-epsbit, 3); alpha = dbltor(0.95); normax1 = gzero; borne1= gadd(BORNE,eps); borne2 = mpmul(borne1,alpha); N = lg(q); n = N-1; v = cgetg(N,t_VEC); dummy = cgetg(1,t_STR); av = avma; lim = stack_lim(av,2); if (check) norms = cgetg(stockmax+1,t_VEC); S = cgetg(stockmax+1,t_VEC); x = cgetg(N,t_COL); y = cgetg(N,t_COL); z = cgetg(N,t_COL); for (i=1; i<N; i++) { v[i] = coeff(q,i,i); x[i]=y[i]=z[i] = zero; } x[n] = lmpent(mpsqrt(gdiv(borne1,(GEN)v[n]))); if (DEBUGLEVEL>3) { fprintferr("\nx[%ld] = %Z\n",n,x[n]); flusherr(); } s = 0; k = n; for(;; x[k] = laddis((GEN)x[k],-1)) /* main */ { do { int fl = 0; if (k > 1) { av1=avma; k--; p1 = mpmul(gcoeff(q,k,k+1),(GEN)x[k+1]); for (j=k+2; j<N; j++) p1 = mpadd(p1, mpmul(gcoeff(q,k,j),(GEN)x[j])); z[k] = (long)gerepileuptoleaf(av1,p1); av1=avma; p1 = gsqr(mpadd((GEN)x[k+1],(GEN)z[k+1])); p1 = mpadd((GEN)y[k+1], mpmul(p1,(GEN)v[k+1])); y[k] = (long)gerepileuptoleaf(av1, p1); /* reject the [x_1,...,x_skipfirst,0,...,0] */ if (k <= skipfirst && !signe(y[skipfirst])) goto END; av1=avma; p1 = mpsub(borne1, (GEN)y[k]); if (signe(p1) < 0) { avma=av1; fl = 1; } else { p1 = mpadd(eps,mpsub(mpsqrt(gdiv(p1,(GEN)v[k])), (GEN)z[k])); x[k] = (long)gerepileuptoleaf(av1,mpent(p1)); } } for(;; x[k] = laddis((GEN)x[k],-1)) { if (!fl) { av1 = avma; /* p1 >= 0 */ p1 = mpmul((GEN)v[k], gsqr(mpadd((GEN)x[k],(GEN)z[k]))); i = mpcmp(mpsub(mpadd(p1,(GEN)y[k]), borne1), gmul2n(p1,-epsbit)); avma = av1; if (i <= 0) break; } k++; fl=0; } if (low_stack(lim, stack_lim(av,2))) { int cnt = 4; if(DEBUGMEM>1) err(warnmem,"smallvectors"); if (stockmax) { /* initialize to dummy values */ GEN T = S; for (i=s+1; i<=stockmax; i++) S[i]=(long)dummy; S = gclone(S); if (isclone(T)) gunclone(T); } if (check) { cnt += 3; for (i=s+1; i<=stockmax; i++) norms[i]=(long)dummy; } gerepileall(av,cnt,&x,&y,&z,&normax1,&borne1,&borne2,&norms); } if (DEBUGLEVEL>3) { if (DEBUGLEVEL>5) fprintferr("%ld ",k); if (k==n) fprintferr("\nx[%ld] = %Z\n",n,x[n]); flusherr(); } } while (k > 1); /* x = 0: we're done */ if (!signe(x[1]) && !signe(y[1])) goto END; av1=avma; p1 = gsqr(mpadd((GEN)x[1],(GEN)z[1])); norme1 = mpadd((GEN)y[1], mpmul(p1, (GEN)v[1])); if (mpcmp(norme1,borne1) > 0) { avma=av1; continue; /* main */ } norme1 = gerepileupto(av1,norme1); if (check) { if (checkcnt < 5 && mpcmp(norme1, borne2) < 0) { if (!check(data,x)) { checkcnt++ ; continue; /* main */} borne1 = mpadd(norme1,eps); borne2 = mpmul(borne1,alpha); s = 0; checkcnt = 0; } } else if (mpcmp(norme1,normax1) > 0) normax1 = norme1; if (++s <= stockmax) { if (check) norms[s] = (long)norme1; S[s] = (long)dummycopy(x); if (s == stockmax) { pari_sp av2 = avma; GEN per; if (!check) goto END; per = sindexsort(norms); if (DEBUGLEVEL) fprintferr("sorting...\n"); for (j=0,i=1; i<=s; i++) { /* let N be the minimal norm so far for x satisfying 'check'. Keep * all elements of norm N */ long k = per[i]; norme1 = (GEN)norms[k]; if (j && mpcmp(norme1, borne1) > 0) break; if (j || check(data,(GEN)S[k])) { if (!j) borne1 = gclone( mpadd(norme1,eps) ); S[++j] = S[k]; } } s = j; if (!j) avma = av2; else { GEN t = borne1; checkcnt = 0; norme1 = mpsub(borne1,eps); for (i=1; i<=s; i++) norms[i] = (long)norme1; borne1 = gcopy(borne1); gunclone(t); borne2 = mpmul(borne1,alpha); } } } }END: if (s < stockmax) stockmax = s; if (check) { GEN per, alph, pols, p; if (DEBUGLEVEL) fprintferr("final sort & check...\n"); s = stockmax; setlg(norms,s+1); per = sindexsort(norms); alph = cgetg(s+1,t_VEC); pols = cgetg(s+1,t_VEC); for (j=0,i=1; i<=s; i++) { long k = per[i]; norme1 = (GEN)norms[k]; if (j && mpcmp(norme1, borne1) > 0) break; if ((p = check(data,(GEN)S[k]))) { if (!j) borne1 = gadd(norme1,eps); j++; pols[j]=(long)p; alph[j]=S[k]; } } u = cgetg(3,t_VEC); setlg(pols,j+1); u[1] = (long)pols; setlg(alph,j+1); u[2] = (long)alph; if (isclone(S)) { u[2] = (long)forcecopy(alph); gunclone(S); } return u; } u = cgetg(4,t_VEC); u[1] = lstoi(s<<1); u[2] = (long)normax1; if (stockmax) { setlg(S,stockmax+1); settyp(S,t_MAT); if (isclone(S)) { p1 = S; S = forcecopy(S); gunclone(p1); } } else S = cgetg(1,t_MAT); u[3] = (long)S; return u;} |
s = j; if (!j) avma = av2; else | s = j; avma = av2; if (s) | smallvectors(GEN q, GEN BORNE, long stockmax, FP_chk_fun *CHECK){ long N, n, i, j, k, s, epsbit, prec, checkcnt = 1; pari_sp av, av1, lim; GEN u,S,x,y,z,v,norme1,normax1,borne1,borne2,eps,p1,alpha,norms,dummy; GEN (*check)(void *,GEN) = CHECK? CHECK->f: NULL; void *data = CHECK? CHECK->data: NULL; int skipfirst = CHECK? CHECK->skipfirst: 0; if (DEBUGLEVEL) fprintferr("smallvectors looking for norm <= %Z\n",gprec_w(BORNE,3)); prec = gprecision(q); epsbit = bit_accuracy(prec) >> 1; eps = real2n(-epsbit, 3); alpha = dbltor(0.95); normax1 = gzero; borne1= gadd(BORNE,eps); borne2 = mpmul(borne1,alpha); N = lg(q); n = N-1; v = cgetg(N,t_VEC); dummy = cgetg(1,t_STR); av = avma; lim = stack_lim(av,2); if (check) norms = cgetg(stockmax+1,t_VEC); S = cgetg(stockmax+1,t_VEC); x = cgetg(N,t_COL); y = cgetg(N,t_COL); z = cgetg(N,t_COL); for (i=1; i<N; i++) { v[i] = coeff(q,i,i); x[i]=y[i]=z[i] = zero; } x[n] = lmpent(mpsqrt(gdiv(borne1,(GEN)v[n]))); if (DEBUGLEVEL>3) { fprintferr("\nx[%ld] = %Z\n",n,x[n]); flusherr(); } s = 0; k = n; for(;; x[k] = laddis((GEN)x[k],-1)) /* main */ { do { int fl = 0; if (k > 1) { av1=avma; k--; p1 = mpmul(gcoeff(q,k,k+1),(GEN)x[k+1]); for (j=k+2; j<N; j++) p1 = mpadd(p1, mpmul(gcoeff(q,k,j),(GEN)x[j])); z[k] = (long)gerepileuptoleaf(av1,p1); av1=avma; p1 = gsqr(mpadd((GEN)x[k+1],(GEN)z[k+1])); p1 = mpadd((GEN)y[k+1], mpmul(p1,(GEN)v[k+1])); y[k] = (long)gerepileuptoleaf(av1, p1); /* reject the [x_1,...,x_skipfirst,0,...,0] */ if (k <= skipfirst && !signe(y[skipfirst])) goto END; av1=avma; p1 = mpsub(borne1, (GEN)y[k]); if (signe(p1) < 0) { avma=av1; fl = 1; } else { p1 = mpadd(eps,mpsub(mpsqrt(gdiv(p1,(GEN)v[k])), (GEN)z[k])); x[k] = (long)gerepileuptoleaf(av1,mpent(p1)); } } for(;; x[k] = laddis((GEN)x[k],-1)) { if (!fl) { av1 = avma; /* p1 >= 0 */ p1 = mpmul((GEN)v[k], gsqr(mpadd((GEN)x[k],(GEN)z[k]))); i = mpcmp(mpsub(mpadd(p1,(GEN)y[k]), borne1), gmul2n(p1,-epsbit)); avma = av1; if (i <= 0) break; } k++; fl=0; } if (low_stack(lim, stack_lim(av,2))) { int cnt = 4; if(DEBUGMEM>1) err(warnmem,"smallvectors"); if (stockmax) { /* initialize to dummy values */ GEN T = S; for (i=s+1; i<=stockmax; i++) S[i]=(long)dummy; S = gclone(S); if (isclone(T)) gunclone(T); } if (check) { cnt += 3; for (i=s+1; i<=stockmax; i++) norms[i]=(long)dummy; } gerepileall(av,cnt,&x,&y,&z,&normax1,&borne1,&borne2,&norms); } if (DEBUGLEVEL>3) { if (DEBUGLEVEL>5) fprintferr("%ld ",k); if (k==n) fprintferr("\nx[%ld] = %Z\n",n,x[n]); flusherr(); } } while (k > 1); /* x = 0: we're done */ if (!signe(x[1]) && !signe(y[1])) goto END; av1=avma; p1 = gsqr(mpadd((GEN)x[1],(GEN)z[1])); norme1 = mpadd((GEN)y[1], mpmul(p1, (GEN)v[1])); if (mpcmp(norme1,borne1) > 0) { avma=av1; continue; /* main */ } norme1 = gerepileupto(av1,norme1); if (check) { if (checkcnt < 5 && mpcmp(norme1, borne2) < 0) { if (!check(data,x)) { checkcnt++ ; continue; /* main */} borne1 = mpadd(norme1,eps); borne2 = mpmul(borne1,alpha); s = 0; checkcnt = 0; } } else if (mpcmp(norme1,normax1) > 0) normax1 = norme1; if (++s <= stockmax) { if (check) norms[s] = (long)norme1; S[s] = (long)dummycopy(x); if (s == stockmax) { pari_sp av2 = avma; GEN per; if (!check) goto END; per = sindexsort(norms); if (DEBUGLEVEL) fprintferr("sorting...\n"); for (j=0,i=1; i<=s; i++) { /* let N be the minimal norm so far for x satisfying 'check'. Keep * all elements of norm N */ long k = per[i]; norme1 = (GEN)norms[k]; if (j && mpcmp(norme1, borne1) > 0) break; if (j || check(data,(GEN)S[k])) { if (!j) borne1 = gclone( mpadd(norme1,eps) ); S[++j] = S[k]; } } s = j; if (!j) avma = av2; else { GEN t = borne1; checkcnt = 0; norme1 = mpsub(borne1,eps); for (i=1; i<=s; i++) norms[i] = (long)norme1; borne1 = gcopy(borne1); gunclone(t); borne2 = mpmul(borne1,alpha); } } } }END: if (s < stockmax) stockmax = s; if (check) { GEN per, alph, pols, p; if (DEBUGLEVEL) fprintferr("final sort & check...\n"); s = stockmax; setlg(norms,s+1); per = sindexsort(norms); alph = cgetg(s+1,t_VEC); pols = cgetg(s+1,t_VEC); for (j=0,i=1; i<=s; i++) { long k = per[i]; norme1 = (GEN)norms[k]; if (j && mpcmp(norme1, borne1) > 0) break; if ((p = check(data,(GEN)S[k]))) { if (!j) borne1 = gadd(norme1,eps); j++; pols[j]=(long)p; alph[j]=S[k]; } } u = cgetg(3,t_VEC); setlg(pols,j+1); u[1] = (long)pols; setlg(alph,j+1); u[2] = (long)alph; if (isclone(S)) { u[2] = (long)forcecopy(alph); gunclone(S); } return u; } u = cgetg(4,t_VEC); u[1] = lstoi(s<<1); u[2] = (long)normax1; if (stockmax) { setlg(S,stockmax+1); settyp(S,t_MAT); if (isclone(S)) { p1 = S; S = forcecopy(S); gunclone(p1); } } else S = cgetg(1,t_MAT); u[3] = (long)S; return u;} |
GEN t = borne1; checkcnt = 0; norme1 = mpsub(borne1,eps); | if (isclone(Sold)) { S = clonefill(S, s, stockmax); gunclone(Sold); } norme1 = (GEN)norms[ per[i-1] ]; norms = cgetg(stockmax+1, t_VEC); | smallvectors(GEN q, GEN BORNE, long stockmax, FP_chk_fun *CHECK){ long N, n, i, j, k, s, epsbit, prec, checkcnt = 1; pari_sp av, av1, lim; GEN u,S,x,y,z,v,norme1,normax1,borne1,borne2,eps,p1,alpha,norms,dummy; GEN (*check)(void *,GEN) = CHECK? CHECK->f: NULL; void *data = CHECK? CHECK->data: NULL; int skipfirst = CHECK? CHECK->skipfirst: 0; if (DEBUGLEVEL) fprintferr("smallvectors looking for norm <= %Z\n",gprec_w(BORNE,3)); prec = gprecision(q); epsbit = bit_accuracy(prec) >> 1; eps = real2n(-epsbit, 3); alpha = dbltor(0.95); normax1 = gzero; borne1= gadd(BORNE,eps); borne2 = mpmul(borne1,alpha); N = lg(q); n = N-1; v = cgetg(N,t_VEC); dummy = cgetg(1,t_STR); av = avma; lim = stack_lim(av,2); if (check) norms = cgetg(stockmax+1,t_VEC); S = cgetg(stockmax+1,t_VEC); x = cgetg(N,t_COL); y = cgetg(N,t_COL); z = cgetg(N,t_COL); for (i=1; i<N; i++) { v[i] = coeff(q,i,i); x[i]=y[i]=z[i] = zero; } x[n] = lmpent(mpsqrt(gdiv(borne1,(GEN)v[n]))); if (DEBUGLEVEL>3) { fprintferr("\nx[%ld] = %Z\n",n,x[n]); flusherr(); } s = 0; k = n; for(;; x[k] = laddis((GEN)x[k],-1)) /* main */ { do { int fl = 0; if (k > 1) { av1=avma; k--; p1 = mpmul(gcoeff(q,k,k+1),(GEN)x[k+1]); for (j=k+2; j<N; j++) p1 = mpadd(p1, mpmul(gcoeff(q,k,j),(GEN)x[j])); z[k] = (long)gerepileuptoleaf(av1,p1); av1=avma; p1 = gsqr(mpadd((GEN)x[k+1],(GEN)z[k+1])); p1 = mpadd((GEN)y[k+1], mpmul(p1,(GEN)v[k+1])); y[k] = (long)gerepileuptoleaf(av1, p1); /* reject the [x_1,...,x_skipfirst,0,...,0] */ if (k <= skipfirst && !signe(y[skipfirst])) goto END; av1=avma; p1 = mpsub(borne1, (GEN)y[k]); if (signe(p1) < 0) { avma=av1; fl = 1; } else { p1 = mpadd(eps,mpsub(mpsqrt(gdiv(p1,(GEN)v[k])), (GEN)z[k])); x[k] = (long)gerepileuptoleaf(av1,mpent(p1)); } } for(;; x[k] = laddis((GEN)x[k],-1)) { if (!fl) { av1 = avma; /* p1 >= 0 */ p1 = mpmul((GEN)v[k], gsqr(mpadd((GEN)x[k],(GEN)z[k]))); i = mpcmp(mpsub(mpadd(p1,(GEN)y[k]), borne1), gmul2n(p1,-epsbit)); avma = av1; if (i <= 0) break; } k++; fl=0; } if (low_stack(lim, stack_lim(av,2))) { int cnt = 4; if(DEBUGMEM>1) err(warnmem,"smallvectors"); if (stockmax) { /* initialize to dummy values */ GEN T = S; for (i=s+1; i<=stockmax; i++) S[i]=(long)dummy; S = gclone(S); if (isclone(T)) gunclone(T); } if (check) { cnt += 3; for (i=s+1; i<=stockmax; i++) norms[i]=(long)dummy; } gerepileall(av,cnt,&x,&y,&z,&normax1,&borne1,&borne2,&norms); } if (DEBUGLEVEL>3) { if (DEBUGLEVEL>5) fprintferr("%ld ",k); if (k==n) fprintferr("\nx[%ld] = %Z\n",n,x[n]); flusherr(); } } while (k > 1); /* x = 0: we're done */ if (!signe(x[1]) && !signe(y[1])) goto END; av1=avma; p1 = gsqr(mpadd((GEN)x[1],(GEN)z[1])); norme1 = mpadd((GEN)y[1], mpmul(p1, (GEN)v[1])); if (mpcmp(norme1,borne1) > 0) { avma=av1; continue; /* main */ } norme1 = gerepileupto(av1,norme1); if (check) { if (checkcnt < 5 && mpcmp(norme1, borne2) < 0) { if (!check(data,x)) { checkcnt++ ; continue; /* main */} borne1 = mpadd(norme1,eps); borne2 = mpmul(borne1,alpha); s = 0; checkcnt = 0; } } else if (mpcmp(norme1,normax1) > 0) normax1 = norme1; if (++s <= stockmax) { if (check) norms[s] = (long)norme1; S[s] = (long)dummycopy(x); if (s == stockmax) { pari_sp av2 = avma; GEN per; if (!check) goto END; per = sindexsort(norms); if (DEBUGLEVEL) fprintferr("sorting...\n"); for (j=0,i=1; i<=s; i++) { /* let N be the minimal norm so far for x satisfying 'check'. Keep * all elements of norm N */ long k = per[i]; norme1 = (GEN)norms[k]; if (j && mpcmp(norme1, borne1) > 0) break; if (j || check(data,(GEN)S[k])) { if (!j) borne1 = gclone( mpadd(norme1,eps) ); S[++j] = S[k]; } } s = j; if (!j) avma = av2; else { GEN t = borne1; checkcnt = 0; norme1 = mpsub(borne1,eps); for (i=1; i<=s; i++) norms[i] = (long)norme1; borne1 = gcopy(borne1); gunclone(t); borne2 = mpmul(borne1,alpha); } } } }END: if (s < stockmax) stockmax = s; if (check) { GEN per, alph, pols, p; if (DEBUGLEVEL) fprintferr("final sort & check...\n"); s = stockmax; setlg(norms,s+1); per = sindexsort(norms); alph = cgetg(s+1,t_VEC); pols = cgetg(s+1,t_VEC); for (j=0,i=1; i<=s; i++) { long k = per[i]; norme1 = (GEN)norms[k]; if (j && mpcmp(norme1, borne1) > 0) break; if ((p = check(data,(GEN)S[k]))) { if (!j) borne1 = gadd(norme1,eps); j++; pols[j]=(long)p; alph[j]=S[k]; } } u = cgetg(3,t_VEC); setlg(pols,j+1); u[1] = (long)pols; setlg(alph,j+1); u[2] = (long)alph; if (isclone(S)) { u[2] = (long)forcecopy(alph); gunclone(S); } return u; } u = cgetg(4,t_VEC); u[1] = lstoi(s<<1); u[2] = (long)normax1; if (stockmax) { setlg(S,stockmax+1); settyp(S,t_MAT); if (isclone(S)) { p1 = S; S = forcecopy(S); gunclone(p1); } } else S = cgetg(1,t_MAT); u[3] = (long)S; return u;} |
borne1 = gcopy(borne1); gunclone(t); borne2 = mpmul(borne1,alpha); | borne1 = mpadd(norme1, eps); borne2 = mpmul(borne1, alpha); checkcnt = 0; | smallvectors(GEN q, GEN BORNE, long stockmax, FP_chk_fun *CHECK){ long N, n, i, j, k, s, epsbit, prec, checkcnt = 1; pari_sp av, av1, lim; GEN u,S,x,y,z,v,norme1,normax1,borne1,borne2,eps,p1,alpha,norms,dummy; GEN (*check)(void *,GEN) = CHECK? CHECK->f: NULL; void *data = CHECK? CHECK->data: NULL; int skipfirst = CHECK? CHECK->skipfirst: 0; if (DEBUGLEVEL) fprintferr("smallvectors looking for norm <= %Z\n",gprec_w(BORNE,3)); prec = gprecision(q); epsbit = bit_accuracy(prec) >> 1; eps = real2n(-epsbit, 3); alpha = dbltor(0.95); normax1 = gzero; borne1= gadd(BORNE,eps); borne2 = mpmul(borne1,alpha); N = lg(q); n = N-1; v = cgetg(N,t_VEC); dummy = cgetg(1,t_STR); av = avma; lim = stack_lim(av,2); if (check) norms = cgetg(stockmax+1,t_VEC); S = cgetg(stockmax+1,t_VEC); x = cgetg(N,t_COL); y = cgetg(N,t_COL); z = cgetg(N,t_COL); for (i=1; i<N; i++) { v[i] = coeff(q,i,i); x[i]=y[i]=z[i] = zero; } x[n] = lmpent(mpsqrt(gdiv(borne1,(GEN)v[n]))); if (DEBUGLEVEL>3) { fprintferr("\nx[%ld] = %Z\n",n,x[n]); flusherr(); } s = 0; k = n; for(;; x[k] = laddis((GEN)x[k],-1)) /* main */ { do { int fl = 0; if (k > 1) { av1=avma; k--; p1 = mpmul(gcoeff(q,k,k+1),(GEN)x[k+1]); for (j=k+2; j<N; j++) p1 = mpadd(p1, mpmul(gcoeff(q,k,j),(GEN)x[j])); z[k] = (long)gerepileuptoleaf(av1,p1); av1=avma; p1 = gsqr(mpadd((GEN)x[k+1],(GEN)z[k+1])); p1 = mpadd((GEN)y[k+1], mpmul(p1,(GEN)v[k+1])); y[k] = (long)gerepileuptoleaf(av1, p1); /* reject the [x_1,...,x_skipfirst,0,...,0] */ if (k <= skipfirst && !signe(y[skipfirst])) goto END; av1=avma; p1 = mpsub(borne1, (GEN)y[k]); if (signe(p1) < 0) { avma=av1; fl = 1; } else { p1 = mpadd(eps,mpsub(mpsqrt(gdiv(p1,(GEN)v[k])), (GEN)z[k])); x[k] = (long)gerepileuptoleaf(av1,mpent(p1)); } } for(;; x[k] = laddis((GEN)x[k],-1)) { if (!fl) { av1 = avma; /* p1 >= 0 */ p1 = mpmul((GEN)v[k], gsqr(mpadd((GEN)x[k],(GEN)z[k]))); i = mpcmp(mpsub(mpadd(p1,(GEN)y[k]), borne1), gmul2n(p1,-epsbit)); avma = av1; if (i <= 0) break; } k++; fl=0; } if (low_stack(lim, stack_lim(av,2))) { int cnt = 4; if(DEBUGMEM>1) err(warnmem,"smallvectors"); if (stockmax) { /* initialize to dummy values */ GEN T = S; for (i=s+1; i<=stockmax; i++) S[i]=(long)dummy; S = gclone(S); if (isclone(T)) gunclone(T); } if (check) { cnt += 3; for (i=s+1; i<=stockmax; i++) norms[i]=(long)dummy; } gerepileall(av,cnt,&x,&y,&z,&normax1,&borne1,&borne2,&norms); } if (DEBUGLEVEL>3) { if (DEBUGLEVEL>5) fprintferr("%ld ",k); if (k==n) fprintferr("\nx[%ld] = %Z\n",n,x[n]); flusherr(); } } while (k > 1); /* x = 0: we're done */ if (!signe(x[1]) && !signe(y[1])) goto END; av1=avma; p1 = gsqr(mpadd((GEN)x[1],(GEN)z[1])); norme1 = mpadd((GEN)y[1], mpmul(p1, (GEN)v[1])); if (mpcmp(norme1,borne1) > 0) { avma=av1; continue; /* main */ } norme1 = gerepileupto(av1,norme1); if (check) { if (checkcnt < 5 && mpcmp(norme1, borne2) < 0) { if (!check(data,x)) { checkcnt++ ; continue; /* main */} borne1 = mpadd(norme1,eps); borne2 = mpmul(borne1,alpha); s = 0; checkcnt = 0; } } else if (mpcmp(norme1,normax1) > 0) normax1 = norme1; if (++s <= stockmax) { if (check) norms[s] = (long)norme1; S[s] = (long)dummycopy(x); if (s == stockmax) { pari_sp av2 = avma; GEN per; if (!check) goto END; per = sindexsort(norms); if (DEBUGLEVEL) fprintferr("sorting...\n"); for (j=0,i=1; i<=s; i++) { /* let N be the minimal norm so far for x satisfying 'check'. Keep * all elements of norm N */ long k = per[i]; norme1 = (GEN)norms[k]; if (j && mpcmp(norme1, borne1) > 0) break; if (j || check(data,(GEN)S[k])) { if (!j) borne1 = gclone( mpadd(norme1,eps) ); S[++j] = S[k]; } } s = j; if (!j) avma = av2; else { GEN t = borne1; checkcnt = 0; norme1 = mpsub(borne1,eps); for (i=1; i<=s; i++) norms[i] = (long)norme1; borne1 = gcopy(borne1); gunclone(t); borne2 = mpmul(borne1,alpha); } } } }END: if (s < stockmax) stockmax = s; if (check) { GEN per, alph, pols, p; if (DEBUGLEVEL) fprintferr("final sort & check...\n"); s = stockmax; setlg(norms,s+1); per = sindexsort(norms); alph = cgetg(s+1,t_VEC); pols = cgetg(s+1,t_VEC); for (j=0,i=1; i<=s; i++) { long k = per[i]; norme1 = (GEN)norms[k]; if (j && mpcmp(norme1, borne1) > 0) break; if ((p = check(data,(GEN)S[k]))) { if (!j) borne1 = gadd(norme1,eps); j++; pols[j]=(long)p; alph[j]=S[k]; } } u = cgetg(3,t_VEC); setlg(pols,j+1); u[1] = (long)pols; setlg(alph,j+1); u[2] = (long)alph; if (isclone(S)) { u[2] = (long)forcecopy(alph); gunclone(S); } return u; } u = cgetg(4,t_VEC); u[1] = lstoi(s<<1); u[2] = (long)normax1; if (stockmax) { setlg(S,stockmax+1); settyp(S,t_MAT); if (isclone(S)) { p1 = S; S = forcecopy(S); gunclone(p1); } } else S = cgetg(1,t_MAT); u[3] = (long)S; return u;} |
m360.brgc1 = smc1BRGC (9600); | m360.brgc1 = smc1BRGC (console_baud_rate); | smc1Initialize (int major, int minor, void *arg){ /* * Allocate buffer descriptors */ smcRxBd = M360AllocateBufferDescriptors (1); smcTxBd = M360AllocateBufferDescriptors (1); /* * Configure port B pins to enable SMTXD1 and SMRXD1 pins */ m360.pbpar |= 0xC0; m360.pbdir &= ~0xC0; m360.pbodr &= ~0xC0; /* * Set up BRG1 (9,600 baud) */ m360.brgc1 = M360_BRG_RST; m360.brgc1 = smc1BRGC (9600); /* * Put SMC1 in NMSI mode, connect SMC1 to BRG1 */ m360.simode |= M360_SI_SMC1_BRG1; /* * Set up SMC1 parameter RAM common to all protocols */ m360.smc1p.rbase = (char *)smcRxBd - (char *)&m360; m360.smc1p.tbase = (char *)smcTxBd - (char *)&m360; m360.smc1p.rfcr = M360_RFCR_MOT | M360_RFCR_DMA_SPACE; m360.smc1p.tfcr = M360_TFCR_MOT | M360_TFCR_DMA_SPACE; if (m360_smc1_interrupt) m360.smc1p.mrblr = RXBUFSIZE; else m360.smc1p.mrblr = 1; /* * Set up SMC1 parameter RAM UART-specific parameters */ m360.smc1p.un.uart.max_idl = 10; m360.smc1p.un.uart.brklen = 0; m360.smc1p.un.uart.brkec = 0; m360.smc1p.un.uart.brkcr = 0; /* * Set up the Receive Buffer Descriptor */ smcRxBd->status = M360_BD_EMPTY | M360_BD_WRAP | M360_BD_INTERRUPT; smcRxBd->length = 0; smcRxBd->buffer = rxBuf; /* * Setup the Transmit Buffer Descriptor */ smcTxBd->status = M360_BD_WRAP; /* * Set up SMC1 general and protocol-specific mode registers */ m360.smc1.smce = ~0; /* Clear any pending events */ m360.smc1.smcm = 0; /* Mask all interrupt/event sources */ m360.smc1.smcmr = M360_SMCMR_CLEN(9) | M360_SMCMR_SM_UART; /* * Send "Init parameters" command */ M360ExecuteRISC (M360_CR_OP_INIT_RX_TX | M360_CR_CHAN_SMC1); /* * Enable receiver and transmitter */ m360.smc1.smcmr |= M360_SMCMR_TEN | M360_SMCMR_REN; if (m360_smc1_interrupt) { rtems_isr_entry old_handler; rtems_status_code sc; sc = rtems_interrupt_catch (smc1InterruptHandler, (m360.cicr & 0xE0) | 0x04, &old_handler); m360.smc1.smcm = 3; /* Enable SMC1 TX and RX interrupts */ m360.cimr |= 1UL << 4; /* Enable SMC1 interrupts */ } return 0;} |
if (!ret_basis) return gerepile(av,tetpil,gcopy(disc)); | nfbasis00(GEN x0, long flag, GEN p, long ret_basis, GEN *y){ GEN x, disc, basis, lead; GEN *gptr[2]; long k, tetpil, av = avma, l = lgef(x0), smll; if (typ(x0)!=t_POL) err(typeer,"nfbasis00"); if (l<=3) err(zeropoler,"nfbasis00"); for (k=2; k<l; k++) if (typ(x0[k])!=t_INT) err(talker,"polynomial not in Z[X] in nfbasis"); x = pol_to_monic(x0,&lead); if (!p || gcmp0(p)) smll = (flag & 1); /* small basis */ else { if (lead) p = update_fact(x,p); smll = (long) p; /* factored basis */ } if (flag & 2) basis = allbase(x,smll,&disc); /* round 2 */ else basis = allbase4(x,smll,&disc,NULL); /* round 4 */ tetpil=avma; if (!ret_basis) return gerepile(av,tetpil,gcopy(disc)); if (!lead) basis = gcopy(basis); else { long v = varn(x); GEN pol = gmul(polx[v],lead); tetpil = avma; basis = gsubst(basis,v,pol); } if (!y) return gerepile(av,tetpil,basis); *y = gcopy(disc); gptr[0]=&basis; gptr[1]=y; gerepilemanysp(av,tetpil,gptr,2); return basis;} |
|
return centermod(idealapprfact_i(nf,fact,1), gcoeff(x,1,1)); | return idealapprfact_i(nf,fact,1); | mat_ideal_two_elt2(GEN nf, GEN x, GEN a){ GEN L, e, fact = idealfactor(nf,a); long i, r; L = gel(fact,1); e = gel(fact,2); r = lg(e); for (i=1; i<r; i++) gel(e,i) = stoi( idealval(nf,x,gel(L,i)) ); return centermod(idealapprfact_i(nf,fact,1), gcoeff(x,1,1));} |
if (valp(x) > 0) return gzero; | if (divise(lift(x), p)) return gzero; | phi_ms(GEN vz, GEN p, long m, GEN s, GEN x){ GEN p1, p2; if (valp(x) > 0) return gzero; p1 = powgi(quickteich(vz, p, x), addis(s, m)); p2 = powgi(x, negi(s)); return gmul(p1, p2);} |
return gmul(p1, p2); | return lift(gmul(p1, p2)); | phi_ms(GEN vz, GEN p, long m, GEN s, GEN x){ GEN p1, p2; if (valp(x) > 0) return gzero; p1 = powgi(quickteich(vz, p, x), addis(s, m)); p2 = powgi(x, negi(s)); return gmul(p1, p2);} |
T.fact = gerepilecopy(av2, sort_vecpol(rep)); | T.fact = gerepilecopy(av2, sort_vecpol(rep, &cmp_pol)); | nfsqff(GEN nf, GEN pol, long fl){ long i, n, nbf, ct, maxf, dpol = degpol(pol); ulong pp; pari_sp av = avma; GEN pr, C0, dk, bad, polbase, init_fa = NULL; GEN N2, rep, polmod, polred, lt, nfpol; byteptr pt = diffptr; nfcmbf_t T; nflift_t L; pari_timer ti, ti_tot; if (DEBUGLEVEL>2) { TIMERstart(&ti); TIMERstart(&ti_tot); } nfpol = (GEN)nf[1]; n = degpol(nfpol); polbase = unifpol(nf, pol, t_COL); if (typ(polbase) != t_POL) err(typeer, "nfsqff"); polmod = unifpol(nf, pol, t_POLMOD); /* heuristic */ if (dpol*3 < n) { GEN z, t; if (DEBUGLEVEL>2) fprintferr("Using Trager's method\n"); z = (GEN)polfnf(polmod, nfpol)[1]; if (fl) { long l = lg(z); for (i = 1; i < l; i++) { t = (GEN)z[i]; if (degpol(t) > 1) break; z[i] = lneg(gdiv((GEN)t[3], (GEN)t[2])); } setlg(z, i); } return gerepilecopy(av, z); } pol = simplify_i(lift(polmod)); lt = leading_term(polbase); /* t_INT */ if (gcmp1(lt)) lt = NULL; dk = absi((GEN)nf[3]); bad = mulii(dk,(GEN)nf[4]); if (lt) bad = mulii(bad, lt); polred = pr = NULL; /* gcc -Wall */ nbf = 0; pp = 0; L.Tp = NULL; /* FIXME: slow factorization of large polynomials over large Fq */ maxf = 1; if (dpol > 100) /* tough */ { if (n >= 20) maxf = 4; } else { if (n >= 15) maxf = 4; } for (ct = 5;;) { GEN aT, apr, ap, modpr, red; long anbf; pari_timer ti_pr; GEN list, r = NULL, fa = NULL; pari_sp av2 = avma; if (DEBUGLEVEL>3) TIMERstart(&ti_pr); for (;;) { NEXT_PRIME_VIADIFF_CHECK(pp, pt); if (! umodiu(bad,pp)) continue; ap = utoi(pp); list = (GEN)factmod0(nfpol, ap)[1]; if (maxf == 1) { /* deg.1 factors are best */ r = (GEN)list[1]; if (degpol(r) == 1) break; } else { /* otherwise, pick factor of largish degree */ long i, dr; for (i = lg(list)-1; i > 0; i--) { r = (GEN)list[i]; dr = degpol(r); if (dr <= maxf) break; } if (i > 0) break; } avma = av2; } apr = apply_kummer(nf,r,gun,ap); modpr = zk_to_ff_init(nf,&apr,&aT,&ap); red = modprX(polbase, nf, modpr); if (!aT) { /* degree 1 */ red = u_Fp_FpX(red, pp); if (!u_FpX_is_squarefree(red, pp)) { avma = av2; continue; } anbf = fl? u_FpX_nbroots(red, pp): u_FpX_nbfact(red, pp); } else { GEN q; if (!FqX_is_squarefree(red,aT,ap)) { avma = av2; continue; } q = gpowgs(ap, degpol(aT)); anbf = fl? FqX_split_deg1(&fa, red, q, aT, ap) : FqX_split_by_degree(&fa, red, q, aT, ap); } if (fl == 2 && anbf < dpol) return cgetg(1,t_VEC); if (anbf <= 1) { if (!fl) /* irreducible */ return gerepilecopy(av, _vec(QXQ_normalize(polmod, nfpol))); if (!anbf) return cgetg(1,t_VEC); /* no root */ } if (!nbf || anbf < nbf || (anbf == nbf && cmpii((GEN)apr[4], (GEN)pr[4]) > 0)) { nbf = anbf; pr = apr; L.Tp = aT; init_fa = fa; } else avma = av2; if (DEBUGLEVEL>3) fprintferr("%3ld %s at prime\n %Z\nTime: %ld\n", anbf, fl?"roots": "factors", apr, TIMER(&ti_pr)); if (--ct <= 0) break; } if (DEBUGLEVEL>2) { msgTIMER(&ti, "choice of a prime ideal"); fprintferr("Prime ideal chosen: %Z\n", pr); } L.tozk = (GEN)nf[8]; L.topow= Q_remove_denom((GEN)nf[7], &L.topowden); T.ZC = L2_bound(nf, L.tozk, &(T.dn)); T.Br = nf_root_bounds(pol, nf); if (lt) T.Br = gmul(T.Br, lt); if (fl) C0 = normlp(T.Br, 2, n); else C0 = nf_factor_bound(nf, polbase); /* bound for T_2(Q_i), Q | P */ T.bound = mulrr(T.ZC, C0); /* bound for |Q_i|^2 in Z^n on chosen Z-basis */ N2 = mulsr(dpol*dpol, normlp(T.Br, 4, n)); /* bound for T_2(lt * S_2) */ T.BS_2 = mulrr(T.ZC, N2); /* bound for |S_2|^2 on chosen Z-basis */ if (DEBUGLEVEL>2) { msgTIMER(&ti, "bound computation"); fprintferr(" 1) T_2 bound for %s: %Z\n", fl?"root":"factor", C0); fprintferr(" 2) Conversion from T_2 --> | |^2 bound : %Z\n", T.ZC); fprintferr(" 3) Final bound: %Z\n", T.bound); } L.p = (GEN)pr[1]; if (L.Tp && degpol(L.Tp) == 1) L.Tp = NULL; bestlift_init(0, nf, pr, T.bound, &L); if (DEBUGLEVEL>2) TIMERstart(&ti); polred = ZqX_normalize(polbase, lt, &L); /* monic */ if (fl) return gerepilecopy(av, nf_DDF_roots(pol, polred, nfpol, lt, init_fa, nbf, fl, &L)); { pari_sp av2 = avma; if (L.Tp) rep = FqX_split_all(init_fa, L.Tp, L.p); else { long d; rep = cgetg(dpol + 1, t_VEC); rep[1] = (long)polred; d = FpX_split_berlekamp((GEN*)(rep + 1), L.p); setlg(rep, d + 1); } T.fact = gerepilecopy(av2, sort_vecpol(rep)); } if (DEBUGLEVEL>2) msgTIMER(&ti, "splitting mod %Z", pr); T.pr = pr; T.L = &L; T.polbase = polbase; T.pol = pol; T.nf = nf; T.hint = 1; /* useless */ rep = nf_combine_factors(&T, polred, L.p, L.k, dpol-1); if (DEBUGLEVEL>2) fprintferr("Total Time: %ld\n===========\n", TIMER(&ti_tot)); return gerepileupto(av, rep);} |
modulereltoabs(GEN nf, GEN rnfeq, GEN x) | modulereltoabs(GEN rnf, GEN x) | modulereltoabs(GEN nf, GEN rnfeq, GEN x){ GEN oms = (GEN)x[1], ids = (GEN)x[2], T = (GEN)nf[1]; GEN p1, M, basnf, cobasnf; long i,j, n = lg(oms)-1, m = degpol(T), degabs = n*m; M = cgetg(degabs+1,t_MAT); basnf = gsubst((GEN)nf[7], varn(T), (GEN)rnfeq[2]); /* removing denominators speeds up multiplication */ basnf = primitive_part(basnf, &cobasnf); for (i=1; i<=n; i++) { GEN c,c0,c1, om = (GEN)oms[i], id = (GEN)ids[i]; om = primitive_part(eltreltoabs(rnfeq, om), &c0); c0 = mul_content(c0, cobasnf); for (j=1; j<=m; j++) { p1 = primitive_part(gmul(basnf,(GEN)id[j]), &c1); p1 = lift_intern(gmul(om,p1)); c = mul_content(c1, c0); if (c) p1 = gmul(c,p1); M[(i-1)*m+j] = (long)pol_to_vec(p1, degabs); } } return M;} |
GEN oms = (GEN)x[1], ids = (GEN)x[2], T = (GEN)nf[1]; GEN p1, M, basnf, cobasnf; long i,j, n = lg(oms)-1, m = degpol(T), degabs = n*m; | GEN oms = (GEN)x[1], ids = (GEN)x[2], nf = (GEN)rnf[10], rnfeq = (GEN)rnf[11]; GEN M, basnf, cobasnf, T = (GEN)nf[1]; long i, j, k, n = lg(oms)-1, m = degpol(T); | modulereltoabs(GEN nf, GEN rnfeq, GEN x){ GEN oms = (GEN)x[1], ids = (GEN)x[2], T = (GEN)nf[1]; GEN p1, M, basnf, cobasnf; long i,j, n = lg(oms)-1, m = degpol(T), degabs = n*m; M = cgetg(degabs+1,t_MAT); basnf = gsubst((GEN)nf[7], varn(T), (GEN)rnfeq[2]); /* removing denominators speeds up multiplication */ basnf = primitive_part(basnf, &cobasnf); for (i=1; i<=n; i++) { GEN c,c0,c1, om = (GEN)oms[i], id = (GEN)ids[i]; om = primitive_part(eltreltoabs(rnfeq, om), &c0); c0 = mul_content(c0, cobasnf); for (j=1; j<=m; j++) { p1 = primitive_part(gmul(basnf,(GEN)id[j]), &c1); p1 = lift_intern(gmul(om,p1)); c = mul_content(c1, c0); if (c) p1 = gmul(c,p1); M[(i-1)*m+j] = (long)pol_to_vec(p1, degabs); } } return M;} |
M = cgetg(degabs+1,t_MAT); | M = cgetg(n*m+1, t_VEC); | modulereltoabs(GEN nf, GEN rnfeq, GEN x){ GEN oms = (GEN)x[1], ids = (GEN)x[2], T = (GEN)nf[1]; GEN p1, M, basnf, cobasnf; long i,j, n = lg(oms)-1, m = degpol(T), degabs = n*m; M = cgetg(degabs+1,t_MAT); basnf = gsubst((GEN)nf[7], varn(T), (GEN)rnfeq[2]); /* removing denominators speeds up multiplication */ basnf = primitive_part(basnf, &cobasnf); for (i=1; i<=n; i++) { GEN c,c0,c1, om = (GEN)oms[i], id = (GEN)ids[i]; om = primitive_part(eltreltoabs(rnfeq, om), &c0); c0 = mul_content(c0, cobasnf); for (j=1; j<=m; j++) { p1 = primitive_part(gmul(basnf,(GEN)id[j]), &c1); p1 = lift_intern(gmul(om,p1)); c = mul_content(c1, c0); if (c) p1 = gmul(c,p1); M[(i-1)*m+j] = (long)pol_to_vec(p1, degabs); } } return M;} |
basnf = primitive_part(basnf, &cobasnf); for (i=1; i<=n; i++) | basnf = Q_primitive_part(basnf, &cobasnf); for (k=i=1; i<=n; i++) | modulereltoabs(GEN nf, GEN rnfeq, GEN x){ GEN oms = (GEN)x[1], ids = (GEN)x[2], T = (GEN)nf[1]; GEN p1, M, basnf, cobasnf; long i,j, n = lg(oms)-1, m = degpol(T), degabs = n*m; M = cgetg(degabs+1,t_MAT); basnf = gsubst((GEN)nf[7], varn(T), (GEN)rnfeq[2]); /* removing denominators speeds up multiplication */ basnf = primitive_part(basnf, &cobasnf); for (i=1; i<=n; i++) { GEN c,c0,c1, om = (GEN)oms[i], id = (GEN)ids[i]; om = primitive_part(eltreltoabs(rnfeq, om), &c0); c0 = mul_content(c0, cobasnf); for (j=1; j<=m; j++) { p1 = primitive_part(gmul(basnf,(GEN)id[j]), &c1); p1 = lift_intern(gmul(om,p1)); c = mul_content(c1, c0); if (c) p1 = gmul(c,p1); M[(i-1)*m+j] = (long)pol_to_vec(p1, degabs); } } return M;} |
om = primitive_part(eltreltoabs(rnfeq, om), &c0); | om = Q_primitive_part(eltreltoabs(rnfeq, om), &c0); | modulereltoabs(GEN nf, GEN rnfeq, GEN x){ GEN oms = (GEN)x[1], ids = (GEN)x[2], T = (GEN)nf[1]; GEN p1, M, basnf, cobasnf; long i,j, n = lg(oms)-1, m = degpol(T), degabs = n*m; M = cgetg(degabs+1,t_MAT); basnf = gsubst((GEN)nf[7], varn(T), (GEN)rnfeq[2]); /* removing denominators speeds up multiplication */ basnf = primitive_part(basnf, &cobasnf); for (i=1; i<=n; i++) { GEN c,c0,c1, om = (GEN)oms[i], id = (GEN)ids[i]; om = primitive_part(eltreltoabs(rnfeq, om), &c0); c0 = mul_content(c0, cobasnf); for (j=1; j<=m; j++) { p1 = primitive_part(gmul(basnf,(GEN)id[j]), &c1); p1 = lift_intern(gmul(om,p1)); c = mul_content(c1, c0); if (c) p1 = gmul(c,p1); M[(i-1)*m+j] = (long)pol_to_vec(p1, degabs); } } return M;} |
p1 = primitive_part(gmul(basnf,(GEN)id[j]), &c1); p1 = lift_intern(gmul(om,p1)); c = mul_content(c1, c0); if (c) p1 = gmul(c,p1); M[(i-1)*m+j] = (long)pol_to_vec(p1, degabs); | GEN z = Q_primitive_part(gmul(basnf,(GEN)id[j]), &c1); z = lift_intern(gmul(om, z)); c = mul_content(c1, c0); if (c) z = gmul(c, z); M[k++] = (long)z; | modulereltoabs(GEN nf, GEN rnfeq, GEN x){ GEN oms = (GEN)x[1], ids = (GEN)x[2], T = (GEN)nf[1]; GEN p1, M, basnf, cobasnf; long i,j, n = lg(oms)-1, m = degpol(T), degabs = n*m; M = cgetg(degabs+1,t_MAT); basnf = gsubst((GEN)nf[7], varn(T), (GEN)rnfeq[2]); /* removing denominators speeds up multiplication */ basnf = primitive_part(basnf, &cobasnf); for (i=1; i<=n; i++) { GEN c,c0,c1, om = (GEN)oms[i], id = (GEN)ids[i]; om = primitive_part(eltreltoabs(rnfeq, om), &c0); c0 = mul_content(c0, cobasnf); for (j=1; j<=m; j++) { p1 = primitive_part(gmul(basnf,(GEN)id[j]), &c1); p1 = lift_intern(gmul(om,p1)); c = mul_content(c1, c0); if (c) p1 = gmul(c,p1); M[(i-1)*m+j] = (long)pol_to_vec(p1, degabs); } } return M;} |
rtems_unsigned32 n = rtems_get_index(*next_id); | uint32_t n = rtems_get_index(*next_id); | rtems_monitor_driver_next( void *object_info, rtems_monitor_driver_t *canonical_driver, rtems_id *next_id){ rtems_configuration_table *c = _Configuration_Table; rtems_unsigned32 n = rtems_get_index(*next_id); if (n >= c->number_of_device_drivers) goto failed; _Thread_Disable_dispatch(); /* * dummy up a fake id and name for this item */ canonical_driver->id = n; canonical_driver->name = rtems_build_name('-', '-', '-', '-'); *next_id += 1; return (void *) (c->Device_driver_table + n);failed: *next_id = RTEMS_OBJECT_ID_FINAL; return 0;} |
isascii(*cp) && !isspace(*cp)) | isascii((int)*cp) && !isspace((int)*cp)) | res_init(){ register FILE *fp; register char *cp, **pp; register int n; char buf[MAXDNAME]; int nserv = 0; /* number of nameserver records read from file */ int haveenv = 0; int havesearch = 0;#ifdef RESOLVSORT int nsort = 0; char *net;#endif#ifndef RFC1535 int dots;#endif /* * These three fields used to be statically initialized. This made * it hard to use this code in a shared library. It is necessary, * now that we're doing dynamic initialization here, that we preserve * the old semantics: if an application modifies one of these three * fields of _res before res_init() is called, res_init() will not * alter them. Of course, if an application is setting them to * _zero_ before calling res_init(), hoping to override what used * to be the static default, we can't detect it and unexpected results * will follow. Zero for any of these fields would make no sense, * so one can safely assume that the applications were already getting * unexpected results. * * _res.options is tricky since some apps were known to diddle the bits * before res_init() was first called. We can't replicate that semantic * with dynamic initialization (they may have turned bits off that are * set in RES_DEFAULT). Our solution is to declare such applications * "broken". They could fool us by setting RES_INIT but none do (yet). */ if (!_res.retrans) _res.retrans = RES_TIMEOUT; if (!_res.retry) _res.retry = 4; if (!(_res.options & RES_INIT)) _res.options = RES_DEFAULT; /* * This one used to initialize implicitly to zero, so unless the app * has set it to something in particular, we can randomize it now. */ if (!_res.id) _res.id = res_randomid();#ifdef USELOOPBACK _res.nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1);#else _res.nsaddr.sin_addr.s_addr = INADDR_ANY;#endif _res.nsaddr.sin_family = AF_INET; _res.nsaddr.sin_port = htons(NAMESERVER_PORT); _res.nscount = 1; _res.ndots = 1; _res.pfcode = 0; /* * RTEMS -- Set up name servers */ {#include <rtems/rtems_bsdnet_internal.h> int n = 0; while ((n < rtems_bsdnet_nameserver_count) && (nserv < MAXNS)) { _res.nsaddr_list[nserv].sin_addr = rtems_bsdnet_nameserver[n]; _res.nsaddr_list[nserv].sin_family = AF_INET; _res.nsaddr_list[nserv].sin_port = htons(NAMESERVER_PORT); nserv++; n++; } if (rtems_bsdnet_domain_name) (void)strncpy(_res.defdname, rtems_bsdnet_domain_name, sizeof(_res.defdname) - 1); } /* Allow user to override the local domain definition */ if ((cp = getenv("LOCALDOMAIN")) != NULL) { (void)strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1); haveenv++; /* * Set search list to be blank-separated strings * from rest of env value. Permits users of LOCALDOMAIN * to still have a search list, and anyone to set the * one that they want to use as an individual (even more * important now that the rfc1535 stuff restricts searches) */ cp = _res.defdname; pp = _res.dnsrch; *pp++ = cp; for (n = 0; *cp && pp < _res.dnsrch + MAXDNSRCH; cp++) { if (*cp == '\n') /* silly backwards compat */ break; else if (*cp == ' ' || *cp == '\t') { *cp = 0; n = 1; } else if (n) { *pp++ = cp; n = 0; havesearch = 1; } } /* null terminate last domain if there are excess */ while (*cp != '\0' && *cp != ' ' && *cp != '\t' && *cp != '\n') cp++; *cp = '\0'; *pp++ = 0; }#define MATCH(line, name) \ (!strncmp(line, name, sizeof(name) - 1) && \ (line[sizeof(name) - 1] == ' ' || \ line[sizeof(name) - 1] == '\t')) if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) { /* read the config file */ while (fgets(buf, sizeof(buf), fp) != NULL) { /* skip comments */ if (*buf == ';' || *buf == '#') continue; /* read default domain name */ if (MATCH(buf, "domain")) { if (haveenv) /* skip if have from environ */ continue; cp = buf + sizeof("domain") - 1; while (*cp == ' ' || *cp == '\t') cp++; if ((*cp == '\0') || (*cp == '\n')) continue; strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1); if ((cp = strpbrk(_res.defdname, " \t\n")) != NULL) *cp = '\0'; havesearch = 0; continue; } /* set search list */ if (MATCH(buf, "search")) { if (haveenv) /* skip if have from environ */ continue; cp = buf + sizeof("search") - 1; while (*cp == ' ' || *cp == '\t') cp++; if ((*cp == '\0') || (*cp == '\n')) continue; strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1); if ((cp = strchr(_res.defdname, '\n')) != NULL) *cp = '\0'; /* * Set search list to be blank-separated strings * on rest of line. */ cp = _res.defdname; pp = _res.dnsrch; *pp++ = cp; for (n = 0; *cp && pp < _res.dnsrch + MAXDNSRCH; cp++) { if (*cp == ' ' || *cp == '\t') { *cp = 0; n = 1; } else if (n) { *pp++ = cp; n = 0; } } /* null terminate last domain if there are excess */ while (*cp != '\0' && *cp != ' ' && *cp != '\t') cp++; *cp = '\0'; *pp++ = 0; havesearch = 1; continue; } /* read nameservers to query */ if (MATCH(buf, "nameserver") && nserv < MAXNS) { struct in_addr a; cp = buf + sizeof("nameserver") - 1; while (*cp == ' ' || *cp == '\t') cp++; if ((*cp != '\0') && (*cp != '\n') && inet_aton(cp, &a)) { _res.nsaddr_list[nserv].sin_addr = a; _res.nsaddr_list[nserv].sin_family = AF_INET; _res.nsaddr_list[nserv].sin_port = htons(NAMESERVER_PORT); nserv++; } continue; }#ifdef RESOLVSORT if (MATCH(buf, "sortlist")) { struct in_addr a; cp = buf + sizeof("sortlist") - 1; while (nsort < MAXRESOLVSORT) { while (*cp == ' ' || *cp == '\t') cp++; if (*cp == '\0' || *cp == '\n' || *cp == ';') break; net = cp; while (*cp && !ISSORTMASK(*cp) && *cp != ';' && isascii(*cp) && !isspace(*cp)) cp++; n = *cp; *cp = 0; if (inet_aton(net, &a)) { _res.sort_list[nsort].addr = a; if (ISSORTMASK(n)) { *cp++ = n; net = cp; while (*cp && *cp != ';' && isascii(*cp) && !isspace(*cp)) cp++; n = *cp; *cp = 0; if (inet_aton(net, &a)) { _res.sort_list[nsort].mask = a.s_addr; } else { _res.sort_list[nsort].mask = net_mask(_res.sort_list[nsort].addr); } } else { _res.sort_list[nsort].mask = net_mask(_res.sort_list[nsort].addr); } nsort++; } *cp = n; } continue; }#endif if (MATCH(buf, "options")) { res_setoptions(buf + sizeof("options") - 1, "conf"); continue; } } if (nserv > 1) _res.nscount = nserv;#ifdef RESOLVSORT _res.nsort = nsort;#endif (void) fclose(fp); } if (_res.defdname[0] == 0 && gethostname(buf, sizeof(_res.defdname) - 1) == 0 && (cp = strchr(buf, '.')) != NULL) strcpy(_res.defdname, cp + 1); /* find components of local domain that might be searched */ if (havesearch == 0) { pp = _res.dnsrch; *pp++ = _res.defdname; *pp = NULL;#ifndef RFC1535 dots = 0; for (cp = _res.defdname; *cp; cp++) dots += (*cp == '.'); cp = _res.defdname; while (pp < _res.dnsrch + MAXDFLSRCH) { if (dots < LOCALDOMAINPARTS) break; cp = strchr(cp, '.') + 1; /* we know there is one */ *pp++ = cp; dots--; } *pp = NULL;#ifdef DEBUG if (_res.options & RES_DEBUG) { printf(";; res_init()... default dnsrch list:\n"); for (pp = _res.dnsrch; *pp; pp++) printf(";;\t%s\n", *pp); printf(";;\t..END..\n"); }#endif#endif /* !RFC1535 */ } if ((cp = getenv("RES_OPTIONS")) != NULL) res_setoptions(cp, "env"); _res.options |= RES_INIT; return (0);} |
} else { *len = requested; | static apr_status_t serf_mmap_read(serf_bucket_t *bucket, apr_size_t requested, const char **data, apr_size_t *len){ mmap_context_t *ctx = bucket->data; if (requested == SERF_READ_ALL_AVAIL || requested > ctx->remaining) { *len = ctx->remaining; } /* ### Would it be faster to call this once and do the offset ourselves? */ apr_mmap_offset((void**)data, ctx->mmap, ctx->offset); /* For the next read... */ ctx->offset += *len; ctx->remaining -= *len; if (ctx->remaining == 0) { return APR_EOF; } return APR_SUCCESS;} |
|
long i,l,ec,av,tetpil; | ulong av = avma; long i,l,ec; | laplace(GEN x){ long i,l,ec,av,tetpil; GEN y,p1; if (typ(x)!=t_SER) err(talker,"not a series in laplace"); if (gcmp0(x)) return gcopy(x); av=avma; ec=valp(x); if (ec<0) err(talker,"negative valuation in laplace"); l=lg(x); y=cgetg(l,t_SER); p1=mpfact(ec); y[1]=x[1]; for (i=2; i<l; i++) { y[i]=lmul(p1,(GEN)x[i]); ec++; p1=mulsi(ec,p1); } tetpil=avma; return gerepile(av,tetpil,gcopy(y));} |
av=avma; ec=valp(x); | ec = valp(x); | laplace(GEN x){ long i,l,ec,av,tetpil; GEN y,p1; if (typ(x)!=t_SER) err(talker,"not a series in laplace"); if (gcmp0(x)) return gcopy(x); av=avma; ec=valp(x); if (ec<0) err(talker,"negative valuation in laplace"); l=lg(x); y=cgetg(l,t_SER); p1=mpfact(ec); y[1]=x[1]; for (i=2; i<l; i++) { y[i]=lmul(p1,(GEN)x[i]); ec++; p1=mulsi(ec,p1); } tetpil=avma; return gerepile(av,tetpil,gcopy(y));} |
tetpil=avma; return gerepile(av,tetpil,gcopy(y)); | return gerepilecopy(av,y); | laplace(GEN x){ long i,l,ec,av,tetpil; GEN y,p1; if (typ(x)!=t_SER) err(talker,"not a series in laplace"); if (gcmp0(x)) return gcopy(x); av=avma; ec=valp(x); if (ec<0) err(talker,"negative valuation in laplace"); l=lg(x); y=cgetg(l,t_SER); p1=mpfact(ec); y[1]=x[1]; for (i=2; i<l; i++) { y[i]=lmul(p1,(GEN)x[i]); ec++; p1=mulsi(ec,p1); } tetpil=avma; return gerepile(av,tetpil,gcopy(y));} |
if (gcmp0(x)) return zeroser(vx,e-1); | if (gcmp0(x)) return zeroser(vx,e? e-1: 0); | derivser(GEN x){ long i,j,vx = varn(x), e = valp(x), lx = lg(x); GEN y; if (gcmp0(x)) return zeroser(vx,e-1); if (e) { y=cgetg(lx,t_SER); y[1] = evalsigne(1) | evalvalp(e-1) | evalvarn(vx); for (i=2; i<lx; i++) y[i]=lmulsg(i+e-2,(GEN)x[i]); return y; } i=3; while (i<lx && gcmp0((GEN)x[i])) i++; if (i==lx) return zeroser(vx,lx-3); lx--; if (lx<3) lx=3; lx = lx-i+3; y=cgetg(lx,t_SER); y[1]=evalsigne(1) | evalvalp(i-3) | evalvarn(vx); for (j=2; j<lx; j++) y[j]=lmulsg(j+i-4,(GEN)x[i+j-2]); return y;} |
long i, j, lgsub, ino, lv = KC+1; | long i, j, lgsub, ino, minSFB, lv = KC+1; | subFBquad(GEN D, double PROD, long KC){ long i, j, lgsub, ino, lv = KC+1; double prod = 1.; pari_sp av; GEN no; vperm = cgetg(lv, t_VECSMALL); av = avma; no = cgetg(lv, t_VECSMALL); ino = 1; for (i=j=1; j < lv; j++) { long p = FB[j]; if (smodis(D, p) == 0) no[ino++] = j; /* ramified */ else { vperm[i] = j; i++; prod *= p; if (i > 2 && prod > PROD) break; } } if (j == lv) return NULL; lgsub = i; for (j = 1; j <ino; i++,j++) vperm[i] = no[j]; for ( ; i < lv; i++) vperm[i] = i; avma = av; if (DEBUGLEVEL) msgtimer("subFBquad (%ld elt.)", lgsub-1); return vecextract_i(vperm, 1, lgsub-1);} |
if (i > 2 && prod > PROD) break; | if (i > minSFB && prod > PROD) break; | subFBquad(GEN D, double PROD, long KC){ long i, j, lgsub, ino, lv = KC+1; double prod = 1.; pari_sp av; GEN no; vperm = cgetg(lv, t_VECSMALL); av = avma; no = cgetg(lv, t_VECSMALL); ino = 1; for (i=j=1; j < lv; j++) { long p = FB[j]; if (smodis(D, p) == 0) no[ino++] = j; /* ramified */ else { vperm[i] = j; i++; prod *= p; if (i > 2 && prod > PROD) break; } } if (j == lv) return NULL; lgsub = i; for (j = 1; j <ino; i++,j++) vperm[i] = no[j]; for ( ; i < lv; i++) vperm[i] = i; avma = av; if (DEBUGLEVEL) msgtimer("subFBquad (%ld elt.)", lgsub-1); return vecextract_i(vperm, 1, lgsub-1);} |
char new_name[ NAME_MAX + 1 ]; | char new_name[ IMFS_NAME_MAX + 1 ]; | int IMFS_symlink( rtems_filesystem_location_info_t *parent_loc, const char *link_name, const char *node_name){ IMFS_types_union info; IMFS_jnode_t *new_node; char new_name[ NAME_MAX + 1 ]; int i; /* * Remove any separators at the end of the string. */ IMFS_get_token( node_name, new_name, &i ); info.sym_link.name = link_name; /* * Create a new link node. */ new_node = IMFS_create_node( parent_loc, IMFS_SYM_LINK, new_name, ( S_IFLNK | ( S_IRWXU | S_IRWXG | S_IRWXO )), &info ); if ( !new_node ) set_errno_and_return_minus_one( ENOMEM ); return 0;} |
*/ | static void serf_limit_destroy(serf_bucket_t *bucket){ limit_context_t *ctx = bucket->data; /* serf_bucket_destroy(ctx->stream); */ serf_default_destroy_and_data(bucket);} |
|
if (ctx->state == READ_DONE) { *len = 0; return APR_EOF; } | static apr_status_t serf_headers_readline(serf_bucket_t *bucket, int acceptable, int *found, const char **data, apr_size_t *len){ headers_context_t *ctx = bucket->data; apr_status_t status; /* ### what behavior should we use here? abort() isn't very friendly */ if ((acceptable & SERF_NEWLINE_CRLF) == 0) abort(); if (ctx->state == READ_DONE) { *len = 0; return APR_EOF; } /* get whatever is in this chunk */ select_value(ctx, data, len); /* we consumed this chunk. advance the state. */ status = consume_chunk(ctx); /* the type of newline found is easy... */ *found = ctx->state == READ_CRLF ? SERF_NEWLINE_CRLF : SERF_NEWLINE_NONE; return status;} |
|
*found = ctx->state == READ_CRLF ? SERF_NEWLINE_CRLF : SERF_NEWLINE_NONE; | *found = (ctx->state == READ_CRLF || ctx->state == READ_TERM) ? SERF_NEWLINE_CRLF : SERF_NEWLINE_NONE; | static apr_status_t serf_headers_readline(serf_bucket_t *bucket, int acceptable, int *found, const char **data, apr_size_t *len){ headers_context_t *ctx = bucket->data; apr_status_t status; /* ### what behavior should we use here? abort() isn't very friendly */ if ((acceptable & SERF_NEWLINE_CRLF) == 0) abort(); if (ctx->state == READ_DONE) { *len = 0; return APR_EOF; } /* get whatever is in this chunk */ select_value(ctx, data, len); /* we consumed this chunk. advance the state. */ status = consume_chunk(ctx); /* the type of newline found is easy... */ *found = ctx->state == READ_CRLF ? SERF_NEWLINE_CRLF : SERF_NEWLINE_NONE; return status;} |
(*pos)->Imports(list); | int main( int argc, char ** argv ){ try { CommandOptionParse * args = makeCommandOptionParse( argc, argv, "\n" "Usage: nmdepend [option(s)] [file(s)]\n" "The options are:" ); if ( option_version.numSet ) { cerr << "nmdepend version 0.1.0 (" __DATE__ ")" << endl; ::exit(0); } if ( helparg.numSet ) { cerr << args->printUsage(); ::exit(0); } args->performTask(); filelist_t list; // print all the other options. for ( int i = 0; i < restoargs.numValue; i ++ ) { fs::path root(restoargs.values[i]); find_file(root, list);//creates list of *.o files } Symbol::SymbolIndex_t symbolIndex; //why use vectors of pointers and not vectors of objects? //this uses two indirections instead of one; //todo change to object container instead of pointer to object container typedef std::vector<ObjectFile*> ObjectList_t; typedef std::vector<Package*> PackageList_t; ObjectList_t objectList; PackageList_t packageList; Package::PackageRegistry_t packages; for(filelist_t::iterator pos = list.begin(); pos != list.end(); ++pos) { //todo define packages as collection of object files //using config setting fs::path::iterator p = pos->end(); --p; //file std::string name = *p; --p; //directory containing file -> Release or Debug using msvc --p; // 1 level higher for visual studio std::string packagename = *p; ObjectFile* o = new ObjectFile(name,symbolIndex); //memory leak Package* pack = packages[packagename]; if (pack == 0) { //std::cout << "Adding package " << packagename << std::endl; pack = new Package(packagename); //memory leak packages[packagename] = pack; } o->Read(*pos); o->SetParent(*pack); objectList.push_back(o); } for (ObjectList_t::iterator pos = objectList.begin(); pos != objectList.end(); ++pos) { (*pos)->Link(); } std::ofstream dotfile; dotfile.open("object.dot"); dotfile << "digraph G {" << std::endl; dotfile << "node [shape=box];" << std::endl; for (ObjectList_t::iterator pos = objectList.begin(); pos != objectList.end(); ++pos) { Package::SubPackageList_t list; // (*pos)->Imports(list); for (Package::SubPackageList_t::iterator package = list.begin(); package != list.end(); ++package) { dotfile << (*pos)->Name2() << " -> " << (*package)->Name2() << ";" << std::endl; } } dotfile << "}" << std::endl; dotfile.close(); dotfile.open("package.dot"); dotfile << "digraph G {" << std::endl; dotfile << "node [shape=box];" << std::endl; for (Package::PackageRegistry_t::iterator pos = packages.begin(); pos != packages.end(); ++pos) { Package::SubPackageList_t list; //pos->second->Imports(list); for (Package::SubPackageList_t::iterator package = list.begin(); package != list.end(); ++package) { dotfile << pos->first << " -> " << (*package)->Name2() << ";" << std::endl; //std::cout << "Super " << pos->first << " -> " // << (*package)->Name2() << ";" << std::endl; //(*package)->Imports(); } } dotfile << "}" << std::endl; dotfile.close(); delete args; return 0; } catch(const std::exception& e) { std::clog << "exception: " << e.what() << std::endl; } catch(...) { std::clog << "caught unknown exception, exiting" << std::endl; } return 1;} |
|
pos->second->Imports(list); | int main( int argc, char ** argv ){ try { CommandOptionParse * args = makeCommandOptionParse( argc, argv, "\n" "Usage: nmdepend [option(s)] [file(s)]\n" "The options are:" ); if ( option_version.numSet ) { cerr << "nmdepend version 0.1.0 (" __DATE__ ")" << endl; ::exit(0); } if ( helparg.numSet ) { cerr << args->printUsage(); ::exit(0); } args->performTask(); filelist_t list; // print all the other options. for ( int i = 0; i < restoargs.numValue; i ++ ) { fs::path root(restoargs.values[i]); find_file(root, list);//creates list of *.o files } Symbol::SymbolIndex_t symbolIndex; //why use vectors of pointers and not vectors of objects? //this uses two indirections instead of one; //todo change to object container instead of pointer to object container typedef std::vector<ObjectFile*> ObjectList_t; typedef std::vector<Package*> PackageList_t; ObjectList_t objectList; PackageList_t packageList; Package::PackageRegistry_t packages; for(filelist_t::iterator pos = list.begin(); pos != list.end(); ++pos) { //todo define packages as collection of object files //using config setting fs::path::iterator p = pos->end(); --p; //file std::string name = *p; --p; //directory containing file -> Release or Debug using msvc --p; // 1 level higher for visual studio std::string packagename = *p; ObjectFile* o = new ObjectFile(name,symbolIndex); //memory leak Package* pack = packages[packagename]; if (pack == 0) { //std::cout << "Adding package " << packagename << std::endl; pack = new Package(packagename); //memory leak packages[packagename] = pack; } o->Read(*pos); o->SetParent(*pack); objectList.push_back(o); } for (ObjectList_t::iterator pos = objectList.begin(); pos != objectList.end(); ++pos) { (*pos)->Link(); } std::ofstream dotfile; dotfile.open("object.dot"); dotfile << "digraph G {" << std::endl; dotfile << "node [shape=box];" << std::endl; for (ObjectList_t::iterator pos = objectList.begin(); pos != objectList.end(); ++pos) { Package::SubPackageList_t list; // (*pos)->Imports(list); for (Package::SubPackageList_t::iterator package = list.begin(); package != list.end(); ++package) { dotfile << (*pos)->Name2() << " -> " << (*package)->Name2() << ";" << std::endl; } } dotfile << "}" << std::endl; dotfile.close(); dotfile.open("package.dot"); dotfile << "digraph G {" << std::endl; dotfile << "node [shape=box];" << std::endl; for (Package::PackageRegistry_t::iterator pos = packages.begin(); pos != packages.end(); ++pos) { Package::SubPackageList_t list; //pos->second->Imports(list); for (Package::SubPackageList_t::iterator package = list.begin(); package != list.end(); ++package) { dotfile << pos->first << " -> " << (*package)->Name2() << ";" << std::endl; //std::cout << "Super " << pos->first << " -> " // << (*package)->Name2() << ";" << std::endl; //(*package)->Imports(); } } dotfile << "}" << std::endl; dotfile.close(); delete args; return 0; } catch(const std::exception& e) { std::clog << "exception: " << e.what() << std::endl; } catch(...) { std::clog << "caught unknown exception, exiting" << std::endl; } return 1;} |
|
printf("0%o\n",msk); | printf("0%o\n", (unsigned int) msk); | int main_umask(int argc,char *argv[]) { mode_t msk=umask(0); if (argc == 2) msk=str2int(argv[1]); umask(msk); msk=umask(0); printf("0%o\n",msk); umask(msk); return 0;} |
void __gnat_signals_Abormal_termination_handler( int signo ) | __gnat_signals_Abormal_termination_handler (int signo) | void __gnat_signals_Abormal_termination_handler( int signo ){ switch ( signo ) { case SIGFPE: DEBUG_puts("\nConstraint_Error\n"); break; case SIGSEGV: DEBUG_puts("\nStorage_Error\n"); break; default: DEBUG_puts("\nProgram_Error\n"); break; } exit( 1 );} |
int rtems_gxx_once(__gthread_once_t *once, void (*func) ()) | int rtems_gxx_once(__gthread_once_t *once, void (*func) (void)) | int rtems_gxx_once(__gthread_once_t *once, void (*func) ()){#ifdef DEBUG_GXX_WRAPPERS printk( "gxx_wrappers: once=%x, func=%x\n", *once, func );#endif if( *(volatile __gthread_once_t *)once == 0 ) { rtems_mode saveMode; rtems_task_mode(RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &saveMode); if( *(volatile __gthread_once_t *)once == 0 ) { *(volatile __gthread_once_t *)once = 1; (*func)(); } rtems_task_mode(saveMode, RTEMS_PREEMPT_MASK, &saveMode); } return 0;} |
while (isdigit(*cp)) | while (isdigit((int)*cp)) | precsize_aton(strptr) char **strptr;{ unsigned int mval = 0, cmval = 0; u_int8_t retval = 0; char *cp; int exponent; int mantissa; cp = *strptr; while (isdigit(*cp)) mval = mval * 10 + (*cp++ - '0'); if (*cp == '.') { /* centimeters */ cp++; if (isdigit(*cp)) { cmval = (*cp++ - '0') * 10; if (isdigit(*cp)) { cmval += (*cp++ - '0'); } } } cmval = (mval * 100) + cmval; for (exponent = 0; exponent < 9; exponent++) if (cmval < poweroften[exponent+1]) break; mantissa = cmval / poweroften[exponent]; if (mantissa > 9) mantissa = 9; retval = (mantissa << 4) | exponent; *strptr = cp; return (retval);} |
if (isdigit(*cp)) { | if (isdigit((int)*cp)) { | precsize_aton(strptr) char **strptr;{ unsigned int mval = 0, cmval = 0; u_int8_t retval = 0; char *cp; int exponent; int mantissa; cp = *strptr; while (isdigit(*cp)) mval = mval * 10 + (*cp++ - '0'); if (*cp == '.') { /* centimeters */ cp++; if (isdigit(*cp)) { cmval = (*cp++ - '0') * 10; if (isdigit(*cp)) { cmval += (*cp++ - '0'); } } } cmval = (mval * 100) + cmval; for (exponent = 0; exponent < 9; exponent++) if (cmval < poweroften[exponent+1]) break; mantissa = cmval / poweroften[exponent]; if (mantissa > 9) mantissa = 9; retval = (mantissa << 4) | exponent; *strptr = cp; return (retval);} |
so_ioctl (struct socket *so, unsigned32 command, void *buffer) | so_ioctl (rtems_libio_t *iop, struct socket *so, unsigned32 command, void *buffer) | so_ioctl (struct socket *so, unsigned32 command, void *buffer){ switch (command) { case FIONBIO: if (*(int *)buffer) so->so_state |= SS_NBIO; else so->so_state &= ~SS_NBIO; return 0; case FIONREAD: *(int *)buffer = so->so_rcv.sb_cc; return 0; } if (IOCGROUP(command) == 'i') return ifioctl (so, command, buffer, NULL); if (IOCGROUP(command) == 'r') return rtioctl (command, buffer, NULL); return (*so->so_proto->pr_usrreqs->pru_control)(so, command, buffer, 0);} |
if (*(int *)buffer) | if (*(int *)buffer) { iop->flags |= O_NONBLOCK; | so_ioctl (struct socket *so, unsigned32 command, void *buffer){ switch (command) { case FIONBIO: if (*(int *)buffer) so->so_state |= SS_NBIO; else so->so_state &= ~SS_NBIO; return 0; case FIONREAD: *(int *)buffer = so->so_rcv.sb_cc; return 0; } if (IOCGROUP(command) == 'i') return ifioctl (so, command, buffer, NULL); if (IOCGROUP(command) == 'r') return rtioctl (command, buffer, NULL); return (*so->so_proto->pr_usrreqs->pru_control)(so, command, buffer, 0);} |
else | } else { iop->flags &= ~O_NONBLOCK; | so_ioctl (struct socket *so, unsigned32 command, void *buffer){ switch (command) { case FIONBIO: if (*(int *)buffer) so->so_state |= SS_NBIO; else so->so_state &= ~SS_NBIO; return 0; case FIONREAD: *(int *)buffer = so->so_rcv.sb_cc; return 0; } if (IOCGROUP(command) == 'i') return ifioctl (so, command, buffer, NULL); if (IOCGROUP(command) == 'r') return rtioctl (command, buffer, NULL); return (*so->so_proto->pr_usrreqs->pru_control)(so, command, buffer, 0);} |
} | so_ioctl (struct socket *so, unsigned32 command, void *buffer){ switch (command) { case FIONBIO: if (*(int *)buffer) so->so_state |= SS_NBIO; else so->so_state &= ~SS_NBIO; return 0; case FIONREAD: *(int *)buffer = so->so_rcv.sb_cc; return 0; } if (IOCGROUP(command) == 'i') return ifioctl (so, command, buffer, NULL); if (IOCGROUP(command) == 'r') return rtioctl (command, buffer, NULL); return (*so->so_proto->pr_usrreqs->pru_control)(so, command, buffer, 0);} |
|
m_reclaim() | m_reclaim(void) | m_reclaim(){ register struct domain *dp; register struct protosw *pr; int s = splimp(); for (dp = domains; dp; dp = dp->dom_next) for (pr = dp->dom_protosw; pr < dp->dom_protoswNPROTOSW; pr++) if (pr->pr_drain) (*pr->pr_drain)(); splx(s); mbstat.m_drain++;} |
Line_Control *line; Line_Control *new_line; Line_Control *next_node; char Buffer[ BUFFER_SIZE ]; char ChapterName[ BUFFER_SIZE ]; char NodeName[ BUFFER_SIZE ]; char NextNode[ BUFFER_SIZE ]; char NextNodeName[ BUFFER_SIZE ]; char PreviousNodeName[ BUFFER_SIZE ]; char UpNodeName[ BUFFER_SIZE ]; char SectionName[ BUFFER_SIZE ]; char MenuBuffer[ BUFFER_SIZE ]; Line_Control *node_insert_point; Line_Control *menu_insert_point; Line_Control *node_line; boolean next_found; int menu_items; | char Buffer[ BUFFER_SIZE ]; Line_Control *line; Line_Control *next_node; Line_Control *up_node; Line_Control *new_line; Line_Control *menu_insert_point; Line_Control *node_line; int next_found; int menu_items; Keyword_indices_t index; char ChapterName[ BUFFER_SIZE ]; char NodeName[ BUFFER_SIZE ]; char UpNodeName[ BUFFER_SIZE ]; char NextNodeName[ BUFFER_SIZE ]; char PreviousNodeName[ BUFFER_SIZE ]; | void BuildTexinfoNodes( void ) { Line_Control *line; Line_Control *new_line; Line_Control *next_node; char Buffer[ BUFFER_SIZE ]; char ChapterName[ BUFFER_SIZE ]; char NodeName[ BUFFER_SIZE ]; char NextNode[ BUFFER_SIZE ]; char NextNodeName[ BUFFER_SIZE ]; char PreviousNodeName[ BUFFER_SIZE ]; char UpNodeName[ BUFFER_SIZE ]; char SectionName[ BUFFER_SIZE ]; char MenuBuffer[ BUFFER_SIZE ]; Line_Control *node_insert_point; Line_Control *menu_insert_point; Line_Control *node_line; boolean next_found; int menu_items; strcpy( PreviousNodeName, DocsPreviousNode ); for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { menu_insert_point = (Line_Control *) line->Node.next; switch ( Keywords[ line->keyword ].level ) { case TEXT: case HEADING: break; case SECTION: if ( line->keyword == KEYWORD_END ) goto bottom; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { LineCopyFromRight( line, ChapterName ); strcpy( UpNodeName, DocsUpNode ); strcpy( NodeName, ChapterName ); } else { LineCopySectionName( line, Buffer ); sprintf( NodeName, "%s %s", ChapterName, Buffer ); strcpy( UpNodeName, ChapterName ); } strcpy( SectionName, NodeName ); /* * Go ahead and put it on the chain in the right order (ahead of * the menu) and we can fill it in later (after the menu is built). */ new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); node_line = AllocateLine(); _Chain_Insert( line->Node.previous, &node_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); menu_items = 0; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( next_node->keyword == KEYWORD_END ) break; if ( Keywords[ next_node->keyword ].level == SECTION ) { LineCopySectionName( next_node, Buffer ); if ( !next_found ) { next_found = TRUE; sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } next_node = (Line_Control *) next_node->Node.next; } } else { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( !next_found ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } next_found = TRUE; } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopySectionName( next_node, MenuBuffer ); /* has next node */ if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s::", MenuBuffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); if ( !next_found ) { next_found = TRUE; strcpy( NextNodeName, MenuBuffer ); } } next_node = (Line_Control *) next_node->Node.next; } } if ( menu_items ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@end menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif /* node_line was previously inserted */ sprintf( node_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); strcpy( PreviousNodeName, NodeName ); break; case SUBSECTION: strcpy( UpNodeName, SectionName ); LineCopyFromRight( line, NodeName ); new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); next_node = (Line_Control *) line->Node.next; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopyFromRight( next_node, NextNodeName ); break; } next_node = (Line_Control *) next_node->Node.next; }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif new_line = AllocateLine(); sprintf( new_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); _Chain_Insert( line->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); strcpy( PreviousNodeName, NodeName ); break; } }bottom:} |
menu_insert_point = (Line_Control *) line->Node.next; | if ( line->level == -1 ) continue; | void BuildTexinfoNodes( void ) { Line_Control *line; Line_Control *new_line; Line_Control *next_node; char Buffer[ BUFFER_SIZE ]; char ChapterName[ BUFFER_SIZE ]; char NodeName[ BUFFER_SIZE ]; char NextNode[ BUFFER_SIZE ]; char NextNodeName[ BUFFER_SIZE ]; char PreviousNodeName[ BUFFER_SIZE ]; char UpNodeName[ BUFFER_SIZE ]; char SectionName[ BUFFER_SIZE ]; char MenuBuffer[ BUFFER_SIZE ]; Line_Control *node_insert_point; Line_Control *menu_insert_point; Line_Control *node_line; boolean next_found; int menu_items; strcpy( PreviousNodeName, DocsPreviousNode ); for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { menu_insert_point = (Line_Control *) line->Node.next; switch ( Keywords[ line->keyword ].level ) { case TEXT: case HEADING: break; case SECTION: if ( line->keyword == KEYWORD_END ) goto bottom; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { LineCopyFromRight( line, ChapterName ); strcpy( UpNodeName, DocsUpNode ); strcpy( NodeName, ChapterName ); } else { LineCopySectionName( line, Buffer ); sprintf( NodeName, "%s %s", ChapterName, Buffer ); strcpy( UpNodeName, ChapterName ); } strcpy( SectionName, NodeName ); /* * Go ahead and put it on the chain in the right order (ahead of * the menu) and we can fill it in later (after the menu is built). */ new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); node_line = AllocateLine(); _Chain_Insert( line->Node.previous, &node_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); menu_items = 0; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( next_node->keyword == KEYWORD_END ) break; if ( Keywords[ next_node->keyword ].level == SECTION ) { LineCopySectionName( next_node, Buffer ); if ( !next_found ) { next_found = TRUE; sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } next_node = (Line_Control *) next_node->Node.next; } } else { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( !next_found ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } next_found = TRUE; } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopySectionName( next_node, MenuBuffer ); /* has next node */ if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s::", MenuBuffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); if ( !next_found ) { next_found = TRUE; strcpy( NextNodeName, MenuBuffer ); } } next_node = (Line_Control *) next_node->Node.next; } } if ( menu_items ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@end menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif /* node_line was previously inserted */ sprintf( node_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); strcpy( PreviousNodeName, NodeName ); break; case SUBSECTION: strcpy( UpNodeName, SectionName ); LineCopyFromRight( line, NodeName ); new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); next_node = (Line_Control *) line->Node.next; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopyFromRight( next_node, NextNodeName ); break; } next_node = (Line_Control *) next_node->Node.next; }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif new_line = AllocateLine(); sprintf( new_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); _Chain_Insert( line->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); strcpy( PreviousNodeName, NodeName ); break; } }bottom:} |
switch ( Keywords[ line->keyword ].level ) { case TEXT: case HEADING: | LineCopyFromRight( line, NodeName ); if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { strcpy( ChapterName, NodeName ); } next_found = FALSE; strcpy( NextNodeName, DocsNextNode ); new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); node_line = AllocateLine(); _Chain_Insert( line->Node.previous, &node_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); next_node = (Line_Control *) line->Node.next; menu_insert_point = next_node; menu_items = 0; for ( ; ; ) { if ( next_node->keyword == KEYWORD_END ) | void BuildTexinfoNodes( void ) { Line_Control *line; Line_Control *new_line; Line_Control *next_node; char Buffer[ BUFFER_SIZE ]; char ChapterName[ BUFFER_SIZE ]; char NodeName[ BUFFER_SIZE ]; char NextNode[ BUFFER_SIZE ]; char NextNodeName[ BUFFER_SIZE ]; char PreviousNodeName[ BUFFER_SIZE ]; char UpNodeName[ BUFFER_SIZE ]; char SectionName[ BUFFER_SIZE ]; char MenuBuffer[ BUFFER_SIZE ]; Line_Control *node_insert_point; Line_Control *menu_insert_point; Line_Control *node_line; boolean next_found; int menu_items; strcpy( PreviousNodeName, DocsPreviousNode ); for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { menu_insert_point = (Line_Control *) line->Node.next; switch ( Keywords[ line->keyword ].level ) { case TEXT: case HEADING: break; case SECTION: if ( line->keyword == KEYWORD_END ) goto bottom; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { LineCopyFromRight( line, ChapterName ); strcpy( UpNodeName, DocsUpNode ); strcpy( NodeName, ChapterName ); } else { LineCopySectionName( line, Buffer ); sprintf( NodeName, "%s %s", ChapterName, Buffer ); strcpy( UpNodeName, ChapterName ); } strcpy( SectionName, NodeName ); /* * Go ahead and put it on the chain in the right order (ahead of * the menu) and we can fill it in later (after the menu is built). */ new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); node_line = AllocateLine(); _Chain_Insert( line->Node.previous, &node_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); menu_items = 0; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( next_node->keyword == KEYWORD_END ) break; if ( Keywords[ next_node->keyword ].level == SECTION ) { LineCopySectionName( next_node, Buffer ); if ( !next_found ) { next_found = TRUE; sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } next_node = (Line_Control *) next_node->Node.next; } } else { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( !next_found ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } next_found = TRUE; } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopySectionName( next_node, MenuBuffer ); /* has next node */ if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s::", MenuBuffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); if ( !next_found ) { next_found = TRUE; strcpy( NextNodeName, MenuBuffer ); } } next_node = (Line_Control *) next_node->Node.next; } } if ( menu_items ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@end menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif /* node_line was previously inserted */ sprintf( node_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); strcpy( PreviousNodeName, NodeName ); break; case SUBSECTION: strcpy( UpNodeName, SectionName ); LineCopyFromRight( line, NodeName ); new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); next_node = (Line_Control *) line->Node.next; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopyFromRight( next_node, NextNodeName ); break; } next_node = (Line_Control *) next_node->Node.next; }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif new_line = AllocateLine(); sprintf( new_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); _Chain_Insert( line->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); strcpy( PreviousNodeName, NodeName ); break; } }bottom:} |
case SECTION: if ( line->keyword == KEYWORD_END ) goto bottom; | void BuildTexinfoNodes( void ) { Line_Control *line; Line_Control *new_line; Line_Control *next_node; char Buffer[ BUFFER_SIZE ]; char ChapterName[ BUFFER_SIZE ]; char NodeName[ BUFFER_SIZE ]; char NextNode[ BUFFER_SIZE ]; char NextNodeName[ BUFFER_SIZE ]; char PreviousNodeName[ BUFFER_SIZE ]; char UpNodeName[ BUFFER_SIZE ]; char SectionName[ BUFFER_SIZE ]; char MenuBuffer[ BUFFER_SIZE ]; Line_Control *node_insert_point; Line_Control *menu_insert_point; Line_Control *node_line; boolean next_found; int menu_items; strcpy( PreviousNodeName, DocsPreviousNode ); for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { menu_insert_point = (Line_Control *) line->Node.next; switch ( Keywords[ line->keyword ].level ) { case TEXT: case HEADING: break; case SECTION: if ( line->keyword == KEYWORD_END ) goto bottom; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { LineCopyFromRight( line, ChapterName ); strcpy( UpNodeName, DocsUpNode ); strcpy( NodeName, ChapterName ); } else { LineCopySectionName( line, Buffer ); sprintf( NodeName, "%s %s", ChapterName, Buffer ); strcpy( UpNodeName, ChapterName ); } strcpy( SectionName, NodeName ); /* * Go ahead and put it on the chain in the right order (ahead of * the menu) and we can fill it in later (after the menu is built). */ new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); node_line = AllocateLine(); _Chain_Insert( line->Node.previous, &node_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); menu_items = 0; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( next_node->keyword == KEYWORD_END ) break; if ( Keywords[ next_node->keyword ].level == SECTION ) { LineCopySectionName( next_node, Buffer ); if ( !next_found ) { next_found = TRUE; sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } next_node = (Line_Control *) next_node->Node.next; } } else { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( !next_found ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } next_found = TRUE; } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopySectionName( next_node, MenuBuffer ); /* has next node */ if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s::", MenuBuffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); if ( !next_found ) { next_found = TRUE; strcpy( NextNodeName, MenuBuffer ); } } next_node = (Line_Control *) next_node->Node.next; } } if ( menu_items ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@end menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif /* node_line was previously inserted */ sprintf( node_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); strcpy( PreviousNodeName, NodeName ); break; case SUBSECTION: strcpy( UpNodeName, SectionName ); LineCopyFromRight( line, NodeName ); new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); next_node = (Line_Control *) line->Node.next; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopyFromRight( next_node, NextNodeName ); break; } next_node = (Line_Control *) next_node->Node.next; }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif new_line = AllocateLine(); sprintf( new_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); _Chain_Insert( line->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); strcpy( PreviousNodeName, NodeName ); break; } }bottom:} |
|
if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { LineCopyFromRight( line, ChapterName ); strcpy( UpNodeName, DocsUpNode ); strcpy( NodeName, ChapterName ); } else { LineCopySectionName( line, Buffer ); sprintf( NodeName, "%s %s", ChapterName, Buffer ); strcpy( UpNodeName, ChapterName ); } strcpy( SectionName, NodeName ); | if ( next_node->level == -1 ) goto continue_menu_loop; | void BuildTexinfoNodes( void ) { Line_Control *line; Line_Control *new_line; Line_Control *next_node; char Buffer[ BUFFER_SIZE ]; char ChapterName[ BUFFER_SIZE ]; char NodeName[ BUFFER_SIZE ]; char NextNode[ BUFFER_SIZE ]; char NextNodeName[ BUFFER_SIZE ]; char PreviousNodeName[ BUFFER_SIZE ]; char UpNodeName[ BUFFER_SIZE ]; char SectionName[ BUFFER_SIZE ]; char MenuBuffer[ BUFFER_SIZE ]; Line_Control *node_insert_point; Line_Control *menu_insert_point; Line_Control *node_line; boolean next_found; int menu_items; strcpy( PreviousNodeName, DocsPreviousNode ); for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { menu_insert_point = (Line_Control *) line->Node.next; switch ( Keywords[ line->keyword ].level ) { case TEXT: case HEADING: break; case SECTION: if ( line->keyword == KEYWORD_END ) goto bottom; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { LineCopyFromRight( line, ChapterName ); strcpy( UpNodeName, DocsUpNode ); strcpy( NodeName, ChapterName ); } else { LineCopySectionName( line, Buffer ); sprintf( NodeName, "%s %s", ChapterName, Buffer ); strcpy( UpNodeName, ChapterName ); } strcpy( SectionName, NodeName ); /* * Go ahead and put it on the chain in the right order (ahead of * the menu) and we can fill it in later (after the menu is built). */ new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); node_line = AllocateLine(); _Chain_Insert( line->Node.previous, &node_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); menu_items = 0; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( next_node->keyword == KEYWORD_END ) break; if ( Keywords[ next_node->keyword ].level == SECTION ) { LineCopySectionName( next_node, Buffer ); if ( !next_found ) { next_found = TRUE; sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } next_node = (Line_Control *) next_node->Node.next; } } else { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( !next_found ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } next_found = TRUE; } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopySectionName( next_node, MenuBuffer ); /* has next node */ if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s::", MenuBuffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); if ( !next_found ) { next_found = TRUE; strcpy( NextNodeName, MenuBuffer ); } } next_node = (Line_Control *) next_node->Node.next; } } if ( menu_items ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@end menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif /* node_line was previously inserted */ sprintf( node_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); strcpy( PreviousNodeName, NodeName ); break; case SUBSECTION: strcpy( UpNodeName, SectionName ); LineCopyFromRight( line, NodeName ); new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); next_node = (Line_Control *) line->Node.next; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopyFromRight( next_node, NextNodeName ); break; } next_node = (Line_Control *) next_node->Node.next; }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif new_line = AllocateLine(); sprintf( new_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); _Chain_Insert( line->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); strcpy( PreviousNodeName, NodeName ); break; } }bottom:} |
LineCopySectionName( next_node, Buffer ); if ( !next_found ) { next_found = TRUE; if (NodeNameIncludesChapter) sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); else sprintf( NextNodeName, "%s", Buffer ); } if ( next_node->level <= line->level ) break; if ( next_node->level != (line->level + 1) ) goto continue_menu_loop; if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); | void BuildTexinfoNodes( void ) { Line_Control *line; Line_Control *new_line; Line_Control *next_node; char Buffer[ BUFFER_SIZE ]; char ChapterName[ BUFFER_SIZE ]; char NodeName[ BUFFER_SIZE ]; char NextNode[ BUFFER_SIZE ]; char NextNodeName[ BUFFER_SIZE ]; char PreviousNodeName[ BUFFER_SIZE ]; char UpNodeName[ BUFFER_SIZE ]; char SectionName[ BUFFER_SIZE ]; char MenuBuffer[ BUFFER_SIZE ]; Line_Control *node_insert_point; Line_Control *menu_insert_point; Line_Control *node_line; boolean next_found; int menu_items; strcpy( PreviousNodeName, DocsPreviousNode ); for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { menu_insert_point = (Line_Control *) line->Node.next; switch ( Keywords[ line->keyword ].level ) { case TEXT: case HEADING: break; case SECTION: if ( line->keyword == KEYWORD_END ) goto bottom; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { LineCopyFromRight( line, ChapterName ); strcpy( UpNodeName, DocsUpNode ); strcpy( NodeName, ChapterName ); } else { LineCopySectionName( line, Buffer ); sprintf( NodeName, "%s %s", ChapterName, Buffer ); strcpy( UpNodeName, ChapterName ); } strcpy( SectionName, NodeName ); /* * Go ahead and put it on the chain in the right order (ahead of * the menu) and we can fill it in later (after the menu is built). */ new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); node_line = AllocateLine(); _Chain_Insert( line->Node.previous, &node_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); menu_items = 0; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( next_node->keyword == KEYWORD_END ) break; if ( Keywords[ next_node->keyword ].level == SECTION ) { LineCopySectionName( next_node, Buffer ); if ( !next_found ) { next_found = TRUE; sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } next_node = (Line_Control *) next_node->Node.next; } } else { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( !next_found ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } next_found = TRUE; } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopySectionName( next_node, MenuBuffer ); /* has next node */ if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s::", MenuBuffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); if ( !next_found ) { next_found = TRUE; strcpy( NextNodeName, MenuBuffer ); } } next_node = (Line_Control *) next_node->Node.next; } } if ( menu_items ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@end menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif /* node_line was previously inserted */ sprintf( node_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); strcpy( PreviousNodeName, NodeName ); break; case SUBSECTION: strcpy( UpNodeName, SectionName ); LineCopyFromRight( line, NodeName ); new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); next_node = (Line_Control *) line->Node.next; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopyFromRight( next_node, NextNodeName ); break; } next_node = (Line_Control *) next_node->Node.next; }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif new_line = AllocateLine(); sprintf( new_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); _Chain_Insert( line->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); strcpy( PreviousNodeName, NodeName ); break; } }bottom:} |
|
strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); | strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } | void BuildTexinfoNodes( void ) { Line_Control *line; Line_Control *new_line; Line_Control *next_node; char Buffer[ BUFFER_SIZE ]; char ChapterName[ BUFFER_SIZE ]; char NodeName[ BUFFER_SIZE ]; char NextNode[ BUFFER_SIZE ]; char NextNodeName[ BUFFER_SIZE ]; char PreviousNodeName[ BUFFER_SIZE ]; char UpNodeName[ BUFFER_SIZE ]; char SectionName[ BUFFER_SIZE ]; char MenuBuffer[ BUFFER_SIZE ]; Line_Control *node_insert_point; Line_Control *menu_insert_point; Line_Control *node_line; boolean next_found; int menu_items; strcpy( PreviousNodeName, DocsPreviousNode ); for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { menu_insert_point = (Line_Control *) line->Node.next; switch ( Keywords[ line->keyword ].level ) { case TEXT: case HEADING: break; case SECTION: if ( line->keyword == KEYWORD_END ) goto bottom; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { LineCopyFromRight( line, ChapterName ); strcpy( UpNodeName, DocsUpNode ); strcpy( NodeName, ChapterName ); } else { LineCopySectionName( line, Buffer ); sprintf( NodeName, "%s %s", ChapterName, Buffer ); strcpy( UpNodeName, ChapterName ); } strcpy( SectionName, NodeName ); /* * Go ahead and put it on the chain in the right order (ahead of * the menu) and we can fill it in later (after the menu is built). */ new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); node_line = AllocateLine(); _Chain_Insert( line->Node.previous, &node_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); menu_items = 0; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( next_node->keyword == KEYWORD_END ) break; if ( Keywords[ next_node->keyword ].level == SECTION ) { LineCopySectionName( next_node, Buffer ); if ( !next_found ) { next_found = TRUE; sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } next_node = (Line_Control *) next_node->Node.next; } } else { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( !next_found ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } next_found = TRUE; } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopySectionName( next_node, MenuBuffer ); /* has next node */ if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s::", MenuBuffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); if ( !next_found ) { next_found = TRUE; strcpy( NextNodeName, MenuBuffer ); } } next_node = (Line_Control *) next_node->Node.next; } } if ( menu_items ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@end menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif /* node_line was previously inserted */ sprintf( node_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); strcpy( PreviousNodeName, NodeName ); break; case SUBSECTION: strcpy( UpNodeName, SectionName ); LineCopyFromRight( line, NodeName ); new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); next_node = (Line_Control *) line->Node.next; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopyFromRight( next_node, NextNodeName ); break; } next_node = (Line_Control *) next_node->Node.next; }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif new_line = AllocateLine(); sprintf( new_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); _Chain_Insert( line->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); strcpy( PreviousNodeName, NodeName ); break; } }bottom:} |
node_line = AllocateLine(); _Chain_Insert( line->Node.previous, &node_line->Node ); | menu_items++; | void BuildTexinfoNodes( void ) { Line_Control *line; Line_Control *new_line; Line_Control *next_node; char Buffer[ BUFFER_SIZE ]; char ChapterName[ BUFFER_SIZE ]; char NodeName[ BUFFER_SIZE ]; char NextNode[ BUFFER_SIZE ]; char NextNodeName[ BUFFER_SIZE ]; char PreviousNodeName[ BUFFER_SIZE ]; char UpNodeName[ BUFFER_SIZE ]; char SectionName[ BUFFER_SIZE ]; char MenuBuffer[ BUFFER_SIZE ]; Line_Control *node_insert_point; Line_Control *menu_insert_point; Line_Control *node_line; boolean next_found; int menu_items; strcpy( PreviousNodeName, DocsPreviousNode ); for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { menu_insert_point = (Line_Control *) line->Node.next; switch ( Keywords[ line->keyword ].level ) { case TEXT: case HEADING: break; case SECTION: if ( line->keyword == KEYWORD_END ) goto bottom; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { LineCopyFromRight( line, ChapterName ); strcpy( UpNodeName, DocsUpNode ); strcpy( NodeName, ChapterName ); } else { LineCopySectionName( line, Buffer ); sprintf( NodeName, "%s %s", ChapterName, Buffer ); strcpy( UpNodeName, ChapterName ); } strcpy( SectionName, NodeName ); /* * Go ahead and put it on the chain in the right order (ahead of * the menu) and we can fill it in later (after the menu is built). */ new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); node_line = AllocateLine(); _Chain_Insert( line->Node.previous, &node_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); menu_items = 0; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( next_node->keyword == KEYWORD_END ) break; if ( Keywords[ next_node->keyword ].level == SECTION ) { LineCopySectionName( next_node, Buffer ); if ( !next_found ) { next_found = TRUE; sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } next_node = (Line_Control *) next_node->Node.next; } } else { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( !next_found ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } next_found = TRUE; } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopySectionName( next_node, MenuBuffer ); /* has next node */ if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s::", MenuBuffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); if ( !next_found ) { next_found = TRUE; strcpy( NextNodeName, MenuBuffer ); } } next_node = (Line_Control *) next_node->Node.next; } } if ( menu_items ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@end menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif /* node_line was previously inserted */ sprintf( node_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); strcpy( PreviousNodeName, NodeName ); break; case SUBSECTION: strcpy( UpNodeName, SectionName ); LineCopyFromRight( line, NodeName ); new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); next_node = (Line_Control *) line->Node.next; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopyFromRight( next_node, NextNodeName ); break; } next_node = (Line_Control *) next_node->Node.next; }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif new_line = AllocateLine(); sprintf( new_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); _Chain_Insert( line->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); strcpy( PreviousNodeName, NodeName ); break; } }bottom:} |
new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); | new_line = AllocateLine(); if (NodeNameIncludesChapter) sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer ); else sprintf( new_line->Contents, "* %s::", Buffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); | void BuildTexinfoNodes( void ) { Line_Control *line; Line_Control *new_line; Line_Control *next_node; char Buffer[ BUFFER_SIZE ]; char ChapterName[ BUFFER_SIZE ]; char NodeName[ BUFFER_SIZE ]; char NextNode[ BUFFER_SIZE ]; char NextNodeName[ BUFFER_SIZE ]; char PreviousNodeName[ BUFFER_SIZE ]; char UpNodeName[ BUFFER_SIZE ]; char SectionName[ BUFFER_SIZE ]; char MenuBuffer[ BUFFER_SIZE ]; Line_Control *node_insert_point; Line_Control *menu_insert_point; Line_Control *node_line; boolean next_found; int menu_items; strcpy( PreviousNodeName, DocsPreviousNode ); for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { menu_insert_point = (Line_Control *) line->Node.next; switch ( Keywords[ line->keyword ].level ) { case TEXT: case HEADING: break; case SECTION: if ( line->keyword == KEYWORD_END ) goto bottom; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { LineCopyFromRight( line, ChapterName ); strcpy( UpNodeName, DocsUpNode ); strcpy( NodeName, ChapterName ); } else { LineCopySectionName( line, Buffer ); sprintf( NodeName, "%s %s", ChapterName, Buffer ); strcpy( UpNodeName, ChapterName ); } strcpy( SectionName, NodeName ); /* * Go ahead and put it on the chain in the right order (ahead of * the menu) and we can fill it in later (after the menu is built). */ new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); node_line = AllocateLine(); _Chain_Insert( line->Node.previous, &node_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); menu_items = 0; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( next_node->keyword == KEYWORD_END ) break; if ( Keywords[ next_node->keyword ].level == SECTION ) { LineCopySectionName( next_node, Buffer ); if ( !next_found ) { next_found = TRUE; sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } next_node = (Line_Control *) next_node->Node.next; } } else { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( !next_found ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } next_found = TRUE; } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopySectionName( next_node, MenuBuffer ); /* has next node */ if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s::", MenuBuffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); if ( !next_found ) { next_found = TRUE; strcpy( NextNodeName, MenuBuffer ); } } next_node = (Line_Control *) next_node->Node.next; } } if ( menu_items ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@end menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif /* node_line was previously inserted */ sprintf( node_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); strcpy( PreviousNodeName, NodeName ); break; case SUBSECTION: strcpy( UpNodeName, SectionName ); LineCopyFromRight( line, NodeName ); new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); next_node = (Line_Control *) line->Node.next; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopyFromRight( next_node, NextNodeName ); break; } next_node = (Line_Control *) next_node->Node.next; }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif new_line = AllocateLine(); sprintf( new_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); _Chain_Insert( line->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); strcpy( PreviousNodeName, NodeName ); break; } }bottom:} |
menu_items = 0; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( next_node->keyword == KEYWORD_END ) break; if ( Keywords[ next_node->keyword ].level == SECTION ) { LineCopySectionName( next_node, Buffer ); if ( !next_found ) { next_found = TRUE; sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } | continue_menu_loop: next_node = (Line_Control *) next_node->Node.next; } | void BuildTexinfoNodes( void ) { Line_Control *line; Line_Control *new_line; Line_Control *next_node; char Buffer[ BUFFER_SIZE ]; char ChapterName[ BUFFER_SIZE ]; char NodeName[ BUFFER_SIZE ]; char NextNode[ BUFFER_SIZE ]; char NextNodeName[ BUFFER_SIZE ]; char PreviousNodeName[ BUFFER_SIZE ]; char UpNodeName[ BUFFER_SIZE ]; char SectionName[ BUFFER_SIZE ]; char MenuBuffer[ BUFFER_SIZE ]; Line_Control *node_insert_point; Line_Control *menu_insert_point; Line_Control *node_line; boolean next_found; int menu_items; strcpy( PreviousNodeName, DocsPreviousNode ); for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { menu_insert_point = (Line_Control *) line->Node.next; switch ( Keywords[ line->keyword ].level ) { case TEXT: case HEADING: break; case SECTION: if ( line->keyword == KEYWORD_END ) goto bottom; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { LineCopyFromRight( line, ChapterName ); strcpy( UpNodeName, DocsUpNode ); strcpy( NodeName, ChapterName ); } else { LineCopySectionName( line, Buffer ); sprintf( NodeName, "%s %s", ChapterName, Buffer ); strcpy( UpNodeName, ChapterName ); } strcpy( SectionName, NodeName ); /* * Go ahead and put it on the chain in the right order (ahead of * the menu) and we can fill it in later (after the menu is built). */ new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); node_line = AllocateLine(); _Chain_Insert( line->Node.previous, &node_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); menu_items = 0; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( next_node->keyword == KEYWORD_END ) break; if ( Keywords[ next_node->keyword ].level == SECTION ) { LineCopySectionName( next_node, Buffer ); if ( !next_found ) { next_found = TRUE; sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } next_node = (Line_Control *) next_node->Node.next; } } else { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( !next_found ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } next_found = TRUE; } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopySectionName( next_node, MenuBuffer ); /* has next node */ if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s::", MenuBuffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); if ( !next_found ) { next_found = TRUE; strcpy( NextNodeName, MenuBuffer ); } } next_node = (Line_Control *) next_node->Node.next; } } if ( menu_items ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@end menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif /* node_line was previously inserted */ sprintf( node_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); strcpy( PreviousNodeName, NodeName ); break; case SUBSECTION: strcpy( UpNodeName, SectionName ); LineCopyFromRight( line, NodeName ); new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); next_node = (Line_Control *) line->Node.next; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopyFromRight( next_node, NextNodeName ); break; } next_node = (Line_Control *) next_node->Node.next; }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif new_line = AllocateLine(); sprintf( new_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); _Chain_Insert( line->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); strcpy( PreviousNodeName, NodeName ); break; } }bottom:} |
if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); | void BuildTexinfoNodes( void ) { Line_Control *line; Line_Control *new_line; Line_Control *next_node; char Buffer[ BUFFER_SIZE ]; char ChapterName[ BUFFER_SIZE ]; char NodeName[ BUFFER_SIZE ]; char NextNode[ BUFFER_SIZE ]; char NextNodeName[ BUFFER_SIZE ]; char PreviousNodeName[ BUFFER_SIZE ]; char UpNodeName[ BUFFER_SIZE ]; char SectionName[ BUFFER_SIZE ]; char MenuBuffer[ BUFFER_SIZE ]; Line_Control *node_insert_point; Line_Control *menu_insert_point; Line_Control *node_line; boolean next_found; int menu_items; strcpy( PreviousNodeName, DocsPreviousNode ); for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { menu_insert_point = (Line_Control *) line->Node.next; switch ( Keywords[ line->keyword ].level ) { case TEXT: case HEADING: break; case SECTION: if ( line->keyword == KEYWORD_END ) goto bottom; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { LineCopyFromRight( line, ChapterName ); strcpy( UpNodeName, DocsUpNode ); strcpy( NodeName, ChapterName ); } else { LineCopySectionName( line, Buffer ); sprintf( NodeName, "%s %s", ChapterName, Buffer ); strcpy( UpNodeName, ChapterName ); } strcpy( SectionName, NodeName ); /* * Go ahead and put it on the chain in the right order (ahead of * the menu) and we can fill it in later (after the menu is built). */ new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); node_line = AllocateLine(); _Chain_Insert( line->Node.previous, &node_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); menu_items = 0; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( next_node->keyword == KEYWORD_END ) break; if ( Keywords[ next_node->keyword ].level == SECTION ) { LineCopySectionName( next_node, Buffer ); if ( !next_found ) { next_found = TRUE; sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } next_node = (Line_Control *) next_node->Node.next; } } else { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( !next_found ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } next_found = TRUE; } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopySectionName( next_node, MenuBuffer ); /* has next node */ if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s::", MenuBuffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); if ( !next_found ) { next_found = TRUE; strcpy( NextNodeName, MenuBuffer ); } } next_node = (Line_Control *) next_node->Node.next; } } if ( menu_items ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@end menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif /* node_line was previously inserted */ sprintf( node_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); strcpy( PreviousNodeName, NodeName ); break; case SUBSECTION: strcpy( UpNodeName, SectionName ); LineCopyFromRight( line, NodeName ); new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); next_node = (Line_Control *) line->Node.next; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopyFromRight( next_node, NextNodeName ); break; } next_node = (Line_Control *) next_node->Node.next; }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif new_line = AllocateLine(); sprintf( new_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); _Chain_Insert( line->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); strcpy( PreviousNodeName, NodeName ); break; } }bottom:} |
|
new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } | if ( menu_items ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@end menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); | void BuildTexinfoNodes( void ) { Line_Control *line; Line_Control *new_line; Line_Control *next_node; char Buffer[ BUFFER_SIZE ]; char ChapterName[ BUFFER_SIZE ]; char NodeName[ BUFFER_SIZE ]; char NextNode[ BUFFER_SIZE ]; char NextNodeName[ BUFFER_SIZE ]; char PreviousNodeName[ BUFFER_SIZE ]; char UpNodeName[ BUFFER_SIZE ]; char SectionName[ BUFFER_SIZE ]; char MenuBuffer[ BUFFER_SIZE ]; Line_Control *node_insert_point; Line_Control *menu_insert_point; Line_Control *node_line; boolean next_found; int menu_items; strcpy( PreviousNodeName, DocsPreviousNode ); for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { menu_insert_point = (Line_Control *) line->Node.next; switch ( Keywords[ line->keyword ].level ) { case TEXT: case HEADING: break; case SECTION: if ( line->keyword == KEYWORD_END ) goto bottom; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { LineCopyFromRight( line, ChapterName ); strcpy( UpNodeName, DocsUpNode ); strcpy( NodeName, ChapterName ); } else { LineCopySectionName( line, Buffer ); sprintf( NodeName, "%s %s", ChapterName, Buffer ); strcpy( UpNodeName, ChapterName ); } strcpy( SectionName, NodeName ); /* * Go ahead and put it on the chain in the right order (ahead of * the menu) and we can fill it in later (after the menu is built). */ new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); node_line = AllocateLine(); _Chain_Insert( line->Node.previous, &node_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); menu_items = 0; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( next_node->keyword == KEYWORD_END ) break; if ( Keywords[ next_node->keyword ].level == SECTION ) { LineCopySectionName( next_node, Buffer ); if ( !next_found ) { next_found = TRUE; sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } next_node = (Line_Control *) next_node->Node.next; } } else { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( !next_found ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } next_found = TRUE; } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopySectionName( next_node, MenuBuffer ); /* has next node */ if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s::", MenuBuffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); if ( !next_found ) { next_found = TRUE; strcpy( NextNodeName, MenuBuffer ); } } next_node = (Line_Control *) next_node->Node.next; } } if ( menu_items ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@end menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif /* node_line was previously inserted */ sprintf( node_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); strcpy( PreviousNodeName, NodeName ); break; case SUBSECTION: strcpy( UpNodeName, SectionName ); LineCopyFromRight( line, NodeName ); new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); next_node = (Line_Control *) line->Node.next; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopyFromRight( next_node, NextNodeName ); break; } next_node = (Line_Control *) next_node->Node.next; }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif new_line = AllocateLine(); sprintf( new_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); _Chain_Insert( line->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); strcpy( PreviousNodeName, NodeName ); break; } }bottom:} |
menu_items++; | new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } | void BuildTexinfoNodes( void ) { Line_Control *line; Line_Control *new_line; Line_Control *next_node; char Buffer[ BUFFER_SIZE ]; char ChapterName[ BUFFER_SIZE ]; char NodeName[ BUFFER_SIZE ]; char NextNode[ BUFFER_SIZE ]; char NextNodeName[ BUFFER_SIZE ]; char PreviousNodeName[ BUFFER_SIZE ]; char UpNodeName[ BUFFER_SIZE ]; char SectionName[ BUFFER_SIZE ]; char MenuBuffer[ BUFFER_SIZE ]; Line_Control *node_insert_point; Line_Control *menu_insert_point; Line_Control *node_line; boolean next_found; int menu_items; strcpy( PreviousNodeName, DocsPreviousNode ); for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { menu_insert_point = (Line_Control *) line->Node.next; switch ( Keywords[ line->keyword ].level ) { case TEXT: case HEADING: break; case SECTION: if ( line->keyword == KEYWORD_END ) goto bottom; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { LineCopyFromRight( line, ChapterName ); strcpy( UpNodeName, DocsUpNode ); strcpy( NodeName, ChapterName ); } else { LineCopySectionName( line, Buffer ); sprintf( NodeName, "%s %s", ChapterName, Buffer ); strcpy( UpNodeName, ChapterName ); } strcpy( SectionName, NodeName ); /* * Go ahead and put it on the chain in the right order (ahead of * the menu) and we can fill it in later (after the menu is built). */ new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); node_line = AllocateLine(); _Chain_Insert( line->Node.previous, &node_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); menu_items = 0; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( next_node->keyword == KEYWORD_END ) break; if ( Keywords[ next_node->keyword ].level == SECTION ) { LineCopySectionName( next_node, Buffer ); if ( !next_found ) { next_found = TRUE; sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } next_node = (Line_Control *) next_node->Node.next; } } else { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( !next_found ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } next_found = TRUE; } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopySectionName( next_node, MenuBuffer ); /* has next node */ if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s::", MenuBuffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); if ( !next_found ) { next_found = TRUE; strcpy( NextNodeName, MenuBuffer ); } } next_node = (Line_Control *) next_node->Node.next; } } if ( menu_items ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@end menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif /* node_line was previously inserted */ sprintf( node_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); strcpy( PreviousNodeName, NodeName ); break; case SUBSECTION: strcpy( UpNodeName, SectionName ); LineCopyFromRight( line, NodeName ); new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); next_node = (Line_Control *) line->Node.next; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopyFromRight( next_node, NextNodeName ); break; } next_node = (Line_Control *) next_node->Node.next; }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif new_line = AllocateLine(); sprintf( new_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); _Chain_Insert( line->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); strcpy( PreviousNodeName, NodeName ); break; } }bottom:} |
new_line = AllocateLine(); sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } next_node = (Line_Control *) next_node->Node.next; } } else { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( !next_found ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } next_found = TRUE; } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopySectionName( next_node, MenuBuffer ); | void BuildTexinfoNodes( void ) { Line_Control *line; Line_Control *new_line; Line_Control *next_node; char Buffer[ BUFFER_SIZE ]; char ChapterName[ BUFFER_SIZE ]; char NodeName[ BUFFER_SIZE ]; char NextNode[ BUFFER_SIZE ]; char NextNodeName[ BUFFER_SIZE ]; char PreviousNodeName[ BUFFER_SIZE ]; char UpNodeName[ BUFFER_SIZE ]; char SectionName[ BUFFER_SIZE ]; char MenuBuffer[ BUFFER_SIZE ]; Line_Control *node_insert_point; Line_Control *menu_insert_point; Line_Control *node_line; boolean next_found; int menu_items; strcpy( PreviousNodeName, DocsPreviousNode ); for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { menu_insert_point = (Line_Control *) line->Node.next; switch ( Keywords[ line->keyword ].level ) { case TEXT: case HEADING: break; case SECTION: if ( line->keyword == KEYWORD_END ) goto bottom; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { LineCopyFromRight( line, ChapterName ); strcpy( UpNodeName, DocsUpNode ); strcpy( NodeName, ChapterName ); } else { LineCopySectionName( line, Buffer ); sprintf( NodeName, "%s %s", ChapterName, Buffer ); strcpy( UpNodeName, ChapterName ); } strcpy( SectionName, NodeName ); /* * Go ahead and put it on the chain in the right order (ahead of * the menu) and we can fill it in later (after the menu is built). */ new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); node_line = AllocateLine(); _Chain_Insert( line->Node.previous, &node_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); menu_items = 0; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( next_node->keyword == KEYWORD_END ) break; if ( Keywords[ next_node->keyword ].level == SECTION ) { LineCopySectionName( next_node, Buffer ); if ( !next_found ) { next_found = TRUE; sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } next_node = (Line_Control *) next_node->Node.next; } } else { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( !next_found ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } next_found = TRUE; } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopySectionName( next_node, MenuBuffer ); /* has next node */ if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s::", MenuBuffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); if ( !next_found ) { next_found = TRUE; strcpy( NextNodeName, MenuBuffer ); } } next_node = (Line_Control *) next_node->Node.next; } } if ( menu_items ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@end menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif /* node_line was previously inserted */ sprintf( node_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); strcpy( PreviousNodeName, NodeName ); break; case SUBSECTION: strcpy( UpNodeName, SectionName ); LineCopyFromRight( line, NodeName ); new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); next_node = (Line_Control *) line->Node.next; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopyFromRight( next_node, NextNodeName ); break; } next_node = (Line_Control *) next_node->Node.next; }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif new_line = AllocateLine(); sprintf( new_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); _Chain_Insert( line->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); strcpy( PreviousNodeName, NodeName ); break; } }bottom:} |
|
new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } | if ( line->level == 0 ) { strcpy( UpNodeName, DocsUpNode ); } else { for ( up_node = line; up_node && !_Chain_Is_first((Chain_Node *)up_node) ; up_node = (Line_Control *) up_node->Node.previous ) { | void BuildTexinfoNodes( void ) { Line_Control *line; Line_Control *new_line; Line_Control *next_node; char Buffer[ BUFFER_SIZE ]; char ChapterName[ BUFFER_SIZE ]; char NodeName[ BUFFER_SIZE ]; char NextNode[ BUFFER_SIZE ]; char NextNodeName[ BUFFER_SIZE ]; char PreviousNodeName[ BUFFER_SIZE ]; char UpNodeName[ BUFFER_SIZE ]; char SectionName[ BUFFER_SIZE ]; char MenuBuffer[ BUFFER_SIZE ]; Line_Control *node_insert_point; Line_Control *menu_insert_point; Line_Control *node_line; boolean next_found; int menu_items; strcpy( PreviousNodeName, DocsPreviousNode ); for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { menu_insert_point = (Line_Control *) line->Node.next; switch ( Keywords[ line->keyword ].level ) { case TEXT: case HEADING: break; case SECTION: if ( line->keyword == KEYWORD_END ) goto bottom; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { LineCopyFromRight( line, ChapterName ); strcpy( UpNodeName, DocsUpNode ); strcpy( NodeName, ChapterName ); } else { LineCopySectionName( line, Buffer ); sprintf( NodeName, "%s %s", ChapterName, Buffer ); strcpy( UpNodeName, ChapterName ); } strcpy( SectionName, NodeName ); /* * Go ahead and put it on the chain in the right order (ahead of * the menu) and we can fill it in later (after the menu is built). */ new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); node_line = AllocateLine(); _Chain_Insert( line->Node.previous, &node_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); menu_items = 0; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( next_node->keyword == KEYWORD_END ) break; if ( Keywords[ next_node->keyword ].level == SECTION ) { LineCopySectionName( next_node, Buffer ); if ( !next_found ) { next_found = TRUE; sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } next_node = (Line_Control *) next_node->Node.next; } } else { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( !next_found ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } next_found = TRUE; } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopySectionName( next_node, MenuBuffer ); /* has next node */ if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s::", MenuBuffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); if ( !next_found ) { next_found = TRUE; strcpy( NextNodeName, MenuBuffer ); } } next_node = (Line_Control *) next_node->Node.next; } } if ( menu_items ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@end menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif /* node_line was previously inserted */ sprintf( node_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); strcpy( PreviousNodeName, NodeName ); break; case SUBSECTION: strcpy( UpNodeName, SectionName ); LineCopyFromRight( line, NodeName ); new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); next_node = (Line_Control *) line->Node.next; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopyFromRight( next_node, NextNodeName ); break; } next_node = (Line_Control *) next_node->Node.next; }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif new_line = AllocateLine(); sprintf( new_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); _Chain_Insert( line->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); strcpy( PreviousNodeName, NodeName ); break; } }bottom:} |
menu_items++; | if ( (up_node->level == -1) ) continue; if ( up_node->level == (line->level - 1) ) { LineCopySectionName( up_node, Buffer ); if (NodeNameIncludesChapter) sprintf( UpNodeName, "%s %s", ChapterName, Buffer ); else sprintf( UpNodeName, "%s", Buffer ); break; } } } | void BuildTexinfoNodes( void ) { Line_Control *line; Line_Control *new_line; Line_Control *next_node; char Buffer[ BUFFER_SIZE ]; char ChapterName[ BUFFER_SIZE ]; char NodeName[ BUFFER_SIZE ]; char NextNode[ BUFFER_SIZE ]; char NextNodeName[ BUFFER_SIZE ]; char PreviousNodeName[ BUFFER_SIZE ]; char UpNodeName[ BUFFER_SIZE ]; char SectionName[ BUFFER_SIZE ]; char MenuBuffer[ BUFFER_SIZE ]; Line_Control *node_insert_point; Line_Control *menu_insert_point; Line_Control *node_line; boolean next_found; int menu_items; strcpy( PreviousNodeName, DocsPreviousNode ); for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { menu_insert_point = (Line_Control *) line->Node.next; switch ( Keywords[ line->keyword ].level ) { case TEXT: case HEADING: break; case SECTION: if ( line->keyword == KEYWORD_END ) goto bottom; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { LineCopyFromRight( line, ChapterName ); strcpy( UpNodeName, DocsUpNode ); strcpy( NodeName, ChapterName ); } else { LineCopySectionName( line, Buffer ); sprintf( NodeName, "%s %s", ChapterName, Buffer ); strcpy( UpNodeName, ChapterName ); } strcpy( SectionName, NodeName ); /* * Go ahead and put it on the chain in the right order (ahead of * the menu) and we can fill it in later (after the menu is built). */ new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); node_line = AllocateLine(); _Chain_Insert( line->Node.previous, &node_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); menu_items = 0; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( next_node->keyword == KEYWORD_END ) break; if ( Keywords[ next_node->keyword ].level == SECTION ) { LineCopySectionName( next_node, Buffer ); if ( !next_found ) { next_found = TRUE; sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } next_node = (Line_Control *) next_node->Node.next; } } else { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( !next_found ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } next_found = TRUE; } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopySectionName( next_node, MenuBuffer ); /* has next node */ if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s::", MenuBuffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); if ( !next_found ) { next_found = TRUE; strcpy( NextNodeName, MenuBuffer ); } } next_node = (Line_Control *) next_node->Node.next; } } if ( menu_items ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@end menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif /* node_line was previously inserted */ sprintf( node_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); strcpy( PreviousNodeName, NodeName ); break; case SUBSECTION: strcpy( UpNodeName, SectionName ); LineCopyFromRight( line, NodeName ); new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); next_node = (Line_Control *) line->Node.next; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopyFromRight( next_node, NextNodeName ); break; } next_node = (Line_Control *) next_node->Node.next; }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif new_line = AllocateLine(); sprintf( new_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); _Chain_Insert( line->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); strcpy( PreviousNodeName, NodeName ); break; } }bottom:} |
new_line = AllocateLine(); sprintf( new_line->Contents, "* %s::", MenuBuffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); if ( !next_found ) { next_found = TRUE; strcpy( NextNodeName, MenuBuffer ); } } next_node = (Line_Control *) next_node->Node.next; } } if ( menu_items ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@end menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } #if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); #endif sprintf( node_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); strcpy( PreviousNodeName, NodeName ); break; case SUBSECTION: strcpy( UpNodeName, SectionName ); LineCopyFromRight( line, NodeName ); new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); next_node = (Line_Control *) line->Node.next; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopyFromRight( next_node, NextNodeName ); break; } next_node = (Line_Control *) next_node->Node.next; } | void BuildTexinfoNodes( void ) { Line_Control *line; Line_Control *new_line; Line_Control *next_node; char Buffer[ BUFFER_SIZE ]; char ChapterName[ BUFFER_SIZE ]; char NodeName[ BUFFER_SIZE ]; char NextNode[ BUFFER_SIZE ]; char NextNodeName[ BUFFER_SIZE ]; char PreviousNodeName[ BUFFER_SIZE ]; char UpNodeName[ BUFFER_SIZE ]; char SectionName[ BUFFER_SIZE ]; char MenuBuffer[ BUFFER_SIZE ]; Line_Control *node_insert_point; Line_Control *menu_insert_point; Line_Control *node_line; boolean next_found; int menu_items; strcpy( PreviousNodeName, DocsPreviousNode ); for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { menu_insert_point = (Line_Control *) line->Node.next; switch ( Keywords[ line->keyword ].level ) { case TEXT: case HEADING: break; case SECTION: if ( line->keyword == KEYWORD_END ) goto bottom; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { LineCopyFromRight( line, ChapterName ); strcpy( UpNodeName, DocsUpNode ); strcpy( NodeName, ChapterName ); } else { LineCopySectionName( line, Buffer ); sprintf( NodeName, "%s %s", ChapterName, Buffer ); strcpy( UpNodeName, ChapterName ); } strcpy( SectionName, NodeName ); /* * Go ahead and put it on the chain in the right order (ahead of * the menu) and we can fill it in later (after the menu is built). */ new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); node_line = AllocateLine(); _Chain_Insert( line->Node.previous, &node_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); menu_items = 0; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( next_node->keyword == KEYWORD_END ) break; if ( Keywords[ next_node->keyword ].level == SECTION ) { LineCopySectionName( next_node, Buffer ); if ( !next_found ) { next_found = TRUE; sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } next_node = (Line_Control *) next_node->Node.next; } } else { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( !next_found ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } next_found = TRUE; } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopySectionName( next_node, MenuBuffer ); /* has next node */ if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s::", MenuBuffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); if ( !next_found ) { next_found = TRUE; strcpy( NextNodeName, MenuBuffer ); } } next_node = (Line_Control *) next_node->Node.next; } } if ( menu_items ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@end menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif /* node_line was previously inserted */ sprintf( node_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); strcpy( PreviousNodeName, NodeName ); break; case SUBSECTION: strcpy( UpNodeName, SectionName ); LineCopyFromRight( line, NodeName ); new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); next_node = (Line_Control *) line->Node.next; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopyFromRight( next_node, NextNodeName ); break; } next_node = (Line_Control *) next_node->Node.next; }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif new_line = AllocateLine(); sprintf( new_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); _Chain_Insert( line->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); strcpy( PreviousNodeName, NodeName ); break; } }bottom:} |
|
new_line = AllocateLine(); sprintf( new_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); _Chain_Insert( line->Node.previous, &new_line->Node ); | void BuildTexinfoNodes( void ) { Line_Control *line; Line_Control *new_line; Line_Control *next_node; char Buffer[ BUFFER_SIZE ]; char ChapterName[ BUFFER_SIZE ]; char NodeName[ BUFFER_SIZE ]; char NextNode[ BUFFER_SIZE ]; char NextNodeName[ BUFFER_SIZE ]; char PreviousNodeName[ BUFFER_SIZE ]; char UpNodeName[ BUFFER_SIZE ]; char SectionName[ BUFFER_SIZE ]; char MenuBuffer[ BUFFER_SIZE ]; Line_Control *node_insert_point; Line_Control *menu_insert_point; Line_Control *node_line; boolean next_found; int menu_items; strcpy( PreviousNodeName, DocsPreviousNode ); for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { menu_insert_point = (Line_Control *) line->Node.next; switch ( Keywords[ line->keyword ].level ) { case TEXT: case HEADING: break; case SECTION: if ( line->keyword == KEYWORD_END ) goto bottom; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { LineCopyFromRight( line, ChapterName ); strcpy( UpNodeName, DocsUpNode ); strcpy( NodeName, ChapterName ); } else { LineCopySectionName( line, Buffer ); sprintf( NodeName, "%s %s", ChapterName, Buffer ); strcpy( UpNodeName, ChapterName ); } strcpy( SectionName, NodeName ); /* * Go ahead and put it on the chain in the right order (ahead of * the menu) and we can fill it in later (after the menu is built). */ new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); node_line = AllocateLine(); _Chain_Insert( line->Node.previous, &node_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); menu_items = 0; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( next_node->keyword == KEYWORD_END ) break; if ( Keywords[ next_node->keyword ].level == SECTION ) { LineCopySectionName( next_node, Buffer ); if ( !next_found ) { next_found = TRUE; sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } next_node = (Line_Control *) next_node->Node.next; } } else { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( !next_found ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } next_found = TRUE; } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopySectionName( next_node, MenuBuffer ); /* has next node */ if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s::", MenuBuffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); if ( !next_found ) { next_found = TRUE; strcpy( NextNodeName, MenuBuffer ); } } next_node = (Line_Control *) next_node->Node.next; } } if ( menu_items ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@end menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif /* node_line was previously inserted */ sprintf( node_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); strcpy( PreviousNodeName, NodeName ); break; case SUBSECTION: strcpy( UpNodeName, SectionName ); LineCopyFromRight( line, NodeName ); new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); next_node = (Line_Control *) line->Node.next; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopyFromRight( next_node, NextNodeName ); break; } next_node = (Line_Control *) next_node->Node.next; }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif new_line = AllocateLine(); sprintf( new_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); _Chain_Insert( line->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); strcpy( PreviousNodeName, NodeName ); break; } }bottom:} |
|
new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); | sprintf( node_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); | void BuildTexinfoNodes( void ) { Line_Control *line; Line_Control *new_line; Line_Control *next_node; char Buffer[ BUFFER_SIZE ]; char ChapterName[ BUFFER_SIZE ]; char NodeName[ BUFFER_SIZE ]; char NextNode[ BUFFER_SIZE ]; char NextNodeName[ BUFFER_SIZE ]; char PreviousNodeName[ BUFFER_SIZE ]; char UpNodeName[ BUFFER_SIZE ]; char SectionName[ BUFFER_SIZE ]; char MenuBuffer[ BUFFER_SIZE ]; Line_Control *node_insert_point; Line_Control *menu_insert_point; Line_Control *node_line; boolean next_found; int menu_items; strcpy( PreviousNodeName, DocsPreviousNode ); for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { menu_insert_point = (Line_Control *) line->Node.next; switch ( Keywords[ line->keyword ].level ) { case TEXT: case HEADING: break; case SECTION: if ( line->keyword == KEYWORD_END ) goto bottom; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { LineCopyFromRight( line, ChapterName ); strcpy( UpNodeName, DocsUpNode ); strcpy( NodeName, ChapterName ); } else { LineCopySectionName( line, Buffer ); sprintf( NodeName, "%s %s", ChapterName, Buffer ); strcpy( UpNodeName, ChapterName ); } strcpy( SectionName, NodeName ); /* * Go ahead and put it on the chain in the right order (ahead of * the menu) and we can fill it in later (after the menu is built). */ new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); node_line = AllocateLine(); _Chain_Insert( line->Node.previous, &node_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); menu_items = 0; if ( line->keyword == KEYWORD_CHAPTER || line->keyword == KEYWORD_CHAPHEADING ) { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( next_node->keyword == KEYWORD_END ) break; if ( Keywords[ next_node->keyword ].level == SECTION ) { LineCopySectionName( next_node, Buffer ); if ( !next_found ) { next_found = TRUE; sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s %s::", ChapterName, Buffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } next_node = (Line_Control *) next_node->Node.next; } } else { next_node = (Line_Control *) line->Node.next; next_found = FALSE; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( !next_found ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } next_found = TRUE; } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopySectionName( next_node, MenuBuffer ); /* has next node */ if ( menu_items == 0 ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); } menu_items++; new_line = AllocateLine(); sprintf( new_line->Contents, "* %s::", MenuBuffer ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); if ( !next_found ) { next_found = TRUE; strcpy( NextNodeName, MenuBuffer ); } } next_node = (Line_Control *) next_node->Node.next; } } if ( menu_items ) { new_line = AllocateLine(); strcpy( new_line->Contents, "@end menu" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( menu_insert_point->Node.previous, &new_line->Node ); }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif /* node_line was previously inserted */ sprintf( node_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); strcpy( PreviousNodeName, NodeName ); break; case SUBSECTION: strcpy( UpNodeName, SectionName ); LineCopyFromRight( line, NodeName ); new_line = AllocateLine(); strcpy( new_line->Contents, "@ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); next_node = (Line_Control *) line->Node.next; for ( ; ; ) { if ( Keywords[ next_node->keyword ].level == SECTION ) { if ( next_node->keyword == KEYWORD_END ) { strcpy( NextNodeName, DocsNextNode ); } else { LineCopySectionName( next_node, Buffer ); sprintf( NextNodeName, "%s %s", ChapterName, Buffer ); } break; } else if ( Keywords[ next_node->keyword ].level == SUBSECTION ) { LineCopyFromRight( next_node, NextNodeName ); break; } next_node = (Line_Control *) next_node->Node.next; }#if 0 fprintf( stderr, "@node %s, %s, %s, %s\n", NodeName, NextNodeName, PreviousNodeName, UpNodeName );#endif new_line = AllocateLine(); sprintf( new_line->Contents, "@node %s, %s, %s, %s", NodeName, NextNodeName, PreviousNodeName, UpNodeName ); _Chain_Insert( line->Node.previous, &new_line->Node ); new_line = AllocateLine(); strcpy( new_line->Contents, "@end ifinfo" ); _Chain_Insert( line->Node.previous, &new_line->Node ); strcpy( PreviousNodeName, NodeName ); break; } }bottom:} |