Changeset 1830 for trunk/src/kmk
- Timestamp:
- Oct 11, 2008, 12:56:20 PM (17 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/expand.c
r1827 r1830 45 45 #define VARIABLE_BUFFER_ZONE 5 46 46 47 #ifndef KMK 47 48 static unsigned int variable_buffer_length; 49 #else 50 unsigned int variable_buffer_length; 51 #endif 48 52 char *variable_buffer; 49 53 54 #ifndef KMK 50 55 /* Subroutine of variable_expand and friends: 51 56 The text to add is LENGTH chars starting at STRING to the variable_buffer. … … 63 68 { 64 69 unsigned int offset = ptr - variable_buffer; 65 #ifdef KMK66 variable_buffer_length = variable_buffer_length <= 102467 ? 2048 : variable_buffer_length * 4;68 if (variable_buffer_length < newlen + 100)69 variable_buffer_length = (newlen + 100 + 1023) & ~1023U;70 #else71 70 variable_buffer_length = (newlen + 100 > 2 * variable_buffer_length 72 71 ? newlen + 100 73 72 : 2 * variable_buffer_length); 74 #endif75 73 variable_buffer = xrealloc (variable_buffer, variable_buffer_length); 76 74 ptr = variable_buffer + offset; … … 80 78 return ptr + length; 81 79 } 80 #endif 82 81 83 82 /* Return a pointer to the beginning of the variable buffer. */ -
trunk/src/kmk/variable.h
r1827 r1830 127 127 extern char *variable_buffer; 128 128 extern struct variable_set_list *current_variable_set_list; 129 #ifdef KMK 130 extern unsigned int variable_buffer_length; 131 #define VARIABLE_BUFFER_ZONE 5 132 #endif 129 133 130 134 /* expand.c */ 135 #ifndef KMK 131 136 char *variable_buffer_output (char *ptr, const char *string, unsigned int length); 137 #else /* KMK */ 138 /* Subroutine of variable_expand and friends: 139 The text to add is LENGTH chars starting at STRING to the variable_buffer. 140 The text is added to the buffer at PTR, and the updated pointer into 141 the buffer is returned as the value. Thus, the value returned by 142 each call to variable_buffer_output should be the first argument to 143 the following call. */ 144 145 __inline static char * 146 variable_buffer_output (char *ptr, const char *string, unsigned int length) 147 { 148 register unsigned int newlen = length + (ptr - variable_buffer); 149 150 if ((newlen + VARIABLE_BUFFER_ZONE) > variable_buffer_length) 151 { 152 unsigned int offset = ptr - variable_buffer; 153 variable_buffer_length = variable_buffer_length <= 1024 154 ? 2048 : variable_buffer_length * 4; 155 if (variable_buffer_length < newlen + 100) 156 variable_buffer_length = (newlen + 100 + 1023) & ~1023U; 157 variable_buffer = xrealloc (variable_buffer, variable_buffer_length); 158 ptr = variable_buffer + offset; 159 } 160 161 # ifndef _MSC_VER 162 switch (length) 163 { 164 case 4: ptr[3] = string[3]; 165 case 3: ptr[2] = string[2]; 166 case 2: ptr[1] = string[1]; 167 case 1: ptr[0] = string[0]; 168 case 0: 169 break; 170 default: 171 memcpy (ptr, string, length); 172 break; 173 } 174 # else 175 memcpy (ptr, string, length); 176 # endif 177 return ptr + length; 178 } 179 180 #endif /* KMK */ 132 181 char *variable_expand (const char *line); 133 182 char *variable_expand_for_file (const char *line, struct file *file);
Note:
See TracChangeset
for help on using the changeset viewer.