Update cmd/re and scm.
This commit is contained in:
@@ -35,6 +35,8 @@
|
|||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#define PF(f, func) { \
|
#define PF(f, func) { \
|
||||||
if (fieldwidth) \
|
if (fieldwidth) \
|
||||||
@@ -232,7 +234,7 @@ escape(fmt)
|
|||||||
register int value;
|
register int value;
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
for (store = fmt; c = *fmt; ++fmt, ++store) {
|
for (store = fmt; (c = *fmt); ++fmt, ++store) {
|
||||||
if (c != '\\') {
|
if (c != '\\') {
|
||||||
*store = c;
|
*store = c;
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
#include "r.defs.h"
|
#include "r.defs.h"
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
static char *searchkey;
|
||||||
|
|
||||||
static int insert_mode = 1; /* Insert mode */
|
static int insert_mode = 1; /* Insert mode */
|
||||||
static int clr_arg_area; /* Need to erase the arg area */
|
static int clr_arg_area; /* Need to erase the arg area */
|
||||||
static int fname_cvt_flag; /* Disable filename conversion on "re -" */
|
static int fname_cvt_flag; /* Disable filename conversion on "re -" */
|
||||||
|
|||||||
@@ -104,8 +104,8 @@ typedef struct {
|
|||||||
int nlines; /* Number of non-empty lines in file */
|
int nlines; /* Number of non-empty lines in file */
|
||||||
} file_t;
|
} file_t;
|
||||||
|
|
||||||
file_t file[MAXFILES]; /* Table of files */
|
extern file_t file[MAXFILES]; /* Table of files */
|
||||||
int curfile;
|
extern int curfile;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Workspace describes a generic file under edit.
|
* Workspace describes a generic file under edit.
|
||||||
@@ -121,7 +121,7 @@ typedef struct {
|
|||||||
int cursorrow; /* Saved cursorline, when not active */
|
int cursorrow; /* Saved cursorline, when not active */
|
||||||
} workspace_t;
|
} workspace_t;
|
||||||
|
|
||||||
workspace_t *curwksp, *pickwksp;
|
extern workspace_t *curwksp, *pickwksp;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Window - a region on the display.
|
* Window - a region on the display.
|
||||||
@@ -146,12 +146,12 @@ typedef struct {
|
|||||||
char *rightbar; /* Symbols on right edge */
|
char *rightbar; /* Symbols on right edge */
|
||||||
} window_t;
|
} window_t;
|
||||||
|
|
||||||
window_t *winlist[MAXWINLIST];
|
extern window_t *winlist[MAXWINLIST];
|
||||||
int nwinlist;
|
extern int nwinlist;
|
||||||
|
|
||||||
window_t *curwin; /* Current window */
|
extern window_t *curwin; /* Current window */
|
||||||
window_t wholescreen; /* The whole screen */
|
extern window_t wholescreen; /* The whole screen */
|
||||||
window_t paramwin; /* Window to enter arguments */
|
extern window_t paramwin; /* Window to enter arguments */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy-and-paste clipboard.
|
* Copy-and-paste clipboard.
|
||||||
@@ -162,7 +162,7 @@ typedef struct {
|
|||||||
int ncolumns; /* Number of columns */
|
int ncolumns; /* Number of columns */
|
||||||
} clipboard_t;
|
} clipboard_t;
|
||||||
|
|
||||||
clipboard_t *pickbuf, *deletebuf;
|
extern clipboard_t *pickbuf, *deletebuf;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Control codes.
|
* Control codes.
|
||||||
@@ -200,19 +200,19 @@ clipboard_t *pickbuf, *deletebuf;
|
|||||||
#define CCQUIT 0177 /* terminate session ^X ^C */
|
#define CCQUIT 0177 /* terminate session ^X ^C */
|
||||||
#define CCINTRUP 0237 /* interrupt (journal) */
|
#define CCINTRUP 0237 /* interrupt (journal) */
|
||||||
|
|
||||||
int cursorline; /* physical position of */
|
extern int cursorline; /* physical position of */
|
||||||
int cursorcol; /* cursor from (0,0)=ulhc of text in window */
|
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 *curspos, *cvtout[];
|
||||||
extern char cntlmotions[];
|
extern char cntlmotions[];
|
||||||
extern const char in0tab[]; /* input control codes */
|
extern const char in0tab[]; /* input control codes */
|
||||||
|
|
||||||
extern int keysym; /* Current input symbol, -1 - need more */
|
extern int keysym; /* Current input symbol, -1 - need more */
|
||||||
char intrflag; /* INTR signal occured */
|
extern char intrflag; /* INTR signal occured */
|
||||||
int highlight_position; /* Highlight the current cursor position */
|
extern int highlight_position; /* Highlight the current cursor position */
|
||||||
int message_displayed; /* Arg area contains an error message */
|
extern int message_displayed; /* Arg area contains an error message */
|
||||||
|
|
||||||
/* Defaults. */
|
/* Defaults. */
|
||||||
extern int defloffset, defroffset;
|
extern int defloffset, defroffset;
|
||||||
@@ -226,33 +226,31 @@ extern char deffile[];
|
|||||||
* param_c0, param_r0, param_c1,
|
* param_c0, param_r0, param_c1,
|
||||||
* param_r1 - coordinates of cursor-defined area
|
* param_r1 - coordinates of cursor-defined area
|
||||||
*/
|
*/
|
||||||
int param_len;
|
extern int param_len;
|
||||||
char *param_str, param_type;
|
extern char *param_str, param_type;
|
||||||
int param_c0, param_r0, param_c1, param_r1;
|
extern int param_c0, param_r0, param_c1, param_r1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Current line.
|
* Current line.
|
||||||
*/
|
*/
|
||||||
char *cline; /* allocated array */
|
extern char *cline; /* allocated array */
|
||||||
int cline_max; /* allocated length */
|
extern int cline_max; /* allocated length */
|
||||||
int cline_len; /* used length */
|
extern int cline_len; /* used length */
|
||||||
int cline_incr; /* increment for reallocation */
|
extern int cline_incr; /* increment for reallocation */
|
||||||
char cline_modified; /* line was modified */
|
extern char cline_modified; /* line was modified */
|
||||||
int clineno; /* line number in file */
|
extern int clineno; /* line number in file */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* File descriptors:
|
* File descriptors:
|
||||||
*/
|
*/
|
||||||
int tempfile; /* Temporary file */
|
extern int tempfile; /* Temporary file */
|
||||||
off_t tempseek; /* Offset in temporary file */
|
extern off_t tempseek; /* Offset in temporary file */
|
||||||
int journal; /* Journaling file */
|
extern int journal; /* Journaling file */
|
||||||
int inputfile; /* Input file (stdin or journal) */
|
extern int inputfile; /* Input file (stdin or journal) */
|
||||||
|
|
||||||
char *searchkey;
|
extern int userid, groupid;
|
||||||
|
|
||||||
int userid, groupid;
|
extern char *tmpname; /* name of file, for do command */
|
||||||
|
|
||||||
char *tmpname; /* name of file, for do command */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Translation of control codes to escape sequences.
|
* Translation of control codes to escape sequences.
|
||||||
|
|||||||
@@ -6,6 +6,21 @@
|
|||||||
*/
|
*/
|
||||||
#include "r.defs.h"
|
#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.
|
* Draw lines from lo to lf.
|
||||||
* In case lo is negative:
|
* In case lo is negative:
|
||||||
|
|||||||
@@ -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 buf_next; /* Next unread index in read_buf */
|
||||||
static int cline_read_offset; /* Offset of next unread symbol */
|
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
|
* Setup for a cline_read routine to read a given file starting
|
||||||
* from a given offset.
|
* from a given offset.
|
||||||
|
|||||||
@@ -6,6 +6,22 @@
|
|||||||
*/
|
*/
|
||||||
#include "r.defs.h"
|
#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
|
* Output codes
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -29,15 +29,22 @@ char deffile[] = "/share/re.help"; /* Help file */
|
|||||||
|
|
||||||
/* Initial values. */
|
/* Initial values. */
|
||||||
int cline_max = 0;
|
int cline_max = 0;
|
||||||
int cline_incr = 20; /* Increment for line expand */
|
int cline_incr = 20; /* Increment for line expand */
|
||||||
int clineno = -1;
|
int clineno = -1;
|
||||||
char cline_modified = 0;
|
char cline_modified = 0;
|
||||||
|
char *cline; /* allocated array */
|
||||||
|
int cline_len; /* used length */
|
||||||
|
|
||||||
int journal = -1; /* File descriptor for a journal */
|
int journal = -1; /* File descriptor for a journal */
|
||||||
int inputfile = 0; /* Journal or stdin */
|
int inputfile = 0; /* Journal or stdin */
|
||||||
|
|
||||||
int oldttmode; /* Saved access mode of /dev/tty */
|
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 char *ttynm, *jname, *rfile;
|
||||||
static clipboard_t pb, db;
|
static clipboard_t pb, db;
|
||||||
|
|
||||||
|
|||||||
@@ -9,12 +9,35 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <errno.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
|
* Change the priority (nice) of processes
|
||||||
* or groups of processes which are already
|
* or groups of processes which are already
|
||||||
* running.
|
* running.
|
||||||
*/
|
*/
|
||||||
|
int
|
||||||
main(argc, argv)
|
main(argc, argv)
|
||||||
char **argv;
|
char **argv;
|
||||||
{
|
{
|
||||||
@@ -67,23 +90,3 @@ main(argc, argv)
|
|||||||
}
|
}
|
||||||
exit(errs != 0);
|
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);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ LIBS += -ltermcap
|
|||||||
all: $(BIN)
|
all: $(BIN)
|
||||||
|
|
||||||
$(BIN): ${SRCS}
|
$(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
|
${SIZE} $(BIN).elf
|
||||||
${OBJDUMP} -S $(BIN).elf > $(BIN).dis
|
${OBJDUMP} -S $(BIN).elf > $(BIN).dis
|
||||||
${ELF2AOUT} $(BIN).elf $@ && rm $(BIN).elf
|
${ELF2AOUT} $(BIN).elf $@ && rm $(BIN).elf
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ TOPSRC = $(shell cd ../../..; pwd)
|
|||||||
include $(TOPSRC)/target.mk
|
include $(TOPSRC)/target.mk
|
||||||
#include $(TOPSRC)/cross.mk
|
#include $(TOPSRC)/cross.mk
|
||||||
|
|
||||||
CFLAGS += -Os -Wall -Werror
|
CFLAGS += -Os -Wall -Werror -DNDEBUG
|
||||||
|
|
||||||
OBJS = scm.o func.o
|
OBJS = scm.o func.o
|
||||||
TESTS = tests/*.scm
|
TESTS = tests/*.scm
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ SECTIONS
|
|||||||
/* Read-only sections, merged into text segment: */
|
/* Read-only sections, merged into text segment: */
|
||||||
PROVIDE (__executable_start = 0x7f008000); . = 0x7f008000;
|
PROVIDE (__executable_start = 0x7f008000); . = 0x7f008000;
|
||||||
.interp : { *(.interp) }
|
.interp : { *(.interp) }
|
||||||
/*.reginfo : { *(.reginfo) }*/
|
|
||||||
.note.gnu.build-id : { *(.note.gnu.build-id) }
|
.note.gnu.build-id : { *(.note.gnu.build-id) }
|
||||||
.dynamic : { *(.dynamic) }
|
.dynamic : { *(.dynamic) }
|
||||||
.hash : { *(.hash) }
|
.hash : { *(.hash) }
|
||||||
@@ -77,6 +76,7 @@ SECTIONS
|
|||||||
/* .gnu.warning sections are handled specially by elf32.em. */
|
/* .gnu.warning sections are handled specially by elf32.em. */
|
||||||
*(.gnu.warning)
|
*(.gnu.warning)
|
||||||
*(.mips16.fn.*) *(.mips16.call.*)
|
*(.mips16.fn.*) *(.mips16.call.*)
|
||||||
|
. = ALIGN(32*2 / 8);
|
||||||
} =0
|
} =0
|
||||||
.fini :
|
.fini :
|
||||||
{
|
{
|
||||||
@@ -163,10 +163,8 @@ SECTIONS
|
|||||||
SORT(CONSTRUCTORS)
|
SORT(CONSTRUCTORS)
|
||||||
}
|
}
|
||||||
.data1 : { *(.data1) }
|
.data1 : { *(.data1) }
|
||||||
.got.plt : { *(.got.plt) }
|
|
||||||
. = .;
|
. = .;
|
||||||
_gp = ALIGN(16) + 0x7ff0;
|
_gp = ALIGN(16) + 0x7ff0;
|
||||||
.got : { *(.got) }
|
|
||||||
/* We want the small data sections together, so single-instruction offsets
|
/* We want the small data sections together, so single-instruction offsets
|
||||||
can access them all, and initialized data all before uninitialized, so
|
can access them all, and initialized data all before uninitialized, so
|
||||||
we can shorten the on-disk segment size. */
|
we can shorten the on-disk segment size. */
|
||||||
|
|||||||
Reference in New Issue
Block a user