[PATCH 5/6] cairo-script: Error if asked to decompress with missing compression lib

"Bryce W. Harrington" <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
This quells the following warning:

warning: enumeration value ‘LZO’ not handled in switch [-Wswitch-enum]

The LZO enum value is defined and used elsewhere, even if lzo support
isn't available.

This situation might arise if cairo scripts were generated on one system
with lzo, and then replayed on a system without it.  For now simply
error out if this occurs.

Signed-off-by: Bryce Harrington <[email protected]>
---
 util/cairo-script/cairo-script-file.c      |    8 ++++----
 util/cairo-script/cairo-script-operators.c |   16 ++++++++--------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/util/cairo-script/cairo-script-file.c b/util/cairo-script/cairo-script-file.c
index 85d292c..c962fce 100644
--- a/util/cairo-script/cairo-script-file.c
+++ b/util/cairo-script/cairo-script-file.c
@@ -176,21 +176,21 @@ csi_file_new_from_string (csi_t *ctx,
 	    status = _csi_error (CAIRO_STATUS_NO_MEMORY);
 	    break;
 
-#if HAVE_ZLIB
 	case ZLIB:
+#if HAVE_ZLIB
 	    if (uncompress ((Bytef *) tmp_str->string, &len,
 			    (Bytef *) src->string, src->len) != Z_OK)
+#endif
 		status = _csi_error (CAIRO_STATUS_NO_MEMORY);
 	    break;
-#endif
-#if HAVE_LZO
 	case LZO:
+#if HAVE_LZO
 	    if (lzo2a_decompress ((lzo_bytep) src->string, src->len,
 				  (lzo_bytep) tmp_str->string, &len,
 				  NULL))
+#endif
 		status = _csi_error (CAIRO_STATUS_NO_MEMORY);
 	    break;
-#endif
 	}
 	if (_csi_unlikely (status)) {
 	    csi_string_free (ctx, tmp_str);
diff --git a/util/cairo-script/cairo-script-operators.c b/util/cairo-script/cairo-script-operators.c
index aae6bea..d4af312 100644
--- a/util/cairo-script/cairo-script-operators.c
+++ b/util/cairo-script/cairo-script-operators.c
@@ -1769,28 +1769,28 @@ inflate_string (csi_t *ctx, csi_string_t *src)
 	free (bytes);
 	return NULL;
 
-#if HAVE_ZLIB
     case ZLIB:
+#if HAVE_ZLIB
 	if (uncompress ((Bytef *) bytes, &len,
 			(Bytef *) src->string, src->len) != Z_OK)
+#endif
 	{
 	    _csi_free (ctx, bytes);
 	    return NULL;
 	}
 	break;
-#endif
 
-#if HAVE_LZO
     case LZO:
+#if HAVE_LZO
 	if (lzo2a_decompress ((Bytef *) src->string, src->len,
 			      (Bytef *) bytes, &len,
 			      NULL))
+#endif
 	{
 	    _csi_free (ctx, bytes);
 	    return NULL;
 	}
 	break;
-#endif
     }
 
     bytes[len] = '\0';
@@ -2970,22 +2970,22 @@ err_decompress:
 	    cairo_surface_destroy (image);
 	    return _csi_error (CSI_STATUS_READ_ERROR);
 
-#if HAVE_ZLIB
 	case ZLIB:
+#if HAVE_ZLIB
 	    if (uncompress ((Bytef *) data, &out,
 			    (Bytef *) s->string, s->len) != Z_OK)
+#endif
 		goto err_decompress;
 	    break;
-#endif
 
-#if HAVE_LZO
 	case LZO:
+#if HAVE_LZO
 	    if (lzo2a_decompress ((Bytef *) s->string, s->len,
 				  (Bytef *) data, &out,
 				  NULL))
+#endif
 		goto err_decompress;
 	    break;
-#endif
 	}
     }
     else
-- 
1.7.9.5
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.