(debug_flag): New variable
[m17n/libotf.git] / src / otfopen.c
index aacbc30..c49eb1d 100644 (file)
@@ -57,6 +57,15 @@ write to the Free Software Foundation, Inc., 59 Temple Place, Suite
 
     (5) API miscellaneous
 */
+
+int debug_flag = -1;
+
+static void
+set_debug_flag ()
+{
+  debug_flag = getenv ("LIBOTF_DEBUG") != NULL;
+}
+
 \f
 /* (0) Stream handler
 
@@ -2933,6 +2942,9 @@ OTF_open (const char *otf_name)
   int len = strlen (otf_name);
   const char *ext = otf_name + (len - 4);
 
+  if (debug_flag < 0)
+    set_debug_flag ();
+
   if (len < 4
       || ext[0] != '.'
       || (ext[1] != 'O' && ext[1] != 'T' && ext[1] != 'o' && ext[1] != 't')
@@ -2983,6 +2995,9 @@ OTF_open_ft_face (FT_Face face)
   OTF *otf;
   OTF_InternalData *internal_data;
 
+  if (debug_flag < 0)
+    set_debug_flag ();
+
   if (! FT_IS_SFNT (face))
     OTF_ERROR (OTF_ERROR_FILE, (char *) face->family_name);
   otf = calloc (1, sizeof (OTF));