* exit (1);
* }
*
- * /* ... */
+ * ...
*
* }
* ]|
* args = g_strdupv (argv);
* #endif
*
- * /* ... setup context ... */
+ * // set up context
*
* if (!g_option_context_parse_strv (context, &args, &error))
* {
- * /* ... error ... */
+ * // error happened
* }
*
- * /* ... */
+ * ...
*
* g_strfreev (args);
*
- * /* ... */
+ * ...
* }
* ]|
*/
#include <errno.h>
#if defined __OpenBSD__
-#include <sys/types.h>
#include <unistd.h>
-#include <sys/param.h>
#include <sys/sysctl.h>
#endif
*
* 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.
*
{
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;
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)
{
* 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
if (new_arg)
new_arg[arg_index] = '\0';
add_pending_null (context, &((*argv)[i]), new_arg);
+ i = new_i;
}
else if (parsed)
{
*
* 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