From af19da1a99c37bc8b5e82f1d272673260f0a976f Mon Sep 17 00:00:00 2001 From: Thiago Farina Date: Mon, 15 Nov 2010 00:10:03 -0200 Subject: [PATCH] uemacs: Move structure line and its functions to its own header file. Signed-off-by: Thiago Farina Signed-off-by: Linus Torvalds --- basic.c | 2 ++ bind.c | 8 +++++--- buffer.c | 8 +++++--- display.c | 12 +++++++----- ebind.h | 4 +++- efunc.h | 18 ------------------ estruct.h | 22 ---------------------- eval.c | 2 ++ exec.c | 19 +++++++++---------- file.c | 14 ++++++++------ isearch.c | 14 ++++++++------ line.c | 11 +++++++---- line.h | 43 +++++++++++++++++++++++++++++++++++++++++++ random.c | 20 +++++++++++--------- region.c | 20 ++++++++++---------- search.c | 14 ++++++++------ spawn.c | 18 ++++++++++-------- window.c | 16 +++++++++------- word.c | 25 +++++++++++++------------ 19 files changed, 160 insertions(+), 130 deletions(-) create mode 100644 line.h diff --git a/basic.c b/basic.c index d651805..3bf0227 100644 --- a/basic.c +++ b/basic.c @@ -10,9 +10,11 @@ */ #include + #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "line.h" /* * This routine, given a pointer to a struct line, and the current cursor goal diff --git a/bind.c b/bind.c index cc20f7d..eb28c1f 100644 --- a/bind.c +++ b/bind.c @@ -1,17 +1,19 @@ -/* BIND.C +/* bind.c * * This file is for functions having to do with key bindings, * descriptions, help commands and startup file. * - * written 11-feb-86 by Daniel Lawrence - * modified by Petri Kutvonen + * Written 11-feb-86 by Daniel Lawrence + * Modified by Petri Kutvonen */ #include + #include "estruct.h" #include "edef.h" #include "efunc.h" #include "epath.h" +#include "line.h" #include "util.h" int help(int f, int n) diff --git a/buffer.c b/buffer.c index 15ff057..2555898 100644 --- a/buffer.c +++ b/buffer.c @@ -10,9 +10,11 @@ */ #include -#include "estruct.h" -#include "edef.h" -#include "efunc.h" + +#include "estruct.h" +#include "edef.h" +#include "efunc.h" +#include "line.h" /* * Attach a buffer to a window. The diff --git a/display.c b/display.c index a122be5..08c9884 100644 --- a/display.c +++ b/display.c @@ -1,20 +1,22 @@ /* display.c * - * The functions in this file handle redisplay. There are two halves, the - * ones that update the virtual display screen, and the ones that make the - * physical display screen the same as the virtual display screen. These - * functions use hints that are left in the windows by the commands. + * The functions in this file handle redisplay. There are two halves, the + * ones that update the virtual display screen, and the ones that make the + * physical display screen the same as the virtual display screen. These + * functions use hints that are left in the windows by the commands. * - * modified by Petri Kutvonen + * Modified by Petri Kutvonen */ #include #include #include #include + #include "estruct.h" #include "edef.h" #include "efunc.h" +#include "line.h" #include "version.h" struct video { diff --git a/ebind.h b/ebind.h index 2138946..f245246 100644 --- a/ebind.h +++ b/ebind.h @@ -1,4 +1,4 @@ -/* EBIND.H +/* ebind.h * * Initial default key to function bindings * @@ -8,6 +8,8 @@ #ifndef EBIND_H_ #define EBIND_H_ +#include "line.h" + /* * Command table. * This table is *roughly* in ASCII order, left to right across the diff --git a/efunc.h b/efunc.h index 0077e71..af032d9 100644 --- a/efunc.h +++ b/efunc.h @@ -26,24 +26,6 @@ extern int justpara(int f, int n); extern int killpara(int f, int n); extern int wordcount(int f, int n); -/* line.c */ -extern void lfree(struct line *lp); -extern void lchange(int flag); -extern int insspace(int f, int n); -extern int linstr(char *instr); -extern int linsert(int n, int c); -extern int lowrite(int c); -extern int lover(char *ostr); -extern int lnewline(void); -extern int ldelete(long n, int kflag); -extern char *getctext(void); -extern int putctext(char *iline); -extern int ldelnewline(void); -extern void kdelete(void); -extern int kinsert(int c); -extern int yank(int f, int n); -extern struct line *lalloc(int); /* Allocate a line. */ - /* window.c */ extern int reposition(int f, int n); extern int redraw(int f, int n); diff --git a/estruct.h b/estruct.h index 75acb4a..21ed08e 100644 --- a/estruct.h +++ b/estruct.h @@ -500,28 +500,6 @@ struct region { long r_size; /* Length in characters. */ }; -/* - * All text is kept in circularly linked lists of "struct line" structures. These - * begin at the header line (which is the blank line beyond the end of the - * buffer). This line is pointed to by the "struct buffer". Each line contains a the - * number of bytes in the line (the "used" size), the size of the text array, - * and the text. The end of line is not stored as a byte; it's implied. Future - * additions will include update hints, and a list of marks into the line. - */ -struct line { - struct line *l_fp; /* Link to the next line */ - struct line *l_bp; /* Link to the previous line */ - short l_size; /* Allocated size */ - short l_used; /* Used size */ - char l_text[1]; /* A bunch of characters. */ -}; - -#define lforw(lp) ((lp)->l_fp) -#define lback(lp) ((lp)->l_bp) -#define lgetc(lp, n) ((lp)->l_text[(n)]&0xFF) -#define lputc(lp, n, c) ((lp)->l_text[(n)]=(c)) -#define llength(lp) ((lp)->l_used) - /* * The editor communicates with the display using a high level interface. A * "TERM" structure holds useful variables, and indirect pointers to routines diff --git a/eval.c b/eval.c index c56be78..44e8a9b 100644 --- a/eval.c +++ b/eval.c @@ -7,10 +7,12 @@ */ #include + #include "estruct.h" #include "edef.h" #include "efunc.h" #include "evar.h" +#include "line.h" #include "util.h" #include "version.h" diff --git a/exec.c b/exec.c index fcbb313..2937966 100644 --- a/exec.c +++ b/exec.c @@ -1,22 +1,21 @@ -/* EXEC.C +/* exec.c * * This file is for functions dealing with execution of - * commands, command lines, buffers, files and startup files + * commands, command lines, buffers, files and startup files. * * written 1986 by Daniel Lawrence * modified by Petri Kutvonen */ -#include -#include "estruct.h" -#include "edef.h" -#include "efunc.h" +#include + +#include "estruct.h" +#include "edef.h" +#include "efunc.h" +#include "line.h" /* - * namedcmd: - * execute a named command even if it is not bound - * - * int f, n; command arguments [passed through to command executed] + * Execute a named command even if it is not bound. */ int namedcmd(int f, int n) { diff --git a/file.c b/file.c index 0a52cb0..29529c3 100644 --- a/file.c +++ b/file.c @@ -1,4 +1,4 @@ -/* FILE.C +/* file.c * * The routines in this file handle the reading, writing * and lookup of disk files. All of details about the @@ -7,11 +7,13 @@ * modified by Petri Kutvonen */ -#include -#include -#include "estruct.h" -#include "edef.h" -#include "efunc.h" +#include +#include + +#include "estruct.h" +#include "edef.h" +#include "efunc.h" +#include "line.h" /* * Read a file into the current diff --git a/isearch.c b/isearch.c index cefd70f..dcc408b 100644 --- a/isearch.c +++ b/isearch.c @@ -1,4 +1,4 @@ -/* ISEARCH.C +/* isearch.c * * The functions in this file implement commands that perform incremental * searches in the forward and backward directions. This "ISearch" command @@ -19,13 +19,15 @@ * checknext(), since there were no circumstances where * it ever equalled FALSE. * - * modified by Petri Kutvonen + * Modified by Petri Kutvonen */ -#include -#include "estruct.h" -#include "edef.h" -#include "efunc.h" +#include + +#include "estruct.h" +#include "edef.h" +#include "efunc.h" +#include "line.h" #if ISRCH diff --git a/line.c b/line.c index e7f1279..f96b259 100644 --- a/line.c +++ b/line.c @@ -13,10 +13,13 @@ * */ -#include -#include "estruct.h" -#include "edef.h" -#include "efunc.h" +#include "line.h" + +#include + +#include "estruct.h" +#include "edef.h" +#include "efunc.h" /* * This routine allocates a block of memory large enough to hold a struct line diff --git a/line.h b/line.h new file mode 100644 index 0000000..3900dbe --- /dev/null +++ b/line.h @@ -0,0 +1,43 @@ +#ifndef LINE_H_ +#define LINE_H_ + +/* + * All text is kept in circularly linked lists of "struct line" structures. These + * begin at the header line (which is the blank line beyond the end of the + * buffer). This line is pointed to by the "struct buffer". Each line contains a the + * number of bytes in the line (the "used" size), the size of the text array, + * and the text. The end of line is not stored as a byte; it's implied. Future + * additions will include update hints, and a list of marks into the line. + */ +struct line { + struct line *l_fp; /* Link to the next line */ + struct line *l_bp; /* Link to the previous line */ + short l_size; /* Allocated size */ + short l_used; /* Used size */ + char l_text[1]; /* A bunch of characters. */ +}; + +#define lforw(lp) ((lp)->l_fp) +#define lback(lp) ((lp)->l_bp) +#define lgetc(lp, n) ((lp)->l_text[(n)]&0xFF) +#define lputc(lp, n, c) ((lp)->l_text[(n)]=(c)) +#define llength(lp) ((lp)->l_used) + +extern void lfree(struct line *lp); +extern void lchange(int flag); +extern int insspace(int f, int n); +extern int linstr(char *instr); +extern int linsert(int n, int c); +extern int lowrite(int c); +extern int lover(char *ostr); +extern int lnewline(void); +extern int ldelete(long n, int kflag); +extern char *getctext(void); +extern int putctext(char *iline); +extern int ldelnewline(void); +extern void kdelete(void); +extern int kinsert(int c); +extern int yank(int f, int n); +extern struct line *lalloc(int); /* Allocate a line. */ + +#endif /* LINE_H_ */ diff --git a/random.c b/random.c index da95b1d..52acd45 100644 --- a/random.c +++ b/random.c @@ -1,17 +1,19 @@ -/* RANDOM.C +/* random.c * - * This file contains the command processing functions for a number of random - * commands. There is no functional grouping here, for sure. + * This file contains the command processing functions for a number of + * random commands. There is no functional grouping here, for sure. * - * modified by Petri Kutvonen + * Modified by Petri Kutvonen */ -#include -#include "estruct.h" -#include "edef.h" -#include "efunc.h" +#include -int tabsize; /* Tab size (0: use real tabs) */ +#include "estruct.h" +#include "edef.h" +#include "efunc.h" +#include "line.h" + +int tabsize; /* Tab size (0: use real tabs) */ /* * Set fill column to n. diff --git a/region.c b/region.c index 80b28e7..5190f86 100644 --- a/region.c +++ b/region.c @@ -1,18 +1,18 @@ /* region.c * - * The routines in this file - * deal with the region, that magic space - * between "." and mark. Some functions are - * commands. Some functions are just for - * internal use. + * The routines in this file deal with the region, that magic space + * between "." and mark. Some functions are commands. Some functions are + * just for internal use. * - * modified by Petri Kutvonen + * Modified by Petri Kutvonen */ -#include -#include "estruct.h" -#include "edef.h" -#include "efunc.h" +#include + +#include "estruct.h" +#include "edef.h" +#include "efunc.h" +#include "line.h" /* * Kill the region. Ask "getregion" diff --git a/search.c b/search.c index af11af7..d86e5f4 100644 --- a/search.c +++ b/search.c @@ -1,4 +1,4 @@ -/* SEARCH.C +/* search.c * * The functions in this file implement commands that search in the forward * and backward directions. There are no special characters in the search @@ -54,13 +54,15 @@ * whether or not to make use of the array. And, put in the * appropriate new structures and variables. * - * modified by Petri Kutvonen + * Modified by Petri Kutvonen */ -#include -#include "estruct.h" -#include "edef.h" -#include "efunc.h" +#include + +#include "estruct.h" +#include "edef.h" +#include "efunc.h" +#include "line.h" static int amatch(MC *mcptr, int direct, struct line **pcwline, int *pcwoff); static int readpattern(char *prompt, char *apat, int srch); diff --git a/spawn.c b/spawn.c index 1286ba3..5ad1366 100644 --- a/spawn.c +++ b/spawn.c @@ -1,14 +1,16 @@ -/* SPAWN.C - * various operating system access commands +/* spaw.c * - * modified by Petri Kutvonen + * Various operating system access commands. + * + * -#include -#include "estruct.h" -#include "edef.h" -#include "efunc.h" +#include +#include + +#include "estruct.h" +#include "edef.h" +#include "efunc.h" #if VMS #define EFN 0 /* Event flag. */ diff --git a/window.c b/window.c index deb7b0c..6a78b81 100644 --- a/window.c +++ b/window.c @@ -1,14 +1,16 @@ -/* WINDOW.C +/* window.c * - * Window management. Some of the functions are internal, and some are - * attached to keys that the user actually types. + * Window management. Some of the functions are internal, and some are + * attached to keys that the user actually types. * */ -#include -#include "estruct.h" -#include "edef.h" -#include "efunc.h" +#include + +#include "estruct.h" +#include "edef.h" +#include "efunc.h" +#include "line.h" /* * Reposition dot in the current window to line "n". If the argument is diff --git a/word.c b/word.c index 1f318b0..4b6fead 100644 --- a/word.c +++ b/word.c @@ -1,16 +1,18 @@ -/* WORD.C +/* word.c * - * The routines in this file implement commands that work word or a - * paragraph at a time. There are all sorts of word mode commands. If I - * do any sentence mode commands, they are likely to be put in this file. + * The routines in this file implement commands that work word or a + * paragraph at a time. There are all sorts of word mode commands. If I + * do any sentence mode commands, they are likely to be put in this file. * - * modified by Petri Kutvonen + * Modified by Petri Kutvonen */ -#include -#include "estruct.h" -#include "edef.h" -#include "efunc.h" +#include + +#include "estruct.h" +#include "edef.h" +#include "efunc.h" +#include "line.h" /* Word wrap on n-spaces. Back-over whatever precedes the point on the current * line and stop on the first word-break or the beginning of the line. If we @@ -19,9 +21,8 @@ * back to the end of the word. * Returns TRUE on success, FALSE on errors. * - * int f; default flag - * int n; numeric argument - * + * @f: default flag. + * @n: numeric argument. */ int wrapword(int f, int n) {