mirror of
https://github.com/rfivet/uemacs.git
synced 2024-11-19 19:15:55 -05:00
fa00fe882f
Yes, yes, it probably made sense 30 years ago as a way to save a tiny amount of memory, but especially when interspersed in structures that have pointers (aligned to 64 bits these days), it's not even saving memory today. And it makes us fail in nasty ways when looking at files with long lines. So just make them 'int'. And if you have a line that is longer than 2GB, you only have yourself to blame. I no longer care. In case anybody care, the "test-case" for this was a lovely UDDF file with a binary divecomputer dump encoded as an XML element. Resulting in a lovely 41kB single line. Not what poor micro-emacs was designed for, I'm afraid. I really should just learn another editor, rather than continue to polish this turd. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
48 lines
1.6 KiB
C
48 lines
1.6 KiB
C
#ifndef LINE_H_
|
|
#define LINE_H_
|
|
|
|
#include "utf8.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 */
|
|
int l_size; /* Allocated size */
|
|
int 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 int ldelchar(long n, int kflag);
|
|
extern int lgetchar(unicode_t *);
|
|
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_ */
|