History

add array helpers

Sigrid Haflínudóttir committed 6 years ago

Commit d613b761 parent b4e6b3b2 files · +26 −0Browse files

Unified · Split

2 files
  1. array.c +22 −0
  2. pdf.h +4 −0
array.c+22−0
@@ -51,3 +51,25 @@ err: · 50 unmodified lines
51 pdfobjfree(o);51 pdfobjfree(o);
52 return nil;52 return nil;
53}53}
54
55int
56arraylen(Object *o)
57{
58 if(o == nil || o == &null)
59 return 0;
60 return (o->type == Oarray) ? o->array.ne : 1;
61}
62
63Object *
64arrayget(Object *o, int i)
65{
66 if(arraylen(o) <= i)
67 sysfatal("array: indexing out of range");
68 return o->type == Oarray ? o->array.e[i] : o;
69}
70
71int
72arrayint(Object *o, int i)
73{
74 return (o = arrayget(o, i))->type == Onum ? o->num : 0;
75}
pdf.h+4−0
@@ -150,6 +150,10 @@ int isws(int c); · 149 unmodified lines
150 */150 */
151int isdelim(int c);151int isdelim(int c);
152 152
153int arraylen(Object *o);
154Object *arrayget(Object *o, int i);
155int arrayint(Object *o, int i);
156
153Object *dictget(Object *o, char *name);157Object *dictget(Object *o, char *name);
154vlong dictint(Object *o, char *name);158vlong dictint(Object *o, char *name);
155char *dictstring(Object *o, char *name);159char *dictstring(Object *o, char *name);

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