- /* In the case of memmove, protect in case the application
- defines it as a macro before including the header. */
- if (!strcmp (fn->fname, "memmove")
- || !strcmp (fn->fname, "vprintf")
- || !strcmp (fn->fname, "vfprintf")
- || !strcmp (fn->fname, "vsprintf")
- || !strcmp (fn->fname, "rewinddir"))
- macro_protect = 1;
-
- if (macro_protect)
- fprintf (outf, "#ifndef %s\n", fn->fname);
- fprintf (outf, "extern %s %s (%s);\n",
- fn->rtype, fn->fname, fn->params);
- if (macro_protect)
- fprintf (outf, "#endif\n");
+ fn = lookup_std_proto (cptr, name_len);
+ if (fn == NULL || !REQUIRED (fn))
+ continue;
+
+ if (!if_was_emitted)
+ {
+/* what about curses. ??? or _flsbuf/_filbuf ??? */
+ if (cur_symbols->flags & ANSI_SYMBOL)
+ fprintf (outf,
+ "#if defined(__USE_FIXED_PROTOTYPES__) || defined(__cplusplus) || defined (__STRICT_ANSI__)\n");
+ else if (cur_symbols->flags & (POSIX1_SYMBOL|POSIX2_SYMBOL))
+ fprintf (outf,
+ "#if defined(__USE_FIXED_PROTOTYPES__) || (defined(__cplusplus) \\\n\
+ ? (!defined(__STRICT_ANSI__) || defined(_POSIX_SOURCE)) \\\n\
+ : (defined(__STRICT_ANSI__) && defined(_POSIX_SOURCE)))\n");
+ else if (cur_symbols->flags & XOPEN_SYMBOL)
+ {
+ fprintf (outf,
+ "#if defined(__USE_FIXED_PROTOTYPES__) \\\n\
+ || (defined(__STRICT_ANSI__) && defined(_XOPEN_SOURCE))\n");
+ }
+ else if (cur_symbols->flags & XOPEN_EXTENDED_SYMBOL)
+ {
+ fprintf (outf,
+ "#if defined(__USE_FIXED_PROTOTYPES__) \\\n\
+ || (defined(__STRICT_ANSI__) && defined(_XOPEN_EXTENDED_SOURCE))\n");
+ }
+ else
+ {
+ fatal ("internal error for function %s", fn->fname);
+ }
+ if_was_emitted = 1;
+ }
+
+ /* In the case of memmove, protect in case the application
+ defines it as a macro before including the header. */
+ if (!strcmp (fn->fname, "memmove")
+ || !strcmp (fn->fname, "vprintf")
+ || !strcmp (fn->fname, "vfprintf")
+ || !strcmp (fn->fname, "vsprintf")
+ || !strcmp (fn->fname, "rewinddir"))
+ macro_protect = 1;
+
+ if (macro_protect)
+ fprintf (outf, "#ifndef %s\n", fn->fname);
+ fprintf (outf, "extern %s %s (%s);\n",
+ fn->rtype, fn->fname, fn->params);
+ if (macro_protect)
+ fprintf (outf, "#endif\n");
+ }
+ if (if_was_emitted)
+ fprintf (outf,
+ "#endif /* defined(__USE_FIXED_PROTOTYPES__) || ... */\n");