]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Support [ScanfFormat] attribute
authorJürg Billeter <j@bitron.ch>
Sat, 1 Aug 2009 16:17:29 +0000 (18:17 +0200)
committerJürg Billeter <j@bitron.ch>
Sat, 1 Aug 2009 16:17:29 +0000 (18:17 +0200)
Fixes bug 589930.

codegen/valaccodebasemodule.vala
codegen/valaccodemethodcallmodule.vala
vala/valacodewriter.vala
vala/valamethod.vala
vapi/glib-2.0.vapi

index 2f7dc9428f88ea5c7dc26d69634e8256af9b4983..ca28952c410e00d3d30375a4e584c7e466d26d6c 100644 (file)
@@ -3228,7 +3228,7 @@ internal class Vala.CCodeBaseModule : CCodeModule {
                        if (ellipsis) {
                                /* ensure variable argument list ends with NULL
                                 * except when using printf-style arguments */
-                               if (!m.printf_format && m.sentinel != "") {
+                               if (!m.printf_format && !m.scanf_format && m.sentinel != "") {
                                        creation_call.add_argument (new CCodeConstant (m.sentinel));
                                }
                        }
index 94862ef6e6c83e73beabd4e67276f502285250b3..f9ff372e09a9b87b21c95878cbf14cedf07d5b6e 100644 (file)
@@ -556,7 +556,7 @@ internal class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                if (ellipsis) {
                        /* ensure variable argument list ends with NULL
                         * except when using printf-style arguments */
-                       if (!m.printf_format && m.sentinel != "") {
+                       if (!m.printf_format && !m.scanf_format && m.sentinel != "") {
                                in_arg_map.set (get_param_pos (-1, true), new CCodeConstant (m.sentinel));
                        }
                } else if (itype is DelegateType) {
index b83b44b09ba916575f577013be5f8e2b9fdbc722..55dd513849b193ab089ce255fa59705861dfd02c 100644 (file)
@@ -826,6 +826,10 @@ public class Vala.CodeWriter : CodeVisitor {
                        write_indent ();
                        write_string ("[PrintfFormat]");
                }
+               if (m.scanf_format) {
+                       write_indent ();
+                       write_string ("[ScanfFormat]");
+               }
 
                var ccode_params = new StringBuilder ();
                var separator = "";
index d1f51724e7cc97e68728d02139eefa28077b6437..88d4e21c78b41fb448a97b9e001d261c3330dffa 100644 (file)
@@ -194,6 +194,11 @@ public class Vala.Method : Member {
         */
        public bool printf_format { get; set; }
 
+       /**
+        * Specifies whether this method expects scanf-style format arguments.
+        */
+       public bool scanf_format { get; set; }
+
        /**
         * Specifies whether a construct function with a GType parameter is
         * available. This is only applicable to creation methods.
@@ -401,6 +406,8 @@ public class Vala.Method : Member {
                                return_type.floating_reference = true;
                        } else if (a.name == "PrintfFormat") {
                                printf_format = true;
+                       } else if (a.name == "ScanfFormat") {
+                               scanf_format = true;
                        }
                }
        }
index 464763e1043d8b3dda9b3be70aa979502315f628..6052c8d4afa543dc5db0f7eab34192f983f27a9b 100644 (file)
@@ -818,7 +818,7 @@ public class string {
        public bool has_suffix (string suffix);
        [CCode (cname = "g_strdup_printf"), PrintfFormat]
        public string printf (...);
-       [CCode (cname = "sscanf", cheader_filename = "stdio.h")]
+       [CCode (cname = "sscanf", cheader_filename = "stdio.h"), ScanfFormat]
        public int scanf (...);
        [CCode (cname = "g_strconcat")]
        public string concat (string string2, ...);
@@ -2402,7 +2402,7 @@ namespace GLib {
                public weak string gets (char[] s);
                [CCode (cname = "feof")]
                public bool eof ();
-               [CCode (cname = "fscanf")]
+               [CCode (cname = "fscanf"), ScanfFormat]
                public int scanf (string format, ...);
                [CCode (cname = "fflush")]
                public int flush ();