Init package for openEuler
(cherry picked from commit edcd34ab3cb221a253b356f0ec2c0c7730ac73bf)
This commit is contained in:
parent
a568bf6cc4
commit
e3ee7b48b1
233
1194.patch
Normal file
233
1194.patch
Normal file
@ -0,0 +1,233 @@
|
||||
From 3d401e71452d890eaf0bc50b11788cb08a6c2fed Mon Sep 17 00:00:00 2001
|
||||
From: "Benjamin A. Beasley" <code@musicinmybrain.net>
|
||||
Date: Tue, 17 Aug 2021 21:30:44 -0400
|
||||
Subject: [PATCH] =?UTF-8?q?Fix=20undefined=20behavior=20from=20array=20?=
|
||||
=?UTF-8?q?=E2=80=9Cshape-punning=E2=80=9D?=
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
In stb_voxel_render.h, there were three cases where a 2D array of
|
||||
dimension [X][Y] was iterated as a 1D array of dimension [1][X*Y]. While
|
||||
this is clever and is correct in terms of the actual memory layout, a
|
||||
second index outside the corresponding dimension ([i][j], j >= Y])
|
||||
actually produces undefined behavior and gives the compiler freedom to
|
||||
do all sorts of terrible things.
|
||||
|
||||
The same thing happens in stb_tilemap_editor.h,
|
||||
tests/caveview/cave_mesher.c, and tests/resample_test.cpp.
|
||||
|
||||
Prior to this commit, a compiler warning regarding the undefined
|
||||
behavior appears on gcc 11.2.1 for at least some of these cases when the
|
||||
tests are compiled with -Waggressive-loop-optimizations (included in
|
||||
-Wall).
|
||||
|
||||
This commit fixes the undefined behavior by iterating these 2D arrays
|
||||
with the conventional nested loops.
|
||||
---
|
||||
stb_tilemap_editor.h | 35 +++++++++++++++++++----------------
|
||||
stb_voxel_render.h | 36 +++++++++++++++++++++---------------
|
||||
tests/caveview/cave_mesher.c | 26 ++++++++++++++------------
|
||||
tests/resample_test.cpp | 15 +++++++++------
|
||||
4 files changed, 63 insertions(+), 49 deletions(-)
|
||||
|
||||
diff --git a/stb_tilemap_editor.h b/stb_tilemap_editor.h
|
||||
index fbd3388084..0b8c2ca997 100644
|
||||
--- a/stb_tilemap_editor.h
|
||||
+++ b/stb_tilemap_editor.h
|
||||
@@ -1066,14 +1066,15 @@ stbte_tilemap *stbte_create_map(int map_x, int map_y, int map_layers, int spacin
|
||||
|
||||
void stbte_set_background_tile(stbte_tilemap *tm, short id)
|
||||
{
|
||||
- int i;
|
||||
+ int i, j;
|
||||
STBTE_ASSERT(id >= -1);
|
||||
// STBTE_ASSERT(id < 32768);
|
||||
if (id < -1)
|
||||
return;
|
||||
- for (i=0; i < STBTE_MAX_TILEMAP_X * STBTE_MAX_TILEMAP_Y; ++i)
|
||||
- if (tm->data[0][i][0] == -1)
|
||||
- tm->data[0][i][0] = id;
|
||||
+ for (i=0; i < STBTE_MAX_TILEMAP_X; ++i)
|
||||
+ for (j=0; j < STBTE_MAX_TILEMAP_Y; ++j)
|
||||
+ if (tm->data[i][j][0] == -1)
|
||||
+ tm->data[i][j][0] = id;
|
||||
tm->background_tile = id;
|
||||
}
|
||||
|
||||
@@ -1212,18 +1213,20 @@ void stbte_set_dimensions(stbte_tilemap *tm, int map_x, int map_y)
|
||||
|
||||
void stbte_clear_map(stbte_tilemap *tm)
|
||||
{
|
||||
- int i,j;
|
||||
- for (i=0; i < STBTE_MAX_TILEMAP_X * STBTE_MAX_TILEMAP_Y; ++i) {
|
||||
- tm->data[0][i][0] = tm->background_tile;
|
||||
- for (j=1; j < tm->num_layers; ++j)
|
||||
- tm->data[0][i][j] = STBTE__NO_TILE;
|
||||
- for (j=0; j < STBTE_MAX_PROPERTIES; ++j)
|
||||
- tm->props[0][i][j] = 0;
|
||||
- #ifdef STBTE_ALLOW_LINK
|
||||
- tm->link[0][i].x = -1;
|
||||
- tm->link[0][i].y = -1;
|
||||
- tm->linkcount[0][i] = 0;
|
||||
- #endif
|
||||
+ int i,j,k;
|
||||
+ for (i=0; i < STBTE_MAX_TILEMAP_X; ++i) {
|
||||
+ for (j=0; j < STBTE_MAX_TILEMAP_Y; ++j) {
|
||||
+ tm->data[i][j][0] = tm->background_tile;
|
||||
+ for (k=1; k < tm->num_layers; ++k)
|
||||
+ tm->data[i][j][k] = STBTE__NO_TILE;
|
||||
+ for (k=0; k < STBTE_MAX_PROPERTIES; ++k)
|
||||
+ tm->props[i][j][k] = 0;
|
||||
+ #ifdef STBTE_ALLOW_LINK
|
||||
+ tm->link[i][j].x = -1;
|
||||
+ tm->link[i][j].y = -1;
|
||||
+ tm->linkcount[i][j] = 0;
|
||||
+ #endif
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/stb_voxel_render.h b/stb_voxel_render.h
|
||||
index 2e7a372f83..51011091f7 100644
|
||||
--- a/stb_voxel_render.h
|
||||
+++ b/stb_voxel_render.h
|
||||
@@ -3126,15 +3126,17 @@ static void stbvox_make_mesh_for_block_with_geo(stbvox_mesh_maker *mm, stbvox_po
|
||||
stbvox_mesh_vertex vmesh[6][4];
|
||||
stbvox_rotate rotate = { 0,0,0,0 };
|
||||
unsigned char simple_rot = rot;
|
||||
- int i;
|
||||
+ int i, j;
|
||||
// we only need to do this for the displayed faces, but it's easier
|
||||
// to just do it up front; @OPTIMIZE check if it's faster to do it
|
||||
// for visible faces only
|
||||
- for (i=0; i < 6*4; ++i) {
|
||||
- int vert = stbvox_vertex_selector[0][i];
|
||||
- vert = stbvox_rotate_vertex[vert][rot];
|
||||
- vmesh[0][i] = stbvox_vmesh_pre_vheight[0][i]
|
||||
- + stbvox_geometry_vheight[geo][vert];
|
||||
+ for (i=0; i < 6; ++i) {
|
||||
+ for (j=0; j < 4; ++j) {
|
||||
+ int vert = stbvox_vertex_selector[i][j];
|
||||
+ vert = stbvox_rotate_vertex[vert][rot];
|
||||
+ vmesh[i][j] = stbvox_vmesh_pre_vheight[i][j]
|
||||
+ + stbvox_geometry_vheight[geo][vert];
|
||||
+ }
|
||||
}
|
||||
|
||||
basevert = stbvox_vertex_encode(pos.x, pos.y, pos.z << STBVOX_CONFIG_PRECISION_Z, 0,0);
|
||||
@@ -3275,11 +3277,13 @@ static void stbvox_make_mesh_for_block_with_geo(stbvox_mesh_maker *mm, stbvox_po
|
||||
|
||||
// build vertex mesh
|
||||
{
|
||||
- int i;
|
||||
- for (i=0; i < 6*4; ++i) {
|
||||
- int vert = stbvox_vertex_selector[0][i];
|
||||
- vmesh[0][i] = stbvox_vmesh_pre_vheight[0][i]
|
||||
- + cube[vert];
|
||||
+ int i, j;
|
||||
+ for (i=0; i < 6; ++i) {
|
||||
+ for (j=0; j < 4; ++j) {
|
||||
+ int vert = stbvox_vertex_selector[i][j];
|
||||
+ vmesh[i][j] = stbvox_vmesh_pre_vheight[i][j]
|
||||
+ + cube[vert];
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3541,10 +3545,12 @@ int stbvox_get_buffer_size_per_quad(stbvox_mesh_maker *mm, int n)
|
||||
|
||||
void stbvox_reset_buffers(stbvox_mesh_maker *mm)
|
||||
{
|
||||
- int i;
|
||||
- for (i=0; i < STBVOX_MAX_MESHES*STBVOX_MAX_MESH_SLOTS; ++i) {
|
||||
- mm->output_cur[0][i] = 0;
|
||||
- mm->output_buffer[0][i] = 0;
|
||||
+ int i, j;
|
||||
+ for (i=0; i < STBVOX_MAX_MESHES; ++i) {
|
||||
+ for (j=0; j < STBVOX_MAX_MESH_SLOTS; ++j) {
|
||||
+ mm->output_cur[i][j] = 0;
|
||||
+ mm->output_buffer[i][j] = 0;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
diff --git a/tests/caveview/cave_mesher.c b/tests/caveview/cave_mesher.c
|
||||
index 1f76c89812..bbf79898b6 100644
|
||||
--- a/tests/caveview/cave_mesher.c
|
||||
+++ b/tests/caveview/cave_mesher.c
|
||||
@@ -802,7 +802,7 @@ void remap_in_place(int bt, int rm)
|
||||
|
||||
void mesh_init(void)
|
||||
{
|
||||
- int i;
|
||||
+ int i, j;
|
||||
|
||||
chunk_cache_mutex = SDL_CreateMutex();
|
||||
chunk_get_mutex = SDL_CreateMutex();
|
||||
@@ -814,17 +814,19 @@ void mesh_init(void)
|
||||
}
|
||||
//effective_blocktype[50] = 0; // delete torches
|
||||
|
||||
- for (i=0; i < 6*256; ++i) {
|
||||
- if (minecraft_tex1_for_blocktype[0][i] == 40)
|
||||
- minecraft_color_for_blocktype[0][i] = 38 | 64; // apply to tex1
|
||||
- if (minecraft_tex1_for_blocktype[0][i] == 39)
|
||||
- minecraft_color_for_blocktype[0][i] = 39 | 64; // apply to tex1
|
||||
- if (minecraft_tex1_for_blocktype[0][i] == 105)
|
||||
- minecraft_color_for_blocktype[0][i] = 63; // emissive
|
||||
- if (minecraft_tex1_for_blocktype[0][i] == 212)
|
||||
- minecraft_color_for_blocktype[0][i] = 63; // emissive
|
||||
- if (minecraft_tex1_for_blocktype[0][i] == 80)
|
||||
- minecraft_color_for_blocktype[0][i] = 63; // emissive
|
||||
+ for (i=0; i < 6; ++i) {
|
||||
+ for (j=0; j < 256; ++j) {
|
||||
+ if (minecraft_tex1_for_blocktype[i][j] == 40)
|
||||
+ minecraft_color_for_blocktype[i][j] = 38 | 64; // apply to tex1
|
||||
+ if (minecraft_tex1_for_blocktype[i][j] == 39)
|
||||
+ minecraft_color_for_blocktype[i][j] = 39 | 64; // apply to tex1
|
||||
+ if (minecraft_tex1_for_blocktype[i][j] == 105)
|
||||
+ minecraft_color_for_blocktype[i][j] = 63; // emissive
|
||||
+ if (minecraft_tex1_for_blocktype[i][j] == 212)
|
||||
+ minecraft_color_for_blocktype[i][j] = 63; // emissive
|
||||
+ if (minecraft_tex1_for_blocktype[i][j] == 80)
|
||||
+ minecraft_color_for_blocktype[i][j] = 63; // emissive
|
||||
+ }
|
||||
}
|
||||
|
||||
for (i=0; i < 6; ++i) {
|
||||
diff --git a/tests/resample_test.cpp b/tests/resample_test.cpp
|
||||
index 21f874f18b..bb8ad82ef6 100644
|
||||
--- a/tests/resample_test.cpp
|
||||
+++ b/tests/resample_test.cpp
|
||||
@@ -646,8 +646,9 @@ void verify_box(void)
|
||||
|
||||
resample_88(STBIR_FILTER_BOX);
|
||||
|
||||
- for (i=0; i < sizeof(image88); ++i)
|
||||
- STBIR_ASSERT(image88[0][i] == output88[0][i]);
|
||||
+ for (i=0; i < sizeof(image88) / sizeof(image88[0]); ++i)
|
||||
+ for (j=0; j < sizeof(image88[0]); ++j)
|
||||
+ STBIR_ASSERT(image88[i][j] == output88[i][j]);
|
||||
|
||||
t = 0;
|
||||
for (j=0; j < 4; ++j)
|
||||
@@ -685,12 +686,14 @@ void test_filters(void)
|
||||
|
||||
mtsrand(0);
|
||||
|
||||
- for (i=0; i < sizeof(image88); ++i)
|
||||
- image88[0][i] = mtrand() & 255;
|
||||
+ for (i=0; i < sizeof(image88) / sizeof(image88[0]); ++i)
|
||||
+ for (j=0; j < sizeof(image88[0]); ++j)
|
||||
+ image88[i][j] = mtrand() & 255;
|
||||
verify_box();
|
||||
|
||||
- for (i=0; i < sizeof(image88); ++i)
|
||||
- image88[0][i] = 0;
|
||||
+ for (i=0; i < sizeof(image88) / sizeof(image88[0]); ++i)
|
||||
+ for (j=0; j < sizeof(image88[0]); ++j)
|
||||
+ image88[i][j] = 0;
|
||||
image88[4][4] = 255;
|
||||
verify_box();
|
||||
|
||||
59
1195.patch
Normal file
59
1195.patch
Normal file
@ -0,0 +1,59 @@
|
||||
From 5818c4e48a7e7d4c21aacf3cd6f1c7e12f770924 Mon Sep 17 00:00:00 2001
|
||||
From: "Benjamin A. Beasley" <code@musicinmybrain.net>
|
||||
Date: Wed, 18 Aug 2021 13:22:14 -0400
|
||||
Subject: [PATCH] Fix misleading indentation in stb_divide.h
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
With -Wmisleading-indentation (part of -Wall), gcc 11.2.1 warns:
|
||||
|
||||
In file included from test_c_compilation.c:22:
|
||||
../stb_divide.h: In function 'test':
|
||||
../stb_divide.h:316:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
|
||||
316 | if (show) printf("(%+11d,%+2d) ", q,r); stbdiv_check(q,r,a,b, "trunc",a);
|
||||
| ^~
|
||||
../stb_divide.h:316:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
|
||||
316 | if (show) printf("(%+11d,%+2d) ", q,r); stbdiv_check(q,r,a,b, "trunc",a);
|
||||
| ^~~~~~~~~~~~
|
||||
../stb_divide.h:318:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
|
||||
318 | if (show) printf("(%+11d,%+2d) ", q,r); stbdiv_check(q,r,a,b, "floor",b);
|
||||
| ^~
|
||||
../stb_divide.h:318:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
|
||||
318 | if (show) printf("(%+11d,%+2d) ", q,r); stbdiv_check(q,r,a,b, "floor",b);
|
||||
| ^~~~~~~~~~~~
|
||||
../stb_divide.h:320:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
|
||||
320 | if (show) printf("(%+11d,%+2d)\n", q,r); stbdiv_check(q,r,a,b, "euclidean",1);
|
||||
| ^~
|
||||
../stb_divide.h:320:45: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
|
||||
320 | if (show) printf("(%+11d,%+2d)\n", q,r); stbdiv_check(q,r,a,b, "euclidean",1);
|
||||
| ^~~~~~~~~~~~
|
||||
|
||||
This commit moves each call to stbdiv_check(…) to the following line to
|
||||
make clear that it is unconditional and to resolve the warning.
|
||||
---
|
||||
stb_divide.h | 9 ++++++---
|
||||
1 file changed, 6 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/stb_divide.h b/stb_divide.h
|
||||
index 6a51e3f2e..4c24143c4 100644
|
||||
--- a/stb_divide.h
|
||||
+++ b/stb_divide.h
|
||||
@@ -313,11 +313,14 @@ void test(int a, int b)
|
||||
int q,r;
|
||||
if (show) printf("(%+11d,%+d) | ", a,b);
|
||||
q = stb_div_trunc(a,b), r = stb_mod_trunc(a,b);
|
||||
- if (show) printf("(%+11d,%+2d) ", q,r); stbdiv_check(q,r,a,b, "trunc",a);
|
||||
+ if (show) printf("(%+11d,%+2d) ", q,r);
|
||||
+ stbdiv_check(q,r,a,b, "trunc",a);
|
||||
q = stb_div_floor(a,b), r = stb_mod_floor(a,b);
|
||||
- if (show) printf("(%+11d,%+2d) ", q,r); stbdiv_check(q,r,a,b, "floor",b);
|
||||
+ if (show) printf("(%+11d,%+2d) ", q,r);
|
||||
+ stbdiv_check(q,r,a,b, "floor",b);
|
||||
q = stb_div_eucl (a,b), r = stb_mod_eucl (a,b);
|
||||
- if (show) printf("(%+11d,%+2d)\n", q,r); stbdiv_check(q,r,a,b, "euclidean",1);
|
||||
+ if (show) printf("(%+11d,%+2d)\n", q,r);
|
||||
+ stbdiv_check(q,r,a,b, "euclidean",1);
|
||||
}
|
||||
|
||||
void testh(int a, int b)
|
||||
22
1196.patch
Normal file
22
1196.patch
Normal file
@ -0,0 +1,22 @@
|
||||
From 49c16b0c2a4efa72d0ce6ea05d3fa7d9e8fc6cba Mon Sep 17 00:00:00 2001
|
||||
From: "Benjamin A. Beasley" <code@musicinmybrain.net>
|
||||
Date: Thu, 19 Aug 2021 12:57:27 -0400
|
||||
Subject: [PATCH] Add missing initializer braces in stb_easy_font.h
|
||||
|
||||
---
|
||||
stb_easy_font.h | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/stb_easy_font.h b/stb_easy_font.h
|
||||
index b66325847b..5f7511560a 100644
|
||||
--- a/stb_easy_font.h
|
||||
+++ b/stb_easy_font.h
|
||||
@@ -202,7 +202,7 @@ static int stb_easy_font_print(float x, float y, char *text, unsigned char color
|
||||
float start_x = x;
|
||||
int offset = 0;
|
||||
|
||||
- stb_easy_font_color c = { 255,255,255,255 }; // use structure copying to avoid needing depending on memcpy()
|
||||
+ stb_easy_font_color c = { { 255,255,255,255 } }; // use structure copying to avoid needing depending on memcpy()
|
||||
if (color) { c.c[0] = color[0]; c.c[1] = color[1]; c.c[2] = color[2]; c.c[3] = color[3]; }
|
||||
|
||||
while (*text && offset < vbuf_size) {
|
||||
24
1198.patch
Normal file
24
1198.patch
Normal file
@ -0,0 +1,24 @@
|
||||
From f9a5eaee846f1a19fbcda2f5adb5238a94cbbc2f Mon Sep 17 00:00:00 2001
|
||||
From: "Benjamin A. Beasley" <code@musicinmybrain.net>
|
||||
Date: Tue, 24 Aug 2021 11:45:48 -0400
|
||||
Subject: [PATCH] Fix signature of dummy realloc() for STB_VORBIS_NO_CRT
|
||||
|
||||
---
|
||||
stb_vorbis.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/stb_vorbis.c b/stb_vorbis.c
|
||||
index 3e5c2504c..c1703426e 100644
|
||||
--- a/stb_vorbis.c
|
||||
+++ b/stb_vorbis.c
|
||||
@@ -594,8 +594,8 @@ enum STBVorbisError
|
||||
#else // STB_VORBIS_NO_CRT
|
||||
#define NULL 0
|
||||
#define malloc(s) 0
|
||||
- #define free(s) ((void) 0)
|
||||
- #define realloc(s) 0
|
||||
+ #define free(p) ((void) 0)
|
||||
+ #define realloc(p, s) 0
|
||||
#endif // STB_VORBIS_NO_CRT
|
||||
|
||||
#include <limits.h>
|
||||
59
1223.patch
Normal file
59
1223.patch
Normal file
@ -0,0 +1,59 @@
|
||||
From 8075c3442ffeadab7594e1fe3ad13344f9c9c783 Mon Sep 17 00:00:00 2001
|
||||
From: Neil Bickford <nbickford@nvidia.com>
|
||||
Date: Thu, 7 Oct 2021 13:00:32 -0700
|
||||
Subject: [PATCH] Fixes two stb_image issues that could occur with specially
|
||||
constructed HDR and PGM files.
|
||||
|
||||
Signed-off-by: Neil Bickford <nbickford@nvidia.com>
|
||||
---
|
||||
stb_image.h | 17 ++++++++++++-----
|
||||
1 file changed, 12 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/stb_image.h b/stb_image.h
|
||||
index d60371b95..8518c05e7 100644
|
||||
--- a/stb_image.h
|
||||
+++ b/stb_image.h
|
||||
@@ -108,7 +108,7 @@ RECENT REVISION HISTORY:
|
||||
Cass Everitt Ryamond Barbiero github:grim210
|
||||
Paul Du Bois Engin Manap Aldo Culquicondor github:sammyhw
|
||||
Philipp Wiesemann Dale Weiler Oriol Ferrer Mesia github:phprus
|
||||
- Josh Tobin Matthew Gregan github:poppolopoppo
|
||||
+ Josh Tobin Neil Bickford Matthew Gregan github:poppolopoppo
|
||||
Julian Raschke Gregory Mullen Christian Floisand github:darealshinji
|
||||
Baldur Karlsson Kevin Schmidt JR Smith github:Michaelangel007
|
||||
Brad Weinberger Matvey Cherevko github:mosra
|
||||
@@ -7187,12 +7187,12 @@ static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int re
|
||||
// Run
|
||||
value = stbi__get8(s);
|
||||
count -= 128;
|
||||
- if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); }
|
||||
+ if ((count == 0) || (count > nleft)) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); }
|
||||
for (z = 0; z < count; ++z)
|
||||
scanline[i++ * 4 + k] = value;
|
||||
} else {
|
||||
// Dump
|
||||
- if (count > nleft) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); }
|
||||
+ if ((count == 0) || (count > nleft)) { STBI_FREE(hdr_data); STBI_FREE(scanline); return stbi__errpf("corrupt", "bad RLE data in HDR"); }
|
||||
for (z = 0; z < count; ++z)
|
||||
scanline[i++ * 4 + k] = stbi__get8(s);
|
||||
}
|
||||
@@ -7446,10 +7446,17 @@ static void *stbi__pnm_load(stbi__context *s, int *x, int *y, int *comp, int req
|
||||
|
||||
out = (stbi_uc *) stbi__malloc_mad4(s->img_n, s->img_x, s->img_y, ri->bits_per_channel / 8, 0);
|
||||
if (!out) return stbi__errpuc("outofmem", "Out of memory");
|
||||
- stbi__getn(s, out, s->img_n * s->img_x * s->img_y * (ri->bits_per_channel / 8));
|
||||
+ if (!stbi__getn(s, out, s->img_n * s->img_x * s->img_y * (ri->bits_per_channel / 8))) {
|
||||
+ STBI_FREE(out);
|
||||
+ return stbi__errpuc("bad PNM", "PNM file truncated");
|
||||
+ }
|
||||
|
||||
if (req_comp && req_comp != s->img_n) {
|
||||
- out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y);
|
||||
+ if (ri->bits_per_channel == 16) {
|
||||
+ out = (stbi_uc *) stbi__convert_format16((stbi__uint16 *) out, s->img_n, req_comp, s->img_x, s->img_y);
|
||||
+ } else {
|
||||
+ out = stbi__convert_format(out, s->img_n, req_comp, s->img_x, s->img_y);
|
||||
+ }
|
||||
if (out == NULL) return out; // stbi__convert_format frees input on failure
|
||||
}
|
||||
return out;
|
||||
32
1230.patch
Normal file
32
1230.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From b5d9d9719b001c67ca922df547a85a0fae364997 Mon Sep 17 00:00:00 2001
|
||||
From: Neil Bickford <nbickford@nvidia.com>
|
||||
Date: Fri, 15 Oct 2021 11:04:41 -0700
|
||||
Subject: [PATCH] stb_image PNG: Checks for invalid DEFLATE codes.
|
||||
|
||||
Specifically, this rejects length codes 286 and 287, and distance codes 30 and 31.
|
||||
This avoids a scenario in which a file could contain a table in which
|
||||
0 corresponded to length code 287, which would result in writing 0 bits.
|
||||
|
||||
Signed-off-by: Neil Bickford <nbickford@nvidia.com>
|
||||
---
|
||||
stb_image.h | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/stb_image.h b/stb_image.h
|
||||
index d60371b95..ab616c56d 100644
|
||||
--- a/stb_image.h
|
||||
+++ b/stb_image.h
|
||||
@@ -4256,11 +4256,12 @@ static int stbi__parse_huffman_block(stbi__zbuf *a)
|
||||
a->zout = zout;
|
||||
return 1;
|
||||
}
|
||||
+ if (z >= 286) return stbi__err("bad huffman code","Corrupt PNG"); // per DEFLATE, length codes 286 and 287 must not appear in compressed data
|
||||
z -= 257;
|
||||
len = stbi__zlength_base[z];
|
||||
if (stbi__zlength_extra[z]) len += stbi__zreceive(a, stbi__zlength_extra[z]);
|
||||
z = stbi__zhuffman_decode(a, &a->z_distance);
|
||||
- if (z < 0) return stbi__err("bad huffman code","Corrupt PNG");
|
||||
+ if (z < 0 || z >= 30) return stbi__err("bad huffman code","Corrupt PNG"); // per DEFLATE, distance codes 30 and 31 must not appear in compressed data
|
||||
dist = stbi__zdist_base[z];
|
||||
if (stbi__zdist_extra[z]) dist += stbi__zreceive(a, stbi__zdist_extra[z]);
|
||||
if (zout - a->zout_start < dist) return stbi__err("bad dist","Corrupt PNG");
|
||||
37
1236.patch
Normal file
37
1236.patch
Normal file
@ -0,0 +1,37 @@
|
||||
From 5cf3af3181f7a0fb8d59ca5fe8daa011c1918d19 Mon Sep 17 00:00:00 2001
|
||||
From: Ryan Wiedemann <Ryan1729@gmail.com>
|
||||
Date: Mon, 25 Oct 2021 22:11:48 -0600
|
||||
Subject: [PATCH] Predeclare stbhw__process struct to fix warnings
|
||||
|
||||
A subset of the warnings as produced by `clang`.
|
||||
```
|
||||
./../stb_herringbone_wang_tile.h:369:41: warning: declaration of 'struct stbhw__process' will not be visible outside of this function [-Wvisibility]
|
||||
typedef void stbhw__process_rect(struct stbhw__process *p, int xpos, int ypos,
|
||||
^
|
||||
./../stb_herringbone_wang_tile.h:401:43: warning: incompatible pointer types passing 'stbhw__process *' (aka 'struct stbhw__process *') to parameter of type 'struct stbhw__process *' [-Wincompatible-pointer-types]
|
||||
p->process_h_rect(p, xpos, ypos, a,b,c,d,e,f);
|
||||
^
|
||||
./../stb_herringbone_wang_tile.h:425:43: warning: incompatible pointer types passing 'stbhw__process *' (aka 'struct stbhw__process *') to parameter of type 'struct stbhw__process *' [-Wincompatible-pointer-types]
|
||||
p->process_v_rect(p, xpos, ypos, a,b,c,d,e,f);
|
||||
^
|
||||
./../stb_herringbone_wang_tile.h:929:21: warning: incompatible pointer types assigning to 'stbhw__process_rect *' (aka 'void (*)(struct stbhw__process *, int, int, int, int, int, int, int, int)') from 'void (stbhw__process *, int, int, int, int, int, int, int, int)' (aka 'void (struct stbhw__process *, int, int, int, int, int, int, int, int)') [-Wincompatible-pointer-types]
|
||||
p.process_h_rect = stbhw__parse_h_rect;
|
||||
^ ~~~~~~~~~~~~~~~~~~~
|
||||
```
|
||||
---
|
||||
stb_herringbone_wang_tile.h | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/stb_herringbone_wang_tile.h b/stb_herringbone_wang_tile.h
|
||||
index 5517941f7a..92c238bb24 100644
|
||||
--- a/stb_herringbone_wang_tile.h
|
||||
+++ b/stb_herringbone_wang_tile.h
|
||||
@@ -366,6 +366,8 @@ STBHW_EXTERN const char *stbhw_get_last_error(void)
|
||||
// need to try to do more sophisticated parsing of edge color
|
||||
// markup or something.
|
||||
|
||||
+struct stbhw__process;
|
||||
+
|
||||
typedef void stbhw__process_rect(struct stbhw__process *p, int xpos, int ypos,
|
||||
int a, int b, int c, int d, int e, int f);
|
||||
|
||||
244
1297.patch
Normal file
244
1297.patch
Normal file
@ -0,0 +1,244 @@
|
||||
From fa43122a169eb79ced5789f2f261cee7fd4db221 Mon Sep 17 00:00:00 2001
|
||||
From: Neil Bickford <nbickford@nvidia.com>
|
||||
Date: Tue, 22 Feb 2022 23:48:42 -0800
|
||||
Subject: [PATCH 1/4] Add checks for PNM integer read overflows, add a 1GB
|
||||
limit on IDAT chunk sizes to fix an OOM issue, and check for a situation
|
||||
where a sequence of bad Huffman code reads could result in a left shift by a
|
||||
negative number.
|
||||
|
||||
---
|
||||
stb_image.h | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
diff --git a/stb_image.h b/stb_image.h
|
||||
index d60371b95..6321f5e02 100644
|
||||
--- a/stb_image.h
|
||||
+++ b/stb_image.h
|
||||
@@ -2283,6 +2283,7 @@ static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__
|
||||
k += (r >> 4) & 15; // run
|
||||
s = r & 15; // combined length
|
||||
j->code_buffer <<= s;
|
||||
+ if (s > j->code_bits) return stbi__err("bad huffman code","Combined length longer than code bits available");
|
||||
j->code_bits -= s;
|
||||
zig = stbi__jpeg_dezigzag[k++];
|
||||
data[zig] = (short) ((r >> 8) * (1 << shift));
|
||||
@@ -5116,6 +5117,7 @@ static int stbi__parse_png_file(stbi__png *z, int scan, int req_comp)
|
||||
if (first) return stbi__err("first not IHDR", "Corrupt PNG");
|
||||
if (pal_img_n && !pal_len) return stbi__err("no PLTE","Corrupt PNG");
|
||||
if (scan == STBI__SCAN_header) { s->img_n = pal_img_n; return 1; }
|
||||
+ if (c.length > (1u << 30)) return stbi__err("IDAT size limit", "IDAT section larger than 2^30 bytes");
|
||||
if ((int)(ioff + c.length) < (int)ioff) return 0;
|
||||
if (ioff + c.length > idata_limit) {
|
||||
stbi__uint32 idata_limit_old = idata_limit;
|
||||
@@ -7486,6 +7488,8 @@ static int stbi__pnm_getinteger(stbi__context *s, char *c)
|
||||
while (!stbi__at_eof(s) && stbi__pnm_isdigit(*c)) {
|
||||
value = value*10 + (*c - '0');
|
||||
*c = (char) stbi__get8(s);
|
||||
+ if((value > 214748364) || (value == 214748364 && *c > '7'))
|
||||
+ return stbi__err("integer parse overflow", "Parsing an integer in the PPM header overflowed a 32-bit int");
|
||||
}
|
||||
|
||||
return value;
|
||||
@@ -7516,9 +7520,13 @@ static int stbi__pnm_info(stbi__context *s, int *x, int *y, int *comp)
|
||||
stbi__pnm_skip_whitespace(s, &c);
|
||||
|
||||
*x = stbi__pnm_getinteger(s, &c); // read width
|
||||
+ if(*x == 0)
|
||||
+ return stbi__err("invalid width", "PPM image header had zero or overflowing width");
|
||||
stbi__pnm_skip_whitespace(s, &c);
|
||||
|
||||
*y = stbi__pnm_getinteger(s, &c); // read height
|
||||
+ if (*y == 0)
|
||||
+ return stbi__err("invalid width", "PPM image header had zero or overflowing width");
|
||||
stbi__pnm_skip_whitespace(s, &c);
|
||||
|
||||
maxv = stbi__pnm_getinteger(s, &c); // read max value
|
||||
|
||||
From 83739b31eeddaaf683948051661ece39af6795cd Mon Sep 17 00:00:00 2001
|
||||
From: Neil Bickford <nbickford@nvidia.com>
|
||||
Date: Wed, 23 Feb 2022 00:53:34 -0800
|
||||
Subject: [PATCH 2/4] Add range checks to fix a few crash issues in stb_image
|
||||
issues 1289 and 1291
|
||||
|
||||
---
|
||||
stb_image.h | 10 ++++++++--
|
||||
1 file changed, 8 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/stb_image.h b/stb_image.h
|
||||
index 6321f5e02..800c83db3 100644
|
||||
--- a/stb_image.h
|
||||
+++ b/stb_image.h
|
||||
@@ -1985,9 +1985,12 @@ static int stbi__build_huffman(stbi__huffman *h, int *count)
|
||||
int i,j,k=0;
|
||||
unsigned int code;
|
||||
// build size list for each symbol (from JPEG spec)
|
||||
- for (i=0; i < 16; ++i)
|
||||
- for (j=0; j < count[i]; ++j)
|
||||
+ for (i=0; i < 16; ++i) {
|
||||
+ for (j=0; j < count[i]; ++j) {
|
||||
h->size[k++] = (stbi_uc) (i+1);
|
||||
+ if(k >= 257) return stbi__err("bad size list","Corrupt JPEG");
|
||||
+ }
|
||||
+ }
|
||||
h->size[k] = 0;
|
||||
|
||||
// compute actual symbols (from jpeg spec)
|
||||
@@ -2112,6 +2115,8 @@ stbi_inline static int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h)
|
||||
|
||||
// convert the huffman code to the symbol id
|
||||
c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k];
|
||||
+ if(c < 0 || c >= 256) // symbol id out of bounds!
|
||||
+ return -1;
|
||||
STBI_ASSERT((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]);
|
||||
|
||||
// convert the id to a symbol
|
||||
@@ -3103,6 +3108,7 @@ static int stbi__process_marker(stbi__jpeg *z, int m)
|
||||
sizes[i] = stbi__get8(z->s);
|
||||
n += sizes[i];
|
||||
}
|
||||
+ if(n > 256) return stbi__err("bad DHT header","Corrupt JPEG"); // Loop over i < n would write past end of values!
|
||||
L -= 17;
|
||||
if (tc == 0) {
|
||||
if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0;
|
||||
|
||||
From 2cdd738fd112e11bec8d7b2ee96449741a203ee2 Mon Sep 17 00:00:00 2001
|
||||
From: Neil Bickford <nbickford@nvidia.com>
|
||||
Date: Wed, 23 Feb 2022 23:48:49 -0800
|
||||
Subject: [PATCH 3/4] Add checks for signed integer overflow; further guard
|
||||
against cases where stbi__grow_buffer_unsafe doesn't read all bits required.
|
||||
|
||||
---
|
||||
stb_image.h | 27 ++++++++++++++++++++++++++-
|
||||
1 file changed, 26 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/stb_image.h b/stb_image.h
|
||||
index 800c83db3..9d10099bb 100644
|
||||
--- a/stb_image.h
|
||||
+++ b/stb_image.h
|
||||
@@ -1063,6 +1063,23 @@ static void *stbi__malloc_mad4(int a, int b, int c, int d, int add)
|
||||
}
|
||||
#endif
|
||||
|
||||
+// returns 1 if the sum of two signed ints is valid (between -2^31 and 2^31-1 inclusive), 0 on overflow.
|
||||
+static int stbi__addints_valid(int a, int b)
|
||||
+{
|
||||
+ if ((a >= 0) != (b >= 0)) return 1; // a and b have different signs, so no overflow
|
||||
+ if (a < 0 && b < 0) return a >= INT_MIN - b; // same as a + b >= INT_MIN; INT_MIN - b cannot overflow since b < 0.
|
||||
+ return a <= INT_MAX - b;
|
||||
+}
|
||||
+
|
||||
+// returns 1 if the product of two signed shorts is valid, 0 on overflow.
|
||||
+static int stbi__mul2shorts_valid(short a, short b)
|
||||
+{
|
||||
+ if (b == 0 || b == -1) return 1; // multiplication by 0 is always 0; check for -1 so SHRT_MIN/b doesn't overflow
|
||||
+ if ((a >= 0) == (b >= 0)) return a <= SHRT_MAX/b; // product is positive, so similar to mul2sizes_valid
|
||||
+ if (b < 0) return a <= SHRT_MIN / b; // same as a * b >= SHRT_MIN
|
||||
+ return a >= SHRT_MIN / b;
|
||||
+}
|
||||
+
|
||||
// stbi__err - error
|
||||
// stbi__errpf - error returning pointer to float
|
||||
// stbi__errpuc - error returning pointer to unsigned char
|
||||
@@ -2135,6 +2152,7 @@ stbi_inline static int stbi__extend_receive(stbi__jpeg *j, int n)
|
||||
unsigned int k;
|
||||
int sgn;
|
||||
if (j->code_bits < n) stbi__grow_buffer_unsafe(j);
|
||||
+ if (j->code_bits < n) return 0; // ran out of bits from stream, return 0s intead of continuing
|
||||
|
||||
sgn = j->code_buffer >> 31; // sign bit always in MSB; 0 if MSB clear (positive), 1 if MSB set (negative)
|
||||
k = stbi_lrot(j->code_buffer, n);
|
||||
@@ -2149,6 +2167,7 @@ stbi_inline static int stbi__jpeg_get_bits(stbi__jpeg *j, int n)
|
||||
{
|
||||
unsigned int k;
|
||||
if (j->code_bits < n) stbi__grow_buffer_unsafe(j);
|
||||
+ if (j->code_bits < n) return 0; // ran out of bits from stream, return 0s intead of continuing
|
||||
k = stbi_lrot(j->code_buffer, n);
|
||||
j->code_buffer = k & ~stbi__bmask[n];
|
||||
k &= stbi__bmask[n];
|
||||
@@ -2160,6 +2179,7 @@ stbi_inline static int stbi__jpeg_get_bit(stbi__jpeg *j)
|
||||
{
|
||||
unsigned int k;
|
||||
if (j->code_bits < 1) stbi__grow_buffer_unsafe(j);
|
||||
+ if (j->code_bits < 1) return 0; // ran out of bits from stream, return 0s intead of continuing
|
||||
k = j->code_buffer;
|
||||
j->code_buffer <<= 1;
|
||||
--j->code_bits;
|
||||
@@ -2197,8 +2217,10 @@ static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman
|
||||
memset(data,0,64*sizeof(data[0]));
|
||||
|
||||
diff = t ? stbi__extend_receive(j, t) : 0;
|
||||
+ if (!stbi__addints_valid(j->img_comp[b].dc_pred, diff)) return stbi__err("bad delta","Corrupt JPEG");
|
||||
dc = j->img_comp[b].dc_pred + diff;
|
||||
j->img_comp[b].dc_pred = dc;
|
||||
+ if (!stbi__mul2shorts_valid(dc, dequant[0])) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
|
||||
data[0] = (short) (dc * dequant[0]);
|
||||
|
||||
// decode AC components, see JPEG spec
|
||||
@@ -2212,6 +2234,7 @@ static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman
|
||||
if (r) { // fast-AC path
|
||||
k += (r >> 4) & 15; // run
|
||||
s = r & 15; // combined length
|
||||
+ if (s > j->code_bits) return stbi__err("bad huffman code", "Combined length longer than code bits available");
|
||||
j->code_buffer <<= s;
|
||||
j->code_bits -= s;
|
||||
// decode into unzigzag'd location
|
||||
@@ -2251,8 +2274,10 @@ static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__
|
||||
if (t < 0 || t > 15) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
|
||||
diff = t ? stbi__extend_receive(j, t) : 0;
|
||||
|
||||
+ if (!stbi__addints_valid(j->img_comp[b].dc_pred, diff)) return stbi__err("bad delta", "Corrupt JPEG");
|
||||
dc = j->img_comp[b].dc_pred + diff;
|
||||
j->img_comp[b].dc_pred = dc;
|
||||
+ if (!stbi__mul2shorts_valid(dc, 1 << j->succ_low)) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
|
||||
data[0] = (short) (dc * (1 << j->succ_low));
|
||||
} else {
|
||||
// refinement scan for DC coefficient
|
||||
@@ -2287,8 +2312,8 @@ static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__
|
||||
if (r) { // fast-AC path
|
||||
k += (r >> 4) & 15; // run
|
||||
s = r & 15; // combined length
|
||||
+ if (s > j->code_bits) return stbi__err("bad huffman code", "Combined length longer than code bits available");
|
||||
j->code_buffer <<= s;
|
||||
- if (s > j->code_bits) return stbi__err("bad huffman code","Combined length longer than code bits available");
|
||||
j->code_bits -= s;
|
||||
zig = stbi__jpeg_dezigzag[k++];
|
||||
data[zig] = (short) ((r >> 8) * (1 << shift));
|
||||
|
||||
From 51e438b04b50eb98540f6df6057004214e9cc81c Mon Sep 17 00:00:00 2001
|
||||
From: Neil Bickford <nbickford@nvidia.com>
|
||||
Date: Fri, 25 Feb 2022 14:27:31 -0800
|
||||
Subject: [PATCH 4/4] Zero-initialize stbi__jpeg to avoid intermittent errors
|
||||
found by fuzz-testing
|
||||
|
||||
---
|
||||
stb_image.h | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/stb_image.h b/stb_image.h
|
||||
index 9d10099bb..631e4e51c 100644
|
||||
--- a/stb_image.h
|
||||
+++ b/stb_image.h
|
||||
@@ -4008,6 +4008,7 @@ static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int re
|
||||
unsigned char* result;
|
||||
stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg));
|
||||
if (!j) return stbi__errpuc("outofmem", "Out of memory");
|
||||
+ memset(j, 0, sizeof(stbi__jpeg));
|
||||
STBI_NOTUSED(ri);
|
||||
j->s = s;
|
||||
stbi__setup_jpeg(j);
|
||||
@@ -4021,6 +4022,7 @@ static int stbi__jpeg_test(stbi__context *s)
|
||||
int r;
|
||||
stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg));
|
||||
if (!j) return stbi__err("outofmem", "Out of memory");
|
||||
+ memset(j, 0, sizeof(stbi__jpeg));
|
||||
j->s = s;
|
||||
stbi__setup_jpeg(j);
|
||||
r = stbi__decode_jpeg_header(j, STBI__SCAN_type);
|
||||
@@ -4046,6 +4048,7 @@ static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp)
|
||||
int result;
|
||||
stbi__jpeg* j = (stbi__jpeg*) (stbi__malloc(sizeof(stbi__jpeg)));
|
||||
if (!j) return stbi__err("outofmem", "Out of memory");
|
||||
+ memset(j, 0, sizeof(stbi__jpeg));
|
||||
j->s = s;
|
||||
result = stbi__jpeg_info_raw(j, x, y, comp);
|
||||
STBI_FREE(j);
|
||||
BIN
stb-8b5f1f37b5b75829fc72d38e7b5d4bcbf8a26d55.tar.gz
Normal file
BIN
stb-8b5f1f37b5b75829fc72d38e7b5d4bcbf8a26d55.tar.gz
Normal file
Binary file not shown.
883
stb.spec
Normal file
883
stb.spec
Normal file
@ -0,0 +1,883 @@
|
||||
## START: Set by rpmautospec
|
||||
## (rpmautospec version 0.3.0)
|
||||
|
||||
%global commit 8b5f1f37b5b75829fc72d38e7b5d4bcbf8a26d55
|
||||
|
||||
# We choose not to package the “stb_include” library (stb_include.h) because,
|
||||
# during the package review, it was observed that it follows coding practices
|
||||
# that make it dangerous to use on untrusted inputs, including but not limited
|
||||
# to:
|
||||
#
|
||||
# - It uses of strcat/strcpy into a fixed-length buffer that is assumed (but
|
||||
# not proven) to be large enough for all possible uses
|
||||
# - It ignores I/O errors (possibly leading to undefined behavior from reading
|
||||
# uninitialized memory), and so on. Making it
|
||||
#
|
||||
# A substantial rewrite would be required to mitigate these concerns. If a
|
||||
# request for this library arises, this decision may be revisited, or the
|
||||
# necessary rewrite may be done and offered upstream. For now, we omit the
|
||||
# library and expect it will not be missed.
|
||||
%bcond_with stb_include
|
||||
|
||||
Name: stb
|
||||
# While the individual header-only libraries are versioned, the overall
|
||||
# collection is not, and there are no releases. See:
|
||||
# https://github.com/nothings/stb/issues/359
|
||||
# https://github.com/nothings/stb/issues/1101
|
||||
%global snapinfo .20220908git8b5f1f3
|
||||
Version: 0%{snapinfo}
|
||||
Release: 0.4
|
||||
Summary: Single-file public domain libraries for C/C++
|
||||
|
||||
# See LICENSE.
|
||||
License: MIT OR Unlicense
|
||||
# Additionally, the following are under different terms, but are not used; to
|
||||
# make certain, they are removed in %%prep.
|
||||
#
|
||||
# - deprecated/rrsprintf.h, tests/caveview/stb_gl.h, and
|
||||
# tests/caveview/win32/SDL_windows_main.c are Public Domain
|
||||
# - tests/caveview/glext.h is MIT (only)
|
||||
URL: https://github.com/nothings/stb
|
||||
Source0: %{url}/archive/%{commit}/stb-%{commit}.tar.gz
|
||||
|
||||
# Fix undefined behavior from array “shape-punning”
|
||||
# https://github.com/nothings/stb/pull/1194
|
||||
Patch01: 1194.patch
|
||||
|
||||
# Fix misleading indentation in stb_divide.h
|
||||
# https://github.com/nothings/stb/pull/1195
|
||||
Patch02: 1195.patch
|
||||
|
||||
# Trivial fix for array-in-structure initialization (missing braces warning)
|
||||
# https://github.com/nothings/stb/pull/1196
|
||||
Patch03: 1196.patch
|
||||
|
||||
# Fix signature of dummy realloc() for STB_VORBIS_NO_CRT
|
||||
# https://github.com/nothings/stb/pull/1198
|
||||
Patch04: 1198.patch
|
||||
|
||||
# Candidate fix for:
|
||||
# https://nvd.nist.gov/vuln/detail/CVE-2021-42715
|
||||
#
|
||||
# In stb_image's HDR reader, loading a specially constructed invalid HDR file
|
||||
# can result in an infinite loop within the RLE decoder
|
||||
# https://github.com/nothings/stb/issues/1224
|
||||
#
|
||||
# ----
|
||||
#
|
||||
# Additionally, this is a candidate fix for:
|
||||
# https://nvd.nist.gov/vuln/detail/CVE-2021-42716
|
||||
#
|
||||
# stbi__pnm_load heap-buffer-overflow bug
|
||||
# https://github.com/nothings/stb/issues/1166
|
||||
#
|
||||
# In stb_image's PNM reader, loading a specially constructed valid 16-bit PGM
|
||||
# file with 4 channels can cause a crash due to an out-of-bounds read
|
||||
# https://github.com/nothings/stb/issues/1225
|
||||
#
|
||||
# ----
|
||||
#
|
||||
# Fixes a crash and an infinite loop in stb_image that could occur with
|
||||
# specially constructed PGM and HDR files
|
||||
# https://github.com/nothings/stb/pull/1223
|
||||
Patch05: 1223.patch
|
||||
|
||||
# Forward declare stbhw__process struct to fix warnings
|
||||
# https://github.com/nothings/stb/pull/1225
|
||||
#
|
||||
# We don’t see these warnings in the “compile tests”, but we can reproduce them
|
||||
# by manually compiling tests/herringbone_map.c; a real user of the
|
||||
# stb_herringbone_wang_tile library would encounter them; and inspection of the
|
||||
# patch shows it to be correct.
|
||||
Patch06: 1236.patch
|
||||
|
||||
# Candidate fix for:
|
||||
# https://nvd.nist.gov/vuln/detail/CVE-2022-28041
|
||||
#
|
||||
# stb_image.h v2.27 was discovered to contain an integer overflow via the
|
||||
# function stbi__jpeg_decode_block_prog_dc. This vulnerability allows attackers
|
||||
# to cause a Denial of Service (DoS) via unspecified vectors.
|
||||
#
|
||||
# UBSAN: integer overflow
|
||||
# https://github.com/nothings/stb/issues/1292
|
||||
#
|
||||
# ----
|
||||
#
|
||||
# Additional stb_image fixes for bugs from ossfuzz and issues 1289, 1291, 1292,
|
||||
# and 1293
|
||||
# https://github.com/nothings/stb/pull/1297
|
||||
Patch07: 1297.patch
|
||||
|
||||
# stb_image PNG reader: Adds checks for invalid DEFLATE codes, fixing an
|
||||
# infinite loop found by ossfuzz.
|
||||
# https://github.com/nothings/stb/pull/1230
|
||||
# Fixes:
|
||||
# Issue 24232: stb:stb_png_read_fuzzer: Timeout in stb_png_read_fuzzer
|
||||
# https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=24232&q=proj%3Dstb
|
||||
Patch08: 1230.patch
|
||||
|
||||
%global stb_c_lexer_version 0.12
|
||||
%global stb_connected_components_version 0.96
|
||||
%global stb_divide_version 0.94
|
||||
%global stb_ds_version 0.67
|
||||
%global stb_dxt_version 1.12
|
||||
%global stb_easy_font_version 1.1
|
||||
%global stb_herringbone_wang_tile_version 0.7
|
||||
%global stb_hexwave_version 0.5
|
||||
%global stb_image_version 2.27
|
||||
%global stb_image_resize_version 0.97
|
||||
%global stb_image_write_version 1.16
|
||||
%global stb_include_version 0.2
|
||||
%global stb_leakcheck_version 0.6
|
||||
%global stb_perlin_version 0.5
|
||||
%global stb_rect_pack_version 1.1
|
||||
%global stb_sprintf_version 1.10
|
||||
%global stb_textedit_version 1.14
|
||||
%global stb_tilemap_editor_version 0.42
|
||||
%global stb_truetype_version 1.26
|
||||
%global stb_vorbis_version 1.22
|
||||
%global stb_voxel_render_version 0.89
|
||||
|
||||
BuildRequires: gcc
|
||||
BuildRequires: gcc-c++
|
||||
BuildRequires: make
|
||||
|
||||
BuildRequires: ImageMagick
|
||||
|
||||
# No compiled binaries are installed, so this would be empty.
|
||||
%global debug_package %{nil}
|
||||
|
||||
%description
|
||||
%{summary}.
|
||||
|
||||
|
||||
%package devel
|
||||
Summary: Development files for stb
|
||||
|
||||
# Dependent packages should prefer to BuildRequire the -static packages for the
|
||||
# specific stb libraries they use.
|
||||
Provides: stb-static = %{version}-%{release}
|
||||
|
||||
Requires: stb_c_lexer-devel%{?_isa} = %{stb_c_lexer_version}%{snapinfo}-%{release}
|
||||
Requires: stb_c_lexer-static = %{stb_c_lexer_version}%{snapinfo}-%{release}
|
||||
Requires: stb_connected_components-devel%{?_isa} = %{stb_connected_components_version}%{snapinfo}-%{release}
|
||||
Requires: stb_connected_components-static = %{stb_connected_components_version}%{snapinfo}-%{release}
|
||||
Requires: stb_divide-devel%{?_isa} = %{stb_divide_version}%{snapinfo}-%{release}
|
||||
Requires: stb_divide-static = %{stb_divide_version}%{snapinfo}-%{release}
|
||||
Requires: stb_ds-devel%{?_isa} = %{stb_ds_version}%{snapinfo}-%{release}
|
||||
Requires: stb_ds-static = %{stb_ds_version}%{snapinfo}-%{release}
|
||||
Requires: stb_dxt-devel%{?_isa} = %{stb_dxt_version}%{snapinfo}-%{release}
|
||||
Requires: stb_dxt-static = %{stb_dxt_version}%{snapinfo}-%{release}
|
||||
Requires: stb_easy_font-devel%{?_isa} = %{stb_easy_font_version}%{snapinfo}-%{release}
|
||||
Requires: stb_easy_font-static = %{stb_easy_font_version}%{snapinfo}-%{release}
|
||||
Requires: stb_herringbone_wang_tile-devel%{?_isa} = %{stb_herringbone_wang_tile_version}%{snapinfo}-%{release}
|
||||
Requires: stb_herringbone_wang_tile-static = %{stb_herringbone_wang_tile_version}%{snapinfo}-%{release}
|
||||
Requires: stb_hexwave-devel%{?_isa} = %{stb_hexwave_version}%{snapinfo}-%{release}
|
||||
Requires: stb_hexwave-static = %{stb_hexwave_version}%{snapinfo}-%{release}
|
||||
Requires: stb_image-devel%{?_isa} = %{stb_image_version}%{snapinfo}-%{release}
|
||||
Requires: stb_image-static = %{stb_image_version}%{snapinfo}-%{release}
|
||||
Requires: stb_image_resize-devel%{?_isa} = %{stb_image_resize_version}%{snapinfo}-%{release}
|
||||
Requires: stb_image_resize-static = %{stb_image_resize_version}%{snapinfo}-%{release}
|
||||
Requires: stb_image_write-devel%{?_isa} = %{stb_image_write_version}%{snapinfo}-%{release}
|
||||
Requires: stb_image_write-static = %{stb_image_write_version}%{snapinfo}-%{release}
|
||||
%if %{with stb_include}
|
||||
Requires: stb_include-devel%{?_isa} = %{stb_include_version}%{snapinfo}-%{release}
|
||||
Requires: stb_include-static = %{stb_include_version}%{snapinfo}-%{release}
|
||||
%endif
|
||||
Requires: stb_leakcheck-devel%{?_isa} = %{stb_leakcheck_version}%{snapinfo}-%{release}
|
||||
Requires: stb_leakcheck-static = %{stb_leakcheck_version}%{snapinfo}-%{release}
|
||||
Requires: stb_perlin-devel%{?_isa} = %{stb_perlin_version}%{snapinfo}-%{release}
|
||||
Requires: stb_perlin-static = %{stb_perlin_version}%{snapinfo}-%{release}
|
||||
Requires: stb_rect_pack-devel%{?_isa} = %{stb_rect_pack_version}%{snapinfo}-%{release}
|
||||
Requires: stb_rect_pack-static = %{stb_rect_pack_version}%{snapinfo}-%{release}
|
||||
Requires: stb_sprintf-devel%{?_isa} = %{stb_sprintf_version}%{snapinfo}-%{release}
|
||||
Requires: stb_sprintf-static = %{stb_sprintf_version}%{snapinfo}-%{release}
|
||||
Requires: stb_textedit-devel%{?_isa} = %{stb_textedit_version}%{snapinfo}-%{release}
|
||||
Requires: stb_textedit-static = %{stb_textedit_version}%{snapinfo}-%{release}
|
||||
Requires: stb_tilemap_editor-devel%{?_isa} = %{stb_tilemap_editor_version}%{snapinfo}-%{release}
|
||||
Requires: stb_tilemap_editor-static = %{stb_tilemap_editor_version}%{snapinfo}-%{release}
|
||||
Requires: stb_truetype-devel%{?_isa} = %{stb_truetype_version}%{snapinfo}-%{release}
|
||||
Requires: stb_truetype-static = %{stb_truetype_version}%{snapinfo}-%{release}
|
||||
Requires: stb_vorbis-devel%{?_isa} = %{stb_vorbis_version}%{snapinfo}-%{release}
|
||||
Requires: stb_vorbis-static = %{stb_vorbis_version}%{snapinfo}-%{release}
|
||||
Requires: stb_voxel_render-devel%{?_isa} = %{stb_voxel_render_version}%{snapinfo}-%{release}
|
||||
Requires: stb_voxel_render-static = %{stb_voxel_render_version}%{snapinfo}-%{release}
|
||||
|
||||
%description devel
|
||||
The stb-devel package contains libraries and header files for developing
|
||||
applications that use stb.
|
||||
|
||||
This is a metapackage that requires the -devel packages for all stb libraries.
|
||||
|
||||
|
||||
%package -n stb_c_lexer-devel
|
||||
Summary: Simplify writing parsers for C-like languages
|
||||
Version: %{stb_c_lexer_version}%{snapinfo}
|
||||
|
||||
Provides: stb_c_lexer-static = %{stb_c_lexer_version}%{snapinfo}-%{release}
|
||||
|
||||
%description -n stb_c_lexer-devel
|
||||
Lexer for making little C-like languages with recursive-descent parsers.
|
||||
|
||||
|
||||
%package -n stb_connected_components-devel
|
||||
Summary: Incrementally compute reachability on grids
|
||||
Version: %{stb_connected_components_version}%{snapinfo}
|
||||
|
||||
Provides: stb_connected_components-static = %{stb_connected_components_version}%{snapinfo}-%{release}
|
||||
|
||||
%description -n stb_connected_components-devel
|
||||
Finds connected components on 2D grids for testing reachability between two
|
||||
points, with fast updates when changing reachability (e.g. on one machine it
|
||||
was typically 0.2ms w/ 1024x1024 grid). Each grid square must be “open” or
|
||||
“closed” (traversable or untraversable), and grid squares are only connected to
|
||||
their orthogonal neighbors, not diagonally.
|
||||
|
||||
|
||||
%package -n stb_divide-devel
|
||||
Summary: More useful 32-bit modulus e.g. “Euclidean divide”
|
||||
Version: %{stb_divide_version}%{snapinfo}
|
||||
|
||||
Provides: stb_divide-static = %{stb_divide_version}%{snapinfo}-%{release}
|
||||
|
||||
%description -n stb_divide-devel
|
||||
This file provides three different consistent divide/mod pairs
|
||||
implemented on top of arbitrary C/C++ division, including correct
|
||||
handling of overflow of intermediate calculations:
|
||||
|
||||
trunc: a/b truncates to 0, a%b has same sign as a
|
||||
floor: a/b truncates to -inf, a%b has same sign as b
|
||||
eucl: a/b truncates to sign(b)*inf, a%b is non-negative
|
||||
|
||||
|
||||
%package -n stb_ds-devel
|
||||
Summary: Typesafe dynamic array and hash tables for C, will compile in C++
|
||||
Version: %{stb_ds_version}%{snapinfo}
|
||||
|
||||
Provides: stb_ds-static = %{stb_ds_version}%{snapinfo}-%{release}
|
||||
|
||||
%description -n stb_ds-devel
|
||||
This is a single-header-file library that provides easy-to-use dynamic arrays
|
||||
and hash tables for C (also works in C++).
|
||||
|
||||
For a gentle introduction: https://nothings.org/stb_ds
|
||||
|
||||
|
||||
%package -n stb_dxt-devel
|
||||
Summary: Fabian “ryg” Giesen’s real-time DXT compressor
|
||||
Version: %{stb_dxt_version}%{snapinfo}
|
||||
|
||||
Provides: stb_dxt-static = %{stb_dxt_version}%{snapinfo}-%{release}
|
||||
|
||||
%description -n stb_dxt-devel
|
||||
DXT1/DXT5 compressor.
|
||||
|
||||
|
||||
%package -n stb_easy_font-devel
|
||||
Summary: Quick-and-dirty easy-to-deploy bitmap font for printing frame rate, etc
|
||||
Version: %{stb_easy_font_version}%{snapinfo}
|
||||
|
||||
Provides: stb_easy_font-static = %{stb_easy_font_version}%{snapinfo}-%{release}
|
||||
|
||||
%description -n stb_easy_font-devel
|
||||
Easy-to-deploy,
|
||||
reasonably compact,
|
||||
extremely inefficient performance-wise,
|
||||
crappy-looking,
|
||||
ASCII-only,
|
||||
bitmap font for use in 3D APIs.
|
||||
|
||||
Intended for when you just want to get some text displaying in a 3D app as
|
||||
quickly as possible.
|
||||
|
||||
Doesn’t use any textures, instead builds characters out of quads.
|
||||
|
||||
|
||||
%package -n stb_herringbone_wang_tile-devel
|
||||
Summary: Herringbone Wang tile map generator
|
||||
Version: %{stb_herringbone_wang_tile_version}%{snapinfo}
|
||||
|
||||
Provides: stb_herringbone_wang_tile-static = %{stb_herringbone_wang_tile_version}%{snapinfo}-%{release}
|
||||
|
||||
%description -n stb_herringbone_wang_tile-devel
|
||||
This library is an SDK for Herringbone Wang Tile generation:
|
||||
|
||||
http://nothings.org/gamedev/herringbone
|
||||
|
||||
The core design is that you use this library offline to generate a “template”
|
||||
of the tiles you’ll create. You then edit those tiles, then load the created
|
||||
tile image file back into this library and use it at runtime to generate
|
||||
“maps”.
|
||||
|
||||
You cannot load arbitrary tile image files with this library; it is only
|
||||
designed to load image files made from the template it created. It stores a
|
||||
binary description of the tile sizes & constraints in a few pixels, and uses
|
||||
those to recover the rules, rather than trying to parse the tiles themselves.
|
||||
|
||||
You *can* use this library to generate from arbitrary tile sets, but only by
|
||||
loading the tile set and specifying the constraints explicitly yourself.
|
||||
|
||||
|
||||
%package -n stb_hexwave-devel
|
||||
Summary: Audio waveform synthesizer
|
||||
Version: %{stb_hexwave_version}%{snapinfo}
|
||||
|
||||
Provides: stb_hexwave-static = %{stb_hexwave_version}%{snapinfo}-%{release}
|
||||
|
||||
%description -n stb_hexwave-devel
|
||||
A flexible anti-aliased (bandlimited) digital audio oscillator.
|
||||
|
||||
This library generates waveforms of a variety of shapes made of line segments.
|
||||
It does not do envelopes, LFO effects, etc.; it merely tries to solve the
|
||||
problem of generating an artifact-free morphable digital waveform with a
|
||||
variety of spectra, and leaves it to the user to rescale the waveform and mix
|
||||
multiple voices, etc.
|
||||
|
||||
|
||||
%package -n stb_image-devel
|
||||
Summary: Image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC
|
||||
Version: %{stb_image_version}%{snapinfo}
|
||||
|
||||
Provides: stb_image-static = %{stb_image_version}%{snapinfo}-%{release}
|
||||
|
||||
%description -n stb_image-devel
|
||||
%{summary}.
|
||||
|
||||
Primarily of interest to game developers and other people who can avoid
|
||||
problematic images and only need the trivial interface.
|
||||
|
||||
|
||||
%package -n stb_image_resize-devel
|
||||
Summary: Resize images larger/smaller with good quality
|
||||
Version: %{stb_image_resize_version}%{snapinfo}
|
||||
|
||||
Provides: stb_image_resize-static = %{stb_image_resize_version}%{snapinfo}-%{release}
|
||||
|
||||
%description -n stb_image_resize-devel
|
||||
Image resizing.
|
||||
|
||||
Written with emphasis on usability, portability, and efficiency. (No SIMD or
|
||||
threads, so it be easily outperformed by libs that use those.) Only scaling and
|
||||
translation is supported, no rotations or shears. Easy API downsamples
|
||||
w/Mitchell filter, upsamples w/cubic interpolation.
|
||||
|
||||
|
||||
%package -n stb_image_write-devel
|
||||
Summary: Image writing to disk: PNG, TGA, BMP
|
||||
Version: %{stb_image_write_version}%{snapinfo}
|
||||
|
||||
Provides: stb_image_write-static = %{stb_image_write_version}%{snapinfo}-%{release}
|
||||
|
||||
%description -n stb_image_write-devel
|
||||
This header file is a library for writing images to C stdio or a callback.
|
||||
|
||||
The PNG output is not optimal; it is 20-50%% larger than the file written by a
|
||||
decent optimizing implementation; though providing a custom zlib compress
|
||||
function (see STBIW_ZLIB_COMPRESS) can mitigate that. This library is designed
|
||||
for source code compactness and simplicity, not optimal image file size or
|
||||
run-time performance.
|
||||
|
||||
|
||||
%if %{with stb_include}
|
||||
%package -n stb_include-devel
|
||||
Summary: Implement recursive #include support, particularly for GLSL
|
||||
Version: %{stb_include_version}%{snapinfo}
|
||||
|
||||
Provides: stb_include-static = %{stb_include_version}%{snapinfo}-%{release}
|
||||
|
||||
%description -n stb_include-devel
|
||||
This program parses a string and replaces lines of the form
|
||||
#include "foo"
|
||||
with the contents of a file named "foo". It also embeds the appropriate #line
|
||||
directives. Note that all include files must reside in the location specified
|
||||
in the path passed to the API; it does not check multiple directories.
|
||||
|
||||
If the string contains a line of the form
|
||||
#inject
|
||||
then it will be replaced with the contents of the string ‘inject’ passed to the
|
||||
API.
|
||||
%endif
|
||||
|
||||
|
||||
%package -n stb_leakcheck-devel
|
||||
Summary: Quick-and-dirty malloc/free leak-checking
|
||||
Version: %{stb_leakcheck_version}%{snapinfo}
|
||||
|
||||
Provides: stb_leakcheck-static = %{stb_leakcheck_version}%{snapinfo}-%{release}
|
||||
|
||||
%description -n stb_leakcheck-devel
|
||||
%{summary}.
|
||||
|
||||
|
||||
%package -n stb_perlin-devel
|
||||
Summary: Perlin’s revised simplex noise w/ different seeds
|
||||
Version: %{stb_perlin_version}%{snapinfo}
|
||||
|
||||
Provides: stb_perlin-static = %{stb_perlin_version}%{snapinfo}-%{release}
|
||||
|
||||
%description -n stb_perlin-devel
|
||||
%{summary}.
|
||||
|
||||
|
||||
%package -n stb_rect_pack-devel
|
||||
Summary: Simple 2D rectangle packer with decent quality
|
||||
Version: %{stb_rect_pack_version}%{snapinfo}
|
||||
|
||||
Provides: stb_rect_pack-static = %{stb_rect_pack_version}%{snapinfo}-%{release}
|
||||
|
||||
%description -n stb_rect_pack-devel
|
||||
Useful for e.g. packing rectangular textures into an atlas. Does not do
|
||||
rotation.
|
||||
|
||||
Not necessarily the awesomest packing method, but better than the totally naive
|
||||
one in stb_truetype (which is primarily what this is meant to replace).
|
||||
|
||||
No memory allocations; uses qsort() and assert() from stdlib. Can override
|
||||
those by defining STBRP_SORT and STBRP_ASSERT.
|
||||
|
||||
This library currently uses the Skyline Bottom-Left algorithm.
|
||||
|
||||
Please note: better rectangle packers are welcome! Please implement them to the
|
||||
same API, but with a different init function.
|
||||
|
||||
|
||||
%package -n stb_sprintf-devel
|
||||
Summary: Fast sprintf, snprintf for C/C++
|
||||
Version: %{stb_sprintf_version}%{snapinfo}
|
||||
|
||||
Provides: stb_sprintf-static = %{stb_sprintf_version}%{snapinfo}-%{release}
|
||||
|
||||
%description -n stb_sprintf-devel
|
||||
This is a full sprintf replacement that supports everything that the C runtime
|
||||
sprintfs support, including float/double, 64-bit integers, hex floats, field
|
||||
parameters (%%*.*d stuff), length reads backs, etc.
|
||||
|
||||
Why would you need this if sprintf already exists? Well, first off, it’s *much*
|
||||
faster (see below). It’s also much smaller than the CRT versions
|
||||
code-space-wise. We’ve also added some simple improvements that are super handy
|
||||
(commas in thousands, callbacks at buffer full, for example). Finally, the
|
||||
format strings for MSVC and GCC differ for 64-bit integers (among other small
|
||||
things), so this lets you use the same format strings in cross platform code.
|
||||
|
||||
It uses the standard single file trick of being both the header file and the
|
||||
source itself. If you just include it normally, you just get the header file
|
||||
function definitions. To get the code, you include it from a C or C++ file and
|
||||
define STB_SPRINTF_IMPLEMENTATION first.
|
||||
|
||||
It only uses va_args macros from the C runtime to do its work. It does cast
|
||||
doubles to S64s and shifts and divides U64s, which does drag in CRT code on
|
||||
most platforms.
|
||||
|
||||
It compiles to roughly 8K with float support, and 4K without. As a comparison,
|
||||
when using MSVC static libs, calling sprintf drags in 16K.
|
||||
|
||||
|
||||
%package -n stb_textedit-devel
|
||||
Summary: Guts of a text editor for games etc., implementing them from scratch
|
||||
Version: %{stb_textedit_version}%{snapinfo}
|
||||
|
||||
Provides: stb_textedit-static = %{stb_textedit_version}%{snapinfo}-%{release}
|
||||
|
||||
%description -n stb_textedit-devel
|
||||
This C header file implements the guts of a multi-line text-editing widget; you
|
||||
implement display, word-wrapping, and low-level string insertion/deletion, and
|
||||
stb_textedit will map user inputs into insertions & deletions, plus updates to
|
||||
the cursor position, selection state, and undo state.
|
||||
|
||||
It is intended for use in games and other systems that need to build their own
|
||||
custom widgets and which do not have heavy text-editing requirements (this
|
||||
library is not recommended for use for editing large texts, as its performance
|
||||
does not scale and it has limited undo).
|
||||
|
||||
Non-trivial behaviors are modelled after Windows text controls.
|
||||
|
||||
|
||||
%package -n stb_tilemap_editor-devel
|
||||
Summary: Embeddable tilemap editor
|
||||
Version: %{stb_tilemap_editor_version}%{snapinfo}
|
||||
|
||||
Provides: stb_tilemap_editor-static = %{stb_tilemap_editor_version}%{snapinfo}-%{release}
|
||||
|
||||
%description -n stb_tilemap_editor-devel
|
||||
Embeddable tilemap editor for C/C++.
|
||||
|
||||
|
||||
%package -n stb_truetype-devel
|
||||
Summary: Parse, decode, and rasterize characters from TrueType fonts
|
||||
Version: %{stb_truetype_version}%{snapinfo}
|
||||
|
||||
Provides: stb_truetype-static = %{stb_truetype_version}%{snapinfo}-%{release}
|
||||
|
||||
%description -n stb_truetype-devel
|
||||
%{summary}.
|
||||
=======================================================================
|
||||
|
||||
NO SECURITY GUARANTEE -- DO NOT USE THIS ON UNTRUSTED FONT FILES
|
||||
|
||||
This library does no range checking of the offsets found in the file,
|
||||
meaning an attacker can use it to read arbitrary memory.
|
||||
|
||||
=======================================================================
|
||||
|
||||
This library processes TrueType files:
|
||||
• parse files
|
||||
• extract glyph metrics
|
||||
• extract glyph shapes
|
||||
• render glyphs to one-channel bitmaps with antialiasing (box filter)
|
||||
• render glyphs to one-channel SDF bitmaps (signed-distance field/function)
|
||||
|
||||
|
||||
%package -n stb_vorbis-devel
|
||||
Summary: Decode Ogg Vorbis files from file/memory to float/16-bit signed output
|
||||
Version: %{stb_vorbis_version}%{snapinfo}
|
||||
|
||||
Provides: stb_vorbis-static = %{stb_vorbis_version}%{snapinfo}-%{release}
|
||||
|
||||
%description -n stb_vorbis-devel
|
||||
Ogg Vorbis audio decoder.
|
||||
|
||||
|
||||
%package -n stb_voxel_render-devel
|
||||
Summary: Helps render large-scale “voxel” worlds for games
|
||||
Version: %{stb_voxel_render_version}%{snapinfo}
|
||||
|
||||
Provides: stb_voxel_render-static = %{stb_voxel_render_version}%{snapinfo}-%{release}
|
||||
|
||||
%description -n stb_voxel_render-devel
|
||||
This library helps render large-scale “voxel” worlds for games, in this case,
|
||||
one with blocks that can have textures and that can also be a few shapes other
|
||||
than cubes.
|
||||
|
||||
Video introduction:
|
||||
http://www.youtube.com/watch?v=2vnTtiLrV1w
|
||||
|
||||
Minecraft-viewer sample app (not very simple though):
|
||||
http://github.com/nothings/stb/tree/master/tests/caveview
|
||||
|
||||
It works by creating triangle meshes. The library includes
|
||||
|
||||
- converter from dense 3D arrays of block info to vertex mesh
|
||||
- vertex & fragment shaders for the vertex mesh
|
||||
- assistance in setting up shader state
|
||||
|
||||
For portability, none of the library code actually accesses the 3D graphics
|
||||
API. (At the moment, it’s not actually portable since the shaders are GLSL
|
||||
only, but patches are welcome.)
|
||||
|
||||
You have to do all the caching and tracking of vertex buffers yourself.
|
||||
However, you could also try making a game with a small enough world that it’s
|
||||
fully loaded rather than streaming. Currently the preferred vertex format is 20
|
||||
bytes per quad. There are designs to allow much more compact formats with a
|
||||
slight reduction in shader features, but no roadmap for actually implementing
|
||||
them.
|
||||
|
||||
|
||||
%package doc
|
||||
Summary: Documentation for stb
|
||||
BuildArch: noarch
|
||||
|
||||
%description doc
|
||||
Documentation for stb.
|
||||
|
||||
|
||||
%prep
|
||||
%autosetup -n stb-%{commit} -p1
|
||||
|
||||
# Append to OS build flags rather than overriding them
|
||||
#
|
||||
# Instead of hard-coding C++ standard and calling the C compiler, defer to the
|
||||
# default and call the C++ compiler.
|
||||
#
|
||||
# When upstream says CPPFLAGS, they
|
||||
# mean C++ flags, i.e. CXXFLAGS, not “C PreProcessor Flags” as is common in
|
||||
# autoconf-influenced projects.
|
||||
sed -r -i \
|
||||
-e 's/([[:alpha:]]+FLAGS[[:blank:]]*)=/\1+=/' \
|
||||
-e 's/(\$\(CC\))(.*)-std=[^[:blank:]]+/\$\(CXX\)\2/' \
|
||||
-e 's/CPPFLAGS/CXXFLAGS/' tests/Makefile
|
||||
|
||||
# Add a dummy main(); how does this one work upstream?! Note that omitting
|
||||
# parameter names is a C++-ism.
|
||||
echo 'int main(int, char *[]) { return 0; }' >> tests/test_cpp_compilation.cpp
|
||||
|
||||
# Remove any pre-compiled Windows executables
|
||||
find . -type f -name '*.exe' -print -delete
|
||||
|
||||
# Remove some unused parts of the source tree that could contribute different
|
||||
# (but acceptable) license terms if they were used—just to prove that we do not
|
||||
# use them.
|
||||
rm -rvf deprecated tests/caveview
|
||||
|
||||
%if %{without stb_include}
|
||||
sed -r -i '/#include[[:blank:]]+"stb_include.h"/d' tests/test_c_compilation.c
|
||||
%endif
|
||||
|
||||
|
||||
%build
|
||||
# There is no compiled code to install, since all stb libraries are
|
||||
# header-only. We do need to build the tests.
|
||||
%set_build_flags
|
||||
%make_build -C tests
|
||||
|
||||
|
||||
%install
|
||||
# Installing a “.c” file in /usr/include is unconventional, but correct and not
|
||||
# unprecedented. Any .c file in stb is meant to be #include’d and used as a
|
||||
# header-only library, just as the “.h” files in the other stb libraries. The
|
||||
# only difference is the file extension.
|
||||
#
|
||||
# Since these are designed to be copied into dependent package source trees,
|
||||
# there is no convention on include paths. Most projects end up using “#include
|
||||
# <stb_foo.h>” or “#include <stb/stb_foo.h>”, so we install to
|
||||
# %%{_includedir}/stb/stb_foo.h and %%{_includedir}/stb_foo.h, with the latter
|
||||
# as a symbolic link to the former. This means most projects can unbundle the
|
||||
# library without having to make their own local symlinks or patch their
|
||||
# sources.
|
||||
install -t '%{buildroot}%{_includedir}/stb' -p -m 0644 -D stb_*.h stb_*.c
|
||||
%if %{without stb_include}
|
||||
rm -vf '%{buildroot}%{_includedir}/stb/stb_include.h'
|
||||
%endif
|
||||
pushd '%{buildroot}%{_includedir}'
|
||||
ln -sv stb/stb_*.? .
|
||||
popd
|
||||
|
||||
|
||||
%check
|
||||
# The tests in tests/Makefile are largely just “will it compile” tests. There
|
||||
# are some other files with main routines under tests/, but they have neither
|
||||
# Makefile targets nor instructions on how to build or run them or what to
|
||||
# expect them to do. We don’t dig through these sources to try to guess what to
|
||||
# do with them.
|
||||
|
||||
# We can run image_write_test and confirm the output images are valid.
|
||||
rm -vf output
|
||||
mkdir -p output
|
||||
./tests/image_write_test
|
||||
# We assume that if ImageMagick can read the output images, then they are valid.
|
||||
for img in wr6x5_flip.bmp wr6x5_flip.jpg wr6x5_flip.tga wr6x5_regular.hdr \
|
||||
wr6x5_regular.png wr6x5_flip.hdr wr6x5_flip.png wr6x5_regular.bmp \
|
||||
wr6x5_regular.jpg wr6x5_regular.tga
|
||||
do
|
||||
convert "output/${img}" 'output/dummy.bmp'
|
||||
done
|
||||
|
||||
# As a sanity check, verify that all of the subpackage version numbers appear
|
||||
# in the corresponding headers.
|
||||
while read -r version header
|
||||
do
|
||||
%{?!with_stb_include:if [ "${header}" = 'stb_include.h' ]; then continue; fi}
|
||||
# The minor version may be zero-padded in the header.
|
||||
grep -E "$(
|
||||
echo "${version}" |
|
||||
sed -r 's/([[:digit:]]+)\.([[:digit:]]+)/\\bv\1\\.0*\2\\b/'
|
||||
)" "%{buildroot}%{_includedir}/${header}" >/dev/null
|
||||
done <<'EOF'
|
||||
%{stb_c_lexer_version} stb_c_lexer.h
|
||||
%{stb_connected_components_version} stb_connected_components.h
|
||||
%{stb_divide_version} stb_divide.h
|
||||
%{stb_ds_version} stb_ds.h
|
||||
%{stb_dxt_version} stb_dxt.h
|
||||
%{stb_easy_font_version} stb_easy_font.h
|
||||
%{stb_herringbone_wang_tile_version} stb_herringbone_wang_tile.h
|
||||
%{stb_hexwave_version} stb_hexwave.h
|
||||
%{stb_image_version} stb_image.h
|
||||
%{stb_image_resize_version} stb_image_resize.h
|
||||
%{stb_image_write_version} stb_image_write.h
|
||||
%{stb_include_version} stb_include.h
|
||||
%{stb_leakcheck_version} stb_leakcheck.h
|
||||
%{stb_perlin_version} stb_perlin.h
|
||||
%{stb_rect_pack_version} stb_rect_pack.h
|
||||
%{stb_sprintf_version} stb_sprintf.h
|
||||
%{stb_textedit_version} stb_textedit.h
|
||||
%{stb_tilemap_editor_version} stb_tilemap_editor.h
|
||||
%{stb_truetype_version} stb_truetype.h
|
||||
%{stb_vorbis_version} stb_vorbis.c
|
||||
%{stb_voxel_render_version} stb_voxel_render.h
|
||||
EOF
|
||||
|
||||
|
||||
%files devel
|
||||
# Empty metapackage
|
||||
|
||||
|
||||
%files doc
|
||||
%license LICENSE
|
||||
%doc docs
|
||||
%doc README.md
|
||||
%doc tests/tilemap_editor_integration_example.c
|
||||
|
||||
|
||||
%files -n stb_c_lexer-devel
|
||||
%license LICENSE
|
||||
# Directory has shared ownership across stb subpackages:
|
||||
%dir %{_includedir}/stb
|
||||
%{_includedir}/stb/stb_c_lexer.h
|
||||
%{_includedir}/stb_c_lexer.h
|
||||
|
||||
|
||||
%files -n stb_connected_components-devel
|
||||
%license LICENSE
|
||||
# Directory has shared ownership across stb subpackages:
|
||||
%dir %{_includedir}/stb
|
||||
%{_includedir}/stb/stb_connected_components.h
|
||||
%{_includedir}/stb_connected_components.h
|
||||
|
||||
|
||||
%files -n stb_divide-devel
|
||||
%license LICENSE
|
||||
# Directory has shared ownership across stb subpackages:
|
||||
%dir %{_includedir}/stb
|
||||
%{_includedir}/stb/stb_divide.h
|
||||
%{_includedir}/stb_divide.h
|
||||
|
||||
|
||||
%files -n stb_ds-devel
|
||||
%license LICENSE
|
||||
# Directory has shared ownership across stb subpackages:
|
||||
%dir %{_includedir}/stb
|
||||
%{_includedir}/stb/stb_ds.h
|
||||
%{_includedir}/stb_ds.h
|
||||
|
||||
|
||||
%files -n stb_dxt-devel
|
||||
%license LICENSE
|
||||
# Directory has shared ownership across stb subpackages:
|
||||
%dir %{_includedir}/stb
|
||||
%{_includedir}/stb/stb_dxt.h
|
||||
%{_includedir}/stb_dxt.h
|
||||
|
||||
|
||||
%files -n stb_easy_font-devel
|
||||
%license LICENSE
|
||||
# Directory has shared ownership across stb subpackages:
|
||||
%dir %{_includedir}/stb
|
||||
%{_includedir}/stb/stb_easy_font.h
|
||||
%{_includedir}/stb_easy_font.h
|
||||
|
||||
|
||||
%files -n stb_herringbone_wang_tile-devel
|
||||
%license LICENSE
|
||||
# Directory has shared ownership across stb subpackages:
|
||||
%dir %{_includedir}/stb
|
||||
%{_includedir}/stb/stb_herringbone_wang_tile.h
|
||||
%{_includedir}/stb_herringbone_wang_tile.h
|
||||
|
||||
|
||||
%files -n stb_hexwave-devel
|
||||
%license LICENSE
|
||||
# Directory has shared ownership across stb subpackages:
|
||||
%dir %{_includedir}/stb
|
||||
%{_includedir}/stb/stb_hexwave.h
|
||||
%{_includedir}/stb_hexwave.h
|
||||
|
||||
|
||||
%files -n stb_image-devel
|
||||
%license LICENSE
|
||||
# Directory has shared ownership across stb subpackages:
|
||||
%dir %{_includedir}/stb
|
||||
%{_includedir}/stb/stb_image.h
|
||||
%{_includedir}/stb_image.h
|
||||
|
||||
|
||||
%files -n stb_image_resize-devel
|
||||
%license LICENSE
|
||||
# Directory has shared ownership across stb subpackages:
|
||||
%dir %{_includedir}/stb
|
||||
%{_includedir}/stb/stb_image_resize.h
|
||||
%{_includedir}/stb_image_resize.h
|
||||
|
||||
|
||||
%files -n stb_image_write-devel
|
||||
%license LICENSE
|
||||
# Directory has shared ownership across stb subpackages:
|
||||
%dir %{_includedir}/stb
|
||||
%{_includedir}/stb/stb_image_write.h
|
||||
%{_includedir}/stb_image_write.h
|
||||
|
||||
|
||||
%if %{with stb_include}
|
||||
%files -n stb_include-devel
|
||||
%license LICENSE
|
||||
# Directory has shared ownership across stb subpackages:
|
||||
%dir %{_includedir}/stb
|
||||
%{_includedir}/stb/stb_include.h
|
||||
%{_includedir}/stb_include.h
|
||||
%endif
|
||||
|
||||
|
||||
%files -n stb_leakcheck-devel
|
||||
%license LICENSE
|
||||
# Directory has shared ownership across stb subpackages:
|
||||
%dir %{_includedir}/stb
|
||||
%{_includedir}/stb/stb_leakcheck.h
|
||||
%{_includedir}/stb_leakcheck.h
|
||||
|
||||
|
||||
%files -n stb_perlin-devel
|
||||
%license LICENSE
|
||||
# Directory has shared ownership across stb subpackages:
|
||||
%dir %{_includedir}/stb
|
||||
%{_includedir}/stb/stb_perlin.h
|
||||
%{_includedir}/stb_perlin.h
|
||||
|
||||
|
||||
%files -n stb_rect_pack-devel
|
||||
%license LICENSE
|
||||
# Directory has shared ownership across stb subpackages:
|
||||
%dir %{_includedir}/stb
|
||||
%{_includedir}/stb/stb_rect_pack.h
|
||||
%{_includedir}/stb_rect_pack.h
|
||||
|
||||
|
||||
%files -n stb_sprintf-devel
|
||||
%license LICENSE
|
||||
# Directory has shared ownership across stb subpackages:
|
||||
%dir %{_includedir}/stb
|
||||
%{_includedir}/stb/stb_sprintf.h
|
||||
%{_includedir}/stb_sprintf.h
|
||||
|
||||
|
||||
%files -n stb_textedit-devel
|
||||
%license LICENSE
|
||||
# Directory has shared ownership across stb subpackages:
|
||||
%dir %{_includedir}/stb
|
||||
%{_includedir}/stb/stb_textedit.h
|
||||
%{_includedir}/stb_textedit.h
|
||||
|
||||
|
||||
%files -n stb_tilemap_editor-devel
|
||||
%license LICENSE
|
||||
# Directory has shared ownership across stb subpackages:
|
||||
%dir %{_includedir}/stb
|
||||
%{_includedir}/stb/stb_tilemap_editor.h
|
||||
%{_includedir}/stb_tilemap_editor.h
|
||||
|
||||
|
||||
%files -n stb_truetype-devel
|
||||
%license LICENSE
|
||||
# Directory has shared ownership across stb subpackages:
|
||||
%dir %{_includedir}/stb
|
||||
%{_includedir}/stb/stb_truetype.h
|
||||
%{_includedir}/stb_truetype.h
|
||||
|
||||
|
||||
%files -n stb_vorbis-devel
|
||||
%license LICENSE
|
||||
# Directory has shared ownership across stb subpackages:
|
||||
%dir %{_includedir}/stb
|
||||
%{_includedir}/stb/stb_vorbis.c
|
||||
%{_includedir}/stb_vorbis.c
|
||||
|
||||
|
||||
%files -n stb_voxel_render-devel
|
||||
%license LICENSE
|
||||
# Directory has shared ownership across stb subpackages:
|
||||
%dir %{_includedir}/stb
|
||||
%{_includedir}/stb/stb_voxel_render.h
|
||||
%{_includedir}/stb_voxel_render.h
|
||||
|
||||
|
||||
%changelog
|
||||
* Mon Dec 5 2022 peijiankang <peijiankang@kylinos.cn> - 0.20220908git8b5f1f3-0.4
|
||||
- Init package for openEuler
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user