diff options
| author | Joakim Verona | 2011-02-05 11:23:09 +0100 |
|---|---|---|
| committer | Joakim Verona | 2011-02-05 11:23:09 +0100 |
| commit | 4bd51ad5c3445b644dfb017d5b57b10a90aa325f (patch) | |
| tree | 894801e7308ce4ecc34933f959e28f4b9cff9533 /lib-src/make-docfile.c | |
| parent | 13cfe8df462ab8da9f0028e16cc84dcaceaca3d1 (diff) | |
| parent | 9bcaafce5351d270ac514e23cb69ff1a5fd35229 (diff) | |
| download | emacs-4bd51ad5c3445b644dfb017d5b57b10a90aa325f.tar.gz emacs-4bd51ad5c3445b644dfb017d5b57b10a90aa325f.zip | |
merge from upstream. currently seems to have bitroted and i get segfaults
Diffstat (limited to 'lib-src/make-docfile.c')
| -rw-r--r-- | lib-src/make-docfile.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c index e2dc99214d2..8addbda0489 100644 --- a/lib-src/make-docfile.c +++ b/lib-src/make-docfile.c | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | /* Generate doc-string file for GNU Emacs from source files. | 1 | /* Generate doc-string file for GNU Emacs from source files. |
| 2 | Copyright (C) 1985, 1986, 1992, 1993, 1994, 1997, 1999, 2000, 2001, | 2 | Copyright (C) 1985-1986, 1992-1994, 1997, 1999-2011 |
| 3 | 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 | ||
| 4 | Free Software Foundation, Inc. | 3 | Free Software Foundation, Inc. |
| 5 | 4 | ||
| 6 | This file is part of GNU Emacs. | 5 | This file is part of GNU Emacs. |
| @@ -78,9 +77,7 @@ void fatal (const char *s1, const char *s2) NO_RETURN; | |||
| 78 | #undef chdir | 77 | #undef chdir |
| 79 | #endif | 78 | #endif |
| 80 | 79 | ||
| 81 | #ifdef HAVE_UNISTD_H | ||
| 82 | #include <unistd.h> | 80 | #include <unistd.h> |
| 83 | #endif | ||
| 84 | 81 | ||
| 85 | /* Stdio stream for output to the DOC file. */ | 82 | /* Stdio stream for output to the DOC file. */ |
| 86 | FILE *outfile; | 83 | FILE *outfile; |
| @@ -160,7 +157,11 @@ main (int argc, char **argv) | |||
| 160 | } | 157 | } |
| 161 | if (argc > i + 1 && !strcmp (argv[i], "-d")) | 158 | if (argc > i + 1 && !strcmp (argv[i], "-d")) |
| 162 | { | 159 | { |
| 163 | chdir (argv[i + 1]); | 160 | if (chdir (argv[i + 1]) != 0) |
| 161 | { | ||
| 162 | perror (argv[i + 1]); | ||
| 163 | return EXIT_FAILURE; | ||
| 164 | } | ||
| 164 | i += 2; | 165 | i += 2; |
| 165 | } | 166 | } |
| 166 | 167 | ||
| @@ -650,6 +651,7 @@ scan_c_file (char *filename, const char *mode) | |||
| 650 | 651 | ||
| 651 | if (defunflag && (commas == 1 || commas == 2)) | 652 | if (defunflag && (commas == 1 || commas == 2)) |
| 652 | { | 653 | { |
| 654 | int scanned = 0; | ||
| 653 | do | 655 | do |
| 654 | c = getc (infile); | 656 | c = getc (infile); |
| 655 | while (c == ' ' || c == '\n' || c == '\r' || c == '\t'); | 657 | while (c == ' ' || c == '\n' || c == '\r' || c == '\t'); |
| @@ -657,12 +659,14 @@ scan_c_file (char *filename, const char *mode) | |||
| 657 | goto eof; | 659 | goto eof; |
| 658 | ungetc (c, infile); | 660 | ungetc (c, infile); |
| 659 | if (commas == 2) /* pick up minargs */ | 661 | if (commas == 2) /* pick up minargs */ |
| 660 | fscanf (infile, "%d", &minargs); | 662 | scanned = fscanf (infile, "%d", &minargs); |
| 661 | else /* pick up maxargs */ | 663 | else /* pick up maxargs */ |
| 662 | if (c == 'M' || c == 'U') /* MANY || UNEVALLED */ | 664 | if (c == 'M' || c == 'U') /* MANY || UNEVALLED */ |
| 663 | maxargs = -1; | 665 | maxargs = -1; |
| 664 | else | 666 | else |
| 665 | fscanf (infile, "%d", &maxargs); | 667 | scanned = fscanf (infile, "%d", &maxargs); |
| 668 | if (scanned < 0) | ||
| 669 | goto eof; | ||
| 666 | } | 670 | } |
| 667 | } | 671 | } |
| 668 | 672 | ||
| @@ -869,8 +873,8 @@ scan_lisp_file (const char *filename, const char *mode) | |||
| 869 | c = getc (infile); | 873 | c = getc (infile); |
| 870 | if (c == '@') | 874 | if (c == '@') |
| 871 | { | 875 | { |
| 872 | int length = 0; | 876 | size_t length = 0; |
| 873 | int i; | 877 | size_t i; |
| 874 | 878 | ||
| 875 | /* Read the length. */ | 879 | /* Read the length. */ |
| 876 | while ((c = getc (infile), | 880 | while ((c = getc (infile), |
| @@ -880,6 +884,12 @@ scan_lisp_file (const char *filename, const char *mode) | |||
| 880 | length += c - '0'; | 884 | length += c - '0'; |
| 881 | } | 885 | } |
| 882 | 886 | ||
| 887 | if (length <= 1) | ||
| 888 | fatal ("invalid dynamic doc string length", ""); | ||
| 889 | |||
| 890 | if (c != ' ') | ||
| 891 | fatal ("space not found after dynamic doc string length", ""); | ||
| 892 | |||
| 883 | /* The next character is a space that is counted in the length | 893 | /* The next character is a space that is counted in the length |
| 884 | but not part of the doc string. | 894 | but not part of the doc string. |
| 885 | We already read it, so just ignore it. */ | 895 | We already read it, so just ignore it. */ |
| @@ -895,7 +905,7 @@ scan_lisp_file (const char *filename, const char *mode) | |||
| 895 | but it is redundant in DOC. So get rid of it here. */ | 905 | but it is redundant in DOC. So get rid of it here. */ |
| 896 | saved_string[length - 1] = 0; | 906 | saved_string[length - 1] = 0; |
| 897 | /* Skip the line break. */ | 907 | /* Skip the line break. */ |
| 898 | while (c == '\n' && c == '\r') | 908 | while (c == '\n' || c == '\r') |
| 899 | c = getc (infile); | 909 | c = getc (infile); |
| 900 | /* Skip the following line. */ | 910 | /* Skip the following line. */ |
| 901 | while (c != '\n' && c != '\r') | 911 | while (c != '\n' && c != '\r') |
| @@ -1201,7 +1211,5 @@ scan_lisp_file (const char *filename, const char *mode) | |||
| 1201 | return 0; | 1211 | return 0; |
| 1202 | } | 1212 | } |
| 1203 | 1213 | ||
| 1204 | /* arch-tag: f7203aaf-991a-4238-acb5-601db56f2894 | ||
| 1205 | (do not change this comment) */ | ||
| 1206 | 1214 | ||
| 1207 | /* make-docfile.c ends here */ | 1215 | /* make-docfile.c ends here */ |