David 'Digit' Turner | b9a8479 | 2009-05-07 20:39:04 +0200 | [diff] [blame] | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| 2 | <html><head> |
| 3 | <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> |
| 4 | <title>GNU Make Standard Library</title></head> |
| 5 | |
| 6 | <body> |
| 7 | <h1>GNU Make Standard Library</h1> |
| 8 | The GNU Make Standard Library (GMSL) is a collection of functions |
| 9 | implemented using native GNU Make functionality that provide list and |
| 10 | string manipulation, integer arithmetic, associative arrays, stacks, |
| 11 | and debugging facilities. The GMSL is released under the BSD License.<br> |
| 12 | <br> |
| 13 | <a href="http://sourceforge.net/projects/gmsl/">[Project Page]</a> <a href="http://sourceforge.net/project/showfiles.php?group_id=129887">[Download]</a> |
| 14 | <a href="http://sourceforge.net/forum/forum.php?forum_id=443916">[Discussion |
| 15 | Forum]</a><br> |
| 16 | <h2>Using GMSL</h2> |
| 17 | The two files needed are <span style="font-family: monospace;">gmsl</span> |
| 18 | and <span style="font-family: monospace;">__gmsl</span>. To |
| 19 | include the GMSL in your Makefile do<br> |
| 20 | <pre style="margin-left: 40px;">include gmsl</pre> |
| 21 | <span style="font-family: monospace;">gmsl</span> automatically includes<span style="font-family: monospace;"> __gmsl</span>. To check that |
| 22 | you have the right version of <span style="font-family: monospace;">gmsl</span> |
| 23 | use the <span style="font-family: monospace;">gmsl_compatible</span> |
| 24 | function (see |
| 25 | below). The current version is <span style="font-family: monospace;">1 |
| 26 | 0 11</span>.<br> |
| 27 | <br> |
| 28 | The GMSL package also includes a test suite for GMSL. Just run <span style="font-family: monospace;">make -f gmsl-tests</span>.<br> |
| 29 | <h2>Logical Operators</h2>GMSL has boolean $(true) (a non-empty string) |
| 30 | and $(false) (an empty string). The following operators can be |
| 31 | used with those variables.<br> |
| 32 | <br> |
| 33 | <hr style="width: 100%; height: 2px;"><span style="font-weight: bold;">not</span><br> |
| 34 | |
| 35 | <br> |
| 36 | |
| 37 | <span style="font-family: monospace;">Arguments: A boolean value</span><br style="font-family: monospace;"> |
| 38 | |
| 39 | <span style="font-family: monospace;">Returns: Returns $(true) if the boolean is $(false) and vice versa</span><br style="font-family: monospace;"> |
| 40 | |
| 41 | <hr style="width: 100%; height: 2px; font-family: monospace;"><span style="font-weight: bold;"></span><span style="font-weight: bold;">and</span><br> |
| 42 | <br> |
| 43 | <span style="font-family: monospace;">Arguments: Two boolean values</span><br style="font-family: monospace;"> |
| 44 | <span style="font-family: monospace;">Returns: Returns $(true) if both of the booleans are true</span><br style="font-family: monospace;"> |
| 45 | <hr style="width: 100%; height: 2px; font-family: monospace;"><span style="font-weight: bold;">or</span><br> |
| 46 | <br> |
| 47 | <span style="font-family: monospace;">Arguments: Two boolean values</span><br style="font-family: monospace;"> |
| 48 | <span style="font-family: monospace;">Returns: Returns $(true) if either of the booleans is true</span><br style="font-family: monospace;"> |
| 49 | <hr style="width: 100%; height: 2px; font-family: monospace;"><span style="font-weight: bold;">xor</span><br style="font-weight: bold;"> |
| 50 | <br> |
| 51 | <span style="font-family: monospace;">Arguments: Two boolean values</span><br style="font-family: monospace;"> |
| 52 | <span style="font-family: monospace;">Returns: Returns $(true) if exactly one of the booleans is true</span><br style="font-family: monospace;"> |
| 53 | <hr style="width: 100%; height: 2px; font-family: monospace;"><span style="font-weight: bold;">nand</span><br> |
| 54 | <br> |
| 55 | <span style="font-family: monospace;">Arguments: Two boolean values</span><br style="font-family: monospace;"> |
| 56 | <span style="font-family: monospace;">Returns: Returns value of 'not and'</span><br style="font-family: monospace;"> |
| 57 | <hr style="width: 100%; height: 2px; font-family: monospace;"><span style="font-weight: bold;">nor</span><br> |
| 58 | <br> |
| 59 | <span style="font-family: monospace;">Arguments: Two boolean values</span><br style="font-family: monospace;"> |
| 60 | <span style="font-family: monospace;">Returns: Returns value of 'not or'</span><br style="font-family: monospace;"> |
| 61 | <hr style="width: 100%; height: 2px; font-family: monospace;"><span style="font-weight: bold;">xnor</span><br> |
| 62 | <br> |
| 63 | <span style="font-family: monospace;">Arguments: Two boolean values</span><br style="font-family: monospace;"> |
| 64 | <span style="font-family: monospace;">Returns: Returns value of 'not xor'</span><br style="font-family: monospace;"> |
| 65 | <hr style="width: 100%; height: 2px; font-family: monospace;"> |
| 66 | <h2>List Manipulation Functions</h2> |
| 67 | A list is a string of characters; the list separator is a space.<br> |
| 68 | |
| 69 | <br> |
| 70 | <hr style="width: 100%; height: 2px;"><b>first</b><br> |
| 71 | <br> |
| 72 | <span style="font-family: monospace;">Arguments: 1: A list<br> |
| 73 | Returns: Returns the first element of a list<br> |
| 74 | </span> |
| 75 | <hr><b>last</b><br> |
| 76 | <br> |
| 77 | <span style="font-family: monospace;">Arguments: 1: A list<br> |
| 78 | Returns: Returns the last element of a list<br> |
| 79 | </span> |
| 80 | <hr><b>rest</b><br> |
| 81 | <br> |
| 82 | <span style="font-family: monospace;">Arguments: 1: A list<br> |
| 83 | Returns: Returns the list with the first element |
| 84 | removed<br> |
| 85 | </span> |
| 86 | <hr><b>chop</b><br> |
| 87 | <br> |
| 88 | <span style="font-family: monospace;">Arguments: 1: A list<br> |
| 89 | Returns: Returns the list with the last element removed<br> |
| 90 | </span> |
| 91 | <hr><b>map</b><br> |
| 92 | <br> |
| 93 | <span style="font-family: monospace;">Arguments: 1: Name of function to |
| 94 | $(call) for each element of list<br> |
| 95 | 2: List to |
| 96 | iterate over calling the function in 1<br> |
| 97 | Returns: The list after calling the function on each |
| 98 | element<br> |
| 99 | </span> |
| 100 | <hr><b>pairmap</b><br> |
| 101 | <br> |
| 102 | <span style="font-family: monospace;">Arguments: 1: Name of function to |
| 103 | $(call) for each pair of elements<br> |
| 104 | 2: List to |
| 105 | iterate over calling the function in 1<br> |
| 106 | 3: Second |
| 107 | list to iterate over calling the function in 1<br> |
| 108 | Returns: The list after calling the function on each |
| 109 | pair of elements<br> |
| 110 | </span> |
| 111 | <hr><b>leq</b><br> |
| 112 | <br> |
| 113 | <span style="font-family: monospace;">Arguments: 1: A list to compare |
| 114 | against...<br> |
| 115 | 2: ...this |
| 116 | list<br> |
| 117 | Returns: Returns $(true) if the two lists are identical<br> |
| 118 | </span> |
| 119 | <hr><b>lne</b><br> |
| 120 | <br> |
| 121 | <span style="font-family: monospace;">Arguments: 1: A list to compare |
| 122 | against...<br> |
| 123 | 2: ...this |
| 124 | list<br> |
| 125 | Returns: Returns $(true) if the two lists are different<br> |
| 126 | </span> |
| 127 | <hr><b>reverse</b><br> |
| 128 | <br> |
| 129 | <span style="font-family: monospace;">Arguments: 1: A list to reverse<br> |
| 130 | Returns: The list with its elements in reverse order<br> |
| 131 | </span> |
| 132 | <hr><b>uniq</b><br> |
| 133 | <br> |
| 134 | <span style="font-family: monospace;">Arguments: 1: A list to deduplicate<br> |
| 135 | Returns: The list with elements in order without duplicates<br> |
| 136 | </span> |
| 137 | <hr><b>length</b><br> |
| 138 | <br> |
| 139 | <span style="font-family: monospace;">Arguments: 1: A list<br> |
| 140 | Returns: The number of elements in the list<br> |
| 141 | </span> |
| 142 | <hr style="width: 100%; height: 2px;"><span style="font-family: monospace;"></span> |
| 143 | <h2>String Manipulation Functions</h2> |
| 144 | A string is any sequence of characters.<br> |
| 145 | <br> |
| 146 | <hr style="width: 100%; height: 2px;"><b>seq</b><br> |
| 147 | <br> |
| 148 | <span style="font-family: monospace;">Arguments: 1: A string to compare |
| 149 | against...<br> |
| 150 | 2: ...this |
| 151 | string<br> |
| 152 | Returns: Returns $(true) if the two strings are |
| 153 | identical<br> |
| 154 | </span> |
| 155 | <hr><b>sne</b><br> |
| 156 | <br> |
| 157 | <span style="font-family: monospace;">Arguments: 1: A string to compare |
| 158 | against...<br> |
| 159 | 2: ...this |
| 160 | string<br> |
| 161 | Returns: Returns $(true) if the two strings are not |
| 162 | the same<br> |
| 163 | </span> |
| 164 | <hr><b>strlen</b><br> |
| 165 | <br> |
| 166 | <span style="font-family: monospace;">Arguments: 1: A string<br> |
| 167 | Returns: Returns the length of the string<br> |
| 168 | </span> |
| 169 | <hr><b>substr</b><br> |
| 170 | <br> |
| 171 | <span style="font-family: monospace;">Arguments: 1: A string<br> |
| 172 | 2: Start offset (first character is 1)<br> |
| 173 | 3: Ending offset (inclusive)<br>Returns: Returns a substring<br> |
| 174 | </span> |
| 175 | <hr><b>split</b><br> |
| 176 | <br> |
| 177 | <span style="font-family: monospace;">Arguments: 1: The character to |
| 178 | split on<br> |
| 179 | 2: A |
| 180 | string to split<br> |
| 181 | Returns: Splits a string into a list separated by |
| 182 | spaces at the split<br> |
| 183 | character |
| 184 | in the first argument<br> |
| 185 | </span> |
| 186 | <hr><b>merge</b><br> |
| 187 | <br> |
| 188 | <span style="font-family: monospace;">Arguments: 1: The character to |
| 189 | put between fields<br> |
| 190 | 2: A list |
| 191 | to merge into a string<br> |
| 192 | Returns: Merges a list into a single string, list |
| 193 | elements are separated<br> |
| 194 | by the |
| 195 | character in the first argument<br> |
| 196 | </span> |
| 197 | <hr><b>tr</b><br> |
| 198 | <br> |
| 199 | <span style="font-family: monospace;">Arguments: 1: The list of |
| 200 | characters to translate from <br> |
| 201 | 2: The |
| 202 | list of characters to translate to<br> |
| 203 | 3: The |
| 204 | text to translate<br> |
| 205 | Returns: Returns the text after translating characters<br> |
| 206 | </span> |
| 207 | <hr><b>uc</b><br> |
| 208 | <br> |
| 209 | <span style="font-family: monospace;">Arguments: 1: Text to upper case<br> |
| 210 | Returns: Returns the text in upper case<br> |
| 211 | </span> |
| 212 | <hr><b>lc</b><br> |
| 213 | <br> |
| 214 | <span style="font-family: monospace;">Arguments: 1: Text to lower case<br> |
| 215 | Returns: Returns the text in lower case<br> |
| 216 | </span> |
| 217 | <hr style="width: 100%; height: 2px;"><span style="font-family: monospace;"></span> |
| 218 | <h2>Set Manipulation Functions</h2> |
| 219 | Sets are represented by sorted, deduplicated lists. To create a set |
| 220 | from a list use <span style="font-family: |
| 221 | monospace;">set_create</span>, or start with the <span |
| 222 | style="font-family: monospace;">empty_set</span> and <span |
| 223 | style="font-family: monospace;">set_insert</span> individual elements. |
| 224 | The empty set is defined as <span style="font-family: |
| 225 | monospace;">empty_set</span>.<p> |
| 226 | |
| 227 | <hr><b>set_create</b><br> |
| 228 | <br> |
| 229 | <span style="font-family: monospace;">Arguments: 1: A list of set elements<br> |
| 230 | Returns: Returns the newly created set<br> |
| 231 | </span> |
| 232 | |
| 233 | <hr><b>set_insert</b><br> |
| 234 | <br> |
| 235 | <span style="font-family: monospace;">Arguments: 1: A single element to add to a set<br> |
| 236 | 2: A set<br> |
| 237 | Returns: Returns the set with the element added<br> |
| 238 | </span> |
| 239 | |
| 240 | <hr><b>set_remove</b><br> |
| 241 | <br> |
| 242 | <span style="font-family: monospace;">Arguments: 1: A single element to remove from a set<br> |
| 243 | 2: A set<br> |
| 244 | Returns: Returns the set with the element removed<br> |
| 245 | </span> |
| 246 | |
| 247 | <hr><b>set_is_member</b><br> |
| 248 | <br> |
| 249 | <span style="font-family: monospace;">Arguments: 1: A single element<br> |
| 250 | 2: A set<br> |
| 251 | Returns: Returns $(true) if the element is in the set<br> |
| 252 | </span> |
| 253 | |
| 254 | <hr><b>set_union</b><br> |
| 255 | <br> |
| 256 | <span style="font-family: monospace;">Arguments: 1: A set<br> |
| 257 | 2: Another set<br> |
| 258 | Returns: Returns the union of the two sets<br> |
| 259 | </span> |
| 260 | |
| 261 | <hr><b>set_intersection</b><br> |
| 262 | <br> |
| 263 | <span style="font-family: monospace;">Arguments: 1: A set<br> |
| 264 | 2: Another set<br> |
| 265 | Returns: Returns the intersection of the two sets<br> |
| 266 | </span> |
| 267 | |
| 268 | <hr><b>set_is_subset</b><br> |
| 269 | <br> |
| 270 | <span style="font-family: monospace;">Arguments: 1: A set<br> |
| 271 | 2: Another set<br> |
| 272 | Returns: Returns $(true) if the first set is a subset of the second<br> |
| 273 | </span> |
| 274 | |
| 275 | <hr><b>set_equal</b><br> |
| 276 | <br> |
| 277 | <span style="font-family: monospace;">Arguments: 1: A set<br> |
| 278 | 2: Another set<br> |
| 279 | Returns: Returns $(true) if the two sets are identical<br> |
| 280 | </span> |
| 281 | |
| 282 | <hr style="width: 100%; height: 2px;"><span style="font-family: monospace;"></span> |
| 283 | <h2>Integer Arithmetic Functions</h2> |
| 284 | Integers are represented by lists with the equivalent number of |
| 285 | x's. For example the number 4 is x x x x. The maximum |
| 286 | integer that the library can handle as <span style="font-style: italic;">input</span> (i.e. as the argument to a |
| 287 | call to <span style="font-family: monospace;">int_encode</span>) is |
| 288 | 65536. There is no limit on integer size for internal computations or |
| 289 | output.<br> |
| 290 | <br> |
| 291 | The arithmetic library functions come in two forms: one form of each |
| 292 | function takes integers as arguments and the other form takes the |
| 293 | encoded form (x's created by a call to <span style="font-family: monospace;">int_encode</span>). For example, |
| 294 | there are two plus functions: <span style="font-family: monospace;">plus</span> |
| 295 | (called with integer arguments and returns an integer) and <span style="font-family: monospace;">int_plus</span> (called with encoded |
| 296 | arguments and returns an encoded result).<br> |
| 297 | <br> |
| 298 | <span style="font-family: monospace;">plus</span> will be slower than <span style="font-family: monospace;">int_plus</span> because its arguments |
| 299 | and result have to be translated between the x's format and |
| 300 | integers. If doing a complex calculation use the <span style="font-family: monospace;">int_*</span> forms with a single |
| 301 | encoding of inputs and single decoding of the output. For simple |
| 302 | calculations the direct forms can be used.<br> |
| 303 | <br> |
| 304 | <hr style="width: 100%; height: 2px;"><b>int_decode</b><br> |
| 305 | <br> |
| 306 | <span style="font-family: monospace;">Arguments: 1: A number of x's |
| 307 | representation<br> |
| 308 | Returns: Returns the integer for human consumption |
| 309 | that is represented<br> |
| 310 | by the |
| 311 | string of x's<br> |
| 312 | </span> |
| 313 | <hr><b>int_encode</b><br> |
| 314 | <br> |
| 315 | <span style="font-family: monospace;">Arguments: 1: A number in |
| 316 | human-readable integer form<br> |
| 317 | Returns: Returns the integer encoded as a string of x's<br> |
| 318 | </span> |
| 319 | <hr><b>int_plus</b><br> |
| 320 | <br> |
| 321 | <span style="font-family: monospace;">Arguments: 1: A number in x's |
| 322 | representation<br> |
| 323 | 2: Another |
| 324 | number in x's represntation<br> |
| 325 | Returns: Returns the sum of the two numbers in x's |
| 326 | representation<br> |
| 327 | </span> |
| 328 | <hr><b>plus (wrapped version of int_plus)</b><br> |
| 329 | <br> |
| 330 | <span style="font-family: monospace;">Arguments: 1: An integer<br> |
| 331 | 2: Another |
| 332 | integer<br> |
| 333 | Returns: Returns the sum of the two integers<br> |
| 334 | </span> |
| 335 | <hr><b>int_subtract</b><br> |
| 336 | <br> |
| 337 | <span style="font-family: monospace;">Arguments: 1: A number in x's |
| 338 | representation<br> |
| 339 | 2: Another |
| 340 | number in x's represntation<br> |
| 341 | Returns: Returns the difference of the two numbers in |
| 342 | x's representation,<br> |
| 343 | or outputs |
| 344 | an error on a numeric underflow<br> |
| 345 | </span> |
| 346 | <hr><b>subtract (wrapped version of int_subtract)</b><br> |
| 347 | <br> |
| 348 | <span style="font-family: monospace;">Arguments: 1: An integer<br> |
| 349 | 2: Another |
| 350 | integer<br> |
| 351 | Returns: Returns the difference of the two integers,<br> |
| 352 | or outputs |
| 353 | an error on a numeric underflow<br> |
| 354 | </span> |
| 355 | <hr><b>int_multiply</b><br> |
| 356 | <br> |
| 357 | <span style="font-family: monospace;">Arguments: 1: A number in x's |
| 358 | representation<br> |
| 359 | 2: Another |
| 360 | number in x's represntation<br> |
| 361 | Returns: Returns the product of the two numbers in x's |
| 362 | representation<br> |
| 363 | </span> |
| 364 | <hr><b>multiply (wrapped version of int_multiply)</b><br> |
| 365 | <br> |
| 366 | <span style="font-family: monospace;">Arguments: 1: An integer<br> |
| 367 | 2: Another |
| 368 | integer<br> |
| 369 | Returns: Returns the product of the two integers<br> |
| 370 | </span> |
| 371 | <hr><b>int_divide</b><br> |
| 372 | <br> |
| 373 | <span style="font-family: monospace;">Arguments: 1: A number in x's |
| 374 | representation<br> |
| 375 | 2: Another |
| 376 | number in x's represntation<br> |
| 377 | Returns: Returns the result of integer division of |
| 378 | argument 1 divided<br> |
| 379 | by |
| 380 | argument 2 in x's representation<br> |
| 381 | </span> |
| 382 | <hr><b>divide (wrapped version of int_divide)</b><br> |
| 383 | <br> |
| 384 | <span style="font-family: monospace;">Arguments: 1: An integer<br> |
| 385 | 2: Another |
| 386 | integer<br> |
| 387 | Returns: Returns the integer division of the first |
| 388 | argument by the second<br> |
| 389 | </span> |
| 390 | <hr><b>int_max, int_min</b><br> |
| 391 | <br> |
| 392 | <span style="font-family: monospace;">Arguments: 1: A number in x's |
| 393 | representation<br> |
| 394 | 2: Another |
| 395 | number in x's represntation<br> |
| 396 | Returns: Returns the maximum or minimum of its |
| 397 | arguments in x's<br> |
| 398 | |
| 399 | representation<br> |
| 400 | </span> |
| 401 | <hr><b>max, min</b><br> |
| 402 | <br> |
| 403 | <span style="font-family: monospace;">Arguments: 1: An integer<br> |
| 404 | 2: Another |
| 405 | integer<br> |
| 406 | Returns: Returns the maximum or minimum of its integer |
| 407 | arguments<br> |
| 408 | </span> |
| 409 | <hr><b>int_gt, int_gte, int_lt, int_lte, int_eq, int_ne</b><br> |
| 410 | <br> |
| 411 | <span style="font-family: monospace;">Arguments: Two x's representation |
| 412 | numbers to be compared<br> |
| 413 | Returns: $(true) or $(false)<br> |
| 414 | <br> |
| 415 | int_gt First argument greater than second argument<br> |
| 416 | int_gte First argument greater than or equal to second argument<br> |
| 417 | int_lt First argument less than second argument <br> |
| 418 | int_lte First argument less than or equal to second argument<br> |
| 419 | int_eq First argument is numerically equal to the second argument<br> |
| 420 | int_ne First argument is not numerically equal to the second argument<br> |
| 421 | </span> |
| 422 | <hr><b>gt, gte, lt, lte, eq, ne</b><br> |
| 423 | <br> |
| 424 | <span style="font-family: monospace;">Arguments: Two integers to be |
| 425 | compared<br> |
| 426 | Returns: $(true) or $(false)<br> |
| 427 | <br> |
| 428 | gt First argument greater than second argument<br> |
| 429 | gte First argument greater than or equal to second argument<br> |
| 430 | lt First argument less than second argument <br> |
| 431 | lte First argument less than or equal to second argument<br> |
| 432 | eq First argument is numerically equal to the second argument<br> |
| 433 | ne First argument is not numerically equal to the second argument<br> |
| 434 | </span> |
| 435 | increment adds 1 to its argument, decrement subtracts 1. Note that<br> |
| 436 | decrement does not range check and hence will not underflow, but<br> |
| 437 | will incorrectly say that 0 - 1 = 0<br> |
| 438 | <hr><b>int_inc</b><br> |
| 439 | <br> |
| 440 | <span style="font-family: monospace;">Arguments: 1: A number in x's |
| 441 | representation<br> |
| 442 | Returns: The number incremented by 1 in x's |
| 443 | representation<br> |
| 444 | </span> |
| 445 | <hr><b>inc</b><br> |
| 446 | <br> |
| 447 | <span style="font-family: monospace;">Arguments: 1: An integer<br> |
| 448 | Returns: The argument incremented by 1<br> |
| 449 | </span> |
| 450 | <hr><b>int_dec</b><br> |
| 451 | <br> |
| 452 | <span style="font-family: monospace;">Arguments: 1: A number in x's |
| 453 | representation<br> |
| 454 | Returns: The number decremented by 1 in x's |
| 455 | representation<br> |
| 456 | </span> |
| 457 | <hr><b>dec</b><br> |
| 458 | <br> |
| 459 | <span style="font-family: monospace;">Arguments: 1: An integer<br> |
| 460 | Returns: The argument decremented by 1<br> |
| 461 | </span> |
| 462 | <hr><b>int_double</b><br> |
| 463 | <br> |
| 464 | <span style="font-family: monospace;">Arguments: 1: A number in x's |
| 465 | representation<br> |
| 466 | Returns: The number doubled (i.e. * 2) and returned in |
| 467 | x's representation<br> |
| 468 | </span> |
| 469 | <hr><b>double</b><br> |
| 470 | <br> |
| 471 | <span style="font-family: monospace;">Arguments: 1: An integer<br> |
| 472 | Returns: The integer times 2<br> |
| 473 | </span> |
| 474 | <hr><b>int_halve</b><br> |
| 475 | <br> |
| 476 | <span style="font-family: monospace;">Arguments: 1: A number in x's |
| 477 | representation<br> |
| 478 | Returns: The number halved (i.e. / 2) and returned in |
| 479 | x's representation<br> |
| 480 | </span> |
| 481 | <hr><b>halve</b><br> |
| 482 | <br> |
| 483 | <span style="font-family: monospace;">Arguments: 1: An integer<br> |
| 484 | Returns: The integer divided by 2<br> |
| 485 | </span> |
| 486 | <hr style="width: 100%; height: 2px;"><span style="font-family: monospace;"></span> |
| 487 | <h2>Associative Arrays</h2> |
| 488 | An associate array maps a key value (a string with no spaces in it) to |
| 489 | a single value (any string). <br> |
| 490 | <b><br> |
| 491 | </b> |
| 492 | <hr style="width: 100%; height: 2px;"><b>set</b><br> |
| 493 | <br> |
| 494 | <span style="font-family: monospace;">Arguments: 1: Name of associative |
| 495 | array<br> |
| 496 | 2: The key |
| 497 | value to associate<br> |
| 498 | 3: The |
| 499 | value associated with the key<br> |
| 500 | Returns: None<br> |
| 501 | </span> |
| 502 | <hr><b>get</b><br> |
| 503 | <br> |
| 504 | <span style="font-family: monospace;">Arguments: 1: Name of associative |
| 505 | array<br> |
| 506 | 2: The key |
| 507 | to retrieve<br> |
| 508 | Returns: The value stored in the array for that key<br> |
| 509 | </span> |
| 510 | <hr><b>keys</b><br> |
| 511 | <br> |
| 512 | <span style="font-family: monospace;">Arguments: 1: Name of associative |
| 513 | array<br> |
| 514 | Returns: Returns a list of all defined keys in the |
| 515 | array<br> |
| 516 | </span> |
| 517 | <hr><b>defined</b><br> |
| 518 | <br> |
| 519 | <span style="font-family: monospace;">Arguments: 1: Name of associative |
| 520 | array<br> |
| 521 | 2: The key |
| 522 | to test<br> |
| 523 | Returns: Returns true if the key is defined (i.e. not |
| 524 | empty)<br> |
| 525 | </span> |
| 526 | <hr style="width: 100%; height: 2px;"><span style="font-family: monospace;"></span> |
| 527 | <h2>Named Stacks</h2> |
| 528 | A stack is an ordered list of strings (with no spaces in them).<br> |
| 529 | <br> |
| 530 | <hr style="width: 100%; height: 2px;"><b>push</b><br> |
| 531 | <br> |
| 532 | <span style="font-family: monospace;">Arguments: 1: Name of stack<br> |
| 533 | 2: Value |
| 534 | to push onto the top of the stack (must not contain<br> |
| 535 | a space)<br> |
| 536 | Returns: None<br> |
| 537 | </span> |
| 538 | <hr><b>pop</b><br> |
| 539 | <br> |
| 540 | <span style="font-family: monospace;">Arguments: 1: Name of stack<br> |
| 541 | Returns: Top element from the stack after removing it<br> |
| 542 | </span> |
| 543 | <hr><b>peek</b><br> |
| 544 | <br> |
| 545 | <span style="font-family: monospace;">Arguments: 1: Name of stack<br> |
| 546 | Returns: Top element from the stack without removing it<br> |
| 547 | </span> |
| 548 | <hr><b>depth</b><br> |
| 549 | <br> |
| 550 | <span style="font-family: monospace;">Arguments: 1: Name of stack<br> |
| 551 | Returns: Number of items on the stack<br> |
| 552 | </span> |
| 553 | <hr style="width: 100%; height: 2px;"><span style="font-family: monospace;"></span> |
| 554 | <h2>Miscellaneous and Debugging Facilities</h2> |
| 555 | GMSL defines the following constants; all are accessed as normal GNU |
| 556 | Make variables by wrapping them in <span style="font-family: monospace;">$()</span> or <span style="font-family: monospace;">${}</span>.<br> |
| 557 | <br> |
| 558 | <table style="text-align: left;" border="1" cellpadding="2" cellspacing="2"> |
| 559 | <tbody> |
| 560 | <tr> |
| 561 | <td><span style="font-style: italic;">Constant</span><br> |
| 562 | </td> |
| 563 | <td><span style="font-style: italic;">Value</span><br> |
| 564 | </td> |
| 565 | <td><span style="font-style: italic;">Purpose</span><br> |
| 566 | </td> |
| 567 | </tr> |
| 568 | <tr> |
| 569 | <td><span style="font-family: monospace;">true</span><br> |
| 570 | </td> |
| 571 | <td><span style="font-family: monospace;">T</span><br> |
| 572 | </td> |
| 573 | <td>Boolean for <span style="font-family: monospace;">$(if)</span> |
| 574 | and return from GMSL functions<br> |
| 575 | </td> |
| 576 | </tr> |
| 577 | <tr> |
| 578 | <td><span style="font-family: monospace;">false</span><br> |
| 579 | </td> |
| 580 | <td><br> |
| 581 | </td> |
| 582 | <td>Boolean for <span style="font-family: monospace;">$(if)</span> |
| 583 | and return from GMSL functions<br> |
| 584 | </td> |
| 585 | </tr> |
| 586 | <tr> |
| 587 | <td><span style="font-family: monospace;">gmsl_version</span><br> |
| 588 | </td> |
| 589 | <td><span style="font-family: monospace;">1 0 0</span><br> |
| 590 | </td> |
| 591 | <td>GMSL version number as list: major minor revision<br> |
| 592 | </td> |
| 593 | </tr> |
| 594 | </tbody> |
| 595 | </table> |
| 596 | <span style="font-weight: bold;"><br> |
| 597 | gmsl_compatible</span><span style="font-family: monospace;"><br> |
| 598 | <br> |
| 599 | Arguments: List containing the desired library version number (maj min |
| 600 | rev)<br> |
| 601 | </span><span style="font-family: monospace;">Returns: |
| 602 | $(true) if this version of the library is compatible<br> |
| 603 | </span><span style="font-family: monospace;"> |
| 604 | with the requested version number, otherwise $(false)</span> |
| 605 | <hr><b>gmsl-print-% (target not a function)</b><br> |
| 606 | <br> |
| 607 | <span style="font-family: monospace;">Arguments: The % should be |
| 608 | replaced by the name of a variable that you<br> |
| 609 | wish to |
| 610 | print out.<br> |
| 611 | Action: Echos the name of the variable that matches |
| 612 | the % and its value.<br> |
| 613 | For |
| 614 | example, 'make gmsl-print-SHELL' will output the value of<br> |
| 615 | the SHELL |
| 616 | variable<br> |
| 617 | </span> |
| 618 | <hr><b>assert</b><br> |
| 619 | <br> |
| 620 | <span style="font-family: monospace;">Arguments: 1: A boolean that must |
| 621 | be true or the assertion will fail<br> |
| 622 | 2: The |
| 623 | message to print with the assertion<br> |
| 624 | Returns: None<br> |
| 625 | </span> |
| 626 | <hr><b>assert_exists</b><br> |
| 627 | <br> |
| 628 | <span style="font-family: monospace;">Arguments: 1: Name of file that |
| 629 | must exist, if it is missing an assertion<br> |
| 630 | will be |
| 631 | generated<br> |
| 632 | Returns: None<br> |
| 633 | </span> |
| 634 | <hr style="width: 100%; height: 2px;"><br> |
| 635 | GMSL has a number of environment variables (or command-line overrides) |
| 636 | that control various bits of functionality:<br> |
| 637 | <br> |
| 638 | <table style="text-align: left;" border="1" cellpadding="2" cellspacing="2"> |
| 639 | <tbody> |
| 640 | <tr> |
| 641 | <td><span style="font-style: italic;">Variable</span><br> |
| 642 | </td> |
| 643 | <td><span style="font-style: italic;">Purpose</span><br> |
| 644 | </td> |
| 645 | </tr> |
| 646 | <tr> |
| 647 | <td><span style="font-family: monospace;">GMSL_NO_WARNINGS</span><br> |
| 648 | </td> |
| 649 | <td>If set prevents GMSL from outputting warning messages: |
| 650 | artithmetic functions generate underflow warnings.<br> |
| 651 | </td> |
| 652 | </tr> |
| 653 | <tr> |
| 654 | <td><span style="font-family: monospace;">GMSL_NO_ERRORS</span><br> |
| 655 | </td> |
| 656 | <td>If set prevents GMSL from generating fatal errors: division |
| 657 | by zero or failed assertions are fatal.<br> |
| 658 | </td> |
| 659 | </tr> |
| 660 | <tr> |
| 661 | <td><span style="font-family: monospace;">GMSL_TRACE</span><br> |
| 662 | </td> |
| 663 | <td>Enables function tracing. Calls to GMSL functions will |
| 664 | result in name and arguments being traced.<br> |
| 665 | </td> |
| 666 | </tr> |
| 667 | </tbody> |
| 668 | </table> |
| 669 | <span style="font-family: monospace;"></span><br> |
| 670 | <hr> |
| 671 | Copyright (c) 2005-2006 <a href="http://www.jgc.org/">John Graham-Cumming</a>.<br> |
| 672 | <hr style="width: 100%; height: 2px;"> |
| 673 | <table style="width: 100%; text-align: left;" border="0" cellpadding="2" cellspacing="2"> |
| 674 | <tbody> |
| 675 | <tr> |
| 676 | <td style="width: 50%;">John Graham-Cumming's work on this |
| 677 | project was sponsored by <a href="http://www.electric-cloud.com/">Electric |
| 678 | Cloud, Inc</a>.<br> |
| 679 | <a href="http://www.electric-cloud.com/"><img alt="" src="http://gmsl.sf.net/ec_logo.gif" style="border: 0px solid ; width: 223px; height: 47px;"></a><br> |
| 680 | </td> |
| 681 | <td align="right"> |
| 682 | <p><a href="http://sourceforge.net/"><img src="http://sourceforge.net/sflogo.php?group_id=129887&type=1" alt="SourceForge.net Logo" border="0" height="31" width="88"></a></p> |
| 683 | </td> |
| 684 | </tr> |
| 685 | </tbody> |
| 686 | </table> |
| 687 | </body></html> |