コード例 #1
0
ファイル: buffer.c プロジェクト: SvenDowideit/clearlinux
/* replace a range of lines with the joined text of those lines */
bool join_lines( const int from, const int to, const bool isglobal )
  {
  static char * buf = 0;
  static int bufsz = 0;
  int size = 0;
  line_t * const ep = search_line_node( inc_addr( to ) );
  line_t * bp = search_line_node( from );

  while( bp != ep )
    {
    const char * const s = get_sbuf_line( bp );
    if( !s || !resize_buffer( &buf, &bufsz, size + bp->len ) ) return false;
    memcpy( buf + size, s, bp->len );
    size += bp->len;
    bp = bp->q_forw;
    }
  if( !resize_buffer( &buf, &bufsz, size + 2 ) ) return false;
  memcpy( buf + size, "\n", 2 );
  size += 2;
  if( !delete_lines( from, to, isglobal ) ) return false;
  current_addr_ = from - 1;
  disable_interrupts();
  if( !put_sbuf_line( buf, size, current_addr_ ) ||
      !push_undo_atom( UADD, current_addr_, current_addr_ ) )
    { enable_interrupts(); return false; }
  modified_ = true;
  enable_interrupts();
  return true;
  }
コード例 #2
0
ファイル: regex.c プロジェクト: ystk/debian-ed
/* for each line in a range, change text matching a pattern according to
   a substitution template; return false if error */
char search_and_replace( const int first_addr, const int second_addr,
                         const int gflags, const int snum, const char isglobal )
  {
  int lc;
  char match_found = 0;

  set_current_addr( first_addr - 1 );
  for( lc = 0; lc <= second_addr - first_addr; ++lc )
    {
    line_t *lp = search_line_node( inc_current_addr() );
    int len = replace_matching_text( lp, gflags, snum );
    if( len < 0 ) return 0;
    if( len )
      {
      const char *txt = rbuf;
      const char *eot = rbuf + len;
      undo_t *up = 0;
      disable_interrupts();
      if( !delete_lines( current_addr(), current_addr(), isglobal ) ) return 0;
      do {
        txt = put_sbuf_line( txt, current_addr() );
        if( !txt ) { enable_interrupts(); return 0; }
        if( up ) up->tail = search_line_node( current_addr() );
        else if( !( up = push_undo_atom( UADD, -1, -1 ) ) )
          { enable_interrupts(); return 0; }
        }
      while( txt != eot );
      enable_interrupts();
      match_found = 1;
      }
    }
  if( !match_found && !( gflags & GLB ) )
    { set_error_msg( "No match" ); return 0; }
  return 1;
  }
