Fix trailing whitespace
Before adoption: this commit came in with the history the project adopted, so no landing records it.
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
Provenance
- Commit
2bb4a0a- Tree
7fcb6b8- Author
Sean Barrett <sean@nothings.org>- Committer
Sean Barrett <sean@nothings.org>- Parent
7a69424
22 files changed+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 lines279 STB_C_LEX_C_ARROW( CLEX_arrow )280 STB_C_LEX_EQUAL_ARROW( CLEX_eqarrow )281 282 #ifdef STB__clex_define_shifts283- CLEX_shleq, CLEX_shreq, 283+ CLEX_shleq, CLEX_shreq,284 #endif285 286 CLEX_first_unused_token287 59 unmodified lines347 }348 349 static 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 lines603 );604 lexer->string[n] = 0;605 return stb__clex_token(lexer, CLEX_id, p, p+n-1);606 }607- 607+608 // check for EOF609 STB_C_LEX_0_IS_EOF(610 if (*p == 0)611 return stb__clex_eof(tok);612 )613 614- single_char: 614+ single_char:615 // not an identifier, return the character as itself616 return stb__clex_token(lexer, *p, p, p);617 618 case '+':309 unmodified lines928 This software is available under 2 licenses -- choose whichever you prefer.929 ------------------------------------------------------------------------------930 ALTERNATIVE A - MIT License931 Copyright (c) 2017 Sean Barrett932-Permission is hereby granted, free of charge, to any person obtaining a copy of 933-this software and associated documentation files (the "Software"), to deal in 934-the Software without restriction, including without limitation the rights to 935-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 936-of the Software, and to permit persons to whom the Software is furnished to do 932+Permission is hereby granted, free of charge, to any person obtaining a copy of933+this software and associated documentation files (the "Software"), to deal in934+the Software without restriction, including without limitation the rights to935+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies936+of the Software, and to permit persons to whom the Software is furnished to do937 so, subject to the following conditions:938-The above copyright notice and this permission notice shall be included in all 938+The above copyright notice and this permission notice shall be included in all939 copies or substantial portions of the Software.940-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 941-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 942-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 943-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 944-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 945-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 940+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR941+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,942+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE943+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER944+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,945+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE946 SOFTWARE.947 ------------------------------------------------------------------------------948 ALTERNATIVE B - Public Domain (www.unlicense.org)949 This is free and unencumbered software released into the public domain.950-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 951-software, either in source code form or as a compiled binary, for any purpose, 950+Anyone is free to copy, modify, publish, use, compile, sell, or distribute this951+software, either in source code form or as a compiled binary, for any purpose,952 commercial or non-commercial, and by any means.953-In jurisdictions that recognize copyright laws, the author or authors of this 954-software dedicate any and all copyright interest in the software to the public 955-domain. We make this dedication for the benefit of the public at large and to 956-the detriment of our heirs and successors. We intend this dedication to be an 957-overt act of relinquishment in perpetuity of all present and future rights to 953+In jurisdictions that recognize copyright laws, the author or authors of this954+software dedicate any and all copyright interest in the software to the public955+domain. We make this dedication for the benefit of the public at large and to956+the detriment of our heirs and successors. We intend this dedication to be an957+overt act of relinquishment in perpetuity of all present and future rights to958 this software under copyright law.959-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 960-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 961-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 962-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 963-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 959+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR960+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,961+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE962+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN963+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION964 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.965 ------------------------------------------------------------------------------966 */modified:stb_connected_components.h+32 added-32 removed
3 unmodified lines4 // 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 103 unmodified lines16 //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 lines51 // - 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 lines434 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 lines598 g->in_batched_update = 0;599 600 #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 #endif605 606 for (j=0; j < h; ++j) {91 unmodified lines698 699 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;704 705 if (i < clump->num_adjacent)706 adj[i] = adj[--clump->num_adjacent];28 unmodified lines735 } 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 lines796 } 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 lines1011 This software is available under 2 licenses -- choose whichever you prefer.1012 ------------------------------------------------------------------------------1013 ALTERNATIVE A - MIT License1014 Copyright (c) 2017 Sean Barrett1015-Permission is hereby granted, free of charge, to any person obtaining a copy of 1016-this software and associated documentation files (the "Software"), to deal in 1017-the Software without restriction, including without limitation the rights to 1018-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 1019-of the Software, and to permit persons to whom the Software is furnished to do 1015+Permission is hereby granted, free of charge, to any person obtaining a copy of1016+this software and associated documentation files (the "Software"), to deal in1017+the Software without restriction, including without limitation the rights to1018+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies1019+of the Software, and to permit persons to whom the Software is furnished to do1020 so, subject to the following conditions:1021-The above copyright notice and this permission notice shall be included in all 1021+The above copyright notice and this permission notice shall be included in all1022 copies or substantial portions of the Software.1023-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1024-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1025-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1026-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1027-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 1028-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 1023+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR1024+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,1025+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE1026+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER1027+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,1028+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE1029 SOFTWARE.1030 ------------------------------------------------------------------------------1031 ALTERNATIVE B - Public Domain (www.unlicense.org)1032 This is free and unencumbered software released into the public domain.1033-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 1034-software, either in source code form or as a compiled binary, for any purpose, 1033+Anyone is free to copy, modify, publish, use, compile, sell, or distribute this1034+software, either in source code form or as a compiled binary, for any purpose,1035 commercial or non-commercial, and by any means.1036-In jurisdictions that recognize copyright laws, the author or authors of this 1037-software dedicate any and all copyright interest in the software to the public 1038-domain. We make this dedication for the benefit of the public at large and to 1039-the detriment of our heirs and successors. We intend this dedication to be an 1040-overt act of relinquishment in perpetuity of all present and future rights to 1036+In jurisdictions that recognize copyright laws, the author or authors of this1037+software dedicate any and all copyright interest in the software to the public1038+domain. We make this dedication for the benefit of the public at large and to1039+the detriment of our heirs and successors. We intend this dedication to be an1040+overt act of relinquishment in perpetuity of all present and future rights to1041 this software under copyright law.1042-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1043-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1044-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 1045-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 1046-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 1042+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR1043+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,1044+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE1045+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN1046+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION1047 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.1048 ------------------------------------------------------------------------------1049 */modified:stb_divide.h+26 added-26 removed
1 unmodified line2 // 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 release299 unmodified lines310 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 lines392 This software is available under 2 licenses -- choose whichever you prefer.393 ------------------------------------------------------------------------------394 ALTERNATIVE A - MIT License395 Copyright (c) 2017 Sean Barrett396-Permission is hereby granted, free of charge, to any person obtaining a copy of 397-this software and associated documentation files (the "Software"), to deal in 398-the Software without restriction, including without limitation the rights to 399-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 400-of the Software, and to permit persons to whom the Software is furnished to do 396+Permission is hereby granted, free of charge, to any person obtaining a copy of397+this software and associated documentation files (the "Software"), to deal in398+the Software without restriction, including without limitation the rights to399+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies400+of the Software, and to permit persons to whom the Software is furnished to do401 so, subject to the following conditions:402-The above copyright notice and this permission notice shall be included in all 402+The above copyright notice and this permission notice shall be included in all403 copies or substantial portions of the Software.404-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 405-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 406-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 407-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 408-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 409-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 404+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR405+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,406+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE407+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER408+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,409+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE410 SOFTWARE.411 ------------------------------------------------------------------------------412 ALTERNATIVE B - Public Domain (www.unlicense.org)413 This is free and unencumbered software released into the public domain.414-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 415-software, either in source code form or as a compiled binary, for any purpose, 414+Anyone is free to copy, modify, publish, use, compile, sell, or distribute this415+software, either in source code form or as a compiled binary, for any purpose,416 commercial or non-commercial, and by any means.417-In jurisdictions that recognize copyright laws, the author or authors of this 418-software dedicate any and all copyright interest in the software to the public 419-domain. We make this dedication for the benefit of the public at large and to 420-the detriment of our heirs and successors. We intend this dedication to be an 421-overt act of relinquishment in perpetuity of all present and future rights to 417+In jurisdictions that recognize copyright laws, the author or authors of this418+software dedicate any and all copyright interest in the software to the public419+domain. We make this dedication for the benefit of the public at large and to420+the detriment of our heirs and successors. We intend this dedication to be an421+overt act of relinquishment in perpetuity of all present and future rights to422 this software under copyright law.423-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 424-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 425-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 426-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 427-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 423+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR424+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,425+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE426+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN427+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION428 WITH 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- 2+3 This is a single-header-file library that provides easy-to-use4 dynamic arrays and hash tables for C (also works in C++).5 6 For a gentle introduction:18 unmodified lines25 26 #define STBDS_NO_SHORT_NAMES27 28 This flag needs to be set globally.29- 29+30 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 lines70 71 Non-function interface:72 73 Declare an empty dynamic array of type T74- T* foo = NULL; 74+ T* foo = NULL;75 76 Access the i'th item of a dynamic array 'foo' of type T, T* foo:77 foo[i]78 147 unmodified lines226 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 lines354 355 * 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- 358+359 * 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 lines435 #define sh_new_strdup stbds_sh_new_strdup436 437 #define stralloc stbds_stralloc438 #define strreset stbds_strreset439-#endif 439+#endif440 441 #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 #endif436 unmodified lines880 #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 table895 896 if (slot_count <= STBDS_BUCKET_LENGTH)897 t->used_count_shrink_threshold = 0;124 unmodified lines1022 // (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;1028 1029 #ifdef STBDS_TEST_SIPHASH_2_41030 // hardcoded with key material in the siphash test vectors94 unmodified lines1125 #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 spacing1141 1142 return (((size_t) hash << 16 << 16) | hash) ^ seed;32 unmodified lines1175 #define STBDS_HASH_TO_ARR(x,elemsize) ((char*) (x) - (elemsize))1176 #define STBDS_ARR_TO_HASH(x,elemsize) ((char*) (x) + (elemsize))1177 1178 #define stbds_hash_table(a) ((stbds_hash_index *) stbds_header(a)->hash_table)1179- 1179+1180 void stbds_hmfree_func(void *a, size_t elemsize)1181 {1182 if (a == NULL) return;1183 if (stbds_hash_table(a) != NULL) {281 unmodified lines1465 STBDS_FREE(NULL, *(char**) ((char *) a+elemsize*old_index));1466 1467 // 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);1471 1472 // now find the slot for the last element1473 if (mode == STBDS_HM_STRING)201 unmodified lines1675 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 lines1719 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 linesmodified:stb_dxt.h+34 added-34 removed
21 unmodified lines22 // 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 lines67 68 // 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 lines158 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- 162+163 // 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 lines237 //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- 241+242 c0Point = (stops[1] + stops[3]) >> 1;243 halfPoint = (stops[3] + stops[2]) >> 1;244 c3Point = (stops[2] + stops[0]) >> 1;245 266 unmodified lines512 int dither;513 int refinecount;514 unsigned short max16, min16;515 unsigned char dblock[16*4],color[4*4];516- 516+517 dither = mode & STB_DXT_DITHER;518 refinecount = (mode & STB_DXT_HIGHQUAL) ? 2 : 1;519 520 // check if block is constant21 unmodified lines542 543 // third step: refine (multiple times if requested)544 for (i=0;i<refinecount;i++) {545 unsigned int lastmask = mask;546- 546+547 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 line552 mask = 0;553 break;554 }555 }556- 556+557 if(mask == lastmask)558 break;559 }560 }45 unmodified lines606 dist2 = dist*2;607 bias = (dist < 8) ? (dist - 1) : (dist/2 + 2);608 bias -= mn * 7;609 bits = 0,mask=0;610- 610+611 for (i=0;i<16;i++) {612 int a = src[i*stride]*7 + bias;613 int ind,t;614 615 // 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- 619+620 // turn linear scale into DXT index (0/1 are extremal pts)621 ind = -ind & 7;622 ind ^= (2 > ind);623 68 unmodified lines692 This software is available under 2 licenses -- choose whichever you prefer.693 ------------------------------------------------------------------------------694 ALTERNATIVE A - MIT License695 Copyright (c) 2017 Sean Barrett696-Permission is hereby granted, free of charge, to any person obtaining a copy of 697-this software and associated documentation files (the "Software"), to deal in 698-the Software without restriction, including without limitation the rights to 699-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 700-of the Software, and to permit persons to whom the Software is furnished to do 696+Permission is hereby granted, free of charge, to any person obtaining a copy of697+this software and associated documentation files (the "Software"), to deal in698+the Software without restriction, including without limitation the rights to699+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies700+of the Software, and to permit persons to whom the Software is furnished to do701 so, subject to the following conditions:702-The above copyright notice and this permission notice shall be included in all 702+The above copyright notice and this permission notice shall be included in all703 copies or substantial portions of the Software.704-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 705-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 706-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 707-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 708-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 709-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 704+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR705+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,706+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE707+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER708+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,709+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE710 SOFTWARE.711 ------------------------------------------------------------------------------712 ALTERNATIVE B - Public Domain (www.unlicense.org)713 This is free and unencumbered software released into the public domain.714-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 715-software, either in source code form or as a compiled binary, for any purpose, 714+Anyone is free to copy, modify, publish, use, compile, sell, or distribute this715+software, either in source code form or as a compiled binary, for any purpose,716 commercial or non-commercial, and by any means.717-In jurisdictions that recognize copyright laws, the author or authors of this 718-software dedicate any and all copyright interest in the software to the public 719-domain. We make this dedication for the benefit of the public at large and to 720-the detriment of our heirs and successors. We intend this dedication to be an 721-overt act of relinquishment in perpetuity of all present and future rights to 717+In jurisdictions that recognize copyright laws, the author or authors of this718+software dedicate any and all copyright interest in the software to the public719+domain. We make this dedication for the benefit of the public at large and to720+the detriment of our heirs and successors. We intend this dedication to be an721+overt act of relinquishment in perpetuity of all present and future rights to722 this software under copyright law.723-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 724-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 725-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 726-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 727-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 723+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR724+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,725+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE726+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN727+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION728 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.729 ------------------------------------------------------------------------------730 */modified:stb_easy_font.h+25 added-25 removed
56 unmodified lines57 // 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 as201 unmodified lines267 This software is available under 2 licenses -- choose whichever you prefer.268 ------------------------------------------------------------------------------269 ALTERNATIVE A - MIT License270 Copyright (c) 2017 Sean Barrett271-Permission is hereby granted, free of charge, to any person obtaining a copy of 272-this software and associated documentation files (the "Software"), to deal in 273-the Software without restriction, including without limitation the rights to 274-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 275-of the Software, and to permit persons to whom the Software is furnished to do 271+Permission is hereby granted, free of charge, to any person obtaining a copy of272+this software and associated documentation files (the "Software"), to deal in273+the Software without restriction, including without limitation the rights to274+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies275+of the Software, and to permit persons to whom the Software is furnished to do276 so, subject to the following conditions:277-The above copyright notice and this permission notice shall be included in all 277+The above copyright notice and this permission notice shall be included in all278 copies or substantial portions of the Software.279-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 280-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 281-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 282-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 283-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 284-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 279+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR280+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,281+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE282+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER283+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,284+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE285 SOFTWARE.286 ------------------------------------------------------------------------------287 ALTERNATIVE B - Public Domain (www.unlicense.org)288 This is free and unencumbered software released into the public domain.289-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 290-software, either in source code form or as a compiled binary, for any purpose, 289+Anyone is free to copy, modify, publish, use, compile, sell, or distribute this290+software, either in source code form or as a compiled binary, for any purpose,291 commercial or non-commercial, and by any means.292-In jurisdictions that recognize copyright laws, the author or authors of this 293-software dedicate any and all copyright interest in the software to the public 294-domain. We make this dedication for the benefit of the public at large and to 295-the detriment of our heirs and successors. We intend this dedication to be an 296-overt act of relinquishment in perpetuity of all present and future rights to 292+In jurisdictions that recognize copyright laws, the author or authors of this293+software dedicate any and all copyright interest in the software to the public294+domain. We make this dedication for the benefit of the public at large and to295+the detriment of our heirs and successors. We intend this dedication to be an296+overt act of relinquishment in perpetuity of all present and future rights to297 this software under copyright law.298-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 299-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 300-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 301-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 302-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 298+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR299+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,300+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE301+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN302+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION303 WITH 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 lines16 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- 20+21 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- 26+27 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 lines141 == VERSION HISTORY ===================142 143 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 release146 147 */148 149 //////////////////////////////////////////////////////////////////////////////100 unmodified lines250 //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 lines512 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 lines688 689 690 691 // 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 error693 STBHW_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 linesmodified: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 lines51 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; bugfixes47 unmodified lines107 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- 111+112 */113 114 #ifndef STBI_INCLUDE_STB_IMAGE_H115 #define STBI_INCLUDE_STB_IMAGE_H777 unmodified lines893 static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri);894 static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp);895 #endif896 897-static 897+static898 #ifdef STBI_THREAD_LOCAL899 STBI_THREAD_LOCAL900 #endif901 const char *stbi__g_failure_reason;256 unmodified lines1158 int slice_size = w * h * bytes_per_pixel;1159 1160 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 lines1245 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- 1249+1250 if (0 == MultiByteToWideChar(65001 /* UTF8 */, 0, mode, -1, wMode, sizeof(wMode)))1251 return 0;1252 1253 #if _MSC_VER >= 140093 unmodified lines1347 #ifndef STBI_NO_GIF1348 STBIDEF 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);1353+1354 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 }1358 1359- return result; 1359+ return result;1360 }1361 #endif1362 1363 #ifndef STBI_NO_LINEAR4928 unmodified lines6292 {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 lines6380 6381 static void stbi__out_gif_code(stbi__gif *g, stbi__uint16 code)6382 {6383 stbi_uc *p, *c;6384- int idx; 6384+ int idx;6385 6386 // 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);6390 6391 if (g->cur_y >= g->max_y) return;6392 6393- 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;6396 6397 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 lines6503 // 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 format6505 static 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);6512 6513 // 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 lines6522 g->history = (stbi_uc *) stbi__malloc(pcount);6523 if (!g->out || !g->background || !g->history)6524 return stbi__errpuc("outofmem", "Out of memory");6525 6526- // 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;6537 6538 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 }6541 6542 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 }6561 6562- // 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 }6565 6566- // clear my history; 6566+ // clear my history;6567 memset( g->history, 0x00, g->w * g->h ); // pixels that were affected previous frame6568 6569 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 lines6611 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");6616+6617 o = stbi__process_gif_raster(s, g);6618 if (!o) return NULL;6619 6620- // 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 lines6634 6635 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.6644 6645 // 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 lines6678 6679 static 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 }6692 6693 do {6694 u = stbi__gif_load_next(s, &g, comp, req_comp, two_back);1 unmodified line6696 6697 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;6702+6703 if (out) {6704 void *tmp = (stbi_uc*) STBI_REALLOC( out, layers * stride );6705 if (NULL == tmp) {6706 STBI_FREE(g.out);3 unmodified lines6710 }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 }6726 6727 if (delays) {6728- (*delays)[layers - 1U] = g.delay; 6728+ (*delays)[layers - 1U] = g.delay;6729 }6730 }6731- } while (u != 0); 6731+ } while (u != 0);6732 6733- // 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);6737 6738- // 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);6741 6742- *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 }6748 6749 static void *stbi__gif_load(stbi__context *s, int *x, int *y, int *comp, int req_comp, stbi__result_info *ri)9 unmodified lines6759 *x = g.w;6760 *y = g.h;6761 6762 // 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 }6770 6771- // 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);6774 6775 return u;6776 }6777 654 unmodified lines7432 #endif // STB_IMAGE_IMPLEMENTATION7433 7434 /*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 BMP218 unmodified linesmodified: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 lines7 Documentation: http://nothings.org/stb/stb_h.html8 Unit tests: http://nothings.org/stb/stb.c9 10 ============================================================================11- You MUST 12- 13- #define STB_DEFINE 14- 11+ You MUST12+13+ #define STB_DEFINE14+15 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:17+18+ #define STB_DEFINE19 #include "stb.h"20- 20+21 All other files should just #include "stb.h" without the #define.22 ============================================================================23 24 Version History282 unmodified lines307 #endif308 #ifndef rad2deg309 #define rad2deg(a) ((a)*(180/M_PI))310 #endif311- 311+312 #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- 318+319 typedef unsigned char uint8 ;320 typedef signed char int8 ;321 typedef unsigned short uint16;322 typedef signed short int16;140 unmodified lines463 #define stb_p_strncpy_s(a,s,b,c) strncpy(a,b,c)464 #define stb_p_mktemp(s) (mktemp(s) != NULL)465 466 #define stb_p_sprintf sprintf467-#define stb_p_size(x) 467+#define stb_p_size(x)468 #endif469 470 #if defined(_WIN32)471 #define stb_p_vsnprintf _vsnprintf1692 unmodified lines2164 }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 lines2807 // 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- 2811+2812 // 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 lines3008 stb__alloc_type t;3009 3010 if (ptr == NULL) return stb_malloc(NULL, newsize);3011 if (newsize == 0) { stb_free(ptr); return NULL; }3012- 3012+3013 t = stb__identify(ptr);3014 assert(t == STB__alloc || t == STB__nochildren);3015 3016 if (t == STB__alloc) {154 unmodified lines3171 #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)3174 3175-// 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)3177 3178 // change the array length so is is exactly N entries long, creating3179 // uninitialized entries as needed726 unmodified lines3906 PREFIX int STB__(N, remove)(TYPE *a, KEY k, VALUE *v);3907 3908 #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 lines4282 //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, returns4287 4288 typedef struct stb__st_stb_spmatrix stb_spmatrix;4289 4290 STB_EXTERN stb_spmatrix * stb_sparse_ptr_matrix_new(int val_size);53 unmodified lines4344 // 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)4350 4351 stb_declare_hash(STB_EXTERN, stb_sdict, stb_sdict_, char *, void *)4352 4353 STB_EXTERN stb_sdict * stb_sdict_new(int use_arena);4354-STB_EXTERN stb_sdict * stb_sdict_copy(stb_sdict*); 4354+STB_EXTERN stb_sdict * stb_sdict_copy(stb_sdict*);4355 STB_EXTERN void stb_sdict_delete(stb_sdict *);4356 STB_EXTERN void * stb_sdict_change(stb_sdict *, char *str, void *p);4357 STB_EXTERN int stb_sdict_count(stb_sdict *d);4358 65 unmodified lines4424 n->arena = new_arena;4425 else if (new_arena)4426 stb_free(new_arena);4427 return n;4428-} 4428+}4429 4430 4431 void stb_sdict_delete(stb_sdict *d)4432 {370 unmodified lines4803 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 }4809 4810 static void * stb__nptr_alloc(int size)4811 {111 unmodified lines4923 4924 int b0 = start >> STB__NPTR_ROOT_SHIFT;4925 int b1 = end >> STB__NPTR_ROOT_SHIFT;4926 int b=b0,i,e0,e1;4927- 4927+4928 e0 = STB__NPTR_NODE_OFFSET(start);4929 4930 if (datum <= 0) {4931 // first block963 unmodified lines5895 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 }5902 5903 void stb_fput_varlen64(FILE *f, stb_uint64 v)9 unmodified lines5913 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 }5920 5921 void stb_fput_ranged(FILE *f, int v, int b, stb_uint n)472 unmodified lines6394 6395 #define STB_ADLER32_SEED 16396 #define STB_CRC32_SEED 0 // note that we logical NOT this in the code6397 6398-STB_EXTERN stb_uint 6398+STB_EXTERN stb_uint6399 stb_adler32(stb_uint adler32, stb_uchar *buffer, stb_uint buflen);6400-STB_EXTERN stb_uint 6400+STB_EXTERN stb_uint6401 stb_crc32_block(stb_uint crc32, stb_uchar *buffer, stb_uint len);6402 STB_EXTERN stb_uint stb_crc32(unsigned char *buffer, stb_uint len);6403 6404 STB_EXTERN void stb_sha1(197 unmodified lines6602 6603 buffer[n++] = 0x80;6604 6605 // if there isn't enough room for the length, double the block6606- if (n + 8 > 64) 6606+ if (n + 8 > 64)6607 block = 128;6608 6609 // pad to end6610 memset(buffer+n, 0, block-8-n);49 unmodified lines6660 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 }6666 6667 #endif // STB_DEFINE6668 20 unmodified lines6689 #define HKEY void *6690 6691 STB_EXTERN __declspec(dllimport) long __stdcall RegCloseKey ( HKEY hKey );6692 STB_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 );6695 STB_EXTERN __declspec(dllimport) long __stdcall RegDeleteKeyA ( HKEY hKey, const char * lpSubKey );6696 STB_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 lines6935 int 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 lines7146 stb__wchar full_path[1024];7147 int has_slash;7148 if (stb__showfile) printf("<");7149 7150- has_slash = (path[0] && path[strlen(path)-1] == '/'); 7150+ has_slash = (path[0] && path[strlen(path)-1] == '/');7151 7152 // @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 lines7584 7585 void stb_wrapper_free(void *p, char *file, int line)7586 {7587 int n;7588- 7588+7589 if (p == NULL) return;7590 7591 n = stb__hashfind(p);7592 15 unmodified lines7608 7609 void stb_wrapper_check(void *p)7610 {7611 int n;7612- 7612+7613 if (p == NULL) return;7614 7615 n = stb__hashfind(p);7616 500 unmodified lines8117 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 lines8449 unsigned int * b = stb__mt_buffer;8450 int idx = stb__mt_index;8451 unsigned int s,r;8452 int i;8453- 8453+8454 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 lines8463 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- 8467+8468 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- 8472+8473 r = *(unsigned int *)((unsigned char *)b + idx);8474- 8474+8475 r ^= (r >> 11);8476 r ^= (r << 7) & 0x9D2C5680;8477 r ^= (r << 15) & 0xEFC60000;8478 r ^= (r >> 18);8479- 8479+8480 return r;8481 }8482 8483 double stb_frand(void)154 unmodified lines8638 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 than307 unmodified lines8954 {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 whitespace172 unmodified lines9135 int stb__wildmatch_raw2(char *expr, char *candidate, int search, int insensitive)9136 {9137 int where=0;9138 int start = -1;9139- 9139+9140 if (!search) {9141 // parse to first '*'9142 if (*expr != '*')9143 start = 0;5 unmodified lines9149 } 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 lines9166 if (!search)9167 ++expr;9168 9169 // implicit '*' at this point9170- 9170+9171 while (*expr) {9172 int o=0;9173 // combine redundant * characters9174 while (expr[0] == '*') ++expr;20 unmodified lines9195 ++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 lines9385 9386 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;9390 9391 case '\\':9392 ++regex;9393 if (!*regex) return NULL;719 unmodified lines10113 } stb_info_struct;10114 10115 extern stb_info_struct stb_introspect_output[];10116 10117-// 10117+//10118 10119 STB_EXTERN void stb_introspect_precompiled(stb_info_struct *compiled);10120 STB_EXTERN void stb__introspect(char *path, char *file);10121 93 unmodified lines10215 10216 stb__introspect_filename(buffer2, path);10217 10218 // get source/include files timestamps, compare to output-file timestamp;10219- // if mismatched, regenerate 10219+ // if mismatched, regenerate10220 10221 if (stb__stat(buffer2, &st))10222 needs_building = STB_TRUE;10223- 10223+10224 {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 them87 unmodified lines10315 t = strchr(s, ')');10316 if (t == NULL) stb_fatal("Error parsing %s", filename);10317 10318 }10319- } 10319+ }10320 }10321 10322 10323 131 unmodified lines10455 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 lines10614 }10615 10616 static 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 lines10701 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 lines10789 {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- 10793+10794 stb__out = NULL;10795 stb__outfile = stb_p_fopen(filename, "wb");10796 if (!stb__outfile) return 0;10797 11 unmodified lines10809 {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- 10813+10814 stb__out = NULL;10815 stb__outfile = f;10816 if (!stb__outfile) return 0;10817 167 unmodified lines10985 // now shift the window10986 memmove(xtb.buffer, xtb.buffer + flush, xtb.valid - flush);10987 xtb.start -= flush;10988 xtb.valid -= flush;10989- 10989+10990 for (i=0; i <= xtb.hashmask; ++i)10991 if (xtb.chash[i] < xtb.buffer + flush)10992 xtb.chash[i] = NULL;10993 else716 unmodified lines11710 }11711 #endif // _WINDOWS_11712 11713 #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 lines11750 mov ebx,[edi];11751 mov ecx,4[edi];11752 mov esi,dest;11753 lock CMPXCHG8B [esi];11754- } 11754+ }11755 #endif // #if 011756 11757 #endif // _WIN3211758 561 unmodified lines12320 int len;12321 FILE *f;12322 stb_uchar *buf;12323 12324- 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 lines12355 fseek(f, 0, SEEK_END);12356 len = ftell(f) - dc->offset;12357 }12358 12359- 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 lines12627 p = stb__alloc_pages(pagecount < 16 ? 16 : pagecount);12628 if (p == NULL) return 0;12629 } else12630 stb__spanlist_unlink(p);12631- 12631+12632 if (p->len > pagecount) {12633 stb__span *q = stb__span_alloc();12634 if (q) {12635 q->start = p->start + pagecount;249 unmodified lines12885 12886 stb_p_sprintf(filebuf stb_p_size(sizeof(filebuf)), "../%s", file);12887 if (!stb_fexists(filebuf)) return filebuf;12888 12889- return file; 12889+ return file;12890 }12891 #endif12892 12893 #define STB_F(x) ((float) STB_H(x))76 unmodified lines12970 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 lines13164 n += stu__getfloat_addend[e] << 24;13165 return *(float *) &n;13166 }13167 13168-stua_obj stua_float(float f) 13168+stua_obj stua_float(float f)13169 {13170 return stu__floatp(&f);13171 }13172 162 unmodified lines13335 13336 // 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]);13344 13345 // 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 line13353 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 lines13738 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 lines13812 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)13815 13816- 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 lines13842 13843 static 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 lines14116 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 lines14231 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 lines14417 This software is available under 2 licenses -- choose whichever you prefer.14418 ------------------------------------------------------------------------------14419 ALTERNATIVE A - MIT License14420 Copyright (c) 2017 Sean Barrett14421-Permission is hereby granted, free of charge, to any person obtaining a copy of 14422-this software and associated documentation files (the "Software"), to deal in 14423-the Software without restriction, including without limitation the rights to 14424-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 14425-of the Software, and to permit persons to whom the Software is furnished to do 14421+Permission is hereby granted, free of charge, to any person obtaining a copy of14422+this software and associated documentation files (the "Software"), to deal in14423+the Software without restriction, including without limitation the rights to14424+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies14425+of the Software, and to permit persons to whom the Software is furnished to do14426 so, subject to the following conditions:14427-The above copyright notice and this permission notice shall be included in all 14427+The above copyright notice and this permission notice shall be included in all14428 copies or substantial portions of the Software.14429-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14430-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14431-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14432-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14433-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 14434-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 14429+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14430+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,14431+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE14432+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER14433+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,14434+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE14435 SOFTWARE.14436 ------------------------------------------------------------------------------14437 ALTERNATIVE B - Public Domain (www.unlicense.org)14438 This is free and unencumbered software released into the public domain.14439-Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 14440-software, either in source code form or as a compiled binary, for any purpose, 14439+Anyone is free to copy, modify, publish, use, compile, sell, or distribute this14440+software, either in source code form or as a compiled binary, for any purpose,14441 commercial or non-commercial, and by any means.14442-In jurisdictions that recognize copyright laws, the author or authors of this 14443-software dedicate any and all copyright interest in the software to the public 14444-domain. We make this dedication for the benefit of the public at large and to 14445-the detriment of our heirs and successors. We intend this dedication to be an 14446-overt act of relinquishment in perpetuity of all present and future rights to 14442+In jurisdictions that recognize copyright laws, the author or authors of this14443+software dedicate any and all copyright interest in the software to the public14444+domain. We make this dedication for the benefit of the public at large and to14445+the detriment of our heirs and successors. We intend this dedication to be an14446+overt act of relinquishment in perpetuity of all present and future rights to14447 this software under copyright law.14448-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14449-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14450-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14451-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 14452-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 14448+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR14449+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,14450+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE14451+AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN14452+ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION14453 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.14454 ------------------------------------------------------------------------------14455 */modified:stretchy_buffer.hnot shown
Its text is not shown, modified.