Update cmd/re and scm.

This commit is contained in:
Serge
2022-05-27 21:12:40 -07:00
parent 146bae8a98
commit e728e7f25d
11 changed files with 105 additions and 60 deletions

View File

@@ -35,6 +35,8 @@
#include <strings.h>
#include <errno.h>
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
#define PF(f, func) { \
if (fieldwidth) \
@@ -232,7 +234,7 @@ escape(fmt)
register int value;
int c;
for (store = fmt; c = *fmt; ++fmt, ++store) {
for (store = fmt; (c = *fmt); ++fmt, ++store) {
if (c != '\\') {
*store = c;
continue;

View File

@@ -7,6 +7,8 @@
#include "r.defs.h"
#include <sys/wait.h>
static char *searchkey;
static int insert_mode = 1; /* Insert mode */
static int clr_arg_area; /* Need to erase the arg area */
static int fname_cvt_flag; /* Disable filename conversion on "re -" */

View File

@@ -104,8 +104,8 @@ typedef struct {
int nlines; /* Number of non-empty lines in file */
} file_t;
file_t file[MAXFILES]; /* Table of files */
int curfile;
extern file_t file[MAXFILES]; /* Table of files */
extern int curfile;
/*
* Workspace describes a generic file under edit.
@@ -121,7 +121,7 @@ typedef struct {
int cursorrow; /* Saved cursorline, when not active */
} workspace_t;
workspace_t *curwksp, *pickwksp;
extern workspace_t *curwksp, *pickwksp;
/*
* Window - a region on the display.
@@ -146,12 +146,12 @@ typedef struct {
char *rightbar; /* Symbols on right edge */
} window_t;
window_t *winlist[MAXWINLIST];
int nwinlist;
extern window_t *winlist[MAXWINLIST];
extern int nwinlist;
window_t *curwin; /* Current window */
window_t wholescreen; /* The whole screen */
window_t paramwin; /* Window to enter arguments */
extern window_t *curwin; /* Current window */
extern window_t wholescreen; /* The whole screen */
extern window_t paramwin; /* Window to enter arguments */
/*
* Copy-and-paste clipboard.
@@ -162,7 +162,7 @@ typedef struct {
int ncolumns; /* Number of columns */
} clipboard_t;
clipboard_t *pickbuf, *deletebuf;
extern clipboard_t *pickbuf, *deletebuf;
/*
* Control codes.
@@ -200,19 +200,19 @@ clipboard_t *pickbuf, *deletebuf;
#define CCQUIT 0177 /* terminate session ^X ^C */
#define CCINTRUP 0237 /* interrupt (journal) */
int cursorline; /* physical position of */
int cursorcol; /* cursor from (0,0)=ulhc of text in window */
extern int cursorline; /* physical position of */
extern int cursorcol; /* cursor from (0,0)=ulhc of text in window */
int NCOLS, NLINES; /* size of the screen */
extern int NCOLS, NLINES; /* size of the screen */
extern char *curspos, *cvtout[];
extern char cntlmotions[];
extern const char in0tab[]; /* input control codes */
extern int keysym; /* Current input symbol, -1 - need more */
char intrflag; /* INTR signal occured */
int highlight_position; /* Highlight the current cursor position */
int message_displayed; /* Arg area contains an error message */
extern int keysym; /* Current input symbol, -1 - need more */
extern char intrflag; /* INTR signal occured */
extern int highlight_position; /* Highlight the current cursor position */
extern int message_displayed; /* Arg area contains an error message */
/* Defaults. */
extern int defloffset, defroffset;
@@ -226,33 +226,31 @@ extern char deffile[];
* param_c0, param_r0, param_c1,
* param_r1 - coordinates of cursor-defined area
*/
int param_len;
char *param_str, param_type;
int param_c0, param_r0, param_c1, param_r1;
extern int param_len;
extern char *param_str, param_type;
extern int param_c0, param_r0, param_c1, param_r1;
/*
* Current line.
*/
char *cline; /* allocated array */
int cline_max; /* allocated length */
int cline_len; /* used length */
int cline_incr; /* increment for reallocation */
char cline_modified; /* line was modified */
int clineno; /* line number in file */
extern char *cline; /* allocated array */
extern int cline_max; /* allocated length */
extern int cline_len; /* used length */
extern int cline_incr; /* increment for reallocation */
extern char cline_modified; /* line was modified */
extern int clineno; /* line number in file */
/*
* File descriptors:
*/
int tempfile; /* Temporary file */
off_t tempseek; /* Offset in temporary file */
int journal; /* Journaling file */
int inputfile; /* Input file (stdin or journal) */
extern int tempfile; /* Temporary file */
extern off_t tempseek; /* Offset in temporary file */
extern int journal; /* Journaling file */
extern int inputfile; /* Input file (stdin or journal) */
char *searchkey;
extern int userid, groupid;
int userid, groupid;
char *tmpname; /* name of file, for do command */
extern char *tmpname; /* name of file, for do command */
/*
* Translation of control codes to escape sequences.

View File

@@ -6,6 +6,21 @@
*/
#include "r.defs.h"
/*
* Global variables for param().
* param_len - length of the parameter;
* param_str - string value of the parameter,
* param_type - type of the parameter,
* param_c0, param_r0, param_c1,
* param_r1 - coordinates of cursor-defined area
*/
int param_len;
char *param_str, param_type;
int param_c0, param_r0, param_c1, param_r1;
int highlight_position; /* Highlight the current cursor position */
int message_displayed; /* Arg area contains an error message */
/*
* Draw lines from lo to lf.
* In case lo is negative:

View File

@@ -22,6 +22,9 @@ static int buf_count; /* Number of valid bytes in read_buf */
static int buf_next; /* Next unread index in read_buf */
static int cline_read_offset; /* Offset of next unread symbol */
file_t file[MAXFILES]; /* Table of files */
int curfile;
/*
* Setup for a cline_read routine to read a given file starting
* from a given offset.

View File

@@ -6,6 +6,22 @@
*/
#include "r.defs.h"
int NCOLS, NLINES; /* size of the screen */
char intrflag; /* INTR signal occured */
int tempfile; /* Temporary file */
off_t tempseek; /* Offset in temporary file */
char *tmpname; /* name of file, for do command */
workspace_t *curwksp, *pickwksp;
clipboard_t *pickbuf, *deletebuf;
window_t *curwin; /* Current window */
window_t wholescreen; /* The whole screen */
window_t paramwin; /* Window to enter arguments */
window_t *winlist[MAXWINLIST];
int nwinlist;
/*
* Output codes
*/

