Revision: 56493
          http://sourceforge.net/p/brlcad/code/56493
Author:   starseeker
Date:     2013-08-02 21:23:10 +0000 (Fri, 02 Aug 2013)
Log Message:
-----------
Ah, right.  Because search expressions run the risk of looking like options, we 
need to constrain the bu_getopt search to the front of the argv string.  Do one 
pass to count the maximum possible number of options.  Then, do a second pass 
and make sure that anything counted as an option is in the front of the argv 
array.  May have to impose even stronger restrictions by identifying a valid 
path or search expression term and haulting there - we'll see.

Modified Paths:
--------------
    brlcad/trunk/src/libged/search.c

Modified: brlcad/trunk/src/libged/search.c
===================================================================
--- brlcad/trunk/src/libged/search.c    2013-08-02 20:55:49 UTC (rev 56492)
+++ brlcad/trunk/src/libged/search.c    2013-08-02 21:23:10 UTC (rev 56493)
@@ -103,7 +103,7 @@
 ged_search(struct ged *gedp, int argc, const char *argv_orig[])
 {
     void *dbplan;
-    int i, c, islocal;
+    int i, c, islocal, optcnt;
     int aflag = 0; /* flag controlling whether hidden objects are examined */
     int want_help = 0;
     int plan_argv = 1;
@@ -129,10 +129,30 @@
        return TCL_OK;
     }
 
+    /* Find how many possible options we have */
+
     bu_optind = 1;
+    optcnt = 0;
     while ((c = bu_getopt(argc, (char * const *)argv_orig, "ah?")) != -1) {
        switch(c) {
            case 'a':
+               optcnt++;
+               break;
+           case 'h':
+           case '?':
+               optcnt++;
+               break;
+           default:
+               break;
+       }
+    }
+
+    /* Options have to come before paths and search expressions, so don't look
+     * any further than the max possible option count */
+    bu_optind = 1;
+    while ((bu_optind < (optcnt + 1)) && ((c = bu_getopt(argc, (char * const 
*)argv_orig, "ah?")) != -1)) {
+       switch(c) {
+           case 'a':
                aflag = 1;
                break;
            case 'h':

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent 
caught up. So what steps can you take to put your SQL databases under 
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to