Branch: Tag:

2006-01-25

2006-01-25 21:07:58 by Henrik Grubbström (Grubba) <grubba@grubba.org>

program_path_to_name() now knows about compat modules.
compat_handler_cache is no longer a weak mapping, since it is wasteful to gc the compat handlers.
compat_handler_cache now also contains the handler for the currentversion.
currentversion is now generated from __REAL_{MAJ,MIN}OR__ for clearity.

Rev: lib/master.pike.in:1.385

6:   // Pike is distributed under GPL, LGPL and MPL. See the file COPYING   // for more information.   // - // $Id: master.pike.in,v 1.384 2006/01/21 14:35:45 grubba Exp $ + // $Id: master.pike.in,v 1.385 2006/01/25 21:07:58 grubba Exp $      #pike __REAL_VERSION__   //#pragma strict_types
3211:   //! returned string if it's an object file (i.e. ends with   //! @expr{".pike"@}).   { +  if (path == "/master") return "master" + (object_suffix || ""); +     array(string) sort_paths_by_length(array(string) paths)    {    sort(map(paths, sizeof), paths);    return reverse(paths);    };    -  if (path == "/master") return "master" + (object_suffix || ""); +  string prefix = "";    -  foreach(sort_paths_by_length(map(pike_module_path - ({""}), +  array(Version) versions = reverse(sort(indices(compat_handler_cache))); +  find_prefix: +  foreach(versions, Version version) { +  CompatResolver r = compat_handler_cache[version]; +  if (!r) continue; // Protection against the gc... +  +  foreach(sort_paths_by_length(map(r->pike_module_path - ({""}),    lambda(string s) {    if (s[-1] == '/') return s;    return s+"/";    })), -  string prefix) { -  if (has_prefix(path, prefix)) { -  path = path[sizeof(prefix)..]; -  break; +  string path_prefix) { +  if (has_prefix(path, path_prefix)) { +  path = path[sizeof(path_prefix)..]; +  if (version != currentversion) { +  prefix = ((string)version) + "::";    } -  +  break find_prefix;    } -  +  } +  }      #if 0    // This seems broken. Why should the current directory or the
3241:    string modname = replace(path, ".pmod/", ".");    if(search(modname, "/")<0) path=modname;    +  path = prefix + path; +     if (has_suffix(path, ".module.pmod")) {    return (module_prefix || "") + path[..<12] + (module_suffix || "");    }
4424:   }      //! Version information about the current Pike version. - Version currentversion=Version(__MAJOR__,__MINOR__); + Version currentversion = Version(__REAL_MAJOR__, __REAL_MINOR__);    - mapping(Version:CompatResolver) compat_handler_cache = set_weak_flag( ([]), 1); + mapping(Version:CompatResolver) compat_handler_cache = ([ +  currentversion:this_object(), + ]);      CompatResolver get_compilation_handler(int major, int minor)   {
4434:       if(v > currentversion)    { -  /* do we want to make an error if major.minor > __MAJOR__.__MINOR ? */ +  /* Do we want to make an error if major.minor > __MAJOR__.__MINOR ? +  * +  * No; it's useful for referring to the next version when writing +  * compat modules. +  */    return 0;    }