comparison lib-src/make-docfile.c @ 112440:b5017c649dfb

Check return values of some library calls.
author Paul Eggert <eggert@cs.ucla.edu>
date Sat, 22 Jan 2011 23:30:19 -0800
parents 56d3e9c28eb0
children
comparison
equal deleted inserted replaced
112438:11f1b4757236 112440:b5017c649dfb
156 outfile = fopen (argv[i + 1], "a"); 156 outfile = fopen (argv[i + 1], "a");
157 i += 2; 157 i += 2;
158 } 158 }
159 if (argc > i + 1 && !strcmp (argv[i], "-d")) 159 if (argc > i + 1 && !strcmp (argv[i], "-d"))
160 { 160 {
161 chdir (argv[i + 1]); 161 if (chdir (argv[i + 1]) != 0)
162 {
163 perror (argv[i + 1]);
164 return EXIT_FAILURE;
165 }
162 i += 2; 166 i += 2;
163 } 167 }
164 168
165 if (outfile == 0) 169 if (outfile == 0)
166 fatal ("No output file specified", ""); 170 fatal ("No output file specified", "");
646 { 650 {
647 commas--; 651 commas--;
648 652
649 if (defunflag && (commas == 1 || commas == 2)) 653 if (defunflag && (commas == 1 || commas == 2))
650 { 654 {
655 int scanned = 0;
651 do 656 do
652 c = getc (infile); 657 c = getc (infile);
653 while (c == ' ' || c == '\n' || c == '\r' || c == '\t'); 658 while (c == ' ' || c == '\n' || c == '\r' || c == '\t');
654 if (c < 0) 659 if (c < 0)
655 goto eof; 660 goto eof;
656 ungetc (c, infile); 661 ungetc (c, infile);
657 if (commas == 2) /* pick up minargs */ 662 if (commas == 2) /* pick up minargs */
658 fscanf (infile, "%d", &minargs); 663 scanned = fscanf (infile, "%d", &minargs);
659 else /* pick up maxargs */ 664 else /* pick up maxargs */
660 if (c == 'M' || c == 'U') /* MANY || UNEVALLED */ 665 if (c == 'M' || c == 'U') /* MANY || UNEVALLED */
661 maxargs = -1; 666 maxargs = -1;
662 else 667 else
663 fscanf (infile, "%d", &maxargs); 668 scanned = fscanf (infile, "%d", &maxargs);
669 if (scanned < 0)
670 goto eof;
664 } 671 }
665 } 672 }
666 673
667 if (c == EOF) 674 if (c == EOF)
668 goto eof; 675 goto eof;