Skip to content

Commit af19da1

Browse files
tfarinatorvalds
authored andcommitted
uemacs: Move structure line and its functions to its own header file.
Signed-off-by: Thiago Farina <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 72a1af4 commit af19da1

19 files changed

+160
-130
lines changed

Diff for: basic.c

+2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
*/
1111

1212
#include <stdio.h>
13+
1314
#include "estruct.h"
1415
#include "edef.h"
1516
#include "efunc.h"
17+
#include "line.h"
1618

1719
/*
1820
* This routine, given a pointer to a struct line, and the current cursor goal

Diff for: bind.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
/* BIND.C
1+
/* bind.c
22
*
33
* This file is for functions having to do with key bindings,
44
* descriptions, help commands and startup file.
55
*
6-
* written 11-feb-86 by Daniel Lawrence
7-
* modified by Petri Kutvonen
6+
* Written 11-feb-86 by Daniel Lawrence
7+
* Modified by Petri Kutvonen
88
*/
99

1010
#include <stdio.h>
11+
1112
#include "estruct.h"
1213
#include "edef.h"
1314
#include "efunc.h"
1415
#include "epath.h"
16+
#include "line.h"
1517
#include "util.h"
1618

1719
int help(int f, int n)

Diff for: buffer.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@
1010
*/
1111

1212
#include <stdio.h>
13-
#include "estruct.h"
14-
#include "edef.h"
15-
#include "efunc.h"
13+
14+
#include "estruct.h"
15+
#include "edef.h"
16+
#include "efunc.h"
17+
#include "line.h"
1618

1719
/*
1820
* Attach a buffer to a window. The

Diff for: display.c

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
/* display.c
22
*
3-
* The functions in this file handle redisplay. There are two halves, the
4-
* ones that update the virtual display screen, and the ones that make the
5-
* physical display screen the same as the virtual display screen. These
6-
* functions use hints that are left in the windows by the commands.
3+
* The functions in this file handle redisplay. There are two halves, the
4+
* ones that update the virtual display screen, and the ones that make the
5+
* physical display screen the same as the virtual display screen. These
6+
* functions use hints that are left in the windows by the commands.
77
*
8-
* modified by Petri Kutvonen
8+
* Modified by Petri Kutvonen
99
*/
1010

1111
#include <errno.h>
1212
#include <stdio.h>
1313
#include <stdarg.h>
1414
#include <unistd.h>
15+
1516
#include "estruct.h"
1617
#include "edef.h"
1718
#include "efunc.h"
19+
#include "line.h"
1820
#include "version.h"
1921

