diff --git a/mozilla/xpcom/typelib/xpidl/xpidl.h b/mozilla/xpcom/typelib/xpidl/xpidl.h index 70eefc6b59a..9ee2d326f95 100644 --- a/mozilla/xpcom/typelib/xpidl/xpidl.h +++ b/mozilla/xpcom/typelib/xpidl/xpidl.h @@ -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. */ diff --git a/mozilla/xpcom/typelib/xpidl/xpidl_header.c b/mozilla/xpcom/typelib/xpidl/xpidl_header.c index e025bb5876b..8e816913249 100644 --- a/mozilla/xpcom/typelib/xpidl/xpidl_header.c +++ b/mozilla/xpcom/typelib/xpidl/xpidl_header.c @@ -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; } diff --git a/mozilla/xpcom/typelib/xpidl/xpidl_idl.c b/mozilla/xpcom/typelib/xpidl/xpidl_idl.c index 62b9db0f692..135119e0398 100644 --- a/mozilla/xpcom/typelib/xpidl/xpidl_idl.c +++ b/mozilla/xpcom/typelib/xpidl/xpidl_idl.c @@ -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; } diff --git a/mozilla/xpcom/typelib/xpidl/xpidl_util.c b/mozilla/xpcom/typelib/xpidl/xpidl_util.c index 0c3776b8944..237c9e463ae 100644 --- a/mozilla/xpcom/typelib/xpidl/xpidl_util.c +++ b/mozilla/xpcom/typelib/xpidl/xpidl_util.c @@ -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; +}