コード例 #3
0
ファイル: test_overlays.c プロジェクト: BIC-MNI/bicgl
main()
{
    Status            status;
    window_struct     *window;
    lines_struct      lines;

    status = G_create_window( "Test Window", -1, -1, -1, -1, &window );

    G_set_background_colour( window, DARK_SLATE_GREY );
    G_set_automatic_clear_state( window, OFF );

    /* ------------ define line to be drawn  ------------- */

    initialize_lines( &lines, 1 );

    lines.n_points = 4;
    ALLOC( lines.points, 4 );
    fill_Point( lines.points[0],  10.0,  10.0, 0.0 );
    fill_Point( lines.points[1], 100.0,  10.0, 0.0 );
    fill_Point( lines.points[2], 100.0, 100.0, 0.0 );
    fill_Point( lines.points[3],  10.0, 100.0, 0.0 );

    lines.n_items = 1;
    ALLOC( lines.end_indices, lines.n_items );
    lines.end_indices[0] = 5;

    ALLOC( lines.indices, lines.end_indices[lines.n_items-1] );
    lines.indices[0] = 0;
    lines.indices[1] = 1;
    lines.indices[2] = 2;
    lines.indices[3] = 3;
    lines.indices[4] = 0;

    G_set_bitplanes( window, NORMAL_PLANES );
    G_clear_window( window );
    G_update_window( window );

    do
    {
        G_set_bitplanes( window, OVERLAY_PLANES );
        G_set_overlay_colour_map( window, 1, GREEN );
        G_set_overlay_colour_map( window, 2, GREEN );
        G_set_overlay_colour_map( window, 3, GREEN );
        G_clear_window( window );
        G_set_view_type( window, PIXEL_VIEW );
        G_draw_lines( window, &lines );
        G_update_window( window );
    }
    while( getchar() == '\n' );

    /* delete drawing objects and window (text does not need to be deleted */

    delete_lines( &lines );

    status = G_delete_window( window );

    return( status != OK );
}
コード例 #4
0
void File::undo_redo(Kontext* kontext, Undo* undo)
      {
      Position* spos = undo->start_pos;
      iLineList l = top.line2iLine(spos->zeile);

      switch(undo->type) {
            case UNDO_CHANGE_LINE:
            	for (iLineList ll = undo->l.begin(); ll != undo->l.end(); ++ll) {
                       	l->swap(*ll);
                  	++l;
                  	}
                  break;
            case UNDO_INSERT_LINE:
                  undo->type = UNDO_DELETE_LINE;
                  undo->n = undo->l.size();
			insert_line(l, &undo->l);
                  undo->l.clear();
                  break;
            case UNDO_DELETE_LINE:
                  delete_lines(l, undo->n);
                  undo->type = UNDO_INSERT_LINE;
                  break;
            case UNDO_LINEBREAK:
                  undo->type = UNDO_LINEUNBREAK;
                  {
                  iLineList pl = l;
                  ++l;
                  append_line(pl, undo->l.begin());
                  undo_list.clear_lines();
                  delete_lines(l, 1);  // verschiebt nach undo_list
                  }
                  break;
            case UNDO_LINEUNBREAK:
                  undo->l.clear();
            	kontext->newline();
                  break;
            default:
                  fprintf(stderr, "internal Error: bad undo type\n");
                  break;
            }
      modified = true;
      dirty = true;
      }
コード例 #5
0
void File::delete_lines(iLineList sl, int n)
      {
      iLineList el = sl;
      while (n--) {
            ++el;
            if (el == top.end())
                  break;
            }
      delete_lines(sl, el);
      modified = true;
      dirty = true;
      }
コード例 #6
0
ファイル: sub.c プロジェクト: AhmadTux/DragonFlyBSD
/* search_and_replace: for each line in a range, change text matching a pattern
   according to a substitution template; return status  */
int
search_and_replace(pattern_t *pat, int gflag, int kth)
{
	undo_t *up;
	const char *txt;
	const char *eot;
	long lc;
	long xa = current_addr;
	int nsubs = 0;
	line_t *lp;
	int len;

	current_addr = first_addr - 1;
	for (lc = 0; lc <= second_addr - first_addr; lc++) {
		lp = get_addressed_line_node(++current_addr);
		if ((len = substitute_matching_text(pat, lp, gflag, kth)) < 0)
			return ERR;
		else if (len) {
			up = NULL;
			if (delete_lines(current_addr, current_addr) < 0)
				return ERR;
			txt = rbuf;
			eot = rbuf + len;
			SPL1();
			do {
				if ((txt = put_sbuf_line(txt)) == NULL) {
					SPL0();
					return ERR;
				} else if (up)
					up->t = get_addressed_line_node(current_addr);
				else if ((up = push_undo_stack(UADD,
				    current_addr, current_addr)) == NULL) {
					SPL0();
					return ERR;
				}
			} while (txt != eot);
			SPL0();
			nsubs++;
			xa = current_addr;
		}
	}
	current_addr = xa;
	if  (nsubs == 0 && !(gflag & GLB)) {
		errmsg = "no match";
		return ERR;
	} else if ((gflag & (GPR | GLS | GNP)) &&
	    display_lines(current_addr, current_addr, gflag) < 0)
		return ERR;
	return 0;
}
コード例 #7
0
ファイル: lines.c プロジェクト: jgpelletier/algorithms
int read_lines_fgets (const char *fname , struct _line_t *lines) // lines is the head
{
    struct _line_t *new_line, *node, *tail; // <- this is the node
    char *s;
    FILE *f;
    int  err;
    err = 0;
    tail = lines->next;
    node = lines;
    if ((f = fopen (fname, "r")) != NULL) {
	
        s = fgets(lines->line, 120, f);

        while (s != NULL) {
               new_line = malloc(sizeof(struct _line_t));
               new_line->next = NULL;
               s = fgets(new_line->line, 120, f);
               new_line->next = tail;
               node->next = new_line;
               node = node->next;
         };
    } else {
        perror("file open  error");
        printf("errno = %d\n", errno);
        return -1;
    }

    new_line = lines->next;
    //print_lines(lines);// <-conditional jump in here
    delete_lines(new_line);

    err = fclose(f);
    if (err == EOF) {
        perror("file error");
        printf("errno = %d\n", errno);
        return -1;
    } else {
        return err;
    }
}
コード例 #8
0
ファイル: cmds.c プロジェクト: slewsys/ed
/*
 * join_lines: Replace a range of lines with the joined text of those lines.
 */
