view 3rdparty/packages/ed/find.c @ 2876:1ca5c484c7a7

joydrv_6551L.asm: Remove spurious ! (OR) from expression
author Tormod Volden <debian.tormod@gmail.com>
date Sun, 24 Nov 2013 15:48:17 +0100
parents bef1844de0dc
children
line wrap: on
line source

/*      find.c  */
#include <stdio.h>
#include "tools.h"
#include "ed.h"

int find(pat, dir)
TOKEN *pat;
int dir;
{
  int i, num;
  char lin[MAXLINE];
  LINE *ptr;

  num = curln;
  ptr = getptr(curln);
  num = (dir ? nextln(num) : prevln(num));
  ptr = (dir ? ptr->l_next : ptr->l_prev);
  for (i = 0; i < lastln; i++) {
        if (num == 0) {
                num = (dir ? nextln(num) : prevln(num));
                ptr = (dir ? ptr->l_next : ptr->l_prev);
        }
        strcpy(lin, ptr->l_buff);
        strcat(lin, "\n");
        if (matchs(lin, pat, 0)) {
                return(num);
        }
        num = (dir ? nextln(num) : prevln(num));
        ptr = (dir ? ptr->l_next : ptr->l_prev);
  }
  return(ERR);
}