}
static glong
-_g_utf8_strwidth (const gchar *p,
- gssize max)
+_g_utf8_strwidth (const gchar *p)
{
glong len = 0;
- const gchar *start = p;
- g_return_val_if_fail (p != NULL || max == 0, 0);
+ g_return_val_if_fail (p != NULL, 0);
- if (max < 0)
+ while (*p)
{
- while (*p)
- {
- len += _g_unichar_get_width (g_utf8_get_char (p));
- p = g_utf8_next_char (p);
- }
- }
- else
- {
- if (max == 0 || !*p)
- return 0;
-
- /* this case may not be quite correct */
-
len += _g_unichar_get_width (g_utf8_get_char (p));
p = g_utf8_next_char (p);
-
- while (p - start < max && *p)
- {
- len += _g_unichar_get_width (g_utf8_get_char (p));
- p = g_utf8_next_char (p);
- }
}
return len;
* g_option_context_add_main_entries:
* @context: a #GOptionContext
* @entries: a %NULL-terminated array of #GOptionEntry<!-- -->s
- * @translation_domain: a translation domain to use for translating
+ * @translation_domain: (allow-none): a translation domain to use for translating
* the <option>--help</option> output for the options in @entries
* with gettext(), or %NULL
*
if (entry->flags & G_OPTION_FLAG_HIDDEN)
continue;
- len = _g_utf8_strwidth (entry->long_name, -1);
+ len = _g_utf8_strwidth (entry->long_name);
if (entry->short_name)
len += 4;
if (!NO_ARG (entry) && entry->arg_description)
- len += 1 + _g_utf8_strwidth (TRANSLATE (group, entry->arg_description), -1);
+ len += 1 + _g_utf8_strwidth (TRANSLATE (group, entry->arg_description));
max_length = MAX (max_length, len);
}
g_string_append_printf (str, "=%s", TRANSLATE (group, entry->arg_description));
g_string_append_printf (string, "%s%*s %s\n", str->str,
- (int) (max_length + 4 - _g_utf8_strwidth (str->str, -1)), "",
+ (int) (max_length + 4 - _g_utf8_strwidth (str->str)), "",
entry->description ? TRANSLATE (group, entry->description) : "");
g_string_free (str, TRUE);
}
* g_option_context_get_help:
* @context: a #GOptionContext
* @main_help: if %TRUE, only include the main group
- * @group: the #GOptionGroup to create help for, or %NULL
+ * @group: (allow-none): the #GOptionGroup to create help for, or %NULL
*
* Returns a formatted, translated help text for the given context.
* To obtain the text produced by <option>--help</option>, call
list = context->groups;
- max_length = _g_utf8_strwidth ("-?, --help", -1);
+ max_length = _g_utf8_strwidth ("-?, --help");
if (list)
{
- len = _g_utf8_strwidth ("--help-all", -1);
+ len = _g_utf8_strwidth ("--help-all");
max_length = MAX (max_length, len);
}
GOptionGroup *g = list->data;
/* First, we check the --help-<groupname> options */
- len = _g_utf8_strwidth ("--help-", -1) + _g_utf8_strwidth (g->name, -1);
+ len = _g_utf8_strwidth ("--help-") + _g_utf8_strwidth (g->name);
max_length = MAX (max_length, len);
/* Then we go through the entries */
* @help_description: a description for the <option>--help-</option>@name option.
* This string is translated using the translation domain or translation function
* of the group
- * @user_data: user data that will be passed to the pre- and post-parse hooks,
+ * @user_data: (allow-none): user data that will be passed to the pre- and post-parse hooks,
* the error hook and to callbacks of %G_OPTION_ARG_CALLBACK options, or %NULL
- * @destroy: a function that will be called to free @user_data, or %NULL
+ * @destroy: (allow-none): a function that will be called to free @user_data, or %NULL
*
* Creates a new #GOptionGroup.
*
/**
* g_option_group_set_parse_hooks:
* @group: a #GOptionGroup
- * @pre_parse_func: a function to call before parsing, or %NULL
- * @post_parse_func: a function to call after parsing, or %NULL
+ * @pre_parse_func: (allow-none): a function to call before parsing, or %NULL
+ * @post_parse_func: (allow-none): a function to call after parsing, or %NULL
*
* Associates two functions with @group which will be called
* from g_option_context_parse() before the first option is parsed
/**
* g_option_group_set_translate_func:
* @group: a #GOptionGroup
- * @func: the #GTranslateFunc, or %NULL
- * @data: user data to pass to @func, or %NULL
- * @destroy_notify: a function which gets called to free @data, or %NULL
+ * @func: (allow-none): the #GTranslateFunc, or %NULL
+ * @data: (allow-none): user data to pass to @func, or %NULL
+ * @destroy_notify: (allow-none): a function which gets called to free @data, or %NULL
*
* Sets the function which is used to translate user-visible
* strings, for <option>--help</option> output. Different
/**
* g_option_context_set_translate_func:
* @context: a #GOptionContext
- * @func: the #GTranslateFunc, or %NULL
- * @data: user data to pass to @func, or %NULL
- * @destroy_notify: a function which gets called to free @data, or %NULL
+ * @func: (allow-none): the #GTranslateFunc, or %NULL
+ * @data: (allow-none): user data to pass to @func, or %NULL
+ * @destroy_notify: (allow-none): a function which gets called to free @data, or %NULL
*
* Sets the function which is used to translate the contexts
* user-visible strings, for <option>--help</option> output.
/**
* g_option_context_set_summary:
* @context: a #GOptionContext
- * @summary: a string to be shown in <option>--help</option> output
+ * @summary: (allow-none): a string to be shown in <option>--help</option> output
* before the list of options, or %NULL
*
* Adds a string to be displayed in <option>--help</option> output
/**
* g_option_context_set_description:
* @context: a #GOptionContext
- * @description: a string to be shown in <option>--help</option> output
+ * @description: (allow-none): a string to be shown in <option>--help</option> output
* after the list of options, or %NULL
*
* Adds a string to be displayed in <option>--help</option> output