Lines Matching defs:sum

27 "[-1lp0s5P?\n@(#)$Id: sum (AT&T Research) 2011-08-23 $\n]"
29 "[+PLUGIN?sum - sort uniq summary discipline]"
53 "[+sum (s)?sum]"
63 "[+sort -k.2.1 -lsum,op=sum::integer::.6.2?Sorts on the 1 byte "
65 "and computes the sum of the integers in the 2 byte fixed width "
73 "\n\n--library=sum[,option[=value]...]\n\n"
127 Summary_t* sum;
159 register Summary_t* sum;
189 for (sum = state->sum; sum; sum = sum->next)
191 while (beg < sum->beg.field)
215 if (sum->beg.index < (e - s))
217 a = s + sum->beg.index;
218 while (end < sum->end.field)
242 if (!sum->end.index)
264 else if (sum->end.index <= (e - s))
265 z = s + sum->end.index;
272 if (!sum->width)
273 sum->format.width = RECTYPE(state->fmt) == REC_fixed ? w : (!(sum->format.flags & CX_FLOAT) || sum->end.index || w >= 8) ? 0 : 8;
274 if (map = sum->map)
278 map = sum->pam;
284 if (sum->op == 'v' || (*sum->type->internalf)(cx, sum->type, NiL, &sum->format, &v, (char*)x, w, cx->rm, cx->disc) < 0)
286 else if (state->regress && (sum->format.flags & CX_FLOAT))
294 sum->value = v.value.number;
295 sum->count = 1;
301 switch (sum->op)
304 sum->value += v.value.number;
305 sum->count += count;
311 if (sum->value < v.value.number)
312 sum->value = v.value.number;
315 if (sum->value > v.value.number)
316 sum->value = v.value.number;
319 sum->value += v.value.number;
324 v.value.number = sum->value;
325 switch (sum->op)
328 v.value.number /= sum->count;
332 *a++ = sum->set;
340 if ((n = (*sum->type->externalf)(cx, sum->type, NiL, &sum->format, &v.value, (char*)state->tmp.buf, y, cx->disc)) < 0)
342 error(2, "%s value %I*g conversion error", sum->type->name, sizeof(v.value.number), v.value.number);
350 if (sum->end.index || RECTYPE(state->fmt) == REC_fixed)
352 error(2, "%s value %I*g width exceeds %d", sum->type->name, sizeof(v.value.number), v.value.number, w);
370 c = (sum->type->format.flags & CX_BINARY) ? 0 : map[' '];
380 c = (sum->type->format.flags & CX_BINARY) ? 0 : ' ';
421 register Summary_t* sum;
473 if (!(sum = vmnewof(dss->vm, 0, Summary_t, 1, 0)))
475 sum->beg.field = -1;
478 sum->type = def->type;
479 sum->format = def->format;
480 sum->op = def->op;
481 sum->set = def->set;
484 sum->format.code = key->code;
485 def = sum;
498 pos = &sum->beg;
501 else if (pos == &sum->beg)
503 pos = &sum->end;
532 if (pos == &sum->beg)
539 sum->end.field = sum->beg.field;
540 sum->end.index = sum->beg.index + n;
588 sum->format.code = n;
604 switch (sum->op = *s++)
611 sum->op = 'm';
615 sum->op = 'M';
620 sum->op = 'v';
631 sum->set = chresc(s, &s);
642 if (type = cxattr(dss->cx, s, &t, &sum->format, dss->cx->disc))
645 sum->type = type;
646 sum->width = sum->format.width;
661 if (sum->beg.field < 0)
666 if (!sum->type)
667 sum->type = cxattr(dss->cx, "integer", NiL, &sum->format, dss->cx->disc);
668 for (prv = 0, cur = state->sum; cur; cur = (prv = cur)->next)
669 if (sum->beg.field < cur->beg.field || sum->beg.field == cur->beg.field && sum->end.field < cur->end.field)
672 prv->next = sum;
674 state->sum = sum;
675 sum->next = cur;
705 for (sum = state->sum; sum; sum = sum->next)
706 if (sum->format.code)
708 if (!CCCONVERT(sum->format.code))
710 if (sum->format.code == CC_NATIVE || (sum->type->format.flags & CX_BINARY))
711 sum->format.code = 0;
713 sum->format.code = CCOP(sum->format.code, CC_NATIVE);
715 if (sum->format.code)
717 sum->map = ccmap(CCIN(sum->format.code), CCOUT(sum->format.code));
718 sum->pam = ccmap(CCOUT(sum->format.code), CCIN(sum->format.code));
722 for (n = 1, sum = state->sum; sum; n++, sum = sum->next)
725 if (sum->beg.field == sum->end.field)
726 sfprintf(sfstderr, ".%d.%d", sum->beg.index + 1, sum->end.index - sum->beg.index);
728 sfprintf(sfstderr, "%d.%d,%d.%d", sum->beg.field + 1, sum->beg.index + 1, sum->end.field + 1, sum->end.index);
729 sfprintf(sfstderr, " %c", sum->op);
730 if (sum->format.code)
731 sfprintf(sfstderr, " %d=>%d ", CCIN(sum->format.code), CCOUT(sum->format.code));
734 if (sum->op == 'v')
736 chr = sum->set;
740 sfprintf(sfstderr, "%s", sum->type->name);
749 SORTLIB(sum)