[librsvg: 4/6] (#596): Fix introspection data for rsvg_handle_set_stylesheet()



commit 4f5671b1f339d542e0bb972be2cc2d4447ff9bab
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue May 5 14:12:58 2020 -0500

    (#596): Fix introspection data for rsvg_handle_set_stylesheet()
    
    Although the function's prototype changes:
    
     gboolean
     rsvg_handle_set_stylesheet (RsvgHandle  *handle,
    -                            const char  *css,
    +                            const guint8 *css,
                                 gsize        css_len,
                                 GError     **error)
    
    This is not an ABI break.  It is just to make clear that this is not a
    normal C string, but a buffer of bytes.
    
    Fixes https://gitlab.gnome.org/GNOME/librsvg/-/issues/596

 librsvg/c_api.rs      |  4 ++--
 librsvg/rsvg-handle.c | 10 +++++-----
 librsvg/rsvg.h        |  8 ++++----
 3 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/librsvg/c_api.rs b/librsvg/c_api.rs
index e72cca48..3e31ebdb 100644
--- a/librsvg/c_api.rs
+++ b/librsvg/c_api.rs
@@ -1615,7 +1615,7 @@ unsafe fn set_out_param<T: Copy>(
 #[no_mangle]
 pub unsafe extern "C" fn rsvg_rust_handle_set_stylesheet(
     handle: *const RsvgHandle,
-    css: *const libc::c_char,
+    css: *const u8,
     css_len: usize,
     error: *mut *mut glib_sys::GError,
 ) -> glib_sys::gboolean {
@@ -1632,7 +1632,7 @@ pub unsafe extern "C" fn rsvg_rust_handle_set_stylesheet(
     let css = match (css, css_len) {
         (p, 0) if p.is_null() => "",
         (_, _) => {
-            let s = slice::from_raw_parts(css as *const u8, css_len);
+            let s = slice::from_raw_parts(css, css_len);
             match str::from_utf8(s) {
                 Ok(s) => s,
                 Err(e) => {
diff --git a/librsvg/rsvg-handle.c b/librsvg/rsvg-handle.c
index 13787bd9..f3539f0a 100644
--- a/librsvg/rsvg-handle.c
+++ b/librsvg/rsvg-handle.c
@@ -734,7 +734,7 @@ rsvg_handle_get_base_uri (RsvgHandle *handle)
  * rsvg_handle_set_stylesheet:
  * @handle: A #RsvgHandle.
  * @css: (array length=css_len): String with CSS data; must be valid UTF-8.
- * @css_len: Length of the @css string in bytes.
+ * @css_len: Length of the @css data in bytes.
  * @error: (optional): return location for errors.
  *
  * Sets a CSS stylesheet to use for an SVG document.
@@ -752,10 +752,10 @@ rsvg_handle_get_base_uri (RsvgHandle *handle)
  * Since: 2.48
  */
 gboolean
-rsvg_handle_set_stylesheet (RsvgHandle  *handle,
-                            const char  *css,
-                            gsize        css_len,
-                            GError     **error)
+rsvg_handle_set_stylesheet (RsvgHandle   *handle,
+                            const guint8 *css,
+                            gsize         css_len,
+                            GError      **error)
 {
     return rsvg_rust_handle_set_stylesheet (handle, css, css_len, error);
 }
diff --git a/librsvg/rsvg.h b/librsvg/rsvg.h
index 63b9354d..c8c7d916 100644
--- a/librsvg/rsvg.h
+++ b/librsvg/rsvg.h
@@ -344,10 +344,10 @@ RSVG_API
 RsvgHandle *rsvg_handle_new_from_file (const gchar *filename, GError **error);
 
 RSVG_API
-gboolean rsvg_handle_set_stylesheet (RsvgHandle  *handle,
-                                     const char  *css,
-                                     gsize        css_len,
-                                     GError     **error);
+gboolean rsvg_handle_set_stylesheet (RsvgHandle   *handle,
+                                     const guint8 *css,
+                                     gsize         css_len,
+                                     GError      **error);
 
 #ifndef __GTK_DOC_IGNORE__
 RSVG_API


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]