Index: /trunk/Ohana/Makefile
===================================================================
--- /trunk/Ohana/Makefile	(revision 6423)
+++ /trunk/Ohana/Makefile	(revision 6424)
@@ -98,4 +98,6 @@
 	for i in $(PROGRAM); do make $$i.clean || exit; done
 	for i in $(EXTRAS); do make $$i.clean || exit; done
+	@rm -f `find . -name .mana`
+	@rm -f `find . -name .dvo`
 
 dist:
Index: /trunk/Ohana/src/addstar/include/2mass.h
===================================================================
--- /trunk/Ohana/src/addstar/include/2mass.h	(revision 6423)
+++ /trunk/Ohana/src/addstar/include/2mass.h	(revision 6424)
@@ -10,4 +10,4 @@
 
 SkyTable *get2mass_acc (SkyRegion *patch, char *path, char *accel);
-Stars *get2mass_2DR_data (SkyRegion *region, SkyRegion *patch, int photcode, int *nstars);
-Stars *get2mass_AS_data (SkyRegion *region, SkyRegion *patch, int phocode, int *nstars);
+Stars *get2mass_2DR_data (SkyRegion *region, char *filename, SkyRegion *patch, int photcode, int *nstars);
+Stars *get2mass_AS_data (SkyRegion *region, char *filename, SkyRegion *patch, int phocode, int *nstars);
Index: /trunk/Ohana/src/addstar/src/get2mass.c
===================================================================
--- /trunk/Ohana/src/addstar/src/get2mass.c	(revision 6423)
+++ /trunk/Ohana/src/addstar/src/get2mass.c	(revision 6424)
@@ -32,9 +32,9 @@
       case 0:
 	// XXX put filename from table here
-	refcat = get2mass_AS_data (&sky[0].regions[i], patch, photcode, &Nrefcat);
+	refcat = get2mass_AS_data (&sky[0].regions[i], sky[0].filename[i], patch, photcode, &Nrefcat);
 	if (VERBOSE) fprintf (stderr, "loaded %d stars from 2MASS (allsky)\n", Nrefcat);
 	break;
       case 1:
-	refcat = get2mass_2DR_data (&sky[0].regions[i], patch, photcode, &Nrefcat);
+	refcat = get2mass_2DR_data (&sky[0].regions[i], sky[0].filename[i], patch, photcode, &Nrefcat);
 	if (VERBOSE) fprintf (stderr, "loaded %d stars from 2MASS (dr2)\n", Nrefcat);
 	break;
@@ -57,5 +57,5 @@
 
   int Nregions, NREGIONS;
-  char accelfile[1024], line[256], filename[128], datafile[256];
+  char accelfile[1024], line[256], filename[128], datafile[256], **filenames;
   FILE *f;
   double Rs, Re, Ds, De;
@@ -71,4 +71,5 @@
   NREGIONS = 200;
   ALLOCATE (regions, SkyRegion, NREGIONS);
+  ALLOCATE (filenames, char *, NREGIONS);
 
   /* read in stars line-by-line */
@@ -84,12 +85,15 @@
     if (Ds > patch[0].Dmax) continue;
     if (De < patch[0].Dmin) continue;
-    sprintf (datafile, "%s/%s", path, filename);
-    // XXX : put in table regions[Nregions].filename = (e_void) strcreate (datafile);
     regions[Nregions].Rmin = Rs;
     regions[Nregions].Rmax = Re;
     regions[Nregions].Dmin = Ds;
     regions[Nregions].Dmax = De;
+
+    sprintf (datafile, "%s/%s", path, filename);
+    filenames[Nregions] = strcreate (datafile);
+
     Nregions ++;
     CHECK_REALLOCATE (regions, SkyRegion, NREGIONS, Nregions, 20);
+    CHECK_REALLOCATE (filenames, char *, NREGIONS, Nregions, 20);
   }    
   fclose (f);
@@ -97,4 +101,5 @@
   ALLOCATE (sky, SkyTable, 1);
   sky[0].regions = regions;
+  sky[0].filename = filenames;
   sky[0].Nregions = Nregions;
   return (sky);
Index: /trunk/Ohana/src/addstar/src/get2mass_as.c
===================================================================
--- /trunk/Ohana/src/addstar/src/get2mass_as.c	(revision 6423)
+++ /trunk/Ohana/src/addstar/src/get2mass_as.c	(revision 6424)
@@ -13,5 +13,5 @@
 e_time get2mass_time (char *ptr, char *buffer, int Nbound, int Nbyte);
 
