- Timestamp:
- Dec 31, 2008, 1:03:02 AM (17 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/Makefile.am
r2161 r2172 145 145 -DCONFIG_WITH_STRING_FUNCTIONS \ 146 146 -DCONFIG_WITH_LOOP_FUNCTIONS \ 147 -DCONFIG_WITH_ROOT_FUNC \ 147 148 -DCONFIG_PRETTY_COMMAND_PRINTING \ 148 149 -DCONFIG_WITH_PRINT_STATS_SWITCH \ -
trunk/src/kmk/Makefile.kmk
r2161 r2172 171 171 CONFIG_WITH_STRING_FUNCTIONS \ 172 172 CONFIG_WITH_LOOP_FUNCTIONS \ 173 CONFIG_WITH_ROOT_FUNC \ 173 174 CONFIG_PRETTY_COMMAND_PRINTING \ 174 175 CONFIG_WITH_PRINT_STATS_SWITCH \ -
trunk/src/kmk/function.c
r2163 r2172 808 808 } 809 809 810 #ifdef CONFIG_WITH_ROOT_FUNC 811 /* 812 $(root path) 813 814 This is mainly for dealing with drive letters and UNC paths on Windows 815 and OS/2. 816 */ 817 static char * 818 func_root (char *o, char **argv, const char *funcname UNUSED) 819 { 820 const char *paths = argv[0] ? argv[0] : ""; 821 int doneany = 0; 822 const char *p; 823 unsigned int len; 824 825 while ((p = find_next_token (&paths, &len)) != 0) 826 { 827 const char *p2 = p; 828 829 #ifdef HAVE_DOS_PATHS 830 if ( len >= 2 831 && p2[1] == ':' 832 && ( (p2[0] >= 'A' && p2[0] <= 'Z') 833 || (p2[0] >= 'a' && p2[0] <= 'z'))) 834 { 835 p2 += 2; 836 len -= 2; 837 } 838 else if (len >= 4 && IS_PATHSEP(p2[0]) && IS_PATHSEP(p2[1]) 839 && !IS_PATHSEP(p2[2])) 840 { 841 /* Min recognized UNC: "//./" - find the next slash 842 Typical root: "//srv/shr/" */ 843 /* XXX: Check if //./ needs special handling. */ 844 845 p2 += 3; 846 len -= 3; 847 while (len > 0 && !IS_PATHSEP(*p2)) 848 p2++, len--; 849 850 if (len && IS_PATHSEP(p2[0]) && (len == 1 || !IS_PATHSEP(p2[1]))) 851 { 852 p2++; 853 len--; 854 855 if (len) /* optional share */ 856 while (len > 0 && !IS_PATHSEP(*p2)) 857 p2++, len--; 858 } 859 else 860 p2 = NULL; 861 } 862 else if (IS_PATHSEP(*p2)) 863 { 864 p2++; 865 len--; 866 } 867 else 868 p2 = NULL; 869 870 #elif defined (VMS) || defined (AMGIA) 871 /* XXX: VMS and AMGIA */ 872 fatal (NILF, _("$(root ) is not implemented on this platform")); 873 #else 874 if (IS_PATHSEP(*p2)) 875 { 876 p2++; 877 len--; 878 } 879 else 880 p2 = NULL; 881 #endif 882 if (p2 != NULL) 883 { 884 /* Include all subsequent path seperators. */ 885 886 while (len > 0 && IS_PATHSEP(*p2)) 887 p2++, len--; 888 o = variable_buffer_output (o, p, p2 - p); 889 o = variable_buffer_output (o, " ", 1); 890 doneany = 1; 891 } 892 } 893 894 if (doneany) 895 /* Kill last space. */ 896 --o; 897 898 return o; 899 } 900 #endif /* CONFIG_WITH_ROOT_FUNC */ 901 810 902 static char * 811 903 func_addsuffix_addprefix (char *o, char **argv, const char *funcname) … … 4971 5063 { STRING_SIZE_TUPLE("dir"), 0, 1, 1, func_basename_dir}, 4972 5064 { STRING_SIZE_TUPLE("notdir"), 0, 1, 1, func_notdir_suffix}, 5065 #ifdef CONFIG_WITH_ROOT_FUNC 5066 { STRING_SIZE_TUPLE("root"), 0, 1, 1, func_root}, 5067 #endif 4973 5068 { STRING_SIZE_TUPLE("subst"), 3, 3, 1, func_subst}, 4974 5069 { STRING_SIZE_TUPLE("suffix"), 0, 1, 1, func_notdir_suffix}, -
trunk/src/kmk/variable.c
r2164 r2172 1207 1207 && defined (CONFIG_WITH_PRINTF) \ 1208 1208 && defined (CONFIG_WITH_LOOP_FUNCTIONS) \ 1209 && defined (CONFIG_WITH_ROOT_FUNC) \ 1209 1210 && defined (CONFIG_WITH_STRING_FUNCTIONS) \ 1210 1211 && defined (KMK_HELPERS) … … 1232 1233 " printf" 1233 1234 " for while" 1235 " root" 1234 1236 " length insert pos lastpos substr translate" 1235 1237 " kb-src-tool kb-obj-base kb-obj-suff kb-src-prop kb-src-one kb-exp-tmpl " … … 1301 1303 strcat (buf, " for while"); 1302 1304 # endif 1305 # if defined (CONFIG_WITH_ROOT_FUNC) 1306 strcat (buf, " root"); 1307 # endif 1303 1308 # if defined (CONFIG_WITH_STRING_FUNCTIONS) 1304 1309 strcat (buf, " length insert pos lastpos substr translate");
Note:
See TracChangeset
for help on using the changeset viewer.