support for comments to ignore lines
use # as first character in a line to skip this line from the slides.
This commit is contained in:
		
							
								
								
									
										1
									
								
								example
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								example
									
									
									
									
									
								
							| @ -7,5 +7,6 @@ no bloat | |||||||
| how? | how? | ||||||
| sent FILENAME | sent FILENAME | ||||||
| one slide per line | one slide per line | ||||||
|  | # comments | ||||||
|  @FILE.png |  @FILE.png | ||||||
| thanks / questions? | thanks / questions? | ||||||
|  | |||||||
							
								
								
									
										7
									
								
								sent.c
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								sent.c
									
									
									
									
									
								
							| @ -440,19 +440,22 @@ void load(FILE *fp) | |||||||
| { | { | ||||||
| 	static size_t size = 0; | 	static size_t size = 0; | ||||||
| 	char buf[BUFSIZ], *p; | 	char buf[BUFSIZ], *p; | ||||||
| 	size_t i; | 	size_t i = slidecount; | ||||||
|  |  | ||||||
| 	/* read each line from stdin and add it to the item list */ | 	/* read each line from stdin and add it to the item list */ | ||||||
| 	for (i = slidecount; fgets(buf, sizeof(buf), fp); i++) { | 	while (fgets(buf, sizeof(buf), fp)) { | ||||||
| 		if ((i+1) * sizeof(*slides) >= size) | 		if ((i+1) * sizeof(*slides) >= size) | ||||||
| 			if (!(slides = realloc(slides, (size += BUFSIZ)))) | 			if (!(slides = realloc(slides, (size += BUFSIZ)))) | ||||||
| 				eprintf("cannot realloc %u bytes:", size); | 				eprintf("cannot realloc %u bytes:", size); | ||||||
|  | 		if (*buf == '#') | ||||||
|  | 			continue; | ||||||
| 		if ((p = strchr(buf, '\n'))) | 		if ((p = strchr(buf, '\n'))) | ||||||
| 			*p = '\0'; | 			*p = '\0'; | ||||||
| 		if (!(slides[i].text = strdup(buf))) | 		if (!(slides[i].text = strdup(buf))) | ||||||
| 			eprintf("cannot strdup %u bytes:", strlen(buf)+1); | 			eprintf("cannot strdup %u bytes:", strlen(buf)+1); | ||||||
| 		if (slides[i].text[0] == '@') | 		if (slides[i].text[0] == '@') | ||||||
| 			slides[i].img = pngopen(slides[i].text + 1); | 			slides[i].img = pngopen(slides[i].text + 1); | ||||||
|  | 		i++; | ||||||
| 	} | 	} | ||||||
| 	if (slides) | 	if (slides) | ||||||
| 		slides[i].text = NULL; | 		slides[i].text = NULL; | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user