Sigrid Solveig HaflínudóttirRunLengthDecode: forgot to inc6405cc75 years agoHistory
49 lines · 671 B · C
RawDownload
#include <u.h>#include <libc.h>#include "pdf.h" /* 7.4.5 RunLengthDecode filter */ static intflreadall(void *aux, Buffer *bi, Buffer *bo){	int sz, i;	uchar *p; 	USED(aux); 	p = bufdata(bi, &sz);	for(; sz > 0;){		i = *p++;		sz--; 		if(i == 0x80) /* EOD */			break;		if(i > 0x80){			if(sz < 1){				werrstr("no byte to repeat");				return -1;			}			for(i = 257 - i; i > 0; i--)				bufput(bo, p, 1);			p++;		}else{			i++;			if(i > sz){				werrstr("short data");				return -1;			}			bufput(bo, p, i);			p += i;			sz -= i;		}	}	bi->off = bi->sz; 	return 0;} Filter filterRunLength = {	.name = "RunLengthDecode",	.readall = flreadall,};

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