History

fix tons of bugs, use proper streaming

Sigrid Haflínudóttir committed 6 years ago

Commit 2ff084d1 parent 474117e16 files · +502 −344Browse files

Showing the changes to array.c (1 of 16 files). Show all

Unified · Split

array.c+8−7
@@ -1,12 +1,11 @@
1#include <u.h>1#include <u.h>
2#include <libc.h>2#include <libc.h>
3#include <bio.h>
4#include "pdf.h"3#include "pdf.h"
5 4
6/* 7.3.6 Array Objects */5/* 7.3.6 Array Objects */
7 6
8Object *7Object *
9pdfarray(Pdf *pdf, Biobuf *b)8pdfarray(Pdf *pdf, Stream *s)
10{9{
11 Object *o, *m;10 Object *o, *m;
12 Object **a;11 Object **a;
@@ -15,18 +14,18 @@ pdfarray(Pdf *pdf, Biobuf *b) · 2 unmodified lines
15 o = calloc(1, sizeof(*o));14 o = calloc(1, sizeof(*o));
16 o->pdf = pdf;15 o->pdf = pdf;
17 o->type = Oarray;16 o->type = Oarray;
18 Bgetc(b); /* throw away '[' */17 Sgetc(s); /* throw away '[' */
19 18
20 for(noel = 0;;){19 for(noel = 0;;){
21 if((c = Bgetc(b)) < 0 || c == ']')20 if((c = Sgetc(s)) < 0 || c == ']')
22 break;21 break;
23 if(noel){22 if(noel){
24 werrstr("no ']'");23 werrstr("no ']'");
25 goto err;24 goto err;
26 }25 }
27 26
28 Bungetc(b);27 Sungetc(s);
29 if((m = pdfobj(pdf, b)) == nil){28 if((m = pdfobj(pdf, s)) == nil){
30 noel = 1;29 noel = 1;
31 continue;30 continue;
32 }31 }
@@ -65,7 +64,9 @@ arrayget(Object *o, int i) · 32 unmodified lines
65{64{
66 if(arraylen(o) <= i)65 if(arraylen(o) <= i)
67 sysfatal("array: indexing out of range");66 sysfatal("array: indexing out of range");
68 return o->type == Oarray ? o->array.e[i] : o;67 o = o->type == Oarray ? o->array.e[i] : o;
68
69 return pdfeval(&o);
69}70}
70 71
71int72int

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t