Fix nvi's cscope support in the case that someone provided a filename
authoroga <oga@openbsd.org>
Fri, 29 Aug 2008 13:07:13 +0000 (13:07 +0000)
committeroga <oga@openbsd.org>
Fri, 29 Aug 2008 13:07:13 +0000 (13:07 +0000)
without a directory (e.g. :cscope add cscope.out). Found and fixed by
Paul Irofti, with help from me; Thanks!

upstream nvi also has this fix.

ok otto@.

usr.bin/vi/ex/ex_cscope.c

index dc7a66d..5609387 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ex_cscope.c,v 1.14 2007/09/11 15:47:17 gilles Exp $   */
+/*     $OpenBSD: ex_cscope.c,v 1.15 2008/08/29 13:07:13 oga Exp $      */
 
 /*-
  * Copyright (c) 1994, 1996
@@ -246,6 +246,10 @@ cscope_add(sp, cmdp, dname)
                dbname = CSCOPE_DBFILE;
        } else if ((dbname = strrchr(dname, '/')) != NULL)
                *dbname++ = '\0';
+       else {
+               dbname = dname;
+               dname = ".";
+       }
 
        /* Allocate a cscope connection structure and initialize its fields. */
        len = strlen(dname);