Unified · Split
| @@ -51,3 +51,25 @@ err: · 50 unmodified lines | |||
| 51 | pdfobjfree(o); | 51 | pdfobjfree(o); |
| 52 | return nil; | 52 | return nil; |
| 53 | } | 53 | } |
| 54 | |||
| 55 | int | ||
| 56 | arraylen(Object *o) | ||
| 57 | { | ||
| 58 | if(o == nil || o == &null) | ||
| 59 | return 0; | ||
| 60 | return (o->type == Oarray) ? o->array.ne : 1; | ||
| 61 | } | ||
| 62 | |||
| 63 | Object * | ||
| 64 | arrayget(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 | |||
| 71 | int | ||
| 72 | arrayint(Object *o, int i) | ||
| 73 | { | ||
| 74 | return (o = arrayget(o, i))->type == Onum ? o->num : 0; | ||
| 75 | } | ||
| @@ -150,6 +150,10 @@ int isws(int c); · 149 unmodified lines | |||
| 150 | */ | 150 | */ |
| 151 | int isdelim(int c); | 151 | int isdelim(int c); |
| 152 | 152 | ||
| 153 | int arraylen(Object *o); | ||
| 154 | Object *arrayget(Object *o, int i); | ||
| 155 | int arrayint(Object *o, int i); | ||
| 156 | |||
| 153 | Object *dictget(Object *o, char *name); | 157 | Object *dictget(Object *o, char *name); |
| 154 | vlong dictint(Object *o, char *name); | 158 | vlong dictint(Object *o, char *name); |
| 155 | char *dictstring(Object *o, char *name); | 159 | char *dictstring(Object *o, char *name); |