In src/utils.c:

> +				gboolean val = *(gboolean *)optentry->arg_data;
> +				gboolean reverse = (optentry->flags & G_OPTION_FLAG_REVERSE);
> +				if ((val && !reverse) || (!val && reverse)) /* logical XOR */
> +					s = g_strdup_printf("--%s", optentry->long_name);
> +			}
> +			break;
> +
> +		case G_OPTION_ARG_INT:
> +			if (*(gint *)optentry->arg_data)
> +				s = g_strdup_printf("--%s=%d", optentry->long_name, *(gint *)optentry->arg_data);
> +			break;
> +
> +		case G_OPTION_ARG_STRING:
> +		case G_OPTION_ARG_FILENAME:
> +			if (*(gchar **)optentry->arg_data)
> +				s = g_strdup_printf("--%s=%s", optentry->long_name, *(gchar **)optentry->arg_data);

STRING and FILENAME have different encoding, I'm not sure if a conversion is needed.

GLib's docs say:

On UNIX systems, the argv that is passed to main() has no particular encoding, even to the extent that different parts of it may have different encodings. In general, normal arguments and flags will be in the current locale and filenames should be considered to be opaque byte strings. Proper use of G_OPTION_ARG_FILENAME vs G_OPTION_ARG_STRING is therefore important.


Reply to this email directly or view it on GitHub.