[PATCH weston v2 1/2] editor: Use parse_options() from shared for command line options

Bryce Harrington bryce at osg.samsung.com
Mon Nov 21 21:26:11 UTC 2016


On Mon, Nov 21, 2016 at 09:08:38PM +0100, Silvan Jegen wrote:
> Hi
> 
> >  int
> >  main(int argc, char *argv[])
> >  {
> >  	struct editor editor;
> >  	int i;
> 
> This is still unused (as pointed out by Daniel) and should be removed.

Oh, thanks, missed that.

Bryce

> Cheers,
> 
> Silvan
> 
> > -	uint32_t click_to_show = 0;
> > -	const char *preferred_language = NULL;
> > -
> > -	for (i = 1; i < argc; i++) {
> > -		if (strcmp("--click-to-show", argv[i]) == 0)
> > -			click_to_show = 1;
> > -		else if (strcmp("--preferred-language", argv[i]) == 0 &&
> > -			 i + 1 < argc) {
> > -			preferred_language = argv[i + 1];
> > -			i++;
> > -		} else {
> > -			printf("Usage: %s [OPTIONS]\n"
> > -			       "  --click-to-show\n"
> > -			       "  --preferred-language LANGUAGE\n",
> > -			       argv[0]);
> > -			return 1;
> > -		}
> > +
> > +	parse_options(editor_options, ARRAY_LENGTH(editor_options),
> > +		      &argc, argv);
> > +	if (opt_help)
> > +		usage(argv[0], EXIT_SUCCESS);
> > +
> > +	if (argc > 1) {
> > +		usage(argv[0], EXIT_FAILURE);
> > +		/* FIXME: Use remaining arguments as a path/filename to load */
> > +		return 0;
> >  	}
> >  
> >  	memset(&editor, 0, sizeof editor);
> > @@ -1537,12 +1573,12 @@ main(int argc, char *argv[])
> >  	editor.widget = window_frame_create(editor.window, &editor);
> >  
> >  	editor.entry = text_entry_create(&editor, "Entry");
> > -	editor.entry->click_to_show = click_to_show;
> > -	if (preferred_language)
> > -		editor.entry->preferred_language = strdup(preferred_language);
> > +	editor.entry->click_to_show = opt_click_to_show;
> > +	if (opt_preferred_language)
> > +		editor.entry->preferred_language = strdup(opt_preferred_language);
> >  	editor.editor = text_entry_create(&editor, "Numeric");
> >  	editor.editor->content_purpose = ZWP_TEXT_INPUT_V1_CONTENT_PURPOSE_NUMBER;
> > -	editor.editor->click_to_show = click_to_show;
> > +	editor.editor->click_to_show = opt_click_to_show;
> >  	editor.selection = NULL;
> >  	editor.selected_text = NULL;
> >  
> > -- 
> > 1.9.1
> > 
> > _______________________________________________
> > wayland-devel mailing list
> > wayland-devel at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list