int
join_lines (off_t from, off_t to, ed_buffer_t *ed)
{
  static char *lj = NULL;       /* line join buffer */
  static size_t lj_size;        /* buffer size */

  ed_line_node_t *lp = get_line_node (from, ed);
  off_t n = from ? to - from + 1 : 0;
  size_t len = 0;
  char *s;

  for (; n; --n, lp = lp->q_forw)
    {
      if (!(s = get_buffer_line (lp, ed)))
        return ERR;
      REALLOC_THROW (lj, lj_size, len + lp->len, ERR, ed);
      memcpy (lj + len, s, lp->len);
      len += lp->len;
    }
  REALLOC_THROW (lj, lj_size, len + 2, ERR, ed);
  memcpy (lj + len++, "\n", 2);
  spl1 ();
  if (delete_lines (from, to, ed) < 0)
    {
      spl0 ();
      return ERR;
    }
  ed->state->dot = from - 1;
  if (!put_buffer_line (lj, len, ed)
      || !append_undo_node (UADD, ed->state->dot, ed->state->dot, ed))
    {
      spl0 ();
      return ERR;
    }
  ed->state->is_modified = 1;
  spl0 ();
  return 0;
}
コード例 #9
0
ファイル: Text.cpp プロジェクト: hugopeixoto/mbot
Text::~Text (void)
{
  delete_lines ();
}
コード例 #10
0
ファイル: lineed.c プロジェクト: hlyytine/daydream
/* FIXME: rethink */
int lineed(char *buffer, size_t bufsize, int mode, struct DayDream_Message *msg)
{
	int i, j;
	char lbuf[300];
	char *s;
	int row;

	*wrapbuf = 0;
	row = 1;

	DDPut(sd[leheadstr]);

	if (mode) 
		row = quote(buffer, bufsize);
	
	for (;;) {
		snprintf(lbuf, sizeof lbuf, "%c", maincfg.CFG_LINEEDCHAR);

		while (row != 495) {
			ddprintf(sd[lelinestr], row);

			s = buffer + (row - 1) * 80;
			*s = 0;
			if (!(Prompt(s, 75, PROMPT_WRAP)))
				return 0;

			if (!*s || !strcasecmp(lbuf, s))
				break;
			row++;
		}

		for (;;) {
			DDPut(sd[lepromptstr]);
			lbuf[0] = 0;
			if (!(Prompt(lbuf, 3, 0)))
				return 0;

			if (!strcasecmp(lbuf, "a")) {
				DDPut(sd[lesureabortstr]);
				i = HotKey(HOT_NOYES);
				if (!i || i == 1)
					return 0;
			} else if (!strcasecmp(lbuf, "c")) {
				TypeFile("lineedcommands", TYPE_WARN | TYPE_MAKE);
			} else if (!strcasecmp(lbuf, "d")) {
				if ((row = delete_lines(row, buffer)) == -1)
					return 0;
			} else if (!strcasecmp(lbuf, "e")) {
				DDPut(sd[leedlinstr]);
				lbuf[0] = 0;
				if (!(Prompt(lbuf, 3, 0)))
					return 0;
				i = atoi(lbuf);
				if (!(i < 1 || i > (row - 1))) {
					ddprintf(sd[leedpstr], i);
					s = buffer + (i - 1) * 80;
					if (!(Prompt(s, 75, 0)))
						return 0;
				}
			} else if (!strcasecmp(lbuf, "r")) {
				break;
			} else if (!strcasecmp(lbuf, "f")) {
				if (msg && *msg->MSG_ATTACH) {
					fileattach();
				} else {
					DDPut(sd[noattachstr]);
				}
			} else if ((!strcasecmp(lbuf, "i")) && row < 495) {
				DDPut(sd[insertstr]);
				lbuf[0] = 0;
				if (!(Prompt(lbuf, 3, 0)))
					return 0;
				DDPut("\nInsert does not work yet, sorry...\n\n");
			} else if (!strcasecmp(lbuf, "l")) {
				int lcount = user.user_screenlength;
				i = row - 1;
				j = 1;
				while (i) {
					s = buffer + (j - 1) * 80;
					ddprintf(sd[lellinestr], j, s);
					lcount--;

					if (lcount == 0) {
						int hot;

						DDPut(sd[morepromptstr]);
						hot = HotKey(0);
						DDPut("\r                                                         \r");
						if (hot == 'N' || hot == 'n')
							break;
						if (hot == 'C' || hot == 'c') {
							lcount = -1;
						} else {
							lcount = user.user_screenlength;
						}
					}
					j++;
					i--;
				}

			} else if (!strcasecmp(lbuf, "s")) {
				return row - 1;
			} else if (!strcasecmp(lbuf, "q")) {
				if (!mode) {
					DDPut(sd[lereperrorstr]);
				}
				row = quote(s, strlen(s));
			}
		}
	}
}
コード例 #11
0
ファイル: lines.c プロジェクト: jgpelletier/algorithms
int read_and_dump_all_over_the_screen_a_bunch_of_lines
    (const char *fname , struct _line_t *lines) // lines is the head
{
    struct _line_t *new_line, *node, *tail;
    char s;
    FILE *f;
    char buffer[BUFFER_SIZE];
    size_t i, len;
    int at_eof, err, count, c, j;
    err = c = j = 0;
    tail = lines->next;
    node = lines;
    if ((f = fopen (fname, "r")) != NULL) {
        count = -1;
        do {
            count ++;
            len = fread(buffer, sizeof(char), sizeof(buffer), f);

            new_line = malloc(sizeof(struct _line_t));
            new_line->next = NULL;

            /*
            while (node->next != NULL) { // <- schemiel the painter
                   node = node->next;
            }*/

            for (i = 0; i < len; i++) {
                if (c == 0) {
                    lines->line[i] =  buffer[i];
                    if (buffer[i] == '\n') {
                        lines->line[i+1] = '\0';
                        c = 1;
                    }
                } else {
                    s = buffer[i];
                    new_line->line[j] =  s;
                    ++j;
                    if (s == '\n') {
                        new_line->line[j+1] = '\0';

                        new_line->next = tail;
                        node->next = new_line;//
                        //tail = new_line->next;
                        /*
                        while (node->next != NULL) {
                           node = node->next;
                        }*/

                        new_line = malloc(sizeof(struct _line_t));
                        new_line->next = NULL;
                        node = node->next;
                        j = 0;
                    }
                }
            }

            free(new_line);

            if (len == sizeof(buffer)) {
                at_eof = 0;
            } else if (feof(f)) {
                at_eof = 1;
            } else {
                perror("fclose error");
                err = -1;
            }

        } while (at_eof == 0);
    } else {
        perror("file open  error");
        printf("errno = %d\n", errno);
        return -1;
    }

    new_line = lines->next;
    print_lines(lines); // <- what?
    delete_lines(new_line);

    err = fclose(f);
    if (err == EOF) {
        perror("file error");
        printf("errno = %d\n", errno);
        return -1;
    } else {
        return err;
   }
}
コード例 #12
0
ファイル: srcd.cpp プロジェクト: kjseefried/pm3
void CSrcFileBySymtab::reread()
{
  delete_lines();
  read_src_by_symtab(symtab);
}
コード例 #13
0
ファイル: srcd.cpp プロジェクト: kjseefried/pm3
CSrcFile::~CSrcFile()
{
  delete_lines();
}
コード例 #14
0
ファイル: main_loop.c プロジェクト: SvenDowideit/clearlinux
/* execute the next command in command buffer; return error status */
static int exec_command( const char ** const ibufpp, const int prev_status,
                         const bool isglobal )
  {
  const char * fnp;
  int gflags = 0;
  int addr, c, n;
  const int addr_cnt = extract_addr_range( ibufpp );

  if( addr_cnt < 0 ) return ERR;
  *ibufpp = skip_blanks( *ibufpp );
  c = *(*ibufpp)++;
  switch( c )
    {
    case 'a': if( !get_command_suffix( ibufpp, &gflags ) ) return ERR;
              if( !isglobal ) clear_undo_stack();
              if( !append_lines( ibufpp, second_addr, isglobal ) ) return ERR;
              break;
    case 'c': if( first_addr == 0 ) first_addr = 1;
              if( second_addr == 0 ) second_addr = 1;
              if( !check_current_addr( addr_cnt ) ||
                  !get_command_suffix( ibufpp, &gflags ) ) return ERR;
              if( !isglobal ) clear_undo_stack();
              if( !delete_lines( first_addr, second_addr, isglobal ) ||
                  !append_lines( ibufpp, current_addr(), isglobal ) ) return ERR;
              break;
    case 'd': if( !check_current_addr( addr_cnt ) ||
                  !get_command_suffix( ibufpp, &gflags ) ) return ERR;
              if( !isglobal ) clear_undo_stack();
              if( !delete_lines( first_addr, second_addr, isglobal ) ) return ERR;
              inc_current_addr();
              break;
    case 'e': if( modified() && !scripted() && prev_status != EMOD )
                return EMOD;				/* fall through */
    case 'E': if( unexpected_address( addr_cnt ) ||
                  unexpected_command_suffix( **ibufpp ) ) return ERR;
              fnp = get_filename( ibufpp );
              if( !fnp || !delete_lines( 1, last_addr(), isglobal ) ||
                  !close_sbuf() ) return ERR;
              if( !open_sbuf() ) return FATAL;
              if( fnp[0] && fnp[0] != '!' ) set_def_filename( fnp );
              if( traditional() && !fnp[0] && !def_filename[0] )
                { set_error_msg( "No current filename" ); return ERR; }
              if( read_file( fnp[0] ? fnp : def_filename, 0 ) < 0 )
                return ERR;
              reset_undo_state(); set_modified( false );
              break;
    case 'f': if( unexpected_address( addr_cnt ) ||
                  unexpected_command_suffix( **ibufpp ) ) return ERR;
              fnp = get_filename( ibufpp );
              if( !fnp ) return ERR;
              if( fnp[0] == '!' )
                { set_error_msg( "Invalid redirection" ); return ERR; }
              if( fnp[0] ) set_def_filename( fnp );
              printf( "%s\n", strip_escapes( def_filename ) );
              break;
    case 'g':
    case 'v':
    case 'G':
    case 'V': if( isglobal )
                { set_error_msg( "Cannot nest global commands" ); return ERR; }
              n = ( c == 'g' || c == 'G' );	/* mark matching lines */
              if( !check_addr_range( 1, last_addr(), addr_cnt ) ||
                  !build_active_list( ibufpp, first_addr, second_addr, n ) )
                return ERR;
              n = ( c == 'G' || c == 'V' );		/* interactive */
              if( ( n && !get_command_suffix( ibufpp, &gflags ) ) ||
                  !exec_global( ibufpp, gflags, n ) )
                return ERR;
              break;
    case 'h':
    case 'H': if( unexpected_address( addr_cnt ) ||
                  !get_command_suffix( ibufpp, &gflags ) ) return ERR;
              if( c == 'H' ) verbose = !verbose;
              if( ( c == 'h' || verbose ) && errmsg[0] )
                fprintf( stderr, "%s\n", errmsg );
              break;
    case 'i': if( second_addr == 0 ) second_addr = 1;
              if( !get_command_suffix( ibufpp, &gflags ) ) return ERR;
              if( !isglobal ) clear_undo_stack();
              if( !append_lines( ibufpp, second_addr - 1, isglobal ) )
                return ERR;
              break;
    case 'j': if( !check_addr_range( current_addr(), current_addr() + 1, addr_cnt ) ||
                  !get_command_suffix( ibufpp, &gflags ) ) return ERR;
              if( !isglobal ) clear_undo_stack();
              if( first_addr != second_addr &&
                  !join_lines( first_addr, second_addr, isglobal ) ) return ERR;
              break;
    case 'k': n = *(*ibufpp)++;
              if( second_addr == 0 ) { invalid_address(); return ERR; }
              if( !get_command_suffix( ibufpp, &gflags ) ||
                  !mark_line_node( search_line_node( second_addr ), n ) )
                return ERR;
              break;
    case 'l':
    case 'n':
    case 'p': if( c == 'l' ) n = GLS; else if( c == 'n' ) n = GNP; else n = GPR;
              if( !check_current_addr( addr_cnt ) ||
                  !get_command_suffix( ibufpp, &gflags ) ||
                  !display_lines( first_addr, second_addr, gflags | n ) )
                return ERR;
              gflags = 0;
              break;
    case 'm': if( !check_current_addr( addr_cnt ) ||
                  !get_third_addr( ibufpp, &addr ) ) return ERR;
              if( addr >= first_addr && addr < second_addr )
                { set_error_msg( "Invalid destination" ); return ERR; }
              if( !get_command_suffix( ibufpp, &gflags ) ) return ERR;
              if( !isglobal ) clear_undo_stack();
              if( !move_lines( first_addr, second_addr, addr, isglobal ) )
                return ERR;
              break;
    case 'P':
    case 'q':
    case 'Q': if( unexpected_address( addr_cnt ) ||
                  !get_command_suffix( ibufpp, &gflags ) ) return ERR;
              if( c == 'P' ) prompt_on = !prompt_on;
              else if( modified() && !scripted() && c == 'q' &&
                       prev_status != EMOD ) return EMOD;
              else return QUIT;
              break;
    case 'r': if( unexpected_command_suffix( **ibufpp ) ) return ERR;
              if( addr_cnt == 0 ) second_addr = last_addr();
              fnp = get_filename( ibufpp );
              if( !fnp ) return ERR;
              if( !isglobal ) clear_undo_stack();
              if( !def_filename[0] && fnp[0] != '!' ) set_def_filename( fnp );
              if( traditional() && !fnp[0] && !def_filename[0] )
                { set_error_msg( "No current filename" ); return ERR; }
              addr = read_file( fnp[0] ? fnp : def_filename, second_addr );
              if( addr < 0 ) return ERR;
              if( addr ) set_modified( true );
              break;
    case 's': if( !command_s( ibufpp, &gflags, addr_cnt, isglobal ) )
                return ERR;
              break;
    case 't': if( !check_current_addr( addr_cnt ) ||
                  !get_third_addr( ibufpp, &addr ) ||
                  !get_command_suffix( ibufpp, &gflags ) ) return ERR;
              if( !isglobal ) clear_undo_stack();
              if( !copy_lines( first_addr, second_addr, addr ) ) return ERR;
              break;
    case 'u': if( unexpected_address( addr_cnt ) ||
                  !get_command_suffix( ibufpp, &gflags ) ||
                  !undo( isglobal ) ) return ERR;
              break;
    case 'w':
    case 'W': n = **ibufpp;
              if( n == 'q' || n == 'Q' ) ++*ibufpp;
              if( unexpected_command_suffix( **ibufpp ) ) return ERR;
              fnp = get_filename( ibufpp );
              if( !fnp ) return ERR;
              if( addr_cnt == 0 && last_addr() == 0 )
                first_addr = second_addr = 0;
              else if( !check_addr_range( 1, last_addr(), addr_cnt ) )
                return ERR;
              if( !def_filename[0] && fnp[0] != '!' ) set_def_filename( fnp );
              if( traditional() && !fnp[0] && !def_filename[0] )
                { set_error_msg( "No current filename" ); return ERR; }
              addr = write_file( fnp[0] ? fnp : def_filename,
                     ( c == 'W' ) ? "a" : "w", first_addr, second_addr );
              if( addr < 0 ) return ERR;
              if( addr == last_addr() ) set_modified( false );
              else if( modified() && !scripted() && n == 'q' &&
                       prev_status != EMOD ) return EMOD;
              if( n == 'q' || n == 'Q' ) return QUIT;
              break;
    case 'x': if( second_addr < 0 || last_addr() < second_addr )
                { invalid_address(); return ERR; }
              if( !get_command_suffix( ibufpp, &gflags ) ) return ERR;
              if( !isglobal ) clear_undo_stack();
              if( !put_lines( second_addr ) ) return ERR;
              break;
    case 'y': if( !check_current_addr( addr_cnt ) ||
                  !get_command_suffix( ibufpp, &gflags ) ||
                  !yank_lines( first_addr, second_addr ) ) return ERR;
              break;
    case 'z': first_addr = 1;
              if( !check_addr_range( first_addr, current_addr() +
                                     ( traditional() || !isglobal ), addr_cnt ) )
                return ERR;
              if( **ibufpp > '0' && **ibufpp <= '9' )
                { if( parse_int( &n, *ibufpp, ibufpp ) ) set_window_lines( n );
                  else return ERR; }
              if( !get_command_suffix( ibufpp, &gflags ) ||
                  !display_lines( second_addr, min( last_addr(), second_addr + window_lines() ),
                                  gflags ) )
                return ERR;
              gflags = 0;
              break;
    case '=': if( !get_command_suffix( ibufpp, &gflags ) ) return ERR;
              printf( "%d\n", addr_cnt ? second_addr : last_addr() );
              break;
    case '!': if( unexpected_address( addr_cnt ) ) return ERR;
              fnp = get_shell_command( ibufpp );
              if( !fnp ) return ERR;
              if( system( fnp + 1 ) < 0 )
                { set_error_msg( "Can't create shell process" ); return ERR; }
              if( !scripted() ) printf( "!\n" );
              break;
    case '\n': first_addr = 1;
              if( !check_addr_range( first_addr, current_addr() +
                                     ( traditional() || !isglobal ), addr_cnt ) ||
                  !display_lines( second_addr, second_addr, 0 ) )
                return ERR;
              break;
    case '#': while( *(*ibufpp)++ != '\n' ) ;
              break;
    default : set_error_msg( "Unknown command" ); return ERR;
    }
  if( gflags && !display_lines( current_addr(), current_addr(), gflags ) )
    return ERR;
  return 0;
  }