2 base js library functions
3 Copyright Andrew Tridgell 2005
4 released under the GNU GPL version 3 or later
7 if (global["HAVE_BASE_JS"] != undefined) {
12 /* bring the string functions into the global frame */
16 an essential function!
20 print(vsprintf(arguments));
24 substitute strings of the form ${NAME} in str, replacing
25 with substitutions from subobj
27 function substitute_var(str, subobj)
29 var list = split("${", str);
31 for (i=1;i<list.length;i++) {
32 var list2 = split("}", list[i], 1);
33 if ((list2.length < 2) && (list2[0] + "}" != list[i])) {
38 if (typeof(subobj[key]) == "undefined") {
39 val = "${" + key + "}";
40 } else if (typeof(subobj[key]) == "string") {
47 list[i] = join("", list2);
49 return join("", list);