summaryrefslogtreecommitdiff
path: root/print.c
diff options
context:
space:
mode:
Diffstat (limited to 'print.c')
-rw-r--r--print.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/print.c b/print.c
index 232fc54..075d372 100644
--- a/print.c
+++ b/print.c
@@ -48,28 +48,28 @@ ppdatums(Datum **ds, int n)
Rune *
pparray(Array *a)
{
- Rune **elemstrs = emalloc(sizeof(Rune *) * a->size);
+ Rune **elemstrs = emalloc(sizeof(Rune *) * GetSize(a));
int rowcount = 1;
- if(a->rank > 0){
- for(int i = 0; i < a->rank-1; i++)
+ if(GetRank(a) > 0){
+ for(int i = 0; i < GetRank(a)-1; i++)
rowcount *= a->shape[i];
}
Rune **rowstrs = emallocz(sizeof(Rune *) * rowcount, 1);
int boxing = !simplearray(a);
- char *align = a->type == AtypeArray ? "-" : "";
- for(int i = 0; i < a->size; i++){
- if(a->type == AtypeArray){
+ char *align = GetType(a) == AtypeArray ? "-" : "";
+ for(int i = 0; i < GetSize(a); i++){
+ if(GetType(a) == AtypeArray){
Rune *arrstr = pparray(a->arraydata[i]);
elemstrs[i] = runesmprint("%S", arrstr);
free(arrstr);
}else{
Array *e = arrayitem(a, i); /* a scalar */
- if(e->type == AtypeInt)
+ if(GetType(e) == AtypeInt)
elemstrs[i] = runesmprint("%lld", e->intdata[0]);
- else if(e->type == AtypeRune)
+ else if(GetType(e) == AtypeRune)
elemstrs[i] = runesmprint("%C", e->runedata[0]);
- else if(e->type == AtypeFloat){
+ else if(GetType(e) == AtypeFloat){
char *fmt = smprint("%%.%df", printprecision);
elemstrs[i] = runesmprint(fmt, e->floatdata[0]);
free(fmt);
@@ -82,17 +82,17 @@ pparray(Array *a)
}
}
- if(elemstrs[i][0] == '-' && (e->type == AtypeInt || e->type == AtypeFloat))
+ if(elemstrs[i][0] == '-' && (GetType(e) == AtypeInt || GetType(e) == AtypeFloat))
elemstrs[i][0] = L'¯';
freearray(e);
}
}
- int lastdim = a->rank ? a->shape[a->rank-1] : 1;
+ int lastdim = GetRank(a) ? a->shape[GetRank(a)-1] : 1;
int *widths = emallocz(sizeof(int) * lastdim, 1);
int *heights = emallocz(sizeof(int) * rowcount, 1);
- for(int i = 0; i < a->size; i++){
+ for(int i = 0; i < GetSize(a); i++){
int w,h;
strdims(elemstrs[i], &w, &h);
if(w > widths[i%lastdim])
@@ -119,7 +119,7 @@ pparray(Array *a)
Rune *spacing;
if(boxing)
spacing = L"│";
- else if(x == lastdim - 1 || a->type == AtypeRune)
+ else if(x == lastdim - 1 || GetType(a) == AtypeRune)
spacing = L"";
else
spacing = L" ";
@@ -148,8 +148,8 @@ pparray(Array *a)
res = printborder(res, widths, lastdim, 0);
int j = 1;
int blanks = 0;
- for(int dim = 0; dim < a->rank - 1 && i+1 != a->size; dim++){
- j *= a->shape[a->rank-dim-2];
+ for(int dim = 0; dim < GetRank(a) - 1 && i+1 != GetSize(a); dim++){
+ j *= a->shape[GetRank(a)-dim-2];
if(i%j == 0)
blanks++;
}