Browse Source

add "lines of code" to README.md

Sean Barrett 10 years ago
parent
commit
ede1ebdaa9
4 changed files with 49 additions and 28 deletions
  1. 31 20
      README.md
  2. 11 0
      tools/README.footer.md
  3. 2 2
      tools/README.header.md
  4. 5 6
      tools/make_readme.c

+ 31 - 20
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&nbsp;graphics | Minecraft-esque voxel rendering "engine" with many more features
-**stb_dxt.h** | 1.04 | 3D&nbsp;graphics | Fabian "ryg" Giesen's real-time DXT compressor
-**stb_perlin.h** | 0.2 | 3D&nbsp;graphics | revised Perlin noise (3D input, 1D output)
-**stb_easy_font.h** | 0.5 | 3D&nbsp;graphics | quick-and-dirty easy-to-deploy bitmap font for printing frame rate, etc
-**stb_tilemap_editor.h** | 0.30 | game&nbsp;development | embeddable tilemap editor
-**stb_herringbone_wang_tile.h** | 0.6 | game&nbsp;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&nbsp;graphics | 3644 | Minecraft-esque voxel rendering "engine" with many more features
+**stb_dxt.h** | 1.04 | 3D&nbsp;graphics | 624 | Fabian "ryg" Giesen's real-time DXT compressor
+**stb_perlin.h** | 0.2 | 3D&nbsp;graphics | 175 | revised Perlin noise (3D input, 1D output)
+**stb_easy_font.h** | 0.5 | 3D&nbsp;graphics | 220 | quick-and-dirty easy-to-deploy bitmap font for printing frame rate, etc
+**stb_tilemap_editor.h** | 0.30 | game&nbsp;development | 4097 | embeddable tilemap editor
+**stb_herringbone_wang_tile.h** | 0.6 | game&nbsp;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

+ 11 - 0
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

+ 2 - 2
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
+--------------------- | ---- | --------------| -------- | --------------------------------

+ 5 - 6
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, " ", "&nbsp;");  // 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");