X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lib-src%2Fmake-docfile.c;h=4cbe8c21faa794c8841a6e404266e3b165fa3b75;hb=94ed1d637acfbec2f9c891890141ec43c81ff829;hp=141287ab55f819ded4ebd8773db3e42acad8b56f;hpb=3e447015251ce6dcde843cbed10d9033d5538622;p=chise%2Fxemacs-chise.git.1 diff --git a/lib-src/make-docfile.c b/lib-src/make-docfile.c index 141287a..4cbe8c2 100644 --- a/lib-src/make-docfile.c +++ b/lib-src/make-docfile.c @@ -46,40 +46,38 @@ Boston, MA 02111-1307, USA. */ #include #if __STDC__ || defined(STDC_HEADERS) #include +#ifdef HAVE_UNISTD_H #include +#endif #include #include #endif -#if defined(MSDOS) || defined(__CYGWIN32__) +#ifdef CYGWIN #include -#endif /* MSDOS */ -#ifdef WINDOWSNT +#endif +#ifdef WIN32_NATIVE #include #include #include #include -#endif /* WINDOWSNT */ +#endif /* WIN32_NATIVE */ +#ifndef WIN32_NATIVE #include +#endif /* not WIN32_NATIVE */ -#if defined(DOS_NT) || defined(__CYGWIN32__) +#if defined(WIN32_NATIVE) || defined(CYGWIN) #define READ_TEXT "rt" #define READ_BINARY "rb" #define WRITE_BINARY "wb" #define APPEND_BINARY "ab" -#else /* not DOS_NT */ +#else /* not WIN32_NATIVE */ #define READ_TEXT "r" #define READ_BINARY "r" #define WRITE_BINARY "w" #define APPEND_BINARY "a" -#endif /* not DOS_NT */ - -#ifdef MSDOS -/* s/msdos.h defines this as sys_chdir, but we're not linking with the - file where that function is defined. */ -#undef chdir -#endif +#endif /* not WIN32_NATIVE */ /* Stdio stream for output to the DOC file. */ static FILE *outfile; @@ -191,19 +189,10 @@ main (int argc, char **argv) outfile = stdout; /* Don't put CRs in the DOC file. */ -#ifdef MSDOS - _fmode = O_BINARY; -#if 0 /* Suspicion is that this causes hanging. - So instead we require people to use -o on MSDOS. */ - (stdout)->_flag &= ~_IOTEXT; - _setmode (fileno (stdout), O_BINARY); -#endif - outfile = 0; -#endif /* MSDOS */ -#ifdef WINDOWSNT +#ifdef WIN32_NATIVE _fmode = O_BINARY; _setmode (fileno (stdout), O_BINARY); -#endif /* WINDOWSNT */ +#endif /* WIN32_NATIVE */ /* If first two args are -o FILE, output to FILE. */ i = 1; @@ -303,48 +292,59 @@ char buf[128]; Convert escape sequences \n and \t to newline and tab; discard \ followed by newline. */ +#define MDGET do { prevc = c; c = getc (infile); } while (0) static int read_c_string (FILE *infile, int printflag, int c_docstring) { - register int c; + register int prevc = 0, c = 0; char *p = buf; int start = -1; - c = getc (infile); + MDGET; while (c != EOF) { while ((c_docstring || c != '"') && c != EOF) { - if (start) + if (c == '*') { - if (c == '*') + int cc = getc (infile); + if (cc == '/') { - int cc = getc (infile); - if (cc == '/') - break; - else - ungetc (cc, infile); + if (prevc != '\n') + { + if (printflag > 0) + { + if (ellcc) + fprintf (outfile, "\\n\\"); + putc ('\n', outfile); + } + else if (printflag < 0) + *p++ = '\n'; + } + break; } + else + ungetc (cc, infile); + } - if (start != -1) + if (start == 1) + { + if (printflag > 0) { - if (printflag > 0) - { - if (ellcc) - fprintf (outfile, "\\n\\"); - putc ('\n', outfile); - } - else if (printflag < 0) - *p++ = '\n'; + if (ellcc) + fprintf (outfile, "\\n\\"); + putc ('\n', outfile); } + else if (printflag < 0) + *p++ = '\n'; } if (c == '\\') { - c = getc (infile); + MDGET; if (c == '\n') { - c = getc (infile); + MDGET; start = 1; continue; } @@ -358,32 +358,36 @@ read_c_string (FILE *infile, int printflag, int c_docstring) else { start = 0; - if (printflag > 0) { - if (ellcc && c == '"') - putc ('\\', outfile); - putc (c, outfile); - } + if (printflag > 0) + { + if (ellcc && c == '"') + putc ('\\', outfile); + putc (c, outfile); + } else if (printflag < 0) *p++ = c; } - c = getc (infile); + MDGET; } /* look for continuation of string */ if (Current_file_type == c_file) { - while (isspace (c = getc (infile))) - ; + do + { + MDGET; + } + while (isspace (c)); if (c != '"') break; } else { - c = getc (infile); + MDGET; if (c != '"') break; /* If we had a "", concatenate the two strings. */ } - c = getc (infile); + MDGET; } if (printflag < 0) @@ -473,6 +477,12 @@ write_c_args (FILE *out, const char *func, char *buff, int minargs, in_ident = 0; just_spaced = 0; } + /* If the character is carriage return, escape it for the C compiler. */ + else if (c == '\n') + { + putc('\\', out); + putc('\n', out); + } else if (c != ' ' || ! just_spaced) { if (c >= 'a' && c <= 'z') @@ -505,7 +515,7 @@ scan_c_file (const char *filename, const char *mode) register int defvarperbufferflag = 0; register int defvarflag; int minargs, maxargs; - int l = strlen (filename); + size_t l = strlen (filename); char f[MAXPATHLEN]; if (l > sizeof (f))