[hackers] [surf] Get rid of these gotos. || Enno Boland (Gottox)

From: <hg_AT_suckless.org>
Date: Mon, 8 Jun 2009 15:25:52 +0000 (UTC)

changeset: 32:c65777fb1475
tag: tip
user: Enno Boland (Gottox) <gottox_AT_s01.de>
date: Mon Jun 08 17:25:52 2009 +0200
files: surf.c
description:
Get rid of these gotos.

diff -r ecfc2e16de41 -r c65777fb1475 surf.c
--- a/surf.c Mon Jun 08 17:01:12 2009 +0200
+++ b/surf.c Mon Jun 08 17:25:52 2009 +0200
@@ -60,6 +60,7 @@
 static void showurl(Client *c);
 static void stop(Client *c);
 static void titlechange(WebKitWebView* view, WebKitWebFrame* frame, const gchar* title, gpointer d);
+static void usage();
 static void updatetitle(Client *c, const gchar *title);
 
 void
@@ -390,6 +391,7 @@
         gtk_widget_show(c->win);
         gdk_window_set_events(GTK_WIDGET(c->win)->window, GDK_ALL_EVENTS_MASK);
         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->title = NULL;
         c->next = clients;
@@ -474,6 +476,12 @@
 }
 
 void
+usage() {
+ fputs("surf - simple browser\n", stderr);
+ die("usage: surf [-e] [-x] [-u uri] [-f file]\n");
+}
+
+void
 updatetitle(Client *c, const char *title) {
         char t[512];
 
@@ -490,7 +498,6 @@
 }
 
 int main(int argc, char *argv[]) {
- gchar *uri = NULL, *file = NULL;
         SoupSession *s;
         Client *c;
         int o;
@@ -510,28 +517,21 @@
                         embed = TRUE;
                         break;
                 case 'u':
- if(!(uri = optarg))
- goto argerr;
                         c = newclient();
- loaduri(c, uri);
+ loaduri(c, optarg);
                         break;
                 case 'f':
- if(!(file = optarg))
- goto argerr;
                         c = newclient();
- loadfile(c, file);
+ loadfile(c, optarg);
                         break;
                 case 'v':
                         die("surf-"VERSION", © 2009 surf engineers, see LICENSE for details\n");
                         break;
- argerr:
                 default:
- puts("surf - simple browser");
- die("usage: surf [-e] [-x] [-u uri] [-f file]\n");
- return EXIT_FAILURE;
+ usage();
                 }
         if(optind != argc)
- goto argerr;
+ usage();
         if(!clients)
                 newclient();
 
Received on Mon Jun 08 2009 - 15:25:52 UTC

This archive was generated by hypermail 2.2.0 : Mon Jun 08 2009 - 15:36:04 UTC