-Stars *get2mass_AS_data (SkyRegion *region, SkyRegion *patch, int photcode, int *nstars) {
+Stars *get2mass_AS_data (SkyRegion *region, char *filename, SkyRegion *patch, int photcode, int *nstars) {
   
   int FilterSkip, TimeSkip;
@@ -20,5 +20,5 @@
   gzFile gf;
   char qc;
-  char *buffer, *filename;
+  char *buffer;
   char *p, *q, *ptr, *tmp;
   double RA, DEC, M, dM;
@@ -55,5 +55,4 @@
   if (!FilterSkip) Shutdown ("invalid photcode %s", GetPhotcodeNamebyCode(photcode));
 
-  // filename = (char *) region[0].filename;
   gf = gzopen (filename, "rb");
   if (gf == NULL) Shutdown ("can't read 2mass data file: %s", filename);
Index: /trunk/Ohana/src/addstar/src/get2mass_dr2.c
===================================================================
--- /trunk/Ohana/src/addstar/src/get2mass_dr2.c	(revision 6423)
+++ /trunk/Ohana/src/addstar/src/get2mass_dr2.c	(revision 6424)
@@ -5,10 +5,10 @@
 # define NLINE 30000
 
-Stars *get2mass_2DR_data (SkyRegion *region, SkyRegion *patch, int photcode, int *nstars) {
+Stars *get2mass_2DR_data (SkyRegion *region, char *filename, SkyRegion *patch, int photcode, int *nstars) {
   
   int i, Nstars, NSTARS, Nbyte, Nline;
   Stars *stars;
   gzFile gf;
-  char *buffer, *filename;
+  char *buffer;
   char line[303];
   double RA, DEC, J, H, K, dJ, dH, dK;
@@ -27,6 +27,4 @@
   fprintf (stderr, "overlap: %f - %f, %f - %f\n", RA0, RA1, DEC0, DEC1);
 
-  // XXX get from args
-  // filename = (char *) region[0].filename;
   gf = gzopen (filename, "rb");
   if (gf == NULL) Shutdown ("can't read 2mass data file: %s", filename);
Index: /trunk/Ohana/src/delstar/Makefile
===================================================================
--- /trunk/Ohana/src/delstar/Makefile	(revision 6423)
+++ /trunk/Ohana/src/delstar/Makefile	(revision 6424)
@@ -40,4 +40,7 @@
 $(SRC)/check_permissions.$(ARCH).o \
 $(SRC)/Shutdown.$(ARCH).o          
+
+skip:
+	@echo "skipping delstar for now"
 
 default: $(PROGRAM)
Index: /trunk/Ohana/src/kapa/event/EventLoop.c
===================================================================
--- /trunk/Ohana/src/kapa/event/EventLoop.c	(revision 6423)
+++ /trunk/Ohana/src/kapa/event/EventLoop.c	(revision 6424)
@@ -1,5 +1,8 @@
 # include "Ximage.h"
 
-# define IgnoreMask (long) (ButtonPressMask | ClientMessage | ButtonReleaseMask | KeyPressMask | PointerMotionMask)
+/* # define IgnoreMask (long) (ButtonPressMask | ClientMessage | ButtonReleaseMask | KeyPressMask | PointerMotionMask) */
+
+/* list events being selected below, all other masks are ignored */ 
+# define IgnoreMask (long) (~(StructureNotifyMask | SubstructureNotifyMask | ExposureMask))
 
 int LastEvent (Display *display, int type, XEvent *event) {
@@ -33,4 +36,5 @@
 
     if (XEventsQueued (graphic.display, QueuedAfterFlush) < 1) {
+	/* fprintf (stderr, "."); */
       usleep (50000);
       continue;
@@ -54,6 +58,82 @@
     /* remove those events we will ignore */
     while (XCheckMaskEvent (display, IgnoreMask, &event)) continue;
-      
+
+    /* events to remove which have no mask component */
+    while (XCheckTypedEvent (display, MappingNotify, &event)) continue;
+    while (XCheckTypedEvent (display, ClientMessage, &event)) continue;
+    while (XCheckTypedEvent (display, SelectionClear, &event)) continue;
+    while (XCheckTypedEvent (display, SelectionNotify, &event)) continue;
+    while (XCheckTypedEvent (display, SelectionRequest, &event)) continue;
   }
   return (status);
 }
+
+# if (0)
+
+/* all masks from X.h for reference: */
+
+#define NoEventMask                     0L
+#define KeyPressMask                    (1L<<0)
+#define KeyReleaseMask                  (1L<<1)
+#define ButtonPressMask                 (1L<<2)
+#define ButtonReleaseMask               (1L<<3)
+#define EnterWindowMask                 (1L<<4)
+#define LeaveWindowMask                 (1L<<5)
+#define PointerMotionMask               (1L<<6)
+#define PointerMotionHintMask           (1L<<7)
+#define Button1MotionMask               (1L<<8)
+#define Button2MotionMask               (1L<<9)
+#define Button3MotionMask               (1L<<10)
+#define Button4MotionMask               (1L<<11)
+#define Button5MotionMask               (1L<<12)
+#define ButtonMotionMask                (1L<<13)
+#define KeymapStateMask                 (1L<<14)
+#define ExposureMask                    (1L<<15)
+#define VisibilityChangeMask            (1L<<16)
+#define StructureNotifyMask             (1L<<17)
+#define ResizeRedirectMask              (1L<<18)
+#define SubstructureNotifyMask          (1L<<19)
+#define SubstructureRedirectMask        (1L<<20)
+#define FocusChangeMask                 (1L<<21)
+#define PropertyChangeMask              (1L<<22)
+#define ColormapChangeMask              (1L<<23)
+#define OwnerGrabButtonMask             (1L<<24)
+
+/* all events from X.h for reference: */
+
+#define KeyPress                2
+#define KeyRelease              3
+#define ButtonPress             4
+#define ButtonRelease           5
+#define MotionNotify            6
+#define EnterNotify             7
+#define LeaveNotify             8
+#define FocusIn                 9
+#define FocusOut                10
+#define KeymapNotify            11
+#define Expose                  12
+#define GraphicsExpose          13
+#define NoExpose                14
+#define VisibilityNotify        15
+#define CreateNotify            16
+#define DestroyNotify           17
+#define UnmapNotify             18
+#define MapNotify               19
+#define MapRequest              20
+#define ReparentNotify          21
+#define ConfigureNotify         22
+#define ConfigureRequest        23
+#define GravityNotify           24
+#define ResizeRequest           25
+#define CirculateNotify         26
+#define CirculateRequest        27
+#define PropertyNotify          28
+#define SelectionClear          29
+#define SelectionRequest        30
+#define SelectionNotify         31
+#define ColormapNotify          32
+#define ClientMessage           33
+#define MappingNotify           34
+#define LASTEvent               35      /* must be bigger than any event # */
+
+# endif
Index: /trunk/Ohana/src/kapa/graph/cursor.c
===================================================================
--- /trunk/Ohana/src/kapa/graph/cursor.c	(revision 6423)
+++ /trunk/Ohana/src/kapa/graph/cursor.c	(revision 6424)
@@ -1,5 +1,6 @@
 # include "Ximage.h"
 
-# define IgnoreMask (long) (ClientMessage | ButtonReleaseMask | PointerMotionMask)
+/* # define IgnoreMask (long) (ClientMessage | ButtonReleaseMask | PointerMotionMask) */
+# define IgnoreMask (long) (~(StructureNotifyMask | SubstructureNotifyMask | ExposureMask | KeyPressMask | ButtonPressMask))
 
 int LastEvent (Display *display, int type, XEvent *event);
@@ -36,5 +37,6 @@
 
   events:
-    if (XEventsQueued (graphic.display, QueuedAfterFlush) < 1){
+    if (XEventsQueued (graphic.display, QueuedAfterFlush) < 1) {
+	fprintf (stderr, ".");
       usleep (50000);
       continue;
@@ -98,4 +100,10 @@
     /* remove those events we will ignore */
     while (XCheckMaskEvent (display, IgnoreMask, &event)) continue;
+
+    /* events to remove which have no mask component */
+    while (XCheckTypedEvent (display, ClientMessage, &event)) continue;
+    while (XCheckTypedEvent (display, SelectionClear, &event)) continue;
+    while (XCheckTypedEvent (display, SelectionNotify, &event)) continue;
+    while (XCheckTypedEvent (display, SelectionRequest, &event)) continue;
   }
   return (FALSE);
Index: /trunk/Ohana/src/kii/event/EventLoop.c
===================================================================
--- /trunk/Ohana/src/kii/event/EventLoop.c	(revision 6423)
+++ /trunk/Ohana/src/kii/event/EventLoop.c	(revision 6424)
@@ -1,5 +1,6 @@
 # include "Ximage.h"
 
-# define IgnoreMask (long) (ClientMessage | ButtonReleaseMask)
+/* # define IgnoreMask (long) (ClientMessage | ButtonReleaseMask) */
+# define IgnoreMask (long) (~(StructureNotifyMask | SubstructureNotifyMask | ExposureMask | KeyPressMask | ButtonPressMask | PointerMotionMask))
 
 int LastEvent (Display *display, int type, XEvent *event) {
Index: /trunk/Ohana/src/kii/picture/cursor.c
===================================================================
--- /trunk/Ohana/src/kii/picture/cursor.c	(revision 6423)
+++ /trunk/Ohana/src/kii/picture/cursor.c	(revision 6424)
@@ -1,3 +1,5 @@
 # include "Ximage.h"
+
+# define IgnoreMask (long) (~(StructureNotifyMask | SubstructureNotifyMask | ExposureMask | KeyPressMask | ButtonPressMask | PointerMotionMask))
 
 int LastEvent (Display *display, int type, XEvent *event);
@@ -66,4 +68,7 @@
       write (layout[0].Ximage, line, 40);
     }
+
+    /* remove those events we will ignore */
+    while (XCheckMaskEvent (display, IgnoreMask, &event)) continue;
   }
   return (FALSE);
Index: unk/Ohana/src/opihi/dvo/.dvo
===================================================================
--- /trunk/Ohana/src/opihi/dvo/.dvo	(revision 6423)
+++ 	(revision )
@@ -1,1 +1,0 @@
-avextract -phothelp
Index: /trunk/Ohana/src/opihi/lib.shell/expand_vars.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/expand_vars.c	(revision 6423)
+++ /trunk/Ohana/src/opihi/lib.shell/expand_vars.c	(revision 6424)
@@ -71,7 +71,13 @@
       *N = *Val; /* place the value of the variable in the newline */
     }
+    N--; /* we overshoot on last loop */
 
-    for (N--,L++; ISVAR(*L); L++);
-    L--;
+    /* skip past the variable in the source line */
+    /* L currently points at $ */
+    L++;
+    if (*L == '?') L++;  /* skip past ? in $?name */
+
+    while (ISVAR(*L)) L++;
+    L--; /* we overshoot */
 
     if (V0 != NULL) free (V0);
Index: /trunk/Ohana/src/opihi/lib.shell/string.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/string.c	(revision 6423)
+++ /trunk/Ohana/src/opihi/lib.shell/string.c	(revision 6424)
@@ -94,5 +94,5 @@
 char *thisvar (char *string) {
 
-  int i;
+  int i, start;
   char *word;
 
@@ -100,7 +100,12 @@
   if (string[0] != '$') return ((char *) NULL);
 
-  for (i = 1; ISVAR(string[i]); i++);
-  if (i == 1) return ((char *) NULL);
-
+  /* special case $?name : check that name is valid */
+  start = 1;
+  if (string[1] == '?') start = 2;
+
+  for (i = start; ISVAR(string[i]); i++);
+  if (i == start) return ((char *) NULL);
+
+  /* the ? is part of the variable */
   word = strncreate (&string[1], i - 1);
   return (word);
@@ -207,11 +212,15 @@
 char *aftervar (char *string) {
 
-  int i, j;
+  int i, j, start;
 
   if (string == (char *) NULL) return ((char *) NULL);
   if (string[0] != '$') return ((char *) NULL);
 
-  for (i = 1; ISVAR(string[i]); i++);
-  if (i == 1) return ((char *) NULL);
+  /* special case: $?name : test only name */
+  start = 1;
+  if (string[1] == '?') start = 2;
+
+  for (i = start; ISVAR(string[i]); i++);
+  if (i == start) return ((char *) NULL);
 
   for (j = i; whitespace (string[j]); j++);
Index: /trunk/Ohana/src/opihi/lib.shell/variable.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/variable.c	(revision 6423)
+++ /trunk/Ohana/src/opihi/lib.shell/variable.c	(revision 6424)
@@ -103,5 +103,5 @@
   
   int i;
-  char *local, *MacroName;
+  char *local, *MacroName, *value;
 
   if (name == NULL) return (NULL);
@@ -111,5 +111,5 @@
   /* return a string which should not be freed */
   if (*name == '?') {
-    value = get_variable_ptr (name[1]);
+    value = get_variable_ptr (&name[1]);
     if (value == NULL) {
       return variable_false;
@@ -152,5 +152,5 @@
   /* return a string which can be freed */
   if (*name == '?') {
-    value = get_variable_ptr (name[1]);
+    value = get_variable_ptr (&name[1]);
     if (value == NULL) {
       value = strcreate (variable_false);
