Beispiel #1
0
int
fisearch(int f, int n)
{
    MARK curpos;		/* current line on entryl */

    /* remember the initial . on entry: */

    curpos = DOT;		/* save current point */

    /* Save direction */
    last_srch_direc = FORWARD;

    /* do the search */

    if (!(isearch(f, n))) {	/* Call ISearch forwards */
	/* If error in search: */
	DOT = curpos;		/* reset */
	curwp->w_flag |= WFMOVE;	/* Say we've moved */
	(void) update(FALSE);	/* And force an update */
	mlwarn("[I-Search failed]");	/* Say we died */
	return FALSE;
    } else
	mlerase();		/* If happy, just erase the cmd line */

    return TRUE;
}
Beispiel #2
0
/*
 * Subroutine to do incremental reverse search.  It actually uses the same
 * code as the normal incremental search, as both can go both ways.
 */
int
risearch(int f, int n)
{
    MARK curpos;		/* Current point on entry */

    /* remember the initial . on entry: */

    curpos = DOT;		/* Save the current point */

    /* Save direction */
    last_srch_direc = REVERSE;

    /* Make sure the search doesn't match where we already are: */

    backchar(TRUE, 1);		/* Back up a character */

    if (!(isearch(f, -n))) {	/* Call ISearch backwards */
	/* If error in search: */
	DOT = curpos;		/* Reset the pointer */
	curwp->w_flag |= WFMOVE;	/* Say we've moved */
	(void) update(FALSE);	/* And force an update */
	mlwarn("[I-Search failed]");	/* Say we died */
	return FALSE;
    } else
	mlerase();		/* If happy, just erase the cmd line */

    return TRUE;
}
Beispiel #3
0
/* ARGSUSED */
int
backisearch(int f, int n)
{
	if (macrodef || inmacro)
		/* We can't isearch in macro. Use search instead */
		return (backsearch(f,n));
	else 
		return (isearch(SRCH_BACK));
}
Beispiel #4
0
/* ARGSUSED */
int
forwisearch(int f, int n)
{
	if (macrodef || inmacro)
		/* We can't isearch in macro. Use search instead */
		return (forwsearch(f,n));
	else 
		return (isearch(SRCH_FORW));
}
Beispiel #5
0
int mount(const char *special_file,
	  const char *dir,
	  const char *fstype, unsigned long int options, const void *data)
{
	extern tk_inode_t *__Rnod;
	tk_inode_t *device_file;
	tk_inode_t *mount_dir;

	device_file = isearch(__Rnod, special_file);
	if (device_file == NULL) {
		errno = EINVAL;
		return -1;
	}
	if (!(device_file->mode & S_IFBLK)) {
		errno = ENOTBLK;
		return -1;
	}
	mount_dir = isearch(__Rnod, dir);
	if (mount_dir == NULL) {
		errno = EINVAL;
		return -1;
	}
	if (!(mount_dir->mode & S_IFDIR)) {
		errno = EACCES;
		return -1;
	}
	if (mount_dir->mount != NULL) {
		errno = EBUSY;
		return -1;
	}

	mount_dir->mount = calloc(1, sizeof(tk_mount_t));
	if (mount_dir->mount == NULL) {
		errno = ENOMEM;
		return -1;
	}
	mount_dir->mount->io_device = device_file->iohandle;
	mount_dir->mount->options = options;
	return 0;
}
Beispiel #6
0
int umount2(const char *file, int flags)
{
	extern tk_inode_t *__Rnod;
	tk_inode_t *mount_dir;

	mount_dir = isearch(__Rnod, file);
	if (mount_dir == NULL) {
		errno = EINVAL;
		return -1;
	}
	if (mount_dir->mount == NULL) {
		errno = EINVAL;
		return -1;
	}
	free(mount_dir->mount);
	mount_dir->mount = NULL;
	return 0;
}
Beispiel #7
0
int fisearch(f, n)
{
    LINE *curline;			/* Current line on entry	      */
    int  curoff;			/* Current offset on entry	      */

    /* remember the initial . on entry: */

    curline = curwp->w_dotp;		/* Save the current line pointer      */
    curoff  = curwp->w_doto;		/* Save the current offset	      */

    /* do the search */

    if (!(isearch(f, n)))		/* Call ISearch forwards	      */
    {					/* If error in search:		      */
	curwp->w_dotp = curline;	/* Reset the line pointer	      */
	curwp->w_doto = curoff;		/*  and the offset to original value  */
	curwp->w_flag |= WFMOVE;	/* Say we've moved		      */
	update(FALSE);			/* And force an update		      */
	mlwrite ("[search failed]");	/* Say we died			      */
    } else mlerase ();			/* If happy, just erase the cmd line  */
}
Beispiel #8
0
int risearch(f, n)
{
    LINE *curline;			/* Current line on entry	      */
    int  curoff;			/* Current offset on entry	      */

    /* remember the initial . on entry: */

    curline = curwp->w_dotp;		/* Save the current line pointer      */
    curoff  = curwp->w_doto;		/* Save the current offset	      */

    /* Make sure the search doesn't match where we already are:		      */

    backchar(TRUE, 1);			/* Back up a character		      */

    if (!(isearch(f, -n)))		/* Call ISearch backwards	      */
    {					/* If error in search:		      */
	curwp->w_dotp = curline;	/* Reset the line pointer	      */
	curwp->w_doto = curoff;		/*  and the offset to original value  */
	curwp->w_flag |= WFMOVE;	/* Say we've moved		      */
	update(FALSE);			/* And force an update		      */
	mlwrite ("[search failed]");	/* Say we died			      */
    } else mlerase ();			/* If happy, just erase the cmd line  */
}
     int indexsearch(int A[], int n, int target) {
     return isearch(A,0,n-1,target);
 }
 int isearch(int A[], int i, int j, int target) {
     int m;
     if(i==j+1) return -1;
     m=(i+j)/2;
     if(A[m]>A[j]) {
         if(target==A[m]) return m;
         else if(target>A[m]) return isearch(A,m+1,j,target);
         else {
             if(target<=A[j]) return isearch(A,m+1,j,target);
             else return isearch(A,i,m-1,target);
         }
     }
     else if(A[m]<A[j]) {
         if(target==A[m]) return m;
         else if(target>A[m]) {
             if(target>A[j]) return isearch(A,i,m-1,target);
             else return isearch(A,m+1,j,target);
         }
         else return isearch(A,i,m-1,target);
     }
     else {
         if(target==A[m]) return m;
         else {
             if(isearch(A,i,m-1,target)==-1&&isearch(A,m+1,j,target)==-1) return -1;
             else {
                 if(isearch(A,i,m-1,target)!=-1) return isearch(A,i,m-1,target);
                 else return isearch(A,m+1,j,target);
             }
         }
     }
 }
Beispiel #11
0
/*ARGSUSED*/
backisearch(f, n)
{
	return isearch(SRCH_BACK);
}
Beispiel #12
0
/*ARGSUSED*/
forwisearch(f, n)
{
	return isearch(SRCH_FORW);
}