-/* $OpenBSD: ed.h,v 1.19 2015/10/09 19:47:02 millert Exp $ */
+/* $OpenBSD: ed.h,v 1.20 2015/10/09 20:27:28 tobias Exp $ */
/* $NetBSD: ed.h,v 1.23 1995/03/21 09:04:40 cgd Exp $ */
/* ed.h: type and constant definitions for the ed editor. */
/* Local Function Declarations */
void add_line_node(line_t *);
-int append_lines(int);
-int apply_subst_template(char *, regmatch_t *, int, int);
int build_active_list(int);
-int check_addr_range(int, int);
void clear_active_list(void);
void clear_undo_stack(void);
int close_sbuf(void);
-int copy_lines(int);
int delete_lines(int, int);
int display_lines(int, int, int);
-line_t *dup_line_node(line_t *);
int exec_command(void);
int exec_global(int, int);
int extract_addr_range(void);
-char *extract_pattern(int);
int extract_subst_tail(int *, int *);
-char *extract_subst_template(void);
line_t *get_addressed_line_node(int);
regex_t *get_compiled_pattern(void);
char *get_extended_line(int *, int);
-char *get_filename(void);
int get_line_node_addr(line_t *);
-int get_matching_node_addr(regex_t *, int);
-int get_marked_node_addr(int);
char *get_sbuf_line(line_t *);
-int get_shell_command(void);
-int get_stream_line(FILE *);
int get_tty_line(void);
void handle_hup(int);
void handle_int(int);
-void handle_winch(int);
int has_trailing_escape(char *, char *);
void init_buffers(void);
-int join_lines(int, int);
-int mark_line_node(line_t *, int);
-int move_lines(int);
-line_t *next_active_node(void);
-int next_addr(void);
int open_sbuf(void);
-char *parse_char_class(char *);
int pop_undo_stack(void);
undo_t *push_undo_stack(int, int, int);
char *put_sbuf_line(char *);
-int put_stream_line(FILE *, char *, int);
int put_tty_line(char *, int, int, int);
void quit(int);
int read_file(char *, int);
-int read_stream(FILE *, int);
int search_and_replace(regex_t *, int, int);
-int set_active_node(line_t *);
void seterrmsg(char *);
-void signal_hup(int);
-void signal_int(int);
char *strip_escapes(char *);
-int substitute_matching_text(regex_t *, line_t *, int, int);
char *translit_text(char *, int, int, int);
void unmark_line_node(line_t *);
void unset_active_nodes(line_t *, line_t *);
int write_file(char *, char *, int, int);
-int write_stream(FILE *, int, int);
/* global buffers */
extern char *ibuf;
-/* $OpenBSD: glbl.c,v 1.16 2015/10/09 19:47:02 millert Exp $ */
+/* $OpenBSD: glbl.c,v 1.17 2015/10/09 20:27:28 tobias Exp $ */
/* $NetBSD: glbl.c,v 1.2 1995/03/21 09:04:41 cgd Exp $ */
/* glob.c: This file contains the global command routines for the ed line
#include "ed.h"
+static int set_active_node(line_t *);
+static line_t *next_active_node(void);
/* build_active_list: add line matching a pattern to the global-active list */
int
static int active_ndx; /* active_list index (modulo active_last) */
/* set_active_node: add a line node to the global-active list */
-int
+static int
set_active_node(line_t *lp)
{
if (active_last + 1 > active_size) {
/* next_active_node: return the next global-active line node */
-line_t *
+static line_t *
next_active_node(void)
{
while (active_ptr < active_last && active_list[active_ptr] == NULL)
-/* $OpenBSD: io.c,v 1.17 2015/10/09 19:47:02 millert Exp $ */
+/* $OpenBSD: io.c,v 1.18 2015/10/09 20:27:28 tobias Exp $ */
/* $NetBSD: io.c,v 1.2 1995/03/21 09:04:43 cgd Exp $ */
/* io.c: This file contains the i/o routines for the ed line editor */
#include "ed.h"
+static int read_stream(FILE *, int);
+static int get_stream_line(FILE *);
+static int write_stream(FILE *, int, int);
+static int put_stream_line(FILE *, char *, int);
extern int scripted;
int newline_added; /* if set, newline appended to input file */
/* read_stream: read a stream into the editor buffer; return status */
-int
+static int
read_stream(FILE *fp, int n)
{
line_t *lp = get_addressed_line_node(n);
}
/* get_stream_line: read a line of text from a stream; return line length */
-int
+static int
get_stream_line(FILE *fp)
{
int c;
/* write_stream: write a range of lines to a stream; return status */
-int
+static int
write_stream(FILE *fp, int n, int m)
{
line_t *lp = get_addressed_line_node(n);
/* put_stream_line: write a line of text to a stream; return status */
-int
+static int
put_stream_line(FILE *fp, char *s, int len)
{
while (len--) {
-/* $OpenBSD: main.c,v 1.51 2015/10/09 19:47:02 millert Exp $ */
+/* $OpenBSD: main.c,v 1.52 2015/10/09 20:27:28 tobias Exp $ */
/* $NetBSD: main.c,v 1.3 1995/03/21 09:04:44 cgd Exp $ */
/* main.c: This file contains the main control and user-interface routines
#include "ed.h"
+void signal_hup(int);
+void signal_int(int);
+void handle_winch(int);
+
+static int next_addr(void);
+static int check_addr_range(int, int);
+static int get_matching_node_addr(regex_t *, int);
+static char *get_filename(void);
+static int get_shell_command(void);
+static int append_lines(int);
+static int join_lines(int, int);
+static int move_lines(int);
+static int copy_lines(int);
+static int mark_line_node(line_t *, int);
+static int get_marked_node_addr(int);
+static line_t *dup_line_node(line_t *);
sigjmp_buf env;
/* next_addr: return the next line address in the command buffer */
-int
+static int
next_addr(void)
{
char *hd;
/* check_addr_range: return status of address range check */
-int
+static int
check_addr_range(int n, int m)
{
if (addr_cnt == 0) {
/* get_matching_node_addr: return the address of the next line matching a
pattern in a given direction. wrap around begin/end of editor buffer if
necessary */
-int
+static int
get_matching_node_addr(regex_t *pat, int dir)
{
char *s;
/* get_filename: return pointer to copy of filename in the command buffer */
-char *
+static char *
get_filename(void)
{
static char *file = NULL;
/* get_shell_command: read a shell command from stdin; return substitution
status */
-int
+static int
get_shell_command(void)
{
static char *buf = NULL;
/* append_lines: insert text from stdin to after line n; stop when either a
single period is read or EOF; return status */
-int
+static int
append_lines(int n)
{
int l;
/* join_lines: replace a range of lines with the joined text of those lines */
-int
+static int
join_lines(int from, int to)
{
static char *buf = NULL;
/* move_lines: move a range of lines */
-int
+static int
move_lines(int addr)
{
line_t *b1, *a1, *b2, *a2;
/* copy_lines: copy a range of lines; return status */
-int
+static int
copy_lines(int addr)
{
line_t *lp, *np = get_addressed_line_node(first_addr);
static int markno; /* line marker count */
/* mark_line_node: set a line node mark */
-int
+static int
mark_line_node(line_t *lp, int n)
{
if (!islower(n)) {
/* get_marked_node_addr: return address of a marked line */
-int
+static int
get_marked_node_addr(int n)
{
if (!islower(n)) {
/* dup_line_node: return a pointer to a copy of a line node */
-line_t *
+static line_t *
dup_line_node(line_t *lp)
{
line_t *np;
-/* $OpenBSD: re.c,v 1.14 2015/10/04 15:23:24 millert Exp $ */
+/* $OpenBSD: re.c,v 1.15 2015/10/09 20:27:28 tobias Exp $ */
/* $NetBSD: re.c,v 1.14 1995/03/21 09:04:48 cgd Exp $ */
/* re.c: This file contains the regular expression interface routines for
#include "ed.h"
+static char *extract_pattern(int);
+static char *parse_char_class(char *);
extern int patlock;
/* extract_pattern: copy a pattern string from the command buffer; return
pointer to the copy */
-char *
+static char *
extract_pattern(int delimiter)
{
static char *lhbuf = NULL; /* buffer */
/* parse_char_class: expand a POSIX character class */
-char *
+static char *
parse_char_class(char *s)
{
int c, d;
-/* $OpenBSD: sub.c,v 1.13 2015/10/09 19:47:02 millert Exp $ */
+/* $OpenBSD: sub.c,v 1.14 2015/10/09 20:27:28 tobias Exp $ */
/* $NetBSD: sub.c,v 1.4 1995/03/21 09:04:50 cgd Exp $ */
/* sub.c: This file contains the substitution routines for the ed
#include "ed.h"
+static char *extract_subst_template(void);
+static int substitute_matching_text(regex_t *, line_t *, int, int);
+static int apply_subst_template(char *, regmatch_t *, int, int);
static char *rhbuf; /* rhs substitution buffer */
static int rhbufsz; /* rhs substitution buffer size */
/* extract_subst_template: return pointer to copy of substitution template
in the command buffer */
-char *
+static char *
extract_subst_template(void)
{
int n = 0;
/* substitute_matching_text: replace text matched by a pattern according to
a substitution template; return pointer to the modified text */
-int
+static int
substitute_matching_text(regex_t *pat, line_t *lp, int gflag, int kth)
{
int off = 0;
/* apply_subst_template: modify text according to a substitution template;
return offset to end of modified text */
-int
+static int
apply_subst_template(char *boln, regmatch_t *rm, int off, int re_nsub)
{
int j = 0;