Fix cmdline argument check
There was a segfault when sent was called without arguments. Now we use stdin when there's no argument or - is used. Thanks to izabera for the report.
This commit is contained in:
		
							
								
								
									
										10
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								README.md
									
									
									
									
									
								
							| @ -25,12 +25,12 @@ You can navigate with the arrow keys and quit with `q`. | |||||||
|  |  | ||||||
| Usage | Usage | ||||||
|  |  | ||||||
| 	sent FILE | 	sent [FILE] | ||||||
|  |  | ||||||
| If FILE equals `-`, stdin will be read. Produce image slides by prepending a | If FILE is omitted or equals `-`, stdin will be read. Produce image slides by | ||||||
| `@` in front of the filename as a single paragraph. Lines starting with `#` will | prepending a `@` in front of the filename as a single paragraph. Lines starting | ||||||
| be ignored. A `\` at the beginning of the line escapes `@` and `#`. A | with `#` will be ignored. A `\` at the beginning of the line escapes `@` and | ||||||
| presentation file could look like this: | `#`. A presentation file could look like this: | ||||||
|  |  | ||||||
| 	sent | 	sent | ||||||
| 	 | 	 | ||||||
|  | |||||||
							
								
								
									
										11
									
								
								sent.c
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								sent.c
									
									
									
									
									
								
							| @ -689,7 +689,7 @@ void | |||||||
| usage() | usage() | ||||||
| { | { | ||||||
| 	die("sent " VERSION " (c) 2014-2015 markus.teich@stusta.mhn.de\n" \ | 	die("sent " VERSION " (c) 2014-2015 markus.teich@stusta.mhn.de\n" \ | ||||||
| 	"usage: sent FILE", argv0); | 	"usage: sent [FILE]", argv0); | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int | ||||||
| @ -703,12 +703,13 @@ main(int argc, char *argv[]) | |||||||
| 		usage(); | 		usage(); | ||||||
| 	} ARGEND; | 	} ARGEND; | ||||||
|  |  | ||||||
| 	if ((fp = strcmp(argv[0], "-") ? fopen(argv[0], "r") : stdin)) { | 	if (!argv[0] || !strcmp(argv[0], "-")) | ||||||
|  | 		fp = stdin; | ||||||
|  | 	else if (!(fp = fopen(argv[0], "r"))) | ||||||
|  | 		die("Unable to open '%s' for reading:", argv[0]); | ||||||
|  |  | ||||||
| 	load(fp); | 	load(fp); | ||||||
| 	fclose(fp); | 	fclose(fp); | ||||||
| 	} else { |  | ||||||
| 		die("Unable to open '%s' for reading:", argv[0]); |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	if (!slidecount) | 	if (!slidecount) | ||||||
| 		usage(); | 		usage(); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user