Lines Matching refs:pp

67  * return the next partition after pp
68 * first call should set pp to 0
73 pzpartnext(Pz_t* pz, Pzpart_t* pp)
76 return pp ? (Pzpart_t*)dtnext(pz->partdict, pp) : (Pzpart_t*)dtfirst(pz->partdict);
77 return pp ? (Pzpart_t*)0 : pz->mainpart;
81 * set the current partition to pp
86 pzpartset(Pz_t* pz, Pzpart_t* pp)
94 pz->part = pp;
107 range(Pz_t* pz, register Pzpart_t* pp, char* s, char** p, int* beg, int* end)
125 if (pp && n >= pp->row)
128 (*pz->disc->errorf)(pz, pz->disc, 2, "column %d is larger than row %d", n, pp->row);
138 m = (pp ? pp->row : INT_MAX) - 1;
143 if (m < n || pp && m >= pp->row)
200 fixed(Pz_t* pz, register Pzpart_t* pp, int n, int m, int k)
205 if (!pp->value)
207 if (!(pp->value = vmnewof(pz->vm, 0, int, pp->row, 0)))
209 for (i = 0; i < pp->row; i++)
210 pp->value[i] = -1;
215 if (pp->value[n] < 0)
216 pp->nfix++;
219 pp->value[n] = v;
225 * initialize the partition map from pp.{<map,nmap>,<grp,ngrp>}
229 pzpartmap(Pz_t* pz, register Pzpart_t* pp)
236 for (i = 0; i < pp->ngrp; i++)
237 for (j = 0; j < pp->grp[i]; j++)
239 if (k >= pp->nmap)
245 pp->lab[k] = i;
246 pp->inc[k++] = pp->grp[i];
248 if (k != pp->nmap)
254 memset(pp->low, 1, pp->row);
255 for (i = 0; i < pp->nmap; i++)
256 pp->low[pp->map[i]] = 0;
257 for (i = 0; i < pp->nfix; i++)
258 pp->low[pp->fix[i]] = 0;
259 if ((pz->flags & PZ_READ) && pp->value)
260 for (i = j = 0; i < pp->nmap; i++)
261 if (pp->value[i] < 0)
262 pp->map[j++] = pp->map[i];
263 pp->flags |= PZ_UPDATE;
272 pzpartinit(Pz_t* pz, Pzpart_t* pp, const char* name)
284 if (!pp->row)
290 if (!pp->name)
293 sfprintf(pz->tmp, "%s:%d:%d", PZ_PART_SUF, pp->row, pp->nmap);
304 if (!(s = sfstruse(pz->tmp)) || !(pp->name = vmstrdup(pz->vm, s)))
307 if (!pp->nmap)
309 pp->nmap = pp->row;
310 if (!(pp->map = vmnewof(pz->vm, pp->map, size_t, VECTOR(pz, pp, pp->nmap), 0)))
312 for (i = 0; i < pp->nmap; i++)
313 pp->map[i] = i;
315 if (!pp->ngrp)
317 pp->ngrp = 1;
318 if (!(pp->grp = vmnewof(pz->vm, pp->grp, size_t, VECTOR(pz, pp, pp->ngrp), 0)))
320 pp->grp[0] = pp->row;
322 pp->loq = ((pz->win / 8 / pp->row) + 8) * pp->row;
323 k = VECTOR(pz, pp, pp->nmap);
324 if (!(pp->low = vmnewof(pz->vm, 0, unsigned char, pp->row, 0)) ||
325 !(pp->mix = vmnewof(pz->vm, 0, unsigned char*, k, 0)) ||
326 !(pp->inc = vmnewof(pz->vm, 0, size_t, k, 0)) ||
327 !(pp->lab = vmnewof(pz->vm, 0, size_t, k, 0)))
329 if (pp->nfix)
331 if (!(pp->fix = vmnewof(pz->vm, 0, size_t, VECTOR(pz, pp, pp->nfix), 0)))
333 for (i = k = 0; i < pp->row; i++)
334 if (pp->value[i] >= 0)
335 pp->fix[k++] = i;
337 if (pzpartmap(pz, pp))
339 if (!(j = pp->nmap))
341 k = pp->row * j;
342 pp->col = ((pz->win / k) * k) / j;
348 if (pp->row > pz->mrow)
350 m = pz->mrow = roundof(pp->row, 1024);
377 n = pp->nfix;
378 pz->part = pp;
379 if (pz->options && pzoptions(pz, pp, pz->options, 0))
381 if (pz->disc->eventf && (*pz->disc->eventf)(pz, PZ_PARTITION, pp, 0, pz->disc) < 0)
383 if (pp->flags & PZ_VARIABLE)
385 if (pp->nfix != n)
387 if (!(pp->fix = vmnewof(pz->vm, pp->fix, size_t, VECTOR(pz, pp, pp->nfix), 0)))
389 for (i = k = 0; i < pp->row; i++)
390 if (pp->value[i] >= 0)
391 pp->low[pp->fix[k++] = i] = 0;
414 dtinsert(pz->partdict, pp);
418 pz->mainpart = pp;
423 pzpartprint(pz, pp, sfstderr);
432 pzoptions(register Pz_t* pz, register Pzpart_t* pp, char* options, int must)
453 switch (range(pz, pp, s, &e, &n, &x))
464 if (pp && fixed(pz, pp, n, x, k))
495 pz->part = pp;
690 register Pzpart_t* pp;
782 pp = 0;
819 if (pzoptions(pz, pp, s, 1))
871 if (!(pp = vmnewof(pz->vm, 0, Pzpart_t, 1, 0)))
873 pp->row = n;
874 pp->flags = f;
877 pp->name = np;
880 if (!(cv = vmnewof(vm, 0, int, (pp->row + 1) * 4, 0)))
883 ce = hv = cv + (pp->row + 1) * 2;
884 gv = hv + pp->row + 1;
897 if (pzoptions(pz, pp, s, 1))
904 if (range(pz, pp, s, &e, &n, &x) <= 0)
916 if (fixed(pz, pp, n, x, k))
927 if (!pp->value || pp->value[n] < 0)
966 pp->nmap = m;
967 if (!(pp->ngrp = g))
968 pp->ngrp = 1;
969 if (!(pp->map = vmnewof(pz->vm, 0, size_t, VECTOR(pz, pp, pp->nmap), 0)) ||
970 !(pp->grp = vmnewof(pz->vm, 0, size_t, VECTOR(pz, pp, pp->ngrp), 0)))
981 pp->grp[g] = k;
985 pp->map[m] = i;
989 pp->grp[g] = k;
990 if (pzpartinit(pz, pp, partition))
999 if (!(pp = pzpartget(pz, pz->partname)))
1006 pz->part = pz->mainpart = pp;
1036 array(register Pz_t* pz, Pzpart_t* pp, size_t** pv, size_t* pn, size_t check)
1049 else if (!(v = vmnewof(pz->vm, *pv, size_t, VECTOR(pz, pp, n), 0)))
1077 buffer(register Pz_t* pz, Pzpart_t* pp, char** pv, size_t* pn)
1109 register Pzpart_t* pp;
1121 if (!(pp = vmnewof(pz->vm, 0, Pzpart_t, 1, 0)))
1125 pp->row = sfgetu(pz->io);
1126 pp->col = sfgetu(pz->io);
1137 if (!po && pzpartinit(pz, pp, NiL))
1141 buffer(pz, pp, (char**)&pz->disc->comment, NiL);
1144 if (array(pz, pp, &pp->fix, &pp->nfix, pp->row))
1146 if (!pp->value)
1148 if (!(pp->value = vmnewof(pz->vm, 0, int, pp->row, 0)))
1150 for (i = 0; i < pp->row; i++)
1151 pp->value[i] = -1;
1153 for (i = 0; i < pp->nfix; i++)
1154 if (pp->value[pp->fix[i]] < 0)
1155 pp->value[pp->fix[i]] = ' ';
1158 if (array(pz, pp, &pp->grp, &pp->ngrp, pp->row + 1))
1162 if (array(pz, pp, &pp->map, &pp->nmap, pp->row))
1166 buffer(pz, pp, (char**)&pz->headoptions, NiL);
1169 buffer(pz, pp, &pz->prefix.data, &pz->prefix.count);
1173 if (pp->row)
1175 if (!po && pzpartinit(pz, pp, NiL))
1177 if (pp = pz->freepart)
1179 else if (!(pp = vmnewof(pz->vm, 0, Pzpart_t, 1, 0)))
1182 buffer(pz, pp, (char**)&pp->name, NiL);
1183 pp->row = sfgetu(pz->io);
1184 pp->col = sfgetu(pz->io);
1185 if (pz->partdict && (po = (Pzpart_t*)dtsearch(pz->partdict, pp)) || (po = pz->mainpart) && streq(pp->name, po->name))
1187 if (pp->row != po->row || pp->col != po->col)
1190 (*pz->disc->errorf)(pz, pz->disc, 1, "%s: %s: partition redefinition ignored", pz->path, pp->name);
1193 sfprintf(sfstderr, "\n# %s benign redefinition\n", pp->name);
1194 vmfree(pz->vm, pp->name);
1195 pz->freepart = pp;
1196 pp->name = 0;
1197 pp = po;
1210 array(pz, pp, NiL, NiL, 0);
1212 buffer(pz, pp, NiL, NiL);
1224 array(pz, pp, &pz->split.data, &pz->split.size, 0);
1230 array(pz, pp, NiL, NiL, 0);
1232 buffer(pz, pp, NiL, NiL);
1253 register Pzpart_t* pp;
1262 pp = pz->mainpart;
1267 pp = (Pzpart_t*)dtfirst(pz->partdict);
1272 pp = pz->part;
1274 while (pp)
1276 if ((pp->flags & (PZ_UPDATE|PZ_HEAD)) == PZ_UPDATE)
1278 pp->flags |= PZ_HEAD;
1280 m = strlen(pp->name) + 1;
1282 sfwrite(op, pp->name, m);
1283 sfputu(op, pp->row);
1284 sfputu(op, pp->col);
1285 if (pp->nmap != pp->row || pp->ngrp != 1)
1288 sfputu(op, pp->nmap);
1289 for (i = 0; i < pp->nmap; i++)
1290 sfputu(op, pp->map[i]);
1292 sfputu(op, pp->ngrp);
1293 for (i = 0; i < pp->ngrp; i++)
1294 sfputu(op, pp->grp[i]);
1296 if (pp->nfix)
1299 sfputu(op, pp->nfix);
1300 for (i = 0; i < pp->nfix; i++)
1301 sfputu(op, pp->fix[i]);
1312 pp = (Pzpart_t*)dtnext(pz->partdict, pp);
1319 * pretty print pp on op
1323 pzpartprint(Pz_t* pz, register Pzpart_t* pp, register Sfio_t* op)
1331 sfprintf(op, "\n\"%s\"\n", pp->name);
1332 sfprintf(op, "\n%I*u\t# high frequency %I*u\n", sizeof(pp->row), pp->row, sizeof(pp->nmap), pp->nmap);
1333 if (pp->nfix)
1337 for (i = 0; i < pp->nfix; i++)
1339 for (j = i + 1; j < pp->nfix && pp->fix[j] == pp->fix[j - 1] + 1 && pp->value[pp->fix[j]] == pp->value[pp->fix[j - 1]]; j++);
1340 sfprintf(op, "%I*u", sizeof(pp->fix[i]), pp->fix[i]);
1344 sfprintf(op, "-%I*u", sizeof(pp->fix[i]), pp->fix[i]);
1346 s = fmtesc((esc[0] = pp->value[pp->fix[i]], esc));
1352 for (i = 0; i < pp->nmap; i++)
1354 if (g != pp->lab[i])
1356 g = pp->lab[i];
1361 for (j = i + 1; j < pp->nmap && pp->map[j] == pp->map[j - 1] + 1 && pp->lab[j] == g; j++);
1362 sfprintf(op, "%I*u", sizeof(pp->map[i]), pp->map[i]);
1366 sfprintf(op, "-%I*u", sizeof(pp->map[i]), pp->map[i]);