Get rid of these gotos.

This commit is contained in:
Enno Boland (Gottox) 2009-06-08 17:25:52 +02:00
parent c54933edc1
commit b95f15e987

24
surf.c
View file

@ -60,6 +60,7 @@ static void showsearch(Client *c);
static void showurl(Client *c); static void showurl(Client *c);
static void stop(Client *c); static void stop(Client *c);
static void titlechange(WebKitWebView* view, WebKitWebFrame* frame, const gchar* title, gpointer d); static void titlechange(WebKitWebView* view, WebKitWebFrame* frame, const gchar* title, gpointer d);
static void usage();
static void updatetitle(Client *c, const gchar *title); static void updatetitle(Client *c, const gchar *title);
void void
@ -390,6 +391,7 @@ newclient(void) {
gtk_widget_show(c->win); gtk_widget_show(c->win);
gdk_window_set_events(GTK_WIDGET(c->win)->window, GDK_ALL_EVENTS_MASK); gdk_window_set_events(GTK_WIDGET(c->win)->window, GDK_ALL_EVENTS_MASK);
gdk_window_add_filter(GTK_WIDGET(c->win)->window, processx, c); gdk_window_add_filter(GTK_WIDGET(c->win)->window, processx, c);
webkit_web_view_set_full_content_zoom(c->view, TRUE);
c->download = NULL; c->download = NULL;
c->title = NULL; c->title = NULL;
c->next = clients; c->next = clients;
@ -473,6 +475,12 @@ titlechange(WebKitWebView *v, WebKitWebFrame *f, const gchar *t, gpointer d) {
updatetitle(c, t); updatetitle(c, t);
} }
void
usage() {
fputs("surf - simple browser\n", stderr);
die("usage: surf [-e] [-x] [-u uri] [-f file]\n");
}
void void
updatetitle(Client *c, const char *title) { updatetitle(Client *c, const char *title) {
char t[512]; char t[512];
@ -490,7 +498,6 @@ updatetitle(Client *c, const char *title) {
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
gchar *uri = NULL, *file = NULL;
SoupSession *s; SoupSession *s;
Client *c; Client *c;
int o; int o;
@ -510,28 +517,21 @@ int main(int argc, char *argv[]) {
embed = TRUE; embed = TRUE;
break; break;
case 'u': case 'u':
if(!(uri = optarg))
goto argerr;
c = newclient(); c = newclient();
loaduri(c, uri); loaduri(c, optarg);
break; break;
case 'f': case 'f':
if(!(file = optarg))
goto argerr;
c = newclient(); c = newclient();
loadfile(c, file); loadfile(c, optarg);
break; break;
case 'v': case 'v':
die("surf-"VERSION", © 2009 surf engineers, see LICENSE for details\n"); die("surf-"VERSION", © 2009 surf engineers, see LICENSE for details\n");
break; break;
argerr:
default: default:
puts("surf - simple browser"); usage();
die("usage: surf [-e] [-x] [-u uri] [-f file]\n");
return EXIT_FAILURE;
} }
if(optind != argc) if(optind != argc)
goto argerr; usage();
if(!clients) if(!clients)
newclient(); newclient();