commit 449522b8c520b06016fd93cd6828700ef33149be
parent 161b5d039e857ab36a4f44cd4d499be7cb162c0d
Author: Kyle Milz <kyle@getaddrinfo.net>
Date: Sun, 27 Mar 2016 08:52:58 -0600
viewer: replace die() with errx()
Diffstat:
6 files changed, 14 insertions(+), 30 deletions(-)
diff --git a/viewer/demo-atlas.cc b/viewer/demo-atlas.cc
@@ -16,10 +16,7 @@
* Google Author(s): Behdad Esfahbod
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
+#include <err.h>
#include "demo-atlas.h"
#define gl(name) \
@@ -134,7 +131,7 @@ demo_atlas_alloc (demo_atlas_t *at,
y = at->cursor_y;
at->cursor_y += (h + at->item_h_q - 1) & ~(at->item_h_q - 1);
} else
- die ("Ran out of atlas memory");
+ errx(1, "Ran out of atlas memory");
demo_atlas_bind_texture (at);
if (w * h == len)
diff --git a/viewer/demo-buffer.cc b/viewer/demo-buffer.cc
@@ -16,12 +16,9 @@
* Google Author(s): Behdad Esfahbod
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include "demo-buffer.h"
+
struct demo_buffer_t {
unsigned int refcount;
diff --git a/viewer/demo-common.h b/viewer/demo-common.h
@@ -50,13 +50,6 @@
#define LOGW(...) ((void) fprintf (stderr, __VA_ARGS__))
#define LOGE(...) ((void) fprintf (stderr, __VA_ARGS__), abort ())
-static inline void
-die (const char *msg)
-{
- fprintf (stderr, "%s\n", msg);
- exit (1);
-}
-
template <typename T>
T clamp (T v, T m, T M)
{
diff --git a/viewer/demo-font.cc b/viewer/demo-font.cc
@@ -16,12 +16,15 @@
* Google Author(s): Behdad Esfahbod
*/
+#include <err.h>
+
#include "demo-font.h"
#include "glyphy/glyphy-freetype.h"
-#include <unordered_map>
+#include <tr1/unordered_map>
+
-typedef std::unordered_map<unsigned int, glyph_info_t> glyph_cache_t;
+typedef std::tr1::unordered_map<unsigned int, glyph_info_t> glyph_cache_t;
struct demo_font_t {
unsigned int refcount;
@@ -125,10 +128,10 @@ encode_ft_glyph (demo_font_t *font,
FT_LOAD_NO_SCALE |
FT_LOAD_LINEAR_DESIGN |
FT_LOAD_IGNORE_TRANSFORM))
- die ("Failed loading FreeType glyph");
+ errx(1, "Failed loading FreeType glyph");
if (face->glyph->format != FT_GLYPH_FORMAT_OUTLINE)
- die ("FreeType loaded glyph format is not outline");
+ errx(1, "FreeType loaded glyph format is not outline");
unsigned int upem = face->units_per_EM;
double tolerance = upem * tolerance_per_em; /* in font design units */
@@ -142,7 +145,7 @@ encode_ft_glyph (demo_font_t *font,
&endpoints);
if (FT_Err_Ok != glyphy_freetype(outline_decompose) (&face->glyph->outline, font->acc))
- die ("Failed converting glyph outline to arcs");
+ errx(1, "Failed converting glyph outline to arcs");
assert (glyphy_arc_accumulator_get_error (font->acc) <= tolerance);
@@ -179,7 +182,7 @@ encode_ft_glyph (demo_font_t *font,
nominal_width,
nominal_height,
extents))
- die ("Failed encoding arcs");
+ errx(1, "Failed encoding arcs");
glyphy_extents_scale (extents, 1. / upem, 1. / upem);
glyphy_extents_scale (extents, SCALE, SCALE);
diff --git a/viewer/demo-glstate.cc b/viewer/demo-glstate.cc
@@ -16,12 +16,9 @@
* Google Author(s): Behdad Esfahbod, Maysum Panju, Wojciech Baranowski
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include "demo-glstate.h"
+
struct demo_glstate_t {
unsigned int refcount;
diff --git a/viewer/demo-shader.cc b/viewer/demo-shader.cc
@@ -16,10 +16,6 @@
* Google Author(s): Behdad Esfahbod
*/
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
#include "demo-shader.h"
#include "demo-atlas-glsl.h"
@@ -27,6 +23,7 @@
#include "demo-fshader-glsl.h"
+
static unsigned int
glyph_encode (unsigned int atlas_x , /* 7 bits */
unsigned int atlas_y, /* 7 bits */