Fix typo
[platform/upstream/glib.git] / glib / goption.c
index 1a4459e..6438281 100644 (file)
  * Another important feature of GOption is that it can automatically
  * generate nicely formatted help output. Unless it is explicitly turned
  * off with g_option_context_set_help_enabled(), GOption will recognize
- * the `--help`, `-?`, `--help-all` and
- * `--help-`<replaceable>groupname</replaceable> options
- * (where <replaceable>groupname</replaceable> is the name of a
- * #GOptionGroup) and write a text similar to the one shown in the
- * following example to stdout.
+ * the `--help`, `-?`, `--help-all` and `--help-groupname` options
+ * (where `groupname` is the name of a #GOptionGroup) and write a text
+ * similar to the one shown in the following example to stdout.
  *
  * |[
  * Usage:
  *       exit (1);
  *     }
  *
- *   /&ast; ... &ast;/
+ *   ...
  *
  * }
  * ]|
  *   args = g_strdupv (argv);
  * #endif
  *
- *   /&ast; ... setup context ... &ast;/
+ *   // set up context
  *
  *   if (!g_option_context_parse_strv (context, &args, &error))
  *     {
- *       /&ast; ... error ... &ast;/
+ *       // error happened
  *     }
  *
- *   /&ast; ... &ast;/
+ *   ...
  *
  *   g_strfreev (args);
  *
- *   /&ast; ... &ast;/
+ *   ...
  * }
  * ]|
  */
 #include <errno.h>
 
 #if defined __OpenBSD__
-#include <sys/types.h>
 #include <unistd.h>
-#include <sys/param.h>
 #include <sys/sysctl.h>
 #endif
 
@@ -325,9 +321,8 @@ G_DEFINE_QUARK (g-option-context-error-quark, g_option_error)
 /**
  * g_option_context_new:
  * @parameter_string: (allow-none): a string which is displayed in
- *    the first line of `--help` output, after the
- *    usage summary
- *    `<replaceable>programname</replaceable> [OPTION...]`
+ *    the first line of `--help` output, after the usage summary
+ *    `programname [OPTION...]`
  *
  * Creates a new option context.
  *
@@ -409,11 +404,10 @@ void g_option_context_free (GOptionContext *context)
  * @context: a #GOptionContext
  * @help_enabled: %TRUE to enable `--help`, %FALSE to disable it
  *
- * Enables or disables automatic generation of `--help`
- * output. By default, g_option_context_parse() recognizes
- * `--help`, `-h`, `-?`, `--help-all`
- * and `--help-`<replaceable>groupname</replaceable> and creates
- * suitable output to stdout.
+ * Enables or disables automatic generation of `--help` output.
+ * By default, g_option_context_parse() recognizes `--help`, `-h`,
+ * `-?`, `--help-all` and `--help-groupname` and creates suitable
+ * output to stdout.
  *
  * Since: 2.6
  */
@@ -562,7 +556,7 @@ g_option_context_set_main_group (GOptionContext *context,
  *
  * Returns a pointer to the main group of @context.
  *
- * Return value: the main group of @context, or %NULL if @context doesn't
+ * Returns: the main group of @context, or %NULL if @context doesn't
  *  have a main group. Note that group belongs to @context and should
  *  not be modified or freed.
  *
@@ -1194,8 +1188,8 @@ parse_arg (GOptionContext *context,
     {
     case G_OPTION_ARG_NONE:
       {
-        change = get_change (context, G_OPTION_ARG_NONE,
-                             entry->arg_data);
+        (void) get_change (context, G_OPTION_ARG_NONE,
+                           entry->arg_data);
 
         *(gboolean *)entry->arg_data = !(entry->flags & G_OPTION_FLAG_REVERSE);
         break;
@@ -1767,13 +1761,16 @@ platform_get_argv0 (void)
   g_free (cmdline);
   return base_arg0;
 #elif defined __OpenBSD__
-  char **cmdline = NULL;
+  char **cmdline;
   char *base_arg0;
-  gsize len = PATH_MAX;
+  gsize len;
 
   int mib[] = { CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV };
 
-  cmdline = (char **) realloc (cmdline, len);
+  if (sysctl (mib, G_N_ELEMENTS (mib), NULL, &len, NULL, 0) == -1)
+      return NULL;
+
+  cmdline = g_malloc0 (len);
 
   if (sysctl (mib, G_N_ELEMENTS (mib), cmdline, &len, NULL, 0) == -1)
     {
@@ -1818,12 +1815,11 @@ platform_get_argv0 (void)
  * this function will produce help output to stdout and
  * call `exit (0)`.
  *
- * Note that function depends on the
- * <link linkend="setlocale">current locale</link> for
+ * Note that function depends on the [current locale][setlocale] for
  * automatic character set conversion of string and filename
  * arguments.
  *
- * Return value: %TRUE if the parsing was successful,
+ * Returns: %TRUE if the parsing was successful,
  *               %FALSE if an error occurred
  *
  * Since: 2.6
@@ -2042,6 +2038,7 @@ g_option_context_parse (GOptionContext   *context,
                       if (new_arg)
                         new_arg[arg_index] = '\0';
                       add_pending_null (context, &((*argv)[i]), new_arg);
+                      i = new_i;
                     }
                   else if (parsed)
                     {
@@ -2168,7 +2165,7 @@ g_option_context_parse (GOptionContext   *context,
  *
  * Creates a new #GOptionGroup.
  *
- * Return value: a newly created option group. It should be added
+ * Returns: a newly created option group. It should be added
  *   to a #GOptionContext or freed with g_option_group_free().
  *
  * Since: 2.6