Removed mono_debugger_create_notification_function() from here.
[mono.git] / mono / metadata / assembly.c
index 4a50672bd797c48753b0a1e36404db3de48b0319..10dbacfd70d12d4a01c83c08c8e879f9d3f92331 100644 (file)
@@ -155,7 +155,7 @@ static void
 check_path_env (void)
 {
        const char *path;
-       char **splitted;
+       char **splitted, **dest;
        
        path = g_getenv ("MONO_PATH");
        if (!path)
@@ -164,7 +164,14 @@ check_path_env (void)
        splitted = g_strsplit (path, G_SEARCHPATH_SEPARATOR_S, 1000);
        if (assemblies_path)
                g_strfreev (assemblies_path);
-       assemblies_path = splitted;
+       assemblies_path = dest = splitted;
+       while (*splitted){
+               if (**splitted)
+                       *dest++ = *splitted;
+               splitted++;
+       }
+       *dest = *splitted;
+       
        if (g_getenv ("MONO_DEBUG") == NULL)
                return;
 
@@ -179,7 +186,7 @@ check_path_env (void)
 static void
 check_extra_gac_path_env (void) {
        const char *path;
-       char **splitted;
+       char **splitted, **dest;
        
        path = g_getenv ("MONO_GAC_PREFIX");
        if (!path)
@@ -188,7 +195,14 @@ check_extra_gac_path_env (void) {
        splitted = g_strsplit (path, G_SEARCHPATH_SEPARATOR_S, 1000);
        if (extra_gac_paths)
                g_strfreev (extra_gac_paths);
-       extra_gac_paths = splitted;
+       extra_gac_paths = dest = splitted;
+       while (*splitted){
+               if (**splitted)
+                       *dest++ = *splitted;
+               splitted++;
+       }
+       *dest = *splitted;
+       
        if (g_getenv ("MONO_DEBUG") == NULL)
                return;
 
@@ -331,6 +345,7 @@ check_policy_versions (MonoAssemblyBindingInfo *info, MonoAssemblyName *name)
  * @r: second assembly.
  *
  * Compares two MonoAssemblyNames and returns whether they are equal.
+ *
  * This compares the names, the cultures, the release version and their
  * public tokens.
  *
@@ -411,8 +426,10 @@ load_in_path (const char *basename, const char** search_path, MonoImageOpenStatu
  * @root_dir: The pathname of the root directory where we will locate assemblies
  *
  * This routine sets the internal default root directory for looking up
- * assemblies.  This is used by Windows installations to compute dynamically
- * the place where the Mono assemblies are located.
+ * assemblies.
+ *
+ * This is used by Windows installations to compute dynamically the
+ * place where the Mono assemblies are located.
  *
  */
 void
@@ -427,8 +444,10 @@ mono_assembly_setrootdir (const char *root_dir)
 
 /**
  * mono_assembly_getrootdir:
+ * 
+ * Obtains the root directory used for looking up assemblies.
  *
- * Returns: The internal root directory used for looking up assemblies
+ * Returns: a string with the directory, this string should not be freed.
  */
 G_CONST_RETURN gchar *
 mono_assembly_getrootdir (void)
@@ -442,10 +461,11 @@ mono_assembly_getrootdir (void)
  * @config_dir: the base directory for configuration files
  *
  * This routine is used internally and by developers embedding
- * the runtime into their own applications.  There are a number
- * of cases to consider: Mono as a system-installed package that
- * is available on the location preconfigured or Mono in a relocated
- * location.
+ * the runtime into their own applications.
+ *
+ * There are a number of cases to consider: Mono as a system-installed
+ * package that is available on the location preconfigured or Mono in
+ * a relocated location.
  *
  * If you are using a system-installed Mono, you can pass NULL
  * to both parameters.  If you are not, you should compute both
@@ -682,11 +702,15 @@ mono_assembly_fill_assembly_name (MonoImage *image, MonoAssemblyName *aname)
        return TRUE;
 }
 
-/*
+/**
  * mono_stringify_assembly_name:
+ * @aname: the assembly name.
  *
- *   Convert @aname into its string format. The returned string is dynamically
+ * Convert @aname into its string format. The returned string is dynamically
  * allocated and should be freed by the caller.
+ *
+ * Returns: a newly allocated string with a string representation of
+ * the assembly name.
  */
 char*
 mono_stringify_assembly_name (MonoAssemblyName *aname)
@@ -1171,11 +1195,12 @@ absolute_dir (const gchar *filename)
        list = g_list_reverse (list);
 
        /* Ignores last data pointer, which should be the filename */
-       for (tmp = list; tmp && tmp->next != NULL; tmp = tmp->next)
+       for (tmp = list; tmp && tmp->next != NULL; tmp = tmp->next){
                if (tmp->data)
                        g_string_append_printf (result, "%s%c", (char *) tmp->data,
                                                                G_DIR_SEPARATOR);
-       
+       }
+
        res = result->str;
        g_string_free (result, FALSE);
        g_list_free (list);
@@ -1380,6 +1405,13 @@ mono_assembly_load_from_full (MonoImage *image, const char*fname,
        GList *loading;
        GHashTable *ass_loading;
 
+       if (!image->tables [MONO_TABLE_ASSEMBLY].rows) {
+               /* 'image' doesn't have a manifest -- maybe someone is trying to Assembly.Load a .netmodule */
+               *status = MONO_IMAGE_IMAGE_INVALID;
+               return NULL;
+       }
+
+
 #if defined (PLATFORM_WIN32)
        {
                gchar *tmp_fn;
@@ -1491,12 +1523,12 @@ mono_assembly_load_from (MonoImage *image, const char *fname,
 }
 
 /**
-* mono_assembly_name_free:
-* @aname: assembly name to free
-* 
-* Frees the provided assembly name object.
-* (it does not frees the object itself, only the name members).
-*/
+ * mono_assembly_name_free:
+ * @aname: assembly name to free
+ 
+ * Frees the provided assembly name object.
+ * (it does not frees the object itself, only the name members).
+ */
 void
 mono_assembly_name_free (MonoAssemblyName *aname)
 {
@@ -1587,18 +1619,29 @@ build_assembly_name (const char *name, const char *version, const char *culture,
 {
        gint major, minor, build, revision;
        gint len;
+       gint version_parts;
        gchar *pkey, *pkeyptr, *encoded, tok [8];
 
        memset (aname, 0, sizeof (MonoAssemblyName));
 
        if (version) {
-               if (sscanf (version, "%u.%u.%u.%u", &major, &minor, &build, &revision) != 4)
+               version_parts = sscanf (version, "%u.%u.%u.%u", &major, &minor, &build, &revision);
+               if (version_parts < 2 || version_parts > 4)
                        return FALSE;
 
+               /* FIXME: we should set build & revision to -1 (instead of 0)
+               if these are not set in the version string. That way, later on,
+               we can still determine if these were specified. */
                aname->major = major;
                aname->minor = minor;
-               aname->build = build;
-               aname->revision = revision;
+               if (version_parts >= 3)
+                       aname->build = build;
+               else
+                       aname->build = 0;
+               if (version_parts == 4)
+                       aname->revision = revision;
+               else
+                       aname->revision = 0;
        }
        
        aname->name = g_strdup (name);
@@ -1720,15 +1763,15 @@ mono_assembly_name_parse_full (const char *name, MonoAssemblyName *aname, gboole
 }
 
 /**
-* mono_assembly_name_parse:
-* @name: name to parse
-* @aname: the destination assembly name
-* 
-* Parses an assembly qualified type name and assigns the name,
-* version, culture and token to the provided assembly name object.
-*
-* Returns: true if the name could be parsed.
-*/
+ * mono_assembly_name_parse:
+ * @name: name to parse
+ * @aname: the destination assembly name
+ 
+ * Parses an assembly qualified type name and assigns the name,
+ * version, culture and token to the provided assembly name object.
+ *
+ * Returns: true if the name could be parsed.
+ */
 gboolean
 mono_assembly_name_parse (const char *name, MonoAssemblyName *aname)
 {