2022
struct video {

Diff for: ebind.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* EBIND.H
1+
/* ebind.h
22
*
33
* Initial default key to function bindings
44
*
@@ -8,6 +8,8 @@
88
#ifndef EBIND_H_
99
#define EBIND_H_
1010

11+
#include "line.h"
12+
1113
/*
1214
* Command table.
1315
* This table is *roughly* in ASCII order, left to right across the

Diff for: efunc.h

-18
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,6 @@ extern int justpara(int f, int n);
2626
extern int killpara(int f, int n);
2727
extern int wordcount(int f, int n);
2828

29-
/* line.c */
30-
extern void lfree(struct line *lp);
31-
extern void lchange(int flag);
32-
extern int insspace(int f, int n);
33-
extern int linstr(char *instr);
34-
extern int linsert(int n, int c);
35-
extern int lowrite(int c);
36-
extern int lover(char *ostr);
37-
extern int lnewline(void);
38-
extern int ldelete(long n, int kflag);
39-
extern char *getctext(void);
40-
extern int putctext(char *iline);
41-
extern int ldelnewline(void);
42-
extern void kdelete(void);
43-
extern int kinsert(int c);
44-
extern int yank(int f, int n);
45-
extern struct line *lalloc(int); /* Allocate a line. */
46-
4729
/* window.c */
4830
extern int reposition(int f, int n);
4931
extern int redraw(int f, int n);

Diff for: estruct.h

-22
Original file line numberDiff line numberDiff line change
@@ -500,28 +500,6 @@ struct region {
500500
long r_size; /* Length in characters. */
501501
};
502502

503-
/*
504-
* All text is kept in circularly linked lists of "struct line" structures. These
505-
* begin at the header line (which is the blank line beyond the end of the
506-
* buffer). This line is pointed to by the "struct buffer". Each line contains a the
507-
* number of bytes in the line (the "used" size), the size of the text array,
508-
* and the text. The end of line is not stored as a byte; it's implied. Future
509-
* additions will include update hints, and a list of marks into the line.
510-
*/
511-
struct line {
512-
struct line *l_fp; /* Link to the next line */
513-
struct line *l_bp; /* Link to the previous line */
514-
short l_size; /* Allocated size */
515-
short l_used; /* Used size */
516-
char l_text[1]; /* A bunch of characters. */
517-
};
518-
519-
#define lforw(lp) ((lp)->l_fp)
520-
#define lback(lp) ((lp)->l_bp)
521-
#define lgetc(lp, n) ((lp)->l_text[(n)]&0xFF)
522-
#define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
523-
#define llength(lp) ((lp)->l_used)
524-
525503
/*
526504
* The editor communicates with the display using a high level interface. A
527505
* "TERM" structure holds useful variables, and indirect pointers to routines

Diff for: eval.c

+2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
*/
88

99
#include <stdio.h>
10+
1011
#include "estruct.h"
1112
#include "edef.h"
1213
#include "efunc.h"
1314
#include "evar.h"
15+
#include "line.h"
1416
#include "util.h"
1517
#include "version.h"
1618

Diff for: exec.c

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
/* EXEC.C
1+
/* exec.c
22
*
33
* This file is for functions dealing with execution of
4-
* commands, command lines, buffers, files and startup files
4+
* commands, command lines, buffers, files and startup files.
55
*
66
* written 1986 by Daniel Lawrence
77
* modified by Petri Kutvonen
88
*/
99

10-
#include <stdio.h>
11-
#include "estruct.h"
12-
#include "edef.h"
13-
#include "efunc.h"
10+
#include <stdio.h>
11+
12+
#include "estruct.h"
13+
#include "edef.h"
14+
#include "efunc.h"
15+
#include "line.h"
1416

1517
/*
16-
* namedcmd:
17-
* execute a named command even if it is not bound
18-
*
19-
* int f, n; command arguments [passed through to command executed]
18+
* Execute a named command even if it is not bound.
2019
*/
2120
int namedcmd(int f, int n)
2221
{

Diff for: file.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* FILE.C
1+
/* file.c
22
*
33
* The routines in this file handle the reading, writing
44
* and lookup of disk files. All of details about the
@@ -7,11 +7,13 @@
77
* modified by Petri Kutvonen
88
*/
99

10-
#include <stdio.h>
11-
#include <unistd.h>
12-
#include "estruct.h"
13-
#include "edef.h"
14-
#include "efunc.h"
10+
#include <stdio.h>
11+
#include <unistd.h>
12+
13+
#include "estruct.h"
14+
#include "edef.h"
15+
#include "efunc.h"
16+
#include "line.h"
1517

1618
/*
1719
* Read a file into the current

Diff for: isearch.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* ISEARCH.C
1+
/* isearch.c
22
*
33
* The functions in this file implement commands that perform incremental
44
* searches in the forward and backward directions. This "ISearch" command
@@ -19,13 +19,15 @@
1919
* checknext(), since there were no circumstances where
2020
* it ever equalled FALSE.
2121
*
22-
* modified by Petri Kutvonen
22+
* Modified by Petri Kutvonen
2323
*/
2424

25-
#include <stdio.h>
26-
#include "estruct.h"
27-
#include "edef.h"
28-
#include "efunc.h"
25+
#include <stdio.h>
26+
27+
#include "estruct.h"
28+
#include "edef.h"
29+
#include "efunc.h"
30+
#include "line.h"
2931

3032
#if ISRCH
3133

Diff for: line.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313
*
1414
*/
1515

16-
#include <stdio.h>
17-
#include "estruct.h"
18-
#include "edef.h"
19-
#include "efunc.h"
16+
#include "line.h"
17+
18+
#include <stdio.h>
19+
20+
#include "estruct.h"
21+
#include "edef.h"
22+
#include "efunc.h"
2023

2124
/*
2225
* This routine allocates a block of memory large enough to hold a struct line

Diff for: line.h

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#ifndef LINE_H_
2+
#define LINE_H_
3+
4+
/*
5+
* All text is kept in circularly linked lists of "struct line" structures. These
6+
* begin at the header line (which is the blank line beyond the end of the
7+
* buffer). This line is pointed to by the "struct buffer". Each line contains a the
8+
* number of bytes in the line (the "used" size), the size of the text array,
9+
* and the text. The end of line is not stored as a byte; it's implied. Future
10+
* additions will include update hints, and a list of marks into the line.
11+
*/
12+
struct line {
13+
struct line *l_fp; /* Link to the next line */
14+
struct line *l_bp; /* Link to the previous line */
15+
short l_size; /* Allocated size */
16+
short l_used; /* Used size */
17+
char l_text[1]; /* A bunch of characters. */
18+
};
19+
20+
#define lforw(lp) ((lp)->l_fp)
21+
#define lback(lp) ((lp)->l_bp)
22+
#define lgetc(lp, n) ((lp)->l_text[(n)]&0xFF)
23+
#define lputc(lp, n, c) ((lp)->l_text[(n)]=(c))
24+
#define llength(lp) ((lp)->l_used)
25+
26+
extern void lfree(struct line *lp);
27+
extern void lchange(int flag);
28+
extern int insspace(int f, int n);
29+
extern int linstr(char *instr);
30+
extern int linsert(int n, int c);
31+
extern int lowrite(int c);
32+
extern int lover(char *ostr);
33+
extern int lnewline(void);
34+
extern int ldelete(long n, int kflag);
35+
extern char *getctext(void);
36+
extern int putctext(char *iline);
37+
extern int ldelnewline(void);
38+
extern void kdelete(void);
39+
extern int kinsert(int c);
40+
extern int yank(int f, int n);
41+
extern struct line *lalloc(int); /* Allocate a line. */
42+
43+
#endif /* LINE_H_ */

Diff for: random.c

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
/* RANDOM.C
1+
/* random.c
22
*
3-
* This file contains the command processing functions for a number of random
4-
* commands. There is no functional grouping here, for sure.
3+
* This file contains the command processing functions for a number of
4+
* random commands. There is no functional grouping here, for sure.
55
*
6-
* modified by Petri Kutvonen
6+
* Modified by Petri Kutvonen
77
*/
88

9-
#include <stdio.h>
10-
#include "estruct.h"
11-
#include "edef.h"
12-
#include "efunc.h"
9+
#include <stdio.h>
1310

14-
int tabsize; /* Tab size (0: use real tabs) */
11+
#include "estruct.h"
12+
#include "edef.h"
13+
#include "efunc.h"
14+
#include "line.h"
15+
16+
int tabsize; /* Tab size (0: use real tabs) */
1517

1618
/*
1719
* Set fill column to n.

Diff for: region.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
/* region.c
22
*
3-
* The routines in this file
4-
* deal with the region, that magic space
5-
* between "." and mark. Some functions are
6-
* commands. Some functions are just for
7-
* internal use.
3+
* The routines in this file deal with the region, that magic space
4+
* between "." and mark. Some functions are commands. Some functions are
5+
* just for internal use.
86
*
9-
* modified by Petri Kutvonen
7+
* Modified by Petri Kutvonen
108
*/
119

12-
#include <stdio.h>
13-
#include "estruct.h"
14-
#include "edef.h"
15-
#include "efunc.h"
10+
#include <stdio.h>
11+
12+
#include "estruct.h"
13+
#include "edef.h"
14+
#include "efunc.h"
15+
#include "line.h"
1616

1717
/*
1818
* Kill the region. Ask "getregion"

Diff for: search.c

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* SEARCH.C
1+
/* search.c
22
*
33
* The functions in this file implement commands that search in the forward
44
* and backward directions. There are no special characters in the search
@@ -54,13 +54,15 @@
5454
* whether or not to make use of the array. And, put in the
5555
* appropriate new structures and variables.
5656
*
57-
* modified by Petri Kutvonen
57+
* Modified by Petri Kutvonen
5858
*/
5959

60-
#include <stdio.h>
61-
#include "estruct.h"
62-
#include "edef.h"
63-
#include "efunc.h"
60+
#include <stdio.h>
61+
62+
#include "estruct.h"
63+
#include "edef.h"
64+
#include "efunc.h"
65+
#include "line.h"
6466

6567
static int amatch(MC *mcptr, int direct, struct line **pcwline, int *pcwoff);
6668
static int readpattern(char *prompt, char *apat, int srch);

0 commit comments

Comments
 (0)