From ede1ebdaa966f98fadc67bfbb2f9b35a8adf1f09 Mon Sep 17 00:00:00 2001 From: Sean Barrett Date: Tue, 14 Apr 2015 03:03:11 -0700 Subject: [PATCH] add "lines of code" to README.md --- README.md | 51 +++++++++++++++++++++++++----------------- tools/README.footer.md | 11 +++++++++ tools/README.header.md | 4 ++-- tools/make_readme.c | 11 +++++---- 4 files changed, 49 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index eec9e98..8c0b594 100644 --- a/README.md +++ b/README.md @@ -3,26 +3,26 @@ stb single-file public domain libraries for C/C++ -library | lastest version | category | description ---------------------- | ---- | -------- | -------------------------------- -**stb_vorbis.c** | 1.04 | audio | decode ogg vorbis files from file/memory to float/16-bit signed output -**stb_image.h** | 2.03 | graphics | image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC -**stb_truetype.h** | 1.03 | graphics | parse, decode, and rasterize characters from truetype fonts -**stb_image_write.h** | 0.98 | graphics | image writing to disk: PNG, TGA, BMP -**stb_image_resize.h** | 0.90 | graphics | resize images larger/smaller with good quality -**stb_rect_pack.h** | 0.05 | graphics | simple 2D rectangle packer with decent quality -**stretchy_buffer.h** | 1.01 | utility | typesafe dynamic array for C (i.e. approximation to vector<>), doesn't compile as C++ -**stb_textedit.h** | 1.5 | UI | guts of a text editor for games etc implementing them from scratch -**stb_voxel_render.h** | 0.80 | 3D graphics | Minecraft-esque voxel rendering "engine" with many more features -**stb_dxt.h** | 1.04 | 3D graphics | Fabian "ryg" Giesen's real-time DXT compressor -**stb_perlin.h** | 0.2 | 3D graphics | revised Perlin noise (3D input, 1D output) -**stb_easy_font.h** | 0.5 | 3D graphics | quick-and-dirty easy-to-deploy bitmap font for printing frame rate, etc -**stb_tilemap_editor.h** | 0.30 | game development | embeddable tilemap editor -**stb_herringbone_wang_tile.h** | 0.6 | game development | herringbone Wang tile map generator -**stb_c_lexer.h** | 0.06 | parsing | simplify writing parsers for C-like languages -**stb_divide.h** | 0.91 | math | more useful 32-bit modulus e.g. "euclidean divide" -**stb.h** | 2.24 | misc | helper functions for C, mostly redundant in C++; basically author's personal stuff -**stb_leakcheck.h** | 0.1 | misc | quick-and-dirty malloc/free leak-checking +library | lastest version | Lines Of Code | category | description +--------------------- | ---- | --------------| -------- | -------------------------------- +**stb_vorbis.c** | 1.04 | audio | 5443 | decode ogg vorbis files from file/memory to float/16-bit signed output +**stb_image.h** | 2.03 | graphics | 6426 | image loading/decoding from file/memory: JPG, PNG, TGA, BMP, PSD, GIF, HDR, PIC +**stb_truetype.h** | 1.03 | graphics | 2629 | parse, decode, and rasterize characters from truetype fonts +**stb_image_write.h** | 0.98 | graphics | 730 | image writing to disk: PNG, TGA, BMP +**stb_image_resize.h** | 0.90 | graphics | 2585 | resize images larger/smaller with good quality +**stb_rect_pack.h** | 0.05 | graphics | 546 | simple 2D rectangle packer with decent quality +**stretchy_buffer.h** | 1.01 | utility | 209 | typesafe dynamic array for C (i.e. approximation to vector<>), doesn't compile as C++ +**stb_textedit.h** | 1.5 | UI | 1284 | guts of a text editor for games etc implementing them from scratch +**stb_voxel_render.h** | 0.80 | 3D graphics | 3644 | Minecraft-esque voxel rendering "engine" with many more features +**stb_dxt.h** | 1.04 | 3D graphics | 624 | Fabian "ryg" Giesen's real-time DXT compressor +**stb_perlin.h** | 0.2 | 3D graphics | 175 | revised Perlin noise (3D input, 1D output) +**stb_easy_font.h** | 0.5 | 3D graphics | 220 | quick-and-dirty easy-to-deploy bitmap font for printing frame rate, etc +**stb_tilemap_editor.h** | 0.30 | game development | 4097 | embeddable tilemap editor +**stb_herringbone_wang_tile.h** | 0.6 | game development | 1217 | herringbone Wang tile map generator +**stb_c_lexer.h** | 0.06 | parsing | 809 | simplify writing parsers for C-like languages +**stb_divide.h** | 0.91 | math | 373 | more useful 32-bit modulus e.g. "euclidean divide" +**stb.h** | 2.24 | misc | 14086 | helper functions for C, mostly redundant in C++; basically author's personal stuff +**stb_leakcheck.h** | 0.1 | misc | 117 | quick-and-dirty malloc/free leak-checking FAQ --- @@ -45,6 +45,17 @@ attribution requirement). They may be less featureful, slower, and/or use more memory. If you're already using an equivalent library, there's probably no good reason to switch. +#### Why do you list "lines of code"? It's a terrible metric. + +Just to give you some idea of the internal complexity of the library, +to help you manage your expectations, or to let you know what you're +getting into. While not all the libraries are written in the same +style, they're certainly similar styles, and so comparisons between +the libraries are probably still meaningful. + +Note though that the lines do include both the implementation, the +part that corresponds to a header file, and the documentation. + #### Why single-file headers? Windows doesn't have standard directories where libraries diff --git a/tools/README.footer.md b/tools/README.footer.md index 24925a3..b97ee47 100644 --- a/tools/README.footer.md +++ b/tools/README.footer.md @@ -20,6 +20,17 @@ attribution requirement). They may be less featureful, slower, and/or use more memory. If you're already using an equivalent library, there's probably no good reason to switch. +#### Why do you list "lines of code"? It's a terrible metric. + +Just to give you some idea of the internal complexity of the library, +to help you manage your expectations, or to let you know what you're +getting into. While not all the libraries are written in the same +style, they're certainly similar styles, and so comparisons between +the libraries are probably still meaningful. + +Note though that the lines do include both the implementation, the +part that corresponds to a header file, and the documentation. + #### Why single-file headers? Windows doesn't have standard directories where libraries diff --git a/tools/README.header.md b/tools/README.header.md index 66871d2..41135cf 100644 --- a/tools/README.header.md +++ b/tools/README.header.md @@ -3,5 +3,5 @@ stb single-file public domain libraries for C/C++ -library | lastest version | category | description ---------------------- | ---- | -------- | -------------------------------- +library | lastest version | Lines Of Code | category | description +--------------------- | ---- | --------------| -------- | -------------------------------- diff --git a/tools/make_readme.c b/tools/make_readme.c index cdc0b85..c562e82 100644 --- a/tools/make_readme.c +++ b/tools/make_readme.c @@ -15,12 +15,10 @@ int main(int argc, char **argv) for (i=0; i < listlen; ++i) { int num,j; char **tokens = stb_tokens_stripwhite(list[i], "|", &num); // stb_tokens -- tokenize string into malloced array of strings - FILE *g = fopen(stb_sprintf("../%s", tokens[0]), "rb"); // stb_sprintf -- sprintf to a static temp buffer (not threadsafe or secure) - char buffer[256], *s1, *s2; - fread(buffer, 1, 256, g); - fclose(g); - buffer[255] = 0; - s1 = strchr(buffer, '-'); + int num_lines; + char **lines = stb_stringfile(stb_sprintf("../%s", tokens[0]), &num_lines); + char *s1, *s2; + s1 = strchr(lines[0], '-'); if (!s1) stb_fatal("Couldn't find '-' before version number in %s", tokens[0]); // stb_fatal -- print error message & exit s2 = strchr(s1+2, '-'); if (!s2) stb_fatal("Couldn't find '-' after version number in %s", tokens[0]); // stb_fatal -- print error message & exit @@ -33,6 +31,7 @@ int main(int argc, char **argv) s2 = stb_dupreplace(s1, " ", " "); // stb_dupreplace -- search & replace string and malloc result fprintf(f, " | %s", s2); free(s2); + fprintf(f, " | %d", num_lines); for (j=2; j < num; ++j) fprintf(f, " | %s", tokens[j]); fprintf(f, "\n");