Re: dillo.cc cleanup and bugfix

123 <[email protected]>
Newsgroups gmane.comp.web.dillo.devel
Message-ID <[email protected]>
I have split patch into three patches.

geometry.diff fixes --geometry flag 
> Fixed --geometry flag. It is --geometry in man page but -geometry in
> usage and only -geometry is recognized by program.

getcmdoption.diff simplifies getCmdOption
> Simplified getCmdOption. Removed State enum, it was overkill. It is
> also possible to remove support for mandatory arguments (opt_argc < 0)
> as it is not used, but it does not add LOC so I left it there.

aboutblank.diff removes unnecessary check.
> Removed check for about:blank as start_page, it is not a special case.

Minor fixes (#include order, indentation) are not included.

_______________________________________________
Dillo-dev mailing list
[email protected]
http://lists.auriga.wearlab.de/cgi-bin/mailman/listinfo/dillo-dev
geometry.diff (text/plain, 772 B)
diff -r 75ba8829a9f1 src/dillo.cc
--- a/src/dillo.cc	Sun Jun 10 00:15:25 2012 +0200
+++ b/src/dillo.cc	Sun Jun 10 22:33:49 2012 +0400
@@ -76,8 +76,8 @@
    {"-f", "--fullwindow", 0, DILLO_CLI_FULLWINDOW,
     "  -f, --fullwindow       Start in full window mode: hide address bar,\n"
     "                         navigation buttons, menu, and status bar."},
-   {"-g", "-geometry",    1, DILLO_CLI_GEOMETRY,
-    "  -g, -geometry GEO      Set initial window position where GEO is\n"
+   {"-g", "--geometry",   1, DILLO_CLI_GEOMETRY,
+    "  -g, --geometry GEO     Set initial window position where GEO is\n"
     "                         WxH[{+-}X{+-}Y]"},
    {"-h", "--help",       0, DILLO_CLI_HELP,
     "  -h, --help             Display this help text and exit."},
getcmdoption.diff (text/plain, 2.1 KB)
diff -r b67b9b11605e src/dillo.cc
--- a/src/dillo.cc	Sun Jun 10 15:40:51 2012 +0400
+++ b/src/dillo.cc	Sun Jun 10 22:34:14 2012 +0400
@@ -126,27 +126,22 @@
 static OptID getCmdOption(const CLI_options *options, int argc, char **argv,
                            char **opt_argv, int *idx)
 {
-   typedef enum { O_SEARCH, O_FOUND, O_NOTFOUND, O_DONE } State;
    OptID opt_id = DILLO_CLI_NONE;
-   int i = 0;
-   State state = O_SEARCH;
+   int i;
 
-   if (*idx >= argc) {
-      state = O_DONE;
-   } else {
-      state = O_NOTFOUND;
-      for (i = 0; options[i].shortopt; i++) {
-         if (strcmp(options[i].shortopt, argv[*idx]) == 0 ||
-             strcmp(options[i].longopt, argv[*idx]) == 0) {
-            state = O_FOUND;
-            ++*idx;
-            break;
-         }
+   if (*idx >= argc)
+      return DILLO_CLI_NONE;
+
+   for (i = 0; options[i].shortopt; i++)
+      if (strcmp(options[i].shortopt, argv[*idx]) == 0 ||
+          strcmp(options[i].longopt, argv[*idx]) == 0) {
+         ++*idx;
+         break;
       }
-   }
-   if (state == O_FOUND) {
+
+   if (options[i].shortopt) {
       int n_arg = options[i].opt_argc;
-      opt_id  = options[i].id;
+      opt_id = options[i].id;
       /* Find the required/optional arguments of the option */
       for (i = 0; *idx < argc && i < abs(n_arg) && argv[*idx][0] != '-'; i++)
          opt_argv[i] = argv[(*idx)++];
@@ -156,17 +151,14 @@
       if (i < n_arg) {
          fprintf(stderr, "Option %s requires %d argument%s\n",
                  argv[*idx-i-1], n_arg, (n_arg == 1) ? "" : "s");
-         opt_id = DILLO_CLI_ERROR;
+         return DILLO_CLI_ERROR;
       }
-   }
-   if (state == O_NOTFOUND) {
-      if (strcmp(argv[*idx], "--") == 0)
-         (*idx)++;
-      else if (argv[*idx][0] == '-') {
-         fprintf(stderr, "Command line option \"%s\" not recognized.\n",
-                 argv[*idx]);
-         opt_id = DILLO_CLI_ERROR;
-      }
+   } else if (strcmp(argv[*idx], "--") == 0)
+      *idx++;
+   else if (argv[*idx][0] == '-') {
+      fprintf(stderr, "Command line option \"%s\" not recognized.\n",
+              argv[*idx]);
+      return DILLO_CLI_ERROR;
    }
    return opt_id;
 }
aboutblank.diff (text/plain, 639 B)
diff -r 8e6faf0c729d src/dillo.cc
--- a/src/dillo.cc	Sun Jun 10 22:33:52 2012 +0400
+++ b/src/dillo.cc	Sun Jun 10 22:34:26 2012 +0400
@@ -402,11 +402,7 @@
 
    if (idx == argc) {
       /* No URLs/files on cmdline. Send startup screen */
-      if (dStrAsciiCasecmp(URL_SCHEME(prefs.start_page), "about") == 0 &&
-          strcmp(URL_PATH(prefs.start_page), "blank") == 0)
-         a_UIcmd_open_url(bw, NULL);
-      else
-         a_UIcmd_open_url(bw, prefs.start_page);
+      a_UIcmd_open_url(bw, prefs.start_page);
    } else {
       for (int i = idx; i < argc; i++) {
          DilloUrl *start_url = makeStartUrl(argv[i], local);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.