Skip to content
Myr

Fix trailing whitespace

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sean Barrett · committed by Sean Barrett · parent 7a69424 · Browse files · 22 files+352 added−352 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

22 files+352 added−352 removed

  • other:+352 added−352 removed

22 files+352 added−352 removed

This commit is too large to show whole: its files are listed by path, without their changes.

added:tools/trailing_whitespace.cnot shown

Its text is not shown, added.

modified:stb_c_lexer.h+28 added-28 removed
278 unmodified lines
279 STB_C_LEX_C_ARROW( CLEX_arrow )280 STB_C_LEX_EQUAL_ARROW( CLEX_eqarrow )281282#ifdef STB__clex_define_shifts283 CLEX_shleq, CLEX_shreq, 283 CLEX_shleq, CLEX_shreq,284#endif285286 CLEX_first_unused_token287
59 unmodified lines
347}348349static const char *stb__strchr(const char *str, int ch)350{351 for (; *str; ++str) 351 for (; *str; ++str)352 if (*str == ch)353 return str;354 return 0;355}
247 unmodified lines
603 );604 lexer->string[n] = 0;605 return stb__clex_token(lexer, CLEX_id, p, p+n-1);606 }607 607608 // check for EOF609 STB_C_LEX_0_IS_EOF(610 if (*p == 0)611 return stb__clex_eof(tok);612 )613614 single_char: 614 single_char:615 // not an identifier, return the character as itself616 return stb__clex_token(lexer, *p, p, p);617618 case '+':
309 unmodified lines
928This software is available under 2 licenses -- choose whichever you prefer.929------------------------------------------------------------------------------930ALTERNATIVE A - MIT License931Copyright (c) 2017 Sean Barrett932Permission is hereby granted, free of charge, to any person obtaining a copy of 933this software and associated documentation files (the "Software"), to deal in 934the Software without restriction, including without limitation the rights to 935use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 936of the Software, and to permit persons to whom the Software is furnished to do 932Permission is hereby granted, free of charge, to any person obtaining a copy of933this software and associated documentation files (the "Software"), to deal in934the Software without restriction, including without limitation the rights to935use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies936of the Software, and to permit persons to whom the Software is furnished to do937so, subject to the following conditions:938The above copyright notice and this permission notice shall be included in all 938The above copyright notice and this permission notice shall be included in all939copies or substantial portions of the Software.940THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 941IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 942FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 943AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 944LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 945OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 940THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR941IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,942FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE943AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER944LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,945OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE946SOFTWARE.947------------------------------------------------------------------------------948ALTERNATIVE B - Public Domain (www.unlicense.org)949This is free and unencumbered software released into the public domain.950Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 951software, either in source code form or as a compiled binary, for any purpose, 950Anyone is free to copy, modify, publish, use, compile, sell, or distribute this951software, either in source code form or as a compiled binary, for any purpose,952commercial or non-commercial, and by any means.953In jurisdictions that recognize copyright laws, the author or authors of this 954software dedicate any and all copyright interest in the software to the public 955domain. We make this dedication for the benefit of the public at large and to 956the detriment of our heirs and successors. We intend this dedication to be an 957overt act of relinquishment in perpetuity of all present and future rights to 953In jurisdictions that recognize copyright laws, the author or authors of this954software dedicate any and all copyright interest in the software to the public955domain. We make this dedication for the benefit of the public at large and to956the detriment of our heirs and successors. We intend this dedication to be an957overt act of relinquishment in perpetuity of all present and future rights to958this software under copyright law.959THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 960IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 961FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 962AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 963ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 959THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR960IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,961FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE962AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN963ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION964WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.965------------------------------------------------------------------------------966*/
modified:stb_connected_components.h+32 added-32 removed
3 unmodified lines
4// Finds connected components on 2D grids for testing reachability between5// two points, with fast updates when changing reachability (e.g. on one machine6// it was typically 0.2ms w/ 1024x1024 grid). Each grid square must be "open" or7// "closed" (traversable or untraversable), and grid squares are only connected8// to their orthogonal neighbors, not diagonally. 8// to their orthogonal neighbors, not diagonally.9//10// In one source file, create the implementation by doing something like this:11//12// #define STBCC_GRID_COUNT_X_LOG2 10
3 unmodified lines
16//17// The above creates an implementation that can run on maps up to 1024x1024.18// Map sizes must be a multiple of (1<<(LOG2/2)) on each axis (e.g. 32 if LOG2=10,19// 16 if LOG2=8, etc.) (You can just pad your map with untraversable space.)20// 20//21// MEMORY USAGE22//23// Uses about 6-7 bytes per grid square (e.g. 7MB for a 1024x1024 grid).24// Uses a single worst-case allocation which you pass in.
26 unmodified lines
51// - more optimized batching (current approach still recomputes local clumps many times)52// - function for setting a grid of squares at once (just use batching)53//54// LICENSE55// 55//56// See end of file for license information.57//58// ALGORITHM59//
374 unmodified lines
434 dx = -1, dy = 0;435 i = 0;436 j = 0;437 step_x = 0;438 step_y = 1; 438 step_y = 1;439 n = STBCC__CLUSTER_SIZE_Y;440 break;441 case 2:442 dy = -1, dx = 0;
155 unmodified lines
598 g->in_batched_update = 0;599600 #if 0601 for (j=0; j < STBCC__CLUSTER_COUNT_Y; ++j)602 for (i=0; i < STBCC__CLUSTER_COUNT_X; ++i) 602 for (i=0; i < STBCC__CLUSTER_COUNT_X; ++i)603 g->cluster_dirty[j][i] = 0;604 #endif605606 for (j=0; j < h; ++j) {
91 unmodified lines
698699 for (i=0; i < clump->num_adjacent; ++i)700 if (rc.clump_index == adj[i].clump_index &&701 rc.cluster_dx == adj[i].cluster_dx &&702 rc.cluster_dy == adj[i].cluster_dy) 702 rc.cluster_dy == adj[i].cluster_dy)703 break;704705 if (i < clump->num_adjacent)706 adj[i] = adj[--clump->num_adjacent];
28 unmodified lines
735 } else if (dx == -1) {736 i = 0;737 j = 0;738 step_x = 0;739 step_y = 1; 739 step_y = 1;740 n = STBCC__CLUSTER_SIZE_Y;741 } else if (dy == -1) {742 i = 0;743 j = 0;
52 unmodified lines
796 } else if (dx == -1) {797 i = 0;798 j = 0;799 step_x = 0;800 step_y = 1; 800 step_y = 1;801 n = STBCC__CLUSTER_SIZE_Y;802 } else if (dy == -1) {803 i = 0;804 j = 0;
206 unmodified lines
1011This software is available under 2 licenses -- choose whichever you prefer.1012------------------------------------------------------------------------------1013ALTERNATIVE A - MIT License1014Copyright (c) 2017 Sean Barrett1015Permission is hereby granted, free of charge, to any person obtaining a copy of 1016this software and associated documentation files (the "Software"), to deal in 1017the Software without restriction, including without limitation the rights to 1018use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 1019of the Software, and to permit persons to whom the Software is furnished to do 1015Permission is hereby granted, free of charge, to any person obtaining a copy of1016this software and associated documentation files (the "Software"), to deal in1017the Software without restriction, including without limitation the rights to1018use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies1019of the Software, and to permit persons to whom the Software is furnished to do1020so, subject to the following conditions:1021The above copyright notice and this permission notice shall be included in all 1021The above copyright notice and this permission notice shall be included in all1022copies or substantial portions of the Software.1023THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1024IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1025FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1026AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1027LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 1028OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 1023THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR1024IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,1025FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE1026AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER1027LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,1028OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE1029SOFTWARE.1030------------------------------------------------------------------------------1031ALTERNATIVE B - Public Domain (www.unlicense.org)1032This is free and unencumbered software released into the public domain.1033Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 1034software, either in source code form or as a compiled binary, for any purpose, 1033Anyone is free to copy, modify, publish, use, compile, sell, or distribute this1034software, either in source code form or as a compiled binary, for any purpose,1035commercial or non-commercial, and by any means.1036In jurisdictions that recognize copyright laws, the author or authors of this 1037software dedicate any and all copyright interest in the software to the public 1038domain. We make this dedication for the benefit of the public at large and to 1039the detriment of our heirs and successors. We intend this dedication to be an 1040overt act of relinquishment in perpetuity of all present and future rights to 1036In jurisdictions that recognize copyright laws, the author or authors of this1037software dedicate any and all copyright interest in the software to the public1038domain. We make this dedication for the benefit of the public at large and to1039the detriment of our heirs and successors. We intend this dedication to be an1040overt act of relinquishment in perpetuity of all present and future rights to1041this software under copyright law.1042THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1043IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1044FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1045AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 1046ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 1042THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR1043IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,1044FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE1045AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN1046ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION1047WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.1048------------------------------------------------------------------------------1049*/
modified:stb_divide.h+26 added-26 removed
1 unmodified line
2// Three kinds of divide/modulus of signed integers.3//4// HISTORY5//6// v0.93 2020-02-02 Write useful exit() value from main() 6// v0.93 2020-02-02 Write useful exit() value from main()7// v0.92 2019-02-25 Fix warning8// v0.91 2010-02-27 Fix euclidean division by INT_MIN for non-truncating C9// Check result with 64-bit math to catch such cases10// v0.90 2010-02-24 First public release
299 unmodified lines
310 int q,r;311 if (show) printf("(%+11d,%+d) | ", a,b);312 q = stb_div_trunc(a,b), r = stb_mod_trunc(a,b);313 if (show) printf("(%+11d,%+2d) ", q,r); stbdiv_check(q,r,a,b, "trunc",a);314 q = stb_div_floor(a,b), r = stb_mod_floor(a,b); 314 q = stb_div_floor(a,b), r = stb_mod_floor(a,b);315 if (show) printf("(%+11d,%+2d) ", q,r); stbdiv_check(q,r,a,b, "floor",b);316 q = stb_div_eucl (a,b), r = stb_mod_eucl (a,b);317 if (show) printf("(%+11d,%+2d)\n", q,r); stbdiv_check(q,r,a,b, "euclidean",1);318}
73 unmodified lines
392This software is available under 2 licenses -- choose whichever you prefer.393------------------------------------------------------------------------------394ALTERNATIVE A - MIT License395Copyright (c) 2017 Sean Barrett396Permission is hereby granted, free of charge, to any person obtaining a copy of 397this software and associated documentation files (the "Software"), to deal in 398the Software without restriction, including without limitation the rights to 399use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 400of the Software, and to permit persons to whom the Software is furnished to do 396Permission is hereby granted, free of charge, to any person obtaining a copy of397this software and associated documentation files (the "Software"), to deal in398the Software without restriction, including without limitation the rights to399use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies400of the Software, and to permit persons to whom the Software is furnished to do401so, subject to the following conditions:402The above copyright notice and this permission notice shall be included in all 402The above copyright notice and this permission notice shall be included in all403copies or substantial portions of the Software.404THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 405IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 406FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 407AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 408LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 409OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 404THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR405IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,406FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE407AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER408LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,409OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE410SOFTWARE.411------------------------------------------------------------------------------412ALTERNATIVE B - Public Domain (www.unlicense.org)413This is free and unencumbered software released into the public domain.414Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 415software, either in source code form or as a compiled binary, for any purpose, 414Anyone is free to copy, modify, publish, use, compile, sell, or distribute this415software, either in source code form or as a compiled binary, for any purpose,416commercial or non-commercial, and by any means.417In jurisdictions that recognize copyright laws, the author or authors of this 418software dedicate any and all copyright interest in the software to the public 419domain. We make this dedication for the benefit of the public at large and to 420the detriment of our heirs and successors. We intend this dedication to be an 421overt act of relinquishment in perpetuity of all present and future rights to 417In jurisdictions that recognize copyright laws, the author or authors of this418software dedicate any and all copyright interest in the software to the public419domain. We make this dedication for the benefit of the public at large and to420the detriment of our heirs and successors. We intend this dedication to be an421overt act of relinquishment in perpetuity of all present and future rights to422this software under copyright law.423THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 424IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 425FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 426AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 427ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 423THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR424IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,425FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE426AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN427ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION428WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.429------------------------------------------------------------------------------430*/
modified:stb_ds.h+29 added-29 removed
1/* stb_ds.h - v0.63 - public domain data structures - Sean Barrett 20192 23 This is a single-header-file library that provides easy-to-use4 dynamic arrays and hash tables for C (also works in C++).56 For a gentle introduction:
18 unmodified lines
2526 #define STBDS_NO_SHORT_NAMES2728 This flag needs to be set globally.29 2930 By default stb_ds exposes shorter function names that are not qualified31 with the "stbds_" prefix. If these names conflict with the names in your32 code, define this flag.33
36 unmodified lines
7071 Non-function interface:7273 Declare an empty dynamic array of type T74 T* foo = NULL; 74 T* foo = NULL;7576 Access the i'th item of a dynamic array 'foo' of type T, T* foo:77 foo[i]78
147 unmodified lines
226 T* hmgetp(T*, TK key)227 T* shgetp(T*, char* key)228 T* hmgetp_ts(T*, TK key, ptrdiff_t tempvar)229 T* hmgetp_null(T*, TK key)230 T* shgetp_null(T*, char *key) 230 T* shgetp_null(T*, char *key)231 Returns a pointer to the structure corresponding to 'key' in232 the hashmap. Functions ending in "_null" return NULL if the key233 is not present in the hashmap; the others return a pointer to a234 structure holding the default value (but not the searched-for key).
119 unmodified lines
354355 * If adversarial input is a serious concern and you're on a 64-bit platform,356 enable STBDS_SIPHASH_2_4 (see the 'Compile-time options' section), and pass357 a strong random number to stbds_rand_seed.358 358359 * The default value for the hash table is stored in foo[-1], so if you360 use code like 'hmget(T,k)->value = 5' you can accidentally overwrite361 the value stored by hmdefault if 'k' is not present.362
72 unmodified lines
435#define sh_new_strdup stbds_sh_new_strdup436437#define stralloc stbds_stralloc438#define strreset stbds_strreset439#endif 439#endif440441#if defined(STBDS_REALLOC) && !defined(STBDS_FREE) || !defined(STBDS_REALLOC) && defined(STBDS_FREE)442#error "You must define both STBDS_REALLOC and STBDS_FREE, or neither."443#endif
436 unmodified lines
880 #endif881 // Following statistics were measured on a Core i7-6700 @ 4.00Ghz, compiled with clang 7.0.1 -O2882 // Note that the larger tables have high variance as they were run fewer times883 // A1 A2 B1 C1884 // 0.10ms : 0.10ms : 0.10ms : 0.11ms : 2,000 inserts creating 2K table 885 // 0.96ms : 0.95ms : 0.97ms : 1.04ms : 20,000 inserts creating 20K table 886 // 14.48ms : 14.46ms : 10.63ms : 11.00ms : 200,000 inserts creating 200K table 887 // 195.74ms : 196.35ms : 203.69ms : 214.92ms : 2,000,000 inserts creating 2M table 888 // 2193.88ms : 2209.22ms : 2285.54ms : 2437.17ms : 20,000,000 inserts creating 20M table 889 // 65.27ms : 53.77ms : 65.33ms : 65.47ms : 500,000 inserts & deletes in 2K table 890 // 72.78ms : 62.45ms : 71.95ms : 72.85ms : 500,000 inserts & deletes in 20K table 884 // 0.10ms : 0.10ms : 0.10ms : 0.11ms : 2,000 inserts creating 2K table885 // 0.96ms : 0.95ms : 0.97ms : 1.04ms : 20,000 inserts creating 20K table886 // 14.48ms : 14.46ms : 10.63ms : 11.00ms : 200,000 inserts creating 200K table887 // 195.74ms : 196.35ms : 203.69ms : 214.92ms : 2,000,000 inserts creating 2M table888 // 2193.88ms : 2209.22ms : 2285.54ms : 2437.17ms : 20,000,000 inserts creating 20M table889 // 65.27ms : 53.77ms : 65.33ms : 65.47ms : 500,000 inserts & deletes in 2K table890 // 72.78ms : 62.45ms : 71.95ms : 72.85ms : 500,000 inserts & deletes in 20K table891 // 89.47ms : 77.72ms : 96.49ms : 96.75ms : 500,000 inserts & deletes in 200K table892 // 97.58ms : 98.14ms : 97.18ms : 97.53ms : 500,000 inserts & deletes in 2M table 893 // 118.61ms : 119.62ms : 120.16ms : 118.86ms : 500,000 inserts & deletes in 20M table 892 // 97.58ms : 98.14ms : 97.18ms : 97.53ms : 500,000 inserts & deletes in 2M table893 // 118.61ms : 119.62ms : 120.16ms : 118.86ms : 500,000 inserts & deletes in 20M table894 // 192.11ms : 194.39ms : 196.38ms : 195.73ms : 500,000 inserts & deletes in 200M table895896 if (slot_count <= STBDS_BUCKET_LENGTH)897 t->used_count_shrink_threshold = 0;
124 unmodified lines
1022 // (computes different results on 32-bit and 64-bit platform)1023 // derived from siphash, but on 32-bit platforms very different as it uses 4 32-bit state not 4 64-bit1024 v0 = ((((size_t) 0x736f6d65 << 16) << 16) + 0x70736575) ^ seed;1025 v1 = ((((size_t) 0x646f7261 << 16) << 16) + 0x6e646f6d) ^ ~seed;1026 v2 = ((((size_t) 0x6c796765 << 16) << 16) + 0x6e657261) ^ seed; 1026 v2 = ((((size_t) 0x6c796765 << 16) << 16) + 0x6e657261) ^ seed;1027 v3 = ((((size_t) 0x74656462 << 16) << 16) + 0x79746573) ^ ~seed;10281029 #ifdef STBDS_TEST_SIPHASH_2_41030 // hardcoded with key material in the siphash test vectors
94 unmodified lines
1125 #endif1126 // Following statistics were measured on a Core i7-6700 @ 4.00Ghz, compiled with clang 7.0.1 -O21127 // Note that the larger tables have high variance as they were run fewer times1128 // HASH32-A // HASH32-BB // HASH32-C1129 // 0.10ms // 0.10ms // 0.10ms : 2,000 inserts creating 2K table 1130 // 0.96ms // 0.95ms // 0.99ms : 20,000 inserts creating 20K table 1131 // 14.69ms // 14.43ms // 14.97ms : 200,000 inserts creating 200K table 1132 // 199.99ms // 195.36ms // 202.05ms : 2,000,000 inserts creating 2M table 1133 // 2234.84ms // 2187.74ms // 2240.38ms : 20,000,000 inserts creating 20M table 1134 // 55.68ms // 53.72ms // 57.31ms : 500,000 inserts & deletes in 2K table 1135 // 63.43ms // 61.99ms // 65.73ms : 500,000 inserts & deletes in 20K table 1129 // 0.10ms // 0.10ms // 0.10ms : 2,000 inserts creating 2K table1130 // 0.96ms // 0.95ms // 0.99ms : 20,000 inserts creating 20K table1131 // 14.69ms // 14.43ms // 14.97ms : 200,000 inserts creating 200K table1132 // 199.99ms // 195.36ms // 202.05ms : 2,000,000 inserts creating 2M table1133 // 2234.84ms // 2187.74ms // 2240.38ms : 20,000,000 inserts creating 20M table1134 // 55.68ms // 53.72ms // 57.31ms : 500,000 inserts & deletes in 2K table1135 // 63.43ms // 61.99ms // 65.73ms : 500,000 inserts & deletes in 20K table1136 // 80.04ms // 77.96ms // 81.83ms : 500,000 inserts & deletes in 200K table1137 // 100.42ms // 97.40ms // 102.39ms : 500,000 inserts & deletes in 2M table 1138 // 119.71ms // 120.59ms // 121.63ms : 500,000 inserts & deletes in 20M table 1137 // 100.42ms // 97.40ms // 102.39ms : 500,000 inserts & deletes in 2M table1138 // 119.71ms // 120.59ms // 121.63ms : 500,000 inserts & deletes in 20M table1139 // 185.28ms // 195.15ms // 187.74ms : 500,000 inserts & deletes in 200M table1140 // 15.58ms // 14.79ms // 15.52ms : 200,000 inserts creating 200K table with varying key spacing11411142 return (((size_t) hash << 16 << 16) | hash) ^ seed;
32 unmodified lines
1175#define STBDS_HASH_TO_ARR(x,elemsize) ((char*) (x) - (elemsize))1176#define STBDS_ARR_TO_HASH(x,elemsize) ((char*) (x) + (elemsize))11771178#define stbds_hash_table(a) ((stbds_hash_index *) stbds_header(a)->hash_table)1179 11791180void stbds_hmfree_func(void *a, size_t elemsize)1181{1182 if (a == NULL) return;1183 if (stbds_hash_table(a) != NULL) {
281 unmodified lines
1465 STBDS_FREE(NULL, *(char**) ((char *) a+elemsize*old_index));14661467 // if indices are the same, memcpy is a no-op, but back-pointer-fixup will fail, so skip1468 if (old_index != final_index) {1469 // swap delete 1469 // swap delete1470 memmove((char*) a + elemsize*old_index, (char*) a + elemsize*final_index, elemsize);14711472 // now find the slot for the last element1473 if (mode == STBDS_HM_STRING)
201 unmodified lines
1675 for (i=0; i < testsize; i+=1)1676 if (i & 3) STBDS_ASSERT(hmget(intmap, i) == -2 );1677 else STBDS_ASSERT(hmget(intmap, i) == i*3);1678 for (i=0; i < testsize; i+=1)1679 hmdel(intmap, i); // delete the rest of the entries 1679 hmdel(intmap, i); // delete the rest of the entries1680 for (i=0; i < testsize; i+=1)1681 STBDS_ASSERT(hmget(intmap, i) == -2 );1682 hmfree(intmap);1683 for (i=0; i < testsize; i+=2)
35 unmodified lines
1719 for (i=0; i < testsize; i+=1)1720 if (i & 3) STBDS_ASSERT(shget(strmap, strkey(i)) == -2 );1721 else STBDS_ASSERT(shget(strmap, strkey(i)) == i*3);1722 for (i=0; i < testsize; i+=1)1723 shdel(strmap, strkey(i)); // delete the rest of the entries 1723 shdel(strmap, strkey(i)); // delete the rest of the entries1724 for (i=0; i < testsize; i+=1)1725 STBDS_ASSERT(shget(strmap, strkey(i)) == -2 );1726 shfree(strmap);1727 }
101 unmodified lines
modified:stb_dxt.h+34 added-34 removed
21 unmodified lines
22// v1.02 - (stb) fix alpha encoding bug23// v1.01 - (stb) fix bug converting to RGB that messed up quality, thanks ryg & cbloom24// v1.00 - (stb) first release25//26// contributors: 26// contributors:27// Kevin Schmidt (#defines for "freestanding" compilation)28// github:ppiastucki (BC4 support)29// 29//30// LICENSE31//32// See end of file for license information.33
33 unmodified lines
6768// STB_DXT_USE_ROUNDING_BIAS69// use a rounding bias during color interpolation. this is closer to what "ideal"70// interpolation would do but doesn't match the S3TC/DX10 spec. old versions (pre-1.03)71// implicitly had this turned on. 71// implicitly had this turned on.72//73// in case you're targeting a specific type of hardware (e.g. console programmers):74// NVidia and Intel GPUs (as of 2010) as well as DX9 ref use DXT decoders that are closer75// to STB_DXT_USE_ROUNDING_BIAS. AMD/ATI, S3 and DX10 ref are closer to rounding with no bias.
82 unmodified lines
158 for (mx=0;mx<size;mx++) {159 int mine = expand[mn];160 int maxe = expand[mx];161 int err = STBD_ABS(stb__Lerp13(maxe, mine) - i);162 162163 // DX10 spec says that interpolation must be within 3% of "correct" result,164 // add this as error term. (normally we'd expect a random distribution of165 // +-1.5% error, but nowhere in the spec does it say that the error has to be166 // unbiased - better safe than sorry).
70 unmodified lines
237 //238 // relying on this 1d approximation isn't always optimal in terms of euclidean distance,239 // but it's very close and a lot faster.240 // http://cbloomrants.blogspot.com/2008/12/12-08-08-dxtc-summary.html241 241242 c0Point = (stops[1] + stops[3]) >> 1;243 halfPoint = (stops[3] + stops[2]) >> 1;244 c3Point = (stops[2] + stops[0]) >> 1;245
266 unmodified lines
512 int dither;513 int refinecount;514 unsigned short max16, min16;515 unsigned char dblock[16*4],color[4*4];516 516517 dither = mode & STB_DXT_DITHER;518 refinecount = (mode & STB_DXT_HIGHQUAL) ? 2 : 1;519520 // check if block is constant
21 unmodified lines
542543 // third step: refine (multiple times if requested)544 for (i=0;i<refinecount;i++) {545 unsigned int lastmask = mask;546 546547 if (stb__RefineBlock(dither ? dblock : block,&max16,&min16,mask)) {548 if (max16 != min16) {549 stb__EvalColors(color,max16,min16);550 mask = stb__MatchColorsBlock(block,color,dither);
1 unmodified line
552 mask = 0;553 break;554 }555 }556 556557 if(mask == lastmask)558 break;559 }560 }
45 unmodified lines
606 dist2 = dist*2;607 bias = (dist < 8) ? (dist - 1) : (dist/2 + 2);608 bias -= mn * 7;609 bits = 0,mask=0;610 610611 for (i=0;i<16;i++) {612 int a = src[i*stride]*7 + bias;613 int ind,t;614615 // select index. this is a "linear scale" lerp factor between 0 (val=min) and 7 (val=max).616 t = (a >= dist4) ? -1 : 0; ind = t & 4; a -= dist4 & t;617 t = (a >= dist2) ? -1 : 0; ind += t & 2; a -= dist2 & t;618 ind += (a >= dist);619 619620 // turn linear scale into DXT index (0/1 are extremal pts)621 ind = -ind & 7;622 ind ^= (2 > ind);623
68 unmodified lines
692This software is available under 2 licenses -- choose whichever you prefer.693------------------------------------------------------------------------------694ALTERNATIVE A - MIT License695Copyright (c) 2017 Sean Barrett696Permission is hereby granted, free of charge, to any person obtaining a copy of 697this software and associated documentation files (the "Software"), to deal in 698the Software without restriction, including without limitation the rights to 699use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 700of the Software, and to permit persons to whom the Software is furnished to do 696Permission is hereby granted, free of charge, to any person obtaining a copy of697this software and associated documentation files (the "Software"), to deal in698the Software without restriction, including without limitation the rights to699use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies700of the Software, and to permit persons to whom the Software is furnished to do701so, subject to the following conditions:702The above copyright notice and this permission notice shall be included in all 702The above copyright notice and this permission notice shall be included in all703copies or substantial portions of the Software.704THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 705IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 706FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 707AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 708LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 709OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 704THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR705IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,706FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE707AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER708LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,709OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE710SOFTWARE.711------------------------------------------------------------------------------712ALTERNATIVE B - Public Domain (www.unlicense.org)713This is free and unencumbered software released into the public domain.714Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 715software, either in source code form or as a compiled binary, for any purpose, 714Anyone is free to copy, modify, publish, use, compile, sell, or distribute this715software, either in source code form or as a compiled binary, for any purpose,716commercial or non-commercial, and by any means.717In jurisdictions that recognize copyright laws, the author or authors of this 718software dedicate any and all copyright interest in the software to the public 719domain. We make this dedication for the benefit of the public at large and to 720the detriment of our heirs and successors. We intend this dedication to be an 721overt act of relinquishment in perpetuity of all present and future rights to 717In jurisdictions that recognize copyright laws, the author or authors of this718software dedicate any and all copyright interest in the software to the public719domain. We make this dedication for the benefit of the public at large and to720the detriment of our heirs and successors. We intend this dedication to be an721overt act of relinquishment in perpetuity of all present and future rights to722this software under copyright law.723THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 724IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 725FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 726AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 727ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 723THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR724IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,725FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE726AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN727ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION728WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.729------------------------------------------------------------------------------730*/
modified:stb_easy_font.h+25 added-25 removed
56 unmodified lines
57// void stb_easy_font_spacing(float spacing)58//59// Use positive values to expand the space between characters,60// and small negative values (no smaller than -1.5) to contract61// the space between characters. 61// the space between characters.62//63// E.g. spacing = 1 adds one "pixel" of spacing between the64// characters. spacing = -1 is reasonable but feels a bit too65// compact to me; -0.5 is a reasonable compromise as long as
201 unmodified lines
267This software is available under 2 licenses -- choose whichever you prefer.268------------------------------------------------------------------------------269ALTERNATIVE A - MIT License270Copyright (c) 2017 Sean Barrett271Permission is hereby granted, free of charge, to any person obtaining a copy of 272this software and associated documentation files (the "Software"), to deal in 273the Software without restriction, including without limitation the rights to 274use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 275of the Software, and to permit persons to whom the Software is furnished to do 271Permission is hereby granted, free of charge, to any person obtaining a copy of272this software and associated documentation files (the "Software"), to deal in273the Software without restriction, including without limitation the rights to274use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies275of the Software, and to permit persons to whom the Software is furnished to do276so, subject to the following conditions:277The above copyright notice and this permission notice shall be included in all 277The above copyright notice and this permission notice shall be included in all278copies or substantial portions of the Software.279THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 280IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 281FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 282AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 283LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 284OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 279THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR280IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,281FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE282AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER283LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,284OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE285SOFTWARE.286------------------------------------------------------------------------------287ALTERNATIVE B - Public Domain (www.unlicense.org)288This is free and unencumbered software released into the public domain.289Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 290software, either in source code form or as a compiled binary, for any purpose, 289Anyone is free to copy, modify, publish, use, compile, sell, or distribute this290software, either in source code form or as a compiled binary, for any purpose,291commercial or non-commercial, and by any means.292In jurisdictions that recognize copyright laws, the author or authors of this 293software dedicate any and all copyright interest in the software to the public 294domain. We make this dedication for the benefit of the public at large and to 295the detriment of our heirs and successors. We intend this dedication to be an 296overt act of relinquishment in perpetuity of all present and future rights to 292In jurisdictions that recognize copyright laws, the author or authors of this293software dedicate any and all copyright interest in the software to the public294domain. We make this dedication for the benefit of the public at large and to295the detriment of our heirs and successors. We intend this dedication to be an296overt act of relinquishment in perpetuity of all present and future rights to297this software under copyright law.298THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 299IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 300FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 301AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 302ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 298THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR299IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,300FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE301AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN302ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION303WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.304------------------------------------------------------------------------------305*/
modified:stb_herringbone_wang_tile.h+6 added-6 removed
15 unmodified lines
16 The core design is that you use this library offline to generate a17 "template" of the tiles you'll create. You then edit those tiles, then18 load the created tile image file back into this library and use it at19 runtime to generate "maps".20 2021 You cannot load arbitrary tile image files with this library; it is22 only designed to load image files made from the template it created.23 It stores a binary description of the tile sizes & constraints in a24 few pixels, and uses those to recover the rules, rather than trying25 to parse the tiles themselves.26 2627 You *can* use this library to generate from arbitrary tile sets, but28 only by loading the tile set and specifying the constraints explicitly29 yourself.30
110 unmodified lines
141== VERSION HISTORY ===================142143 0.7 2019-03-04 - fix warnings144 0.6 2014-08-17 - fix broken map-maker145 0.5 2014-07-07 - initial release 145 0.5 2014-07-07 - initial release146147*/148149//////////////////////////////////////////////////////////////////////////////
100 unmodified lines
250//251// there are 4 "types" of corners and 6 types of edges.252// you can configure the tileset to have different numbers253// of colors for each type of color or edge.254// 254//255// corner types:256//257// 0---*---1---*---2---*---3258// | | |
253 unmodified lines
512 for (k=0; k < c->num_color[3]; ++k) {513 for (j=0; j < c->num_color[0]; ++j) {514 for (i=0; i < c->num_color[1]; ++i) {515 for (q=0; q < c->num_vary_x; ++q) {516 stbhw__process_v_row(p, 0,ypos, 516 stbhw__process_v_row(p, 0,ypos,517 0,c->num_color[0]-1, 0,c->num_color[3]-1, 0,c->num_color[2]-1,518 i,i, j,j, k,k,519 c->num_vary_y);520 ypos += (c->short_side_len*2) + 3;
167 unmodified lines
688689690691// generate a map that is w * h pixels (3-bytes each)692// returns 1 on success, 0 on error 692// returns 1 on success, 0 on error693STBHW_EXTERN int stbhw_generate_image(stbhw_tileset *ts, int **weighting, unsigned char *output, int stride, int w, int h)694{695 int sidelen = ts->short_side_len;696 int xmax = (w / sidelen) + 6;
525 unmodified lines
modified:stb_image_resize.hnot shown

Its text is not shown, modified.

modified:stb_image_write.hnot shown

Its text is not shown, modified.

modified:stb_image.h+73 added-73 removed
50 unmodified lines
51 2.24 (2020-02-02) fix warnings; thread-local failure_reason and flip_vertically52 2.23 (2019-08-11) fix clang static analysis warning53 2.22 (2019-03-04) gif fixes, fix warnings54 2.21 (2019-02-25) fix typo in comment55 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs 55 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs56 2.19 (2018-02-11) fix warning57 2.18 (2018-01-30) fix warnings58 2.17 (2018-01-29) bugfix, 1-bit BMP, 16-bitness query, fix warnings59 2.16 (2017-07-23) all functions have 16-bit variants; optimizations; bugfixes
47 unmodified lines
107 Julian Raschke Gregory Mullen Baldur Karlsson github:poppolopoppo108 Christian Floisand Kevin Schmidt JR Smith github:darealshinji109 Brad Weinberger Matvey Cherevko github:Michaelangel007110 Blazej Dariusz Roszkowski111 111112*/113114#ifndef STBI_INCLUDE_STB_IMAGE_H115#define STBI_INCLUDE_STB_IMAGE_H
777 unmodified lines
893static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);894static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp);895#endif896897static 897static898#ifdef STBI_THREAD_LOCAL899STBI_THREAD_LOCAL900#endif901const char *stbi__g_failure_reason;
256 unmodified lines
1158 int slice_size = w * h * bytes_per_pixel;11591160 stbi_uc *bytes = (stbi_uc *)image;1161 for (slice = 0; slice < z; ++slice) {1162 stbi__vertical_flip(bytes, w, h, bytes_per_pixel); 1163 bytes += slice_size; 1162 stbi__vertical_flip(bytes, w, h, bytes_per_pixel);1163 bytes += slice_size;1164 }1165}1166#endif1167
77 unmodified lines
1245 wchar_t wMode[64];1246 wchar_t wFilename[1024];1247 if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, filename, -1, wFilename, sizeof(wFilename)))1248 return 0;1249 12491250 if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode)))1251 return 0;12521253#if _MSC_VER >= 1400
93 unmodified lines
1347#ifndef STBI_NO_GIF1348STBIDEF stbi_uc *stbi_load_gif_from_memory(stbi_uc const *buffer, int len, int **delays, int *x, int *y, int *z, int *comp, int req_comp)1349{1350 unsigned char *result;1351 stbi__context s; 1352 stbi__start_mem(&s,buffer,len); 1353 1351 stbi__context s;1352 stbi__start_mem(&s,buffer,len);13531354 result = (unsigned char*) stbi__load_gif_main(&s, delays, x, y, z, comp, req_comp);1355 if (stbi__vertically_flip_on_load) {1356 stbi__vertical_flip_slices( result, *x, *y, *z, *comp ); 1356 stbi__vertical_flip_slices( result, *x, *y, *z, *comp );1357 }13581359 return result; 1359 return result;1360}1361#endif13621363#ifndef STBI_NO_LINEAR
4928 unmodified lines
6292{6293 int w,h;6294 stbi_uc *out; // output buffer (always 4 components)6295 stbi_uc *background; // The current "background" as far as a gif is concerned6296 stbi_uc *history; 6296 stbi_uc *history;6297 int flags, bgindex, ratio, transparent, eflags;6298 stbi_uc pal[256][4];6299 stbi_uc lpal[256][4];6300 stbi__gif_lzw codes[8192];
79 unmodified lines
63806381static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code)6382{6383 stbi_uc *p, *c;6384 int idx; 6384 int idx;63856386 // recurse to decode the prefixes, since the linked-list is backwards,6387 // and working backwards through an interleaved image would be nasty6388 if (g->codes[code].prefix >= 0)6389 stbi__out_gif_code(g, g->codes[code].prefix);63906391 if (g->cur_y >= g->max_y) return;63926393 idx = g->cur_x + g->cur_y; 6393 idx = g->cur_x + g->cur_y;6394 p = &g->out[idx];6395 g->history[idx / 4] = 1; 6395 g->history[idx / 4] = 1;63966397 c = &g->color_table[g->codes[code].suffix * 4];6398 if (c[3] > 128) { // don't render transparent pixels; 6398 if (c[3] > 128) { // don't render transparent pixels;6399 p[0] = c[2];6400 p[1] = c[1];6401 p[2] = c[0];6402 p[3] = c[3];
100 unmodified lines
6503// this function is designed to support animated gifs, although stb_image doesn't support it6504// two back is the image from two frames ago, used for a very specific disposal format6505static stbi_uc *stbi__gif_load_next(stbi__context *s, stbi__gif *g, int *comp, int req_comp, stbi_uc *two_back)6506{6507 int dispose; 6508 int first_frame; 6509 int pi; 6510 int pcount; 6507 int dispose;6508 int first_frame;6509 int pi;6510 int pcount;6511 STBI_NOTUSED(req_comp);65126513 // on first frame, any non-written pixels get the background colour (non-transparent)6514 first_frame = 0; 6514 first_frame = 0;6515 if (g->out == 0) {6516 if (!stbi__gif_header(s, g, comp,0)) return 0; // stbi__g_failure_reason set by stbi__gif_header6517 if (!stbi__mad3sizes_valid(4, g->w, g->h, 0))6518 return stbi__errpuc("too large", "GIF image is too large");
3 unmodified lines
6522 g->history = (stbi_uc *) stbi__malloc(pcount);6523 if (!g->out || !g->background || !g->history)6524 return stbi__errpuc("outofmem", "Out of memory");65256526 // image is treated as "transparent" at the start - ie, nothing overwrites the current background; 6526 // image is treated as "transparent" at the start - ie, nothing overwrites the current background;6527 // background colour is only used for pixels that are not rendered first frame, after that "background"6528 // color refers to the color that was there the previous frame. 6528 // color refers to the color that was there the previous frame.6529 memset(g->out, 0x00, 4 * pcount);6530 memset(g->background, 0x00, 4 * pcount); // state of the background (starts transparent)6531 memset(g->history, 0x00, pcount); // pixels that were affected previous frame6532 first_frame = 1; 6532 first_frame = 1;6533 } else {6534 // second frame - how do we dispoase of the previous one?6535 dispose = (g->eflags & 0x1C) >> 2; 6536 pcount = g->w * g->h; 6535 dispose = (g->eflags & 0x1C) >> 2;6536 pcount = g->w * g->h;65376538 if ((dispose == 3) && (two_back == 0)) {6539 dispose = 2; // if I don't have an image to revert back to, default to the old background6540 }65416542 if (dispose == 3) { // use previous graphic6543 for (pi = 0; pi < pcount; ++pi) {6544 if (g->history[pi]) {6545 memcpy( &g->out[pi * 4], &two_back[pi * 4], 4 ); 6545 memcpy( &g->out[pi * 4], &two_back[pi * 4], 4 );6546 }6547 }6548 } else if (dispose == 2) { 6549 // restore what was changed last frame to background before that frame; 6548 } else if (dispose == 2) {6549 // restore what was changed last frame to background before that frame;6550 for (pi = 0; pi < pcount; ++pi) {6551 if (g->history[pi]) {6552 memcpy( &g->out[pi * 4], &g->background[pi * 4], 4 ); 6552 memcpy( &g->out[pi * 4], &g->background[pi * 4], 4 );6553 }6554 }6555 } else {6556 // This is a non-disposal case eithe way, so just 6556 // This is a non-disposal case eithe way, so just6557 // leave the pixels as is, and they will become the new background6558 // 1: do not dispose6559 // 0: not specified.6560 }65616562 // background is what out is after the undoing of the previou frame; 6563 memcpy( g->background, g->out, 4 * g->w * g->h ); 6562 // background is what out is after the undoing of the previou frame;6563 memcpy( g->background, g->out, 4 * g->w * g->h );6564 }65656566 // clear my history; 6566 // clear my history;6567 memset( g->history, 0x00, g->w * g->h ); // pixels that were affected previous frame65686569 for (;;) {6570 int tag = stbi__get8(s); 6570 int tag = stbi__get8(s);6571 switch (tag) {6572 case 0x2C: /* Image Descriptor */6573 {6574 stbi__int32 x, y, w, h;
36 unmodified lines
6611 g->color_table = (stbi_uc *) g->lpal;6612 } else if (g->flags & 0x80) {6613 g->color_table = (stbi_uc *) g->pal;6614 } else6615 return stbi__errpuc("missing color table", "Corrupt GIF"); 6616 6615 return stbi__errpuc("missing color table", "Corrupt GIF");66166617 o = stbi__process_gif_raster(s, g);6618 if (!o) return NULL;66196620 // if this was the first frame, 6621 pcount = g->w * g->h; 6620 // if this was the first frame,6621 pcount = g->w * g->h;6622 if (first_frame && (g->bgindex > 0)) {6623 // if first frame, any pixel not drawn to gets the background color6624 for (pi = 0; pi < pcount; ++pi) {6625 if (g->history[pi] == 0) {6626 g->pal[g->bgindex][3] = 255; // just in case it was made transparent, undo that; It will be reset next frame if need be; 6627 memcpy( &g->out[pi * 4], &g->pal[g->bgindex], 4 ); 6626 g->pal[g->bgindex][3] = 255; // just in case it was made transparent, undo that; It will be reset next frame if need be;6627 memcpy( &g->out[pi * 4], &g->pal[g->bgindex], 4 );6628 }6629 }6630 }6631
2 unmodified lines
66346635 case 0x21: // Comment Extension.6636 {6637 int len;6638 int ext = stbi__get8(s); 6638 int ext = stbi__get8(s);6639 if (ext == 0xF9) { // Graphic Control Extension.6640 len = stbi__get8(s);6641 if (len == 4) {6642 g->eflags = stbi__get8(s);6643 g->delay = 10 * stbi__get16le(s); // delay - 1/100th of a second, saving as 1/1000ths.66446645 // unset old transparent6646 if (g->transparent >= 0) {6647 g->pal[g->transparent][3] = 255; 6648 } 6647 g->pal[g->transparent][3] = 255;6648 }6649 if (g->eflags & 0x01) {6650 g->transparent = stbi__get8(s);6651 if (g->transparent >= 0) {6652 g->pal[g->transparent][3] = 0; 6652 g->pal[g->transparent][3] = 0;6653 }6654 } else {6655 // don't need transparent6656 stbi__skip(s, 1); 6657 g->transparent = -1; 6656 stbi__skip(s, 1);6657 g->transparent = -1;6658 }6659 } else {6660 stbi__skip(s, len);6661 break;6662 }6663 } 6663 }6664 while ((len = stbi__get8(s)) != 0) {6665 stbi__skip(s, len);6666 }6667 break;
10 unmodified lines
66786679static void *stbi__load_gif_main(stbi__context *s, int **delays, int *x, int *y, int *z, int *comp, int req_comp)6680{6681 if (stbi__gif_test(s)) {6682 int layers = 0; 6682 int layers = 0;6683 stbi_uc *u = 0;6684 stbi_uc *out = 0;6685 stbi_uc *two_back = 0; 6685 stbi_uc *two_back = 0;6686 stbi__gif g;6687 int stride; 6687 int stride;6688 memset(&g, 0, sizeof(g));6689 if (delays) {6690 *delays = 0; 6690 *delays = 0;6691 }66926693 do {6694 u = stbi__gif_load_next(s, &g, comp, req_comp, two_back);
1 unmodified line
66966697 if (u) {6698 *x = g.w;6699 *y = g.h;6700 ++layers; 6701 stride = g.w * g.h * 4; 6702 6700 ++layers;6701 stride = g.w * g.h * 4;67026703 if (out) {6704 void *tmp = (stbi_uc*) STBI_REALLOC( out, layers * stride );6705 if (NULL == tmp) {6706 STBI_FREE(g.out);
3 unmodified lines
6710 }6711 else6712 out = (stbi_uc*) tmp;6713 if (delays) {6714 *delays = (int*) STBI_REALLOC( *delays, sizeof(int) * layers ); 6714 *delays = (int*) STBI_REALLOC( *delays, sizeof(int) * layers );6715 }6716 } else {6717 out = (stbi_uc*)stbi__malloc( layers * stride ); 6717 out = (stbi_uc*)stbi__malloc( layers * stride );6718 if (delays) {6719 *delays = (int*) stbi__malloc( layers * sizeof(int) ); 6719 *delays = (int*) stbi__malloc( layers * sizeof(int) );6720 }6721 }6722 memcpy( out + ((layers - 1) * stride), u, stride ); 6722 memcpy( out + ((layers - 1) * stride), u, stride );6723 if (layers >= 2) {6724 two_back = out - 2 * stride; 6724 two_back = out - 2 * stride;6725 }67266727 if (delays) {6728 (*delays)[layers - 1U] = g.delay; 6728 (*delays)[layers - 1U] = g.delay;6729 }6730 }6731 } while (u != 0); 6731 } while (u != 0);67326733 // free temp buffer; 6734 STBI_FREE(g.out); 6735 STBI_FREE(g.history); 6736 STBI_FREE(g.background); 6733 // free temp buffer;6734 STBI_FREE(g.out);6735 STBI_FREE(g.history);6736 STBI_FREE(g.background);67376738 // do the final conversion after loading everything; 6738 // do the final conversion after loading everything;6739 if (req_comp && req_comp != 4)6740 out = stbi__convert_format(out, 4, req_comp, layers * g.w, g.h);67416742 *z = layers; 6742 *z = layers;6743 return out;6744 } else {6745 return stbi__errpuc("not GIF", "Image was not as a gif type."); 6745 return stbi__errpuc("not GIF", "Image was not as a gif type.");6746 }6747}67486749static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)
9 unmodified lines
6759 *x = g.w;6760 *y = g.h;67616762 // moved conversion to after successful load so that the same6763 // can be done for multiple frames. 6763 // can be done for multiple frames.6764 if (req_comp && req_comp != 4)6765 u = stbi__convert_format(u, 4, req_comp, g.w, g.h);6766 } else if (g.out) {6767 // if there was an error and we allocated an image buffer, free it!6768 STBI_FREE(g.out);6769 }67706771 // free buffers needed for multiple frame loading; 6771 // free buffers needed for multiple frame loading;6772 STBI_FREE(g.history);6773 STBI_FREE(g.background); 6773 STBI_FREE(g.background);67746775 return u;6776}6777
654 unmodified lines
7432#endif // STB_IMAGE_IMPLEMENTATION74337434/*7435 revision history:7436 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs 7436 2.20 (2019-02-07) support utf8 filenames in Windows; fix warnings and platform ifdefs7437 2.19 (2018-02-11) fix warning7438 2.18 (2018-01-30) fix warnings7439 2.17 (2018-01-29) change sbti__shiftsigned to avoid clang -O2 bug7440 1-bit BMP
218 unmodified lines
modified:stb_include.hnot shown

Its text is not shown, modified.

modified:stb_leakcheck.hnot shown

Its text is not shown, modified.

modified:stb_perlin.hnot shown

Its text is not shown, modified.

modified:stb_rect_pack.hnot shown

Its text is not shown, modified.

modified:stb_textedit.hnot shown

Its text is not shown, modified.

modified:stb_tilemap_editor.hnot shown

Its text is not shown, modified.

modified:stb_truetype.hnot shown

Its text is not shown, modified.

modified:stb_vorbis.cnot shown

Its text is not shown, modified.

modified:stb_voxel_render.hnot shown

Its text is not shown, modified.

modified:stb.h+99 added-99 removed
6 unmodified lines
7 Documentation: http://nothings.org/stb/stb_h.html8 Unit tests: http://nothings.org/stb/stb.c910 ============================================================================11 You MUST 12 13 #define STB_DEFINE 14 11 You MUST1213 #define STB_DEFINE1415 in EXACTLY _one_ C or C++ file that includes this header, BEFORE the16 include, like this: 17 18 #define STB_DEFINE 16 include, like this:1718 #define STB_DEFINE19 #include "stb.h"20 2021 All other files should just #include "stb.h" without the #define.22 ============================================================================2324Version History
282 unmodified lines
307 #endif308 #ifndef rad2deg309 #define rad2deg(a) ((a)*(180/M_PI))310 #endif311 311312 #ifndef swap313 #ifndef __cplusplus314 #define swap(TYPE,a,b) \315 do { TYPE stb__t; stb__t = (a); (a) = (b); (b) = stb__t; } while (0)316 #endif 316 #endif317 #endif318 318319 typedef unsigned char uint8 ;320 typedef signed char int8 ;321 typedef unsigned short uint16;322 typedef signed short int16;
140 unmodified lines
463#define stb_p_strncpy_s(a,s,b,c) strncpy(a,b,c)464#define stb_p_mktemp(s) (mktemp(s) != NULL)465466#define stb_p_sprintf sprintf467#define stb_p_size(x) 467#define stb_p_size(x)468#endif469470#if defined(_WIN32)471#define stb_p_vsnprintf _vsnprintf
1692 unmodified lines
2164 }2165 }2166 }2167 }2168 } else 2168 } else2169 while (nested || !stb_tokentable[*s]) {2170 if (stable[*s]) {2171 if (!*s) break;2172 if (end ? etable[*s] : nested)
634 unmodified lines
2807 // try a second chunk to reduce wastage2808 if (c->next) {2809 p = stb__try_chunk(c->next, size, align, pre_align);2810 if (p) { ++c->alloc; return p; }2811 28112812 // put the bigger chunk first, since the second will get buried2813 // the upshot of this is that, until it gets allocated from, chunk #22814 // is always the largest remaining chunk. (could formalize2815 // this with a heap!)
192 unmodified lines
3008 stb__alloc_type t;30093010 if (ptr == NULL) return stb_malloc(NULL, newsize);3011 if (newsize == 0) { stb_free(ptr); return NULL; }3012 30123013 t = stb__identify(ptr);3014 assert(t == STB__alloc || t == STB__nochildren);30153016 if (t == STB__alloc) {
154 unmodified lines
3171#define stb_arr_len(a) (a ? stb_arrhead(a)->len : 0)3172#define stb_arr_len2(a) ((stb__arr *) (a) ? stb_arrhead2(a)->len : 0)3173#define stb_arr_lastn(a) (stb_arr_len(a)-1)31743175// check whether a given index is valid -- tests 0 <= i < stb_arr_len(a) 3175// check whether a given index is valid -- tests 0 <= i < stb_arr_len(a)3176#define stb_arr_valid(a,i) (a ? (int) (i) < stb_arrhead(a)->len : 0)31773178// change the array length so is is exactly N entries long, creating3179// uninitialized entries as needed
726 unmodified lines
3906 PREFIX int STB__(N, remove)(TYPE *a, KEY k, VALUE *v);39073908#define STB_nocopy(x) (x)3909#define STB_nodelete(x) 03910#define STB_nofields 3910#define STB_nofields3911#define STB_nonullvalue(x)3912#define STB_nullvalue(x) x3913#define STB_safecompare(x) x3914#define STB_nosafe(x)
367 unmodified lines
4282//4283// An stb_ptrmap data structure is an O(1) hash table storing an arbitrary4284// block of data for a given pair of pointers.4285//4286// If create=0, returns 4286// If create=0, returns42874288typedef struct stb__st_stb_spmatrix stb_spmatrix;42894290STB_EXTERN stb_spmatrix * stb_sparse_ptr_matrix_new(int val_size);
53 unmodified lines
4344// SDICT: Hash Table for Strings (symbol table)4345//4346// if "use_arena=1", then strings will be copied4347// into blocks and never freed until the sdict is freed;4348// otherwise they're malloc()ed and free()d on the fly. 4348// otherwise they're malloc()ed and free()d on the fly.4349// (specify use_arena=1 if you never stb_sdict_remove)43504351stb_declare_hash(STB_EXTERN, stb_sdict, stb_sdict_, char *, void *)43524353STB_EXTERN stb_sdict * stb_sdict_new(int use_arena);4354STB_EXTERN stb_sdict * stb_sdict_copy(stb_sdict*); 4354STB_EXTERN stb_sdict * stb_sdict_copy(stb_sdict*);4355STB_EXTERN void stb_sdict_delete(stb_sdict *);4356STB_EXTERN void * stb_sdict_change(stb_sdict *, char *str, void *p);4357STB_EXTERN int stb_sdict_count(stb_sdict *d);4358
65 unmodified lines
4424 n->arena = new_arena;4425 else if (new_arena)4426 stb_free(new_arena);4427 return n;4428} 4428}442944304431void stb_sdict_delete(stb_sdict *d)4432{
370 unmodified lines
4803 stb__memory_node *z = stb__memtab_root[address >> STB__NPTR_ROOT_SHIFT];4804 if (z)4805 return z->children[STB__NPTR_NODE_OFFSET(address)];4806 else4807 return NULL; 4807 return NULL;4808}48094810static void * stb__nptr_alloc(int size)4811{
111 unmodified lines
49234924 int b0 = start >> STB__NPTR_ROOT_SHIFT;4925 int b1 = end >> STB__NPTR_ROOT_SHIFT;4926 int b=b0,i,e0,e1;4927 49274928 e0 = STB__NPTR_NODE_OFFSET(start);49294930 if (datum <= 0) {4931 // first block
963 unmodified lines
5895 if (v < 0x10000000) return 4;5896 if (v < STB_IMM_UINT64(0x0000000800000000)) return 5;5897 if (v < STB_IMM_UINT64(0x0000040000000000)) return 6;5898 if (v < STB_IMM_UINT64(0x0002000000000000)) return 7;5899 if (v < STB_IMM_UINT64(0x0100000000000000)) return 8; 5899 if (v < STB_IMM_UINT64(0x0100000000000000)) return 8;5900 return 9;5901}59025903void stb_fput_varlen64(FILE *f, stb_uint64 v)
9 unmodified lines
5913 if (z >= STB_IMM_UINT64(0x00000800000000)) fputc((first ? 0xF8 : 0)+(char)(z>>40),f), first=0;5914 if (z >= STB_IMM_UINT64(0x00000010000000)) fputc((first ? 0xF0 : 0)+(char)(z>>32),f), first=0;5915 if (z >= STB_IMM_UINT64(0x00000000200000)) fputc((first ? 0xE0 : 0)+(char)(z>>24),f), first=0;5916 if (z >= STB_IMM_UINT64(0x00000000004000)) fputc((first ? 0xC0 : 0)+(char)(z>>16),f), first=0;5917 if (z >= STB_IMM_UINT64(0x00000000000080)) fputc((first ? 0x80 : 0)+(char)(z>> 8),f), first=0; 5917 if (z >= STB_IMM_UINT64(0x00000000000080)) fputc((first ? 0x80 : 0)+(char)(z>> 8),f), first=0;5918 fputc((char)z,f);5919}59205921void stb_fput_ranged(FILE *f, int v, int b, stb_uint n)
472 unmodified lines
63946395#define STB_ADLER32_SEED 16396#define STB_CRC32_SEED 0 // note that we logical NOT this in the code63976398STB_EXTERN stb_uint 6398STB_EXTERN stb_uint6399 stb_adler32(stb_uint adler32, stb_uchar *buffer, stb_uint buflen);6400STB_EXTERN stb_uint 6400STB_EXTERN stb_uint6401 stb_crc32_block(stb_uint crc32, stb_uchar *buffer, stb_uint len);6402STB_EXTERN stb_uint stb_crc32(unsigned char *buffer, stb_uint len);64036404STB_EXTERN void stb_sha1(
197 unmodified lines
66026603 buffer[n++] = 0x80;66046605 // if there isn't enough room for the length, double the block6606 if (n + 8 > 64) 6606 if (n + 8 > 64)6607 block = 128;66086609 // pad to end6610 memset(buffer+n, 0, block-8-n);
49 unmodified lines
6660 acc >>= 6;6661 num_bits -= 6;6662 }6663 assert(num_bits == 20*8 - 26*6);6664 display[o++] = encoding[acc]; 6664 display[o++] = encoding[acc];6665}66666667#endif // STB_DEFINE6668
20 unmodified lines
6689#define HKEY void *66906691STB_EXTERN __declspec(dllimport) long __stdcall RegCloseKey ( HKEY hKey );6692STB_EXTERN __declspec(dllimport) long __stdcall RegCreateKeyExA ( HKEY hKey, const char * lpSubKey,6693 int Reserved, char * lpClass, int dwOptions, 6693 int Reserved, char * lpClass, int dwOptions,6694 int samDesired, void *lpSecurityAttributes, HKEY * phkResult, int * lpdwDisposition );6695STB_EXTERN __declspec(dllimport) long __stdcall RegDeleteKeyA ( HKEY hKey, const char * lpSubKey );6696STB_EXTERN __declspec(dllimport) long __stdcall RegQueryValueExA ( HKEY hKey, const char * lpValueName,6697 int * lpReserved, unsigned long * lpType, unsigned char * lpData, unsigned long * lpcbData );
237 unmodified lines
6935int stb_cfg_delete(stb_cfg *z, char *key)6936{6937 int i;6938 for (i=0; i < stb_arr_len(z->data); ++i)6939 if (!stb_stricmp(z->data[i].key, key)) { 6939 if (!stb_stricmp(z->data[i].key, key)) {6940 stb_arr_fastdelete(z->data, i);6941 return 1;6942 }6943 return 0;
202 unmodified lines
7146 stb__wchar full_path[1024];7147 int has_slash;7148 if (stb__showfile) printf("<");71497150 has_slash = (path[0] && path[strlen(path)-1] == '/'); 7150 has_slash = (path[0] && path[strlen(path)-1] == '/');71517152 // @TODO: do this concatenation without using swprintf to avoid this mess:7153#if (defined(_MSC_VER) && _MSC_VER < 1400) // || (defined(__clang__))7154 // confusingly, Windows Kits\10 needs to go down this path?!?
429 unmodified lines
75847585void stb_wrapper_free(void *p, char *file, int line)7586{7587 int n;7588 75887589 if (p == NULL) return;75907591 n = stb__hashfind(p);7592
15 unmodified lines
76087609void stb_wrapper_check(void *p)7610{7611 int n;7612 76127613 if (p == NULL) return;76147615 n = stb__hashfind(p);7616
500 unmodified lines
8117 b->p[last] = 0;8118 if (count == 2) {8119 void *leftover = b->p[slast]; // second to last8120 stb_bucket_free(b);8121 return (stb_ps *) leftover; 8121 return (stb_ps *) leftover;8122 }8123 return ps;8124 }8125 case STB_ps_array: {
323 unmodified lines
8449 unsigned int * b = stb__mt_buffer;8450 int idx = stb__mt_index;8451 unsigned int s,r;8452 int i;8453 84538454 if (idx >= STB__MT_LEN*sizeof(unsigned int)) {8455 if (idx > STB__MT_LEN*sizeof(unsigned int))8456 stb_srand(0);8457 idx = 0;
5 unmodified lines
8463 for (; i < STB__MT_LEN-1; i++) {8464 s = STB__TWIST(b, i, i+1);8465 b[i] = b[i - STB__MT_IB] ^ (s >> 1) ^ STB__MAGIC(s);8466 }8467 84678468 s = STB__TWIST(b, STB__MT_LEN-1, 0);8469 b[STB__MT_LEN-1] = b[STB__MT_IA-1] ^ (s >> 1) ^ STB__MAGIC(s);8470 }8471 stb__mt_index = idx + sizeof(unsigned int);8472 84728473 r = *(unsigned int *)((unsigned char *)b + idx);8474 84748475 r ^= (r >> 11);8476 r ^= (r << 7) & 0x9D2C5680;8477 r ^= (r << 15) & 0xEFC60000;8478 r ^= (r >> 18);8479 84798480 return r;8481}84828483double stb_frand(void)
154 unmodified lines
8638 int i,j,k;8639 assert(sd->dupes == NULL);8640 for (i=0; i < sd->hash_size; ++i) {8641 void ** list = sd->hash_table[i];8642 if (list != NULL) { 8642 if (list != NULL) {8643 int n = stb_arr_len(list);8644 // @TODO: measure to find good numbers instead of just making them up!8645 int thresh = (sd->ineq ? 200 : 20);8646 // if n is large enough to be worth it, and n is smaller than
307 unmodified lines
8954{8955 int n=0,i=0, start=0,nonwhite=0;8956 if (pairs == NULL) pair_max = 0x7ffffff0;8957 else pair_max *= 2;8958 // parse 8958 // parse8959 for(;;) {8960 int s=i; // first whitespace char; last nonwhite+18961 int w; // word start8962 // accept whitespace
172 unmodified lines
9135int stb__wildmatch_raw2(char *expr, char *candidate, int search, int insensitive)9136{9137 int where=0;9138 int start = -1;9139 91399140 if (!search) {9141 // parse to first '*'9142 if (*expr != '*')9143 start = 0;
5 unmodified lines
9149 } else {9150 if (insensitive) {9151 if (tolower(*candidate) != tolower(*expr))9152 return -1;9153 } else 9153 } else9154 if (*candidate != *expr)9155 return -1;9156 }9157 ++candidate, ++expr, ++where;
8 unmodified lines
9166 if (!search)9167 ++expr;91689169 // implicit '*' at this point9170 91709171 while (*expr) {9172 int o=0;9173 // combine redundant * characters9174 while (expr[0] == '*') ++expr;
20 unmodified lines
9195 ++z;9196 // ok, now check if they match9197 if (stb__match_qstring(candidate+z-o, expr, o, insensitive))9198 return start >= 0 ? start : 0;9199 return -1; 9199 return -1;9200 } else {9201 // if yes '*', then do stb__find_qmatch on the intervening chars9202 int n = stb__find_qstring(candidate, expr, o, insensitive);9203 if (n < 0)
181 unmodified lines
93859386 case '{': // not supported!9387 // @TODO: given {n,m}, clone last_start to last_end m times,9388 // and include epsilons from start to first m-n blocks9389 return NULL; 9389 return NULL;93909391 case '\\':9392 ++regex;9393 if (!*regex) return NULL;
719 unmodified lines
10113} stb_info_struct;1011410115extern stb_info_struct stb_introspect_output[];1011610117// 10117//1011810119STB_EXTERN void stb_introspect_precompiled(stb_info_struct *compiled);10120STB_EXTERN void stb__introspect(char *path, char *file);10121
93 unmodified lines
1021510216 stb__introspect_filename(buffer2, path);1021710218 // get source/include files timestamps, compare to output-file timestamp;10219 // if mismatched, regenerate 10219 // if mismatched, regenerate1022010221 if (stb__stat(buffer2, &st))10222 needs_building = STB_TRUE;10223 1022310224 {10225 // find any file that contains an introspection command and is newer10226 // if needs_building is already true, we don't need to do this test,10227 // but we still need these arrays, so go ahead and get them
87 unmodified lines
10315 t = strchr(s, ')');10316 if (t == NULL) stb_fatal("Error parsing %s", filename);1031710318 }10319 } 10319 }10320}103211032210323
131 unmodified lines
10455 assert(0); /* NOTREACHED */10456 return 0;10457 }10458 }10459 assert(stb__dout <= output + olen); 10459 assert(stb__dout <= output + olen);10460 if (stb__dout > output + olen)10461 return 0;10462 }10463}
150 unmodified lines
10614}1061510616static int stb_not_crap(int best, int dist)10617{10618 return ((best > 2 && dist <= 0x00100) 10618 return ((best > 2 && dist <= 0x00100)10619 || (best > 5 && dist <= 0x04000)10620 || (best > 7 && dist <= 0x80000));10621}10622
78 unmodified lines
10701 stb_out(0x80 + best-1);10702 stb_out(dist-1);10703 } else if (best > 5 && best <= 0x100 && dist <= 0x4000) {10704 outliterals(lit_start, q-lit_start); lit_start = (q += best);10705 stb_out2(0x4000 + dist-1); 10705 stb_out2(0x4000 + dist-1);10706 stb_out(best-1);10707 } else if (best > 7 && best <= 0x100 && dist <= 0x80000) {10708 outliterals(lit_start, q-lit_start); lit_start = (q += best);10709 stb_out3(0x180000 + dist-1); 10709 stb_out3(0x180000 + dist-1);10710 stb_out(best-1);10711 } else if (best > 8 && best <= 0x10000 && dist <= 0x80000) {10712 outliterals(lit_start, q-lit_start); lit_start = (q += best);10713 stb_out3(0x100000 + dist-1); 10713 stb_out3(0x100000 + dist-1);10714 stb_out2(best-1);10715 } else if (best > 9 && dist <= 0x1000000) {10716 if (best > 65536) best = 65536;10717 outliterals(lit_start, q-lit_start); lit_start = (q += best);
71 unmodified lines
10789{10790 //int maxlen = length + 512 + (length >> 2); // total guess10791 //char *buffer = (char *) malloc(maxlen);10792 //int blen = stb_compress((stb_uchar*)buffer, (stb_uchar*)input, length);10793 1079310794 stb__out = NULL;10795 stb__outfile = stb_p_fopen(filename, "wb");10796 if (!stb__outfile) return 0;10797
11 unmodified lines
10809{10810 //int maxlen = length + 512 + (length >> 2); // total guess10811 //char *buffer = (char*)malloc(maxlen);10812 //int blen = stb_compress((stb_uchar*)buffer, (stb_uchar*)input, length);10813 1081310814 stb__out = NULL;10815 stb__outfile = f;10816 if (!stb__outfile) return 0;10817
167 unmodified lines
10985 // now shift the window10986 memmove(xtb.buffer, xtb.buffer + flush, xtb.valid - flush);10987 xtb.start -= flush;10988 xtb.valid -= flush;10989 1098910990 for (i=0; i <= xtb.hashmask; ++i)10991 if (xtb.chash[i] < xtb.buffer + flush)10992 xtb.chash[i] = NULL;10993 else
716 unmodified lines
11710}11711#endif // _WINDOWS_1171211713#if 011714// for future reference, 11714// for future reference,11715// InterlockedCompareExchange for x86:11716 int cas64_mp(void * dest, void * xcmp, void * xxchg) {11717 __asm11718 {
31 unmodified lines
11750 mov ebx,[edi];11751 mov ecx,4[edi];11752 mov esi,dest;11753 lock CMPXCHG8B [esi];11754 } 11754 }11755#endif // #if 01175611757#endif // _WIN3211758
561 unmodified lines
12320 int len;12321 FILE *f;12322 stb_uchar *buf;1232312324 if (dc->stat_out) { 12324 if (dc->stat_out) {12325 struct _stati64 s;12326 if (!_stati64(dc->filename, &s)) {12327 dc->stat_out->filesize = s.st_size;12328 dc->stat_out->filetime = s.st_mtime;
26 unmodified lines
12355 fseek(f, 0, SEEK_END);12356 len = ftell(f) - dc->offset;12357 }1235812359 if (fseek(f, dc->offset, SEEK_SET)) { 12359 if (fseek(f, dc->offset, SEEK_SET)) {12360 fclose(f);12361 return stb__io_error(dc);12362 }12363
263 unmodified lines
12627 p = stb__alloc_pages(pagecount < 16 ? 16 : pagecount);12628 if (p == NULL) return 0;12629 } else12630 stb__spanlist_unlink(p);12631 1263112632 if (p->len > pagecount) {12633 stb__span *q = stb__span_alloc();12634 if (q) {12635 q->start = p->start + pagecount;
249 unmodified lines
1288512886 stb_p_sprintf(filebuf stb_p_size(sizeof(filebuf)), "../%s", file);12887 if (!stb_fexists(filebuf)) return filebuf;1288812889 return file; 12889 return file;12890}12891#endif1289212893#define STB_F(x) ((float) STB_H(x))
76 unmodified lines
12970 break;12971 matched_int: {12972 int neg=0;12973 s = stb_skipwhite(s);12974 while (*s == '-') { neg = !neg; s = stb_skipwhite(s+1); } // handle '- - 5', pointlessly 12974 while (*s == '-') { neg = !neg; s = stb_skipwhite(s+1); } // handle '- - 5', pointlessly12975 if (s[0] == '0' && tolower(s[1]) == 'x')12976 f->entries[i].ival = strtol(s, NULL, 16);12977 else if (s[0] == '0')12978 f->entries[i].ival = strtol(s, NULL, 8);
185 unmodified lines
13164 n += stu__getfloat_addend[e] << 24;13165 return *(float *) &n;13166}1316713168stua_obj stua_float(float f) 13168stua_obj stua_float(float f)13169{13170 return stu__floatp(&f);13171}13172
162 unmodified lines
1333513336 // stu__mark everything reachable13337 stu__nil.stua_gc = stu__true.stua_gc = stu__false.stua_gc = 1;13338 stu__mark(stua_globals);13339 if (!stu__number(stu__flow_val)) 13339 if (!stu__number(stu__flow_val))13340 stu__mark(stu__flow_val);13341 for (i=0; i < stb_arr_len(stu__gc_root_stack); ++i)13342 if (!stu__number(stu__gc_root_stack[i]))13343 stu__mark(stu__gc_root_stack[i]);1334413345 // sweep unreachables13346 for (i=0; i < stb_arr_len(stu__gc_ptrlist);) {13347 stu__box *z = stu__gc_ptrlist[i]; 13347 stu__box *z = stu__gc_ptrlist[i];13348 if (!z->stua_gc) {13349 switch (z->type) {13350 case STU___dict: stb_idict_destroy((stua_dict *) z); break;13351 case STU___error: free(((stu__wrapper *) z)->ptr); break;
1 unmodified line
13353 case STU___function: stu__free_func((stu__func *) z); break;13354 }13355 // swap in the last item over this, and repeat13356 z = stb_arr_pop(stu__gc_ptrlist);13357 stu__gc_ptrlist[i] = z; 13357 stu__gc_ptrlist[i] = z;13358 } else13359 ++i;13360 }13361}
376 unmodified lines
13738 else {13739 stu__f = f->code, stu__c = context;13740 stu__f_obj = co;13741 ++stb__stua_nesting;13742 if (stu__f[1]) 13742 if (stu__f[1])13743 p = stu__eval(stu__f[1]);13744 else13745 p = stua_nil;13746 --stb__stua_nesting;
65 unmodified lines
13812 stua_key4(if,then,else,elseif) stua_key4(while,do,for,in)13813 stua_key4(func,var,let,break) stua_key4(nil,true,false,end)13814 stua_key4(return,continue,as,repeat) stua_key4(_frame,catch,catch,catch)1381513816 ST_shl, "<<", ST_and, "&&", ST_eq, "==", ST_ge, ">=", 13816 ST_shl, "<<", ST_and, "&&", ST_eq, "==", ST_ge, ">=",13817 ST_shr, ">>", ST_or , "||", ST_ne, "!=", ST_le, "<=",13818 ST_shru,">>>", ST_into, "=>",13819 T__none, ".",13820};
21 unmodified lines
1384213843static void stu__pop_func_comp(void)13844{13845 stb_arr_free(stu__pfunc.code);13846 stb_arr_free(stu__pfunc.data); 13846 stb_arr_free(stu__pfunc.data);13847 stb_idict_destroy(stu__pfunc.locals);13848 stb_arr_free(stu__pfunc.non_local_refs);13849 stu__pfunc = stb_arr_pop(func_stack);13850}
265 unmodified lines
14116 stb_arr_push(dict, z);14117 if (!stu__accept(',')) break;14118 }14119 if (!stu__demand(end))14120 return stu__err(end == ')' ? "Expecting ) at end of function call" 14120 return stu__err(end == ')' ? "Expecting ) at end of function call"14121 : "Expecting } at end of dictionary definition");14122 z = stu__cc2('{', stb_arr_len(dict)/2);14123 for (i=0; i < stb_arr_len(dict); ++i)14124 stu__cc(dict[i]);
106 unmodified lines
14231 short *nonlocal;14232 stua_obj v,f=stua_nil;14233 assert(stu__tok == ST_func);14234 stu__nexttoken();14235 if (id) { 14235 if (id) {14236 if (!stu__demandv(ST_id, id)) return stu__err("Expecting function name");14237 } else14238 stu__accept(ST_id);14239 if (!stu__demand('(')) return stu__err("Expecting ( for function parameter");
177 unmodified lines
14417This software is available under 2 licenses -- choose whichever you prefer.14418------------------------------------------------------------------------------14419ALTERNATIVE A - MIT License14420Copyright (c) 2017 Sean Barrett14421Permission is hereby granted, free of charge, to any person obtaining a copy of 14422this software and associated documentation files (the "Software"), to deal in 14423the Software without restriction, including without limitation the rights to 14424use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 14425of the Software, and to permit persons to whom the Software is furnished to do 14421Permission is hereby granted, free of charge, to any person obtaining a copy of14422this software and associated documentation files (the "Software"), to deal in14423the Software without restriction, including without limitation the rights to14424use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies14425of the Software, and to permit persons to whom the Software is furnished to do14426so, subject to the following conditions:14427The above copyright notice and this permission notice shall be included in all 14427The above copyright notice and this permission notice shall be included in all14428copies or substantial portions of the Software.14429THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14430IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14431FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14432AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14433LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 14434OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 14429THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14430IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,14431FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE14432AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER14433LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,14434OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE14435SOFTWARE.14436------------------------------------------------------------------------------14437ALTERNATIVE B - Public Domain (www.unlicense.org)14438This is free and unencumbered software released into the public domain.14439Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 14440software, either in source code form or as a compiled binary, for any purpose, 14439Anyone is free to copy, modify, publish, use, compile, sell, or distribute this14440software, either in source code form or as a compiled binary, for any purpose,14441commercial or non-commercial, and by any means.14442In jurisdictions that recognize copyright laws, the author or authors of this 14443software dedicate any and all copyright interest in the software to the public 14444domain. We make this dedication for the benefit of the public at large and to 14445the detriment of our heirs and successors. We intend this dedication to be an 14446overt act of relinquishment in perpetuity of all present and future rights to 14442In jurisdictions that recognize copyright laws, the author or authors of this14443software dedicate any and all copyright interest in the software to the public14444domain. We make this dedication for the benefit of the public at large and to14445the detriment of our heirs and successors. We intend this dedication to be an14446overt act of relinquishment in perpetuity of all present and future rights to14447this software under copyright law.14448THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14449IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14450FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14451AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 14452ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 14448THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14449IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,14450FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE14451AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN14452ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION14453WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.14454------------------------------------------------------------------------------14455*/
modified:stretchy_buffer.hnot shown

Its text is not shown, modified.