Bug 114257 - win32 xpidl doesn't handle unix paths properly. patch=dbradley, r=cls, sr=jag

This commit is contained in:
dbradley%netscape.com 2002-01-10 13:03:45 +00:00
parent d88005c917
commit 9a5a5969de
4 changed files with 34 additions and 11 deletions

View File

@ -154,6 +154,12 @@ xpidl_malloc(size_t nbytes);
char *
xpidl_strdup(const char *s);
/*
* Return a pointer to the start of the base filename of path
*/
const char *
xpidl_basename(const char * path);
/*
* Process an XPIDL node and its kids, if any.
*/

View File

@ -60,7 +60,7 @@ write_indent(FILE *outfile) {
static gboolean
header_prolog(TreeState *state)
{
const char *define = g_basename(state->basename);
const char *define = xpidl_basename(state->basename);
fprintf(state->file, "/*\n * DO NOT EDIT. THIS FILE IS GENERATED FROM"
" %s.idl\n */\n", state->basename);
fprintf(state->file,
@ -116,7 +116,7 @@ header_prolog(TreeState *state)
static gboolean
header_epilog(TreeState *state)
{
const char *define = g_basename(state->basename);
const char *define = xpidl_basename(state->basename);
fprintf(state->file, "\n#endif /* __gen_%s_h__ */\n", define);
return TRUE;
}

View File

@ -733,21 +733,18 @@ xpidl_process_idl(char *filename, IncludePathEntry *include_path,
if (strcmp(outname, "-")) {
const char *fopen_mode;
const char *out_basename;
#if defined(XP_UNIX)
const char os_separator = '/';
#elif defined(XP_WIN)
const char os_separator = '\\';
#endif
/* explicit_output_filename can't be true without a filename */
if (explicit_output_filename) {
real_outname = g_strdup(outname);
} else {
/*
*This combination seems a little strange, what about OS/2?
* Assume it's some build issue
*/
#if defined(XP_UNIX) || defined(XP_WIN)
tmp = strrchr(outname, os_separator);
if (!file_basename && tmp) {
out_basename = tmp + 1;
if (!file_basename) {
out_basename = xpidl_basename(outname);
} else {
out_basename = outname;
}

View File

@ -733,3 +733,23 @@ verify_interface_declaration(IDL_tree interface_tree)
}
return TRUE;
}
/*
* Return a pointer to the start of the base filename of path
*/
const char *
xpidl_basename(const char * path)
{
const char * result = g_basename(path);
/*
*If this is windows then we'll handle either / or \ as a separator
* g_basename only handles \ for windows
*/
#if defined(XP_WIN32)
const char * slash = strrchr(path, '/');
/* If we found a slash and its after the current default OS separator */
if (slash != NULL && (slash > result))
result = slash + 1;
#endif
return result;
}