View File

@@ -29,15 +29,22 @@ char deffile[] = "/share/re.help"; /* Help file */
/* Initial values. */
int cline_max = 0;
int cline_incr = 20; /* Increment for line expand */
int cline_incr = 20; /* Increment for line expand */
int clineno = -1;
char cline_modified = 0;
char *cline; /* allocated array */
int cline_len; /* used length */
int journal = -1; /* File descriptor for a journal */
int inputfile = 0; /* Journal or stdin */
int oldttmode; /* Saved access mode of /dev/tty */
int userid, groupid;
int cursorline; /* physical position of */
int cursorcol; /* cursor from (0,0)=ulhc of text in window */
static char *ttynm, *jname, *rfile;
static clipboard_t pb, db;

View File

@@ -9,12 +9,35 @@
#include <stdlib.h>
#include <pwd.h>
#include <errno.h>
#include <string.h>
int
donice(which, who, prio)
int which, who, prio;
{
int oldprio;
errno = 0, oldprio = getpriority(which, who);
if (oldprio == -1 && errno) {
fprintf(stderr, "renice: %d: ", who);
perror("getpriority");
return (1);
}
if (setpriority(which, who, prio) < 0) {
fprintf(stderr, "renice: %d: ", who);
perror("setpriority");
return (1);
}
printf("%d: old priority %d, new priority %d\n", who, oldprio, prio);
return (0);
}
/*
* Change the priority (nice) of processes
* or groups of processes which are already
* running.
*/
int
main(argc, argv)
char **argv;
{
@@ -67,23 +90,3 @@ main(argc, argv)
}
exit(errs != 0);
}
donice(which, who, prio)
int which, who, prio;
{
int oldprio;
errno = 0, oldprio = getpriority(which, who);
if (oldprio == -1 && errno) {
fprintf(stderr, "renice: %d: ", who);
perror("getpriority");
return (1);
}
if (setpriority(which, who, prio) < 0) {
fprintf(stderr, "renice: %d: ", who);
perror("setpriority");
return (1);
}
printf("%d: old priority %d, new priority %d\n", who, oldprio, prio);
return (0);
}

View File

@@ -11,7 +11,8 @@ LIBS += -ltermcap
all: $(BIN)
$(BIN): ${SRCS}
${LD} ${LDFLAGS} -o $(BIN).elf $(SRCS) ${LIBS}
${CC} ${CFLAGS} -c -o $(OBJS) $(SRCS)
${LD} ${LDFLAGS} -o $(BIN).elf $(OBJS) ${LIBS}
${SIZE} $(BIN).elf
${OBJDUMP} -S $(BIN).elf > $(BIN).dis
${ELF2AOUT} $(BIN).elf $@ && rm $(BIN).elf

View File

@@ -2,7 +2,7 @@ TOPSRC = $(shell cd ../../..; pwd)
include $(TOPSRC)/target.mk
#include $(TOPSRC)/cross.mk
CFLAGS += -Os -Wall -Werror
CFLAGS += -Os -Wall -Werror -DNDEBUG
OBJS = scm.o func.o
TESTS = tests/*.scm

View File

@@ -21,7 +21,6 @@ SECTIONS
/* Read-only sections, merged into text segment: */
PROVIDE (__executable_start = 0x7f008000); . = 0x7f008000;
.interp : { *(.interp) }
/*.reginfo : { *(.reginfo) }*/
.note.gnu.build-id : { *(.note.gnu.build-id) }
.dynamic : { *(.dynamic) }
.hash : { *(.hash) }
@@ -77,6 +76,7 @@ SECTIONS
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.mips16.fn.*) *(.mips16.call.*)
. = ALIGN(32*2 / 8);
} =0
.fini :
{
@@ -163,10 +163,8 @@ SECTIONS
SORT(CONSTRUCTORS)
}
.data1 : { *(.data1) }
.got.plt : { *(.got.plt) }
. = .;
_gp = ALIGN(16) + 0x7ff0;
.got : { *(.got) }
/* We want the small data sections together, so single-instruction offsets
can access them all, and initialized data all before uninitialized, so
we can shorten the on-disk segment size. */