mirror of
https://github.com/rfivet/uemacs.git
synced 2025-11-23 11:41:15 -05:00
Compare commits
150 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fa96d9e63e | |||
| 4918da601c | |||
| 45f138ac07 | |||
| 15453a9d52 | |||
| bcba236265 | |||
| b59a47bb3a | |||
| b86ceeaf5e | |||
| db30d6d734 | |||
| 575659b1c1 | |||
| 9682cdb2d2 | |||
| 06b0d3f00d | |||
| d3b02af275 | |||
| f13ae3957c | |||
| 7f5f0dd7b3 | |||
| 198980b81f | |||
| ce4d105794 | |||
| 3ffa8967ef | |||
| cbbd860bdc | |||
| cfa5c7fb65 | |||
| b5eb424ad0 | |||
| 2c9cbbfb1e | |||
| e0550db4d1 | |||
| c3f4666ff3 | |||
| 8d412dc388 | |||
| 51967939b8 | |||
| 1ab601071e | |||
| 6b3061cedb | |||
| 02d12c5d84 | |||
| 84bf4de212 | |||
| c10b525fb5 | |||
| 2522a858c1 | |||
| dfc9a50fcf | |||
| 4d19ef668a | |||
| 26f0f2eb8b | |||
| 405d8683dc | |||
| 90c170e200 | |||
| 4a0759fa89 | |||
| 783ad9c2f0 | |||
| 1adae6bead | |||
| 6dfc2f057e | |||
| 42d4a6be70 | |||
| 0dc28967b5 | |||
| af919c3f9c | |||
| 267c218b9b | |||
| 4ac1913cd1 | |||
| e3b6d1e076 | |||
| 8597e3adcd | |||
| 247fcfdfb8 | |||
| ac267617ae | |||
| cfed6fdddf | |||
| 5a900d59e6 | |||
| e34c15741e | |||
| 4042ebe3d1 | |||
| f8eb3531a4 | |||
| 66649313ae | |||
| 8502fb66c6 | |||
| 70a5812928 | |||
| d57257d653 | |||
| 7f7cc5b6fd | |||
| 9b40894342 | |||
| 8de64f81be | |||
| eb7217f8ec | |||
| b1cc7bfe3a | |||
| 911b4cd402 | |||
| d01649bf3a | |||
| f97746a87b | |||
| 5f9de6bb89 | |||
| d56b3af45a | |||
| 87350f4c16 | |||
| 80cbd37f5c | |||
| e8bb7b1ea2 | |||
| 61f5fe7e2d | |||
| 4b2c50f6d2 | |||
| e2be62323b | |||
| e556f7714b | |||
| 2b8992350d | |||
| c10c550bdd | |||
| 115d9babae | |||
| fbe92a1f52 | |||
| 703c472f0b | |||
| bb44fc57ad | |||
| 2953531913 | |||
| 5e5558e00b | |||
| 6021a22b60 | |||
| f8df147015 | |||
| e13bc9ca7e | |||
| b2306e379d | |||
| a68c05ed77 | |||
| cbb6a26e33 | |||
| 5401aec485 | |||
| 7da7916b28 | |||
| 3f1ac2596c | |||
| 135238106c | |||
| 356a003194 | |||
| bdbd2d5437 | |||
| 2cef071492 | |||
| 4cbf1e9ae1 | |||
| a2d1b54c61 | |||
| de04424e51 | |||
| 83b323272d | |||
| 91455a2e5a | |||
| 7c74bfdc1a | |||
| a6a8936b8d | |||
| ebe4b9b2cc | |||
| 639d912c88 | |||
| bc90c36603 | |||
| fe1eaf7348 | |||
| 7018880551 | |||
| 5a235ecf8c | |||
| 09d5907f9e | |||
| daa6395128 | |||
| 15ae2d4135 | |||
| 891f4c3238 | |||
| b101f703c0 | |||
| fbfaa29497 | |||
| 4ca3f53385 | |||
| 36f24332c2 | |||
| f60e3fbc9f | |||
| 5fda2735a5 | |||
| 434c9ba7ab | |||
| 01a84a3ac0 | |||
| e3c8805260 | |||
| 259de639e4 | |||
| 84919039a5 | |||
| a634ae5087 | |||
| f8c405f501 | |||
| 63776bb3f8 | |||
| 3ce31669ae | |||
| 57e5338ebd | |||
| 4070a97fc9 | |||
| a6669903b2 | |||
| 8ddc8676ef | |||
| b596a3a09c | |||
| d2d3581e74 | |||
| 5756354dd5 | |||
| 534da43d08 | |||
| e096092d5b | |||
| 48ea9279a6 | |||
| 923d7bdc8e | |||
| c64d4ad381 | |||
| 20d21435e0 | |||
| b6bd5c2927 | |||
| 5f7a1aa1a9 | |||
| 8de97e3323 | |||
| f0874a8497 | |||
| 7e8654faa1 | |||
| 14bfe4fa5f | |||
| 3a67809c74 | |||
| bdd71519c4 | |||
|
|
8841922689 |
149
Makefile
149
Makefile
@@ -1,8 +1,8 @@
|
||||
# Makefile for emacs, updated Mon, Nov 17, 2014 1:05:02 PM
|
||||
# Makefile for emacs, updated Fri, Feb 13, 2015 12:02:52 PM
|
||||
|
||||
SRC=ansi.c basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c ibmpc.c input.c isearch.c line.c lock.c log.c main.c mingw32.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c vmsvt.c vt52.c window.c word.c wrapper.c wscreen.c
|
||||
OBJ=ansi.o basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o ibmpc.o input.o isearch.o line.o lock.o log.o main.o mingw32.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o vmsvt.o vt52.o window.o word.o wrapper.o wscreen.o
|
||||
HDR=basic.h bind.h bindable.h buffer.h crypt.h defines.h display.h ebind.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h log.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h version.h window.h word.h wrapper.h wscreen.h
|
||||
SRC=basic.c bind.c bindable.c buffer.c crypt.c display.c ebind.c eval.c exec.c execute.c file.c fileio.c flook.c input.c isearch.c line.c lock.c main.c mingw32.c mlout.c names.c pklock.c posix.c random.c region.c search.c spawn.c tcap.c termio.c utf8.c window.c word.c wrapper.c wscreen.c
|
||||
OBJ=basic.o bind.o bindable.o buffer.o crypt.o display.o ebind.o eval.o exec.o execute.o file.o fileio.o flook.o input.o isearch.o line.o lock.o main.o mingw32.o mlout.o names.o pklock.o posix.o random.o region.o search.o spawn.o tcap.o termio.o utf8.o window.o word.o wrapper.o wscreen.o
|
||||
HDR=basic.h bind.h bindable.h buffer.h crypt.h defines.h display.h ebind.h estruct.h eval.h exec.h execute.h file.h fileio.h flook.h input.h isearch.h line.h lock.h mlout.h names.h pklock.h random.h region.h retcode.h search.h spawn.h terminal.h termio.h utf8.h version.h window.h word.h wrapper.h wscreen.h
|
||||
|
||||
# DO NOT ADD OR MODIFY ANY LINES ABOVE THIS -- make source creates them
|
||||
|
||||
@@ -19,18 +19,22 @@ endif
|
||||
export E Q
|
||||
|
||||
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
|
||||
# for windows based target, insure we strip the variant part
|
||||
# CYGWIN_NT-6.1, CYGWIN_NT-6.1-WOW, CYGWIN_NT-6.1-WOW64, MINGW32_NT-6.1
|
||||
uname_S := $(shell sh -c 'echo $(uname_S) | sed s/_.*$$//')
|
||||
|
||||
PROGRAM=ue
|
||||
|
||||
CC=gcc
|
||||
WARNINGS=-Wall -Wstrict-prototypes
|
||||
WARNINGS=-Wall -Wextra -Wstrict-prototypes -Wno-unused-parameter
|
||||
CFLAGS=-O2 $(WARNINGS)
|
||||
#CC=c89 +O3 # HP
|
||||
#CFLAGS= -D_HPUX_SOURCE -DSYSV
|
||||
#CFLAGS=-O4 -DSVR4 # Sun
|
||||
#CFLAGS=-O -qchars=signed # RS/6000
|
||||
ifeq ($(uname_S),Linux)
|
||||
DEFINES=-DAUTOCONF -DPOSIX -DUSG -D_BSD_SOURCE -D_SVID_SOURCE -D_XOPEN_SOURCE=600
|
||||
DEFINES=-DAUTOCONF -DPROGRAM=$(PROGRAM) -DPOSIX -DUSG -D_BSD_SOURCE -D_SVID_SOURCE -D_XOPEN_SOURCE=600
|
||||
LIBS=-lcurses
|
||||
endif
|
||||
ifeq ($(uname_S),FreeBSD)
|
||||
DEFINES=-DAUTOCONF -DPOSIX -DSYSV -D_FREEBSD_C_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_XOPEN_SOURCE=600
|
||||
@@ -38,15 +42,11 @@ endif
|
||||
ifeq ($(uname_S),Darwin)
|
||||
DEFINES=-DAUTOCONF -DPOSIX -DSYSV -D_DARWIN_C_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE -D_XOPEN_SOURCE=600
|
||||
endif
|
||||
ifeq ($(uname_S),CYGWIN_NT-6.1-WOW64)
|
||||
DEFINES=-DAUTOCONF -DCYGWIN -DPROGRAM=$(PROGRAM)
|
||||
LIBS=-lcurses # SYSV
|
||||
ifeq ($(uname_S),CYGWIN)
|
||||
DEFINES=-DAUTOCONF -DCYGWIN -DPOSIX -DSYSV -DPROGRAM=$(PROGRAM)
|
||||
LIBS=-lcurses
|
||||
endif
|
||||
ifeq ($(uname_S),CYGWIN_NT-6.1)
|
||||
DEFINES=-DAUTOCONF -DCYGWIN -DPROGRAM=$(PROGRAM)
|
||||
LIBS=-lcurses # SYSV
|
||||
endif
|
||||
ifeq ($(uname_S),MINGW32_NT-6.1)
|
||||
ifeq ($(uname_S),MINGW32)
|
||||
DEFINES=-DAUTOCONF -DSYSV -DMINGW32 -DPROGRAM=$(PROGRAM)
|
||||
LIBS=
|
||||
endif
|
||||
@@ -86,6 +86,9 @@ lint: ${SRC}
|
||||
lint ${LFLAGS} ${SRC} >lintout
|
||||
cat lintout
|
||||
|
||||
splint:
|
||||
splint -weak $(DEFINES) $(SRC) -booltype boolean -booltrue TRUE -boolfalse FALSE +posixlib +matchanyintegral
|
||||
|
||||
errs:
|
||||
@rm -f makeout
|
||||
make $(PROGRAM) >makeout
|
||||
@@ -98,111 +101,101 @@ source:
|
||||
@mv Makefile Makefile.bak
|
||||
@echo "# Makefile for emacs, updated `date`" >Makefile
|
||||
@echo '' >>Makefile
|
||||
#Sorted
|
||||
@echo SRC=`ls *.c` >>Makefile
|
||||
@echo OBJ=`ls *.c | sed s/c$$/o/` >>Makefile
|
||||
@echo HDR=`ls *.h` >>Makefile
|
||||
#UnSorted
|
||||
# @echo SRC=$(wildcard *.c) >>Makefile
|
||||
# @echo OBJ=$(patsubst %.c,%.o,$(wildcard *.c)) >>Makefile
|
||||
# @echo HDR=$(wildcard *.h) >>Makefile
|
||||
@echo '' >>Makefile
|
||||
@sed -n -e '/^# DO NOT ADD OR MODIFY/,$$p' <Makefile.bak >>Makefile
|
||||
|
||||
depend: ${SRC}
|
||||
@mv Makefile Makefile.bak
|
||||
@sed -n -e '1,/^# DO NOT DELETE THIS LINE/p' Makefile.bak > Makefile
|
||||
@echo >> Makefile
|
||||
@for i in ${SRC}; do\
|
||||
cc ${DEFINES} -MM $$i ; done >makedep
|
||||
@echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
|
||||
@echo '$$r ./makedep' >>eddep
|
||||
@echo 'w' >>eddep
|
||||
@cp Makefile Makefile.bak
|
||||
@ed - Makefile <eddep
|
||||
@rm eddep makedep
|
||||
cc ${DEFINES} -MM $$i ; done >> Makefile
|
||||
@echo '' >>Makefile
|
||||
@echo '# DEPENDENCIES MUST END AT END OF FILE' >>Makefile
|
||||
@echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >>Makefile
|
||||
@echo '# see make depend above' >>Makefile
|
||||
|
||||
# @for i in ${SRC}; do\
|
||||
# cc ${DEFINES} -M $$i | sed -e 's, \./, ,' | grep -v '/usr/include' | \
|
||||
# awk '{ if ($$1 != prev) { if (rec != "") print rec; \
|
||||
# rec = $$0; prev = $$1; } \
|
||||
# else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
|
||||
# else rec = rec " " $$2 } } \
|
||||
# END { print rec }'; done >makedep
|
||||
|
||||
.c.o:
|
||||
$(E) " CC " $@
|
||||
$(Q) ${CC} ${CFLAGS} ${DEFINES} -c $*.c
|
||||
|
||||
# DO NOT DELETE THIS LINE -- make depend uses it
|
||||
|
||||
ansi.o: ansi.c estruct.h
|
||||
basic.o: basic.c basic.h buffer.h crypt.h line.h utf8.h display.h \
|
||||
estruct.h input.h bind.h random.h terminal.h defines.h retcode.h \
|
||||
window.h
|
||||
bind.o: bind.c bind.h estruct.h bindable.h buffer.h crypt.h line.h utf8.h \
|
||||
display.h ebind.h exec.h retcode.h file.h flook.h input.h names.h \
|
||||
basic.o: basic.c basic.h buffer.h crypt.h line.h retcode.h utf8.h \
|
||||
estruct.h input.h bind.h mlout.h random.h terminal.h defines.h window.h
|
||||
bind.o: bind.c bind.h estruct.h bindable.h buffer.h crypt.h line.h \
|
||||
retcode.h utf8.h display.h ebind.h exec.h file.h flook.h input.h names.h \
|
||||
window.h defines.h
|
||||
bindable.o: bindable.c bindable.h defines.h buffer.h crypt.h line.h \
|
||||
utf8.h display.h estruct.h file.h retcode.h input.h bind.h lock.h \
|
||||
terminal.h
|
||||
buffer.o: buffer.c buffer.h crypt.h line.h utf8.h defines.h display.h \
|
||||
estruct.h file.h retcode.h input.h bind.h window.h
|
||||
retcode.h utf8.h display.h estruct.h file.h input.h bind.h lock.h \
|
||||
mlout.h terminal.h
|
||||
buffer.o: buffer.c buffer.h crypt.h line.h retcode.h utf8.h defines.h \
|
||||
estruct.h file.h input.h bind.h mlout.h window.h
|
||||
crypt.o: crypt.c crypt.h
|
||||
display.o: display.c display.h buffer.h crypt.h line.h utf8.h estruct.h \
|
||||
input.h bind.h termio.h terminal.h defines.h retcode.h version.h \
|
||||
display.o: display.c display.h estruct.h buffer.h crypt.h line.h \
|
||||
retcode.h utf8.h input.h bind.h termio.h terminal.h defines.h version.h \
|
||||
wrapper.h window.h
|
||||
ebind.o: ebind.c ebind.h basic.h bind.h estruct.h bindable.h buffer.h \
|
||||
crypt.h line.h utf8.h eval.h exec.h retcode.h file.h isearch.h random.h \
|
||||
crypt.h line.h retcode.h utf8.h eval.h exec.h file.h isearch.h random.h \
|
||||
region.h search.h spawn.h window.h defines.h word.h
|
||||
eval.o: eval.c eval.h basic.h bind.h buffer.h crypt.h line.h utf8.h \
|
||||
display.h estruct.h exec.h retcode.h execute.h flook.h input.h random.h \
|
||||
eval.o: eval.c eval.h basic.h bind.h buffer.h crypt.h line.h retcode.h \
|
||||
utf8.h display.h estruct.h exec.h execute.h flook.h input.h random.h \
|
||||
search.h terminal.h defines.h termio.h version.h window.h
|
||||
exec.o: exec.c exec.h retcode.h buffer.h crypt.h line.h utf8.h bind.h \
|
||||
display.h estruct.h eval.h file.h flook.h input.h random.h window.h \
|
||||
defines.h
|
||||
execute.o: execute.c execute.h estruct.h bind.h random.h display.h file.h \
|
||||
buffer.h crypt.h line.h utf8.h retcode.h terminal.h defines.h window.h
|
||||
file.o: file.c file.h buffer.h crypt.h line.h utf8.h retcode.h defines.h \
|
||||
estruct.h execute.h fileio.h input.h bind.h lock.h log.h window.h
|
||||
fileio.o: fileio.c fileio.h crypt.h retcode.h defines.h
|
||||
buffer.h crypt.h line.h retcode.h utf8.h mlout.h window.h defines.h
|
||||
file.o: file.c file.h buffer.h crypt.h line.h retcode.h utf8.h defines.h \
|
||||
estruct.h execute.h fileio.h input.h bind.h lock.h mlout.h window.h
|
||||
fileio.o: fileio.c fileio.h crypt.h retcode.h defines.h utf8.h
|
||||
flook.o: flook.c flook.h retcode.h defines.h fileio.h crypt.h
|
||||
ibmpc.o: ibmpc.c estruct.h
|
||||
input.o: input.c input.h bind.h estruct.h bindable.h display.h exec.h \
|
||||
retcode.h names.h terminal.h defines.h wrapper.h
|
||||
isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h utf8.h \
|
||||
display.h estruct.h exec.h retcode.h input.h bind.h search.h terminal.h \
|
||||
retcode.h names.h terminal.h defines.h utf8.h wrapper.h
|
||||
isearch.o: isearch.c isearch.h basic.h buffer.h crypt.h line.h retcode.h \
|
||||
utf8.h display.h estruct.h exec.h input.h bind.h search.h terminal.h \
|
||||
defines.h window.h
|
||||
line.o: line.c line.h utf8.h buffer.h crypt.h estruct.h log.h retcode.h \
|
||||
line.o: line.c line.h retcode.h utf8.h buffer.h crypt.h estruct.h mlout.h \
|
||||
window.h defines.h
|
||||
lock.o: lock.c estruct.h lock.h
|
||||
log.o: log.c log.h retcode.h
|
||||
main.o: main.c estruct.h basic.h bind.h bindable.h buffer.h crypt.h \
|
||||
line.h utf8.h display.h eval.h execute.h file.h retcode.h input.h lock.h \
|
||||
log.h random.h search.h terminal.h defines.h termio.h version.h window.h
|
||||
mingw32.o: mingw32.c
|
||||
names.o: names.c names.h basic.h bind.h bindable.h buffer.h crypt.h \
|
||||
line.h utf8.h display.h eval.h exec.h retcode.h file.h isearch.h \
|
||||
region.h random.h search.h spawn.h window.h defines.h word.h
|
||||
pklock.o: pklock.c estruct.h pklock.h
|
||||
posix.o: posix.c termio.h
|
||||
random.o: random.c random.h basic.h buffer.h crypt.h line.h utf8.h \
|
||||
display.h estruct.h execute.h input.h bind.h log.h retcode.h search.h \
|
||||
terminal.h defines.h window.h
|
||||
region.o: region.c region.h line.h utf8.h buffer.h crypt.h estruct.h \
|
||||
log.h retcode.h random.h window.h defines.h
|
||||
search.o: search.c search.h line.h utf8.h basic.h buffer.h crypt.h \
|
||||
display.h estruct.h input.h bind.h log.h retcode.h terminal.h defines.h \
|
||||
line.h retcode.h utf8.h display.h eval.h execute.h file.h input.h lock.h \
|
||||
mlout.h random.h search.h terminal.h defines.h termio.h version.h \
|
||||
window.h
|
||||
spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h utf8.h \
|
||||
display.h estruct.h exec.h retcode.h file.h flook.h input.h bind.h log.h \
|
||||
mingw32.o: mingw32.c
|
||||
mlout.o: mlout.c mlout.h
|
||||
names.o: names.c names.h basic.h bind.h bindable.h buffer.h crypt.h \
|
||||
line.h retcode.h utf8.h display.h estruct.h eval.h exec.h file.h \
|
||||
isearch.h region.h random.h search.h spawn.h window.h defines.h word.h
|
||||
pklock.o: pklock.c estruct.h pklock.h
|
||||
posix.o: posix.c termio.h estruct.h retcode.h utf8.h
|
||||
random.o: random.c random.h basic.h buffer.h crypt.h line.h retcode.h \
|
||||
utf8.h display.h estruct.h execute.h input.h bind.h search.h terminal.h \
|
||||
defines.h window.h
|
||||
region.o: region.c region.h line.h retcode.h utf8.h buffer.h crypt.h \
|
||||
estruct.h mlout.h random.h window.h defines.h
|
||||
search.o: search.c search.h line.h retcode.h utf8.h basic.h buffer.h \
|
||||
crypt.h display.h estruct.h input.h bind.h mlout.h terminal.h defines.h \
|
||||
window.h
|
||||
spawn.o: spawn.c spawn.h defines.h buffer.h crypt.h line.h retcode.h \
|
||||
utf8.h display.h estruct.h exec.h file.h flook.h input.h bind.h \
|
||||
terminal.h window.h
|
||||
tcap.o: tcap.c terminal.h defines.h retcode.h display.h estruct.h \
|
||||
termio.h
|
||||
termio.o: termio.c termio.h estruct.h retcode.h utf8.h
|
||||
termio.o: termio.c
|
||||
utf8.o: utf8.c utf8.h
|
||||
vmsvt.o: vmsvt.c estruct.h
|
||||
vt52.o: vt52.c estruct.h
|
||||
window.o: window.c window.h defines.h buffer.h crypt.h line.h utf8.h \
|
||||
basic.h display.h estruct.h execute.h terminal.h retcode.h wrapper.h
|
||||
word.o: word.c word.h basic.h buffer.h crypt.h line.h utf8.h estruct.h \
|
||||
log.h retcode.h random.h region.h window.h defines.h
|
||||
window.o: window.c window.h defines.h buffer.h crypt.h line.h retcode.h \
|
||||
utf8.h basic.h display.h estruct.h execute.h terminal.h wrapper.h
|
||||
word.o: word.c word.h basic.h buffer.h crypt.h line.h retcode.h utf8.h \
|
||||
estruct.h mlout.h random.h region.h window.h defines.h
|
||||
wrapper.o: wrapper.c wrapper.h
|
||||
wscreen.o: wscreen.c wscreen.h
|
||||
|
||||
|
||||
38
README.md
38
README.md
@@ -1,29 +1,19 @@
|
||||
# README #
|
||||
|
||||
Cigue is ue on Cygwin, based on uEmacs/PK from kernel.org.
|
||||
Ciguë is µEMACS (ue) on Cygwin/Linux, based on uEmacs/PK (em) from kernel.org.
|
||||
|
||||
### What is this repository for? ###
|
||||
### Changes compare to uEmacs/PK ###
|
||||
* Line termination detection with new buffer mode (either Unix or DOS).
|
||||
* Encoding detection (ASCII, Extended ASCII, UTF-8 or Mixed).
|
||||
* Some fixes related to size either unchecked or limited (strcpy, insert-string, filenames, $kill).
|
||||
* Major refactoring of headers and file dependencies, hopefully to improve maintenance.
|
||||
* Reactivation of target 'source' and 'depend' in Makefile.
|
||||
* Some defaults changed due to 'finger habits': ue instead of em, ^S in commands mapping...
|
||||
|
||||
* Quick summary
|
||||
* Version
|
||||
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
|
||||
### How to build ###
|
||||
* dependencies: ncurses.
|
||||
* make depend ; make
|
||||
* MINGW32 target is experimental and lacks screen/kbd support.
|
||||
|
||||
### How do I get set up? ###
|
||||
|
||||
* Summary of set up
|
||||
* Configuration
|
||||
* Dependencies
|
||||
* Database configuration
|
||||
* How to run tests
|
||||
* Deployment instructions
|
||||
|
||||
### Contribution guidelines ###
|
||||
|
||||
* Writing tests
|
||||
* Code review
|
||||
* Other guidelines
|
||||
|
||||
### Who do I talk to? ###
|
||||
|
||||
* Repo owner or admin
|
||||
* Other community or team contact
|
||||
### Badges ###
|
||||
[](https://scan.coverity.com/projects/4449)
|
||||
|
||||
91
basic.c
91
basic.c
@@ -19,10 +19,10 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "buffer.h"
|
||||
#include "display.h"
|
||||
#include "estruct.h"
|
||||
#include "input.h"
|
||||
#include "line.h"
|
||||
#include "mlout.h"
|
||||
#include "random.h"
|
||||
#include "terminal.h"
|
||||
#include "utf8.h"
|
||||
@@ -38,35 +38,33 @@ int curgoal ; /* Goal for C-P, C-N */
|
||||
* column, return the best choice for the offset. The offset is returned.
|
||||
* Used by "C-N" and "C-P".
|
||||
*/
|
||||
static int getgoal(struct line *dlp)
|
||||
{
|
||||
int col;
|
||||
int newcol;
|
||||
int dbo;
|
||||
int len = llength(dlp);
|
||||
static unsigned getgoal( struct line *dlp) {
|
||||
int col ;
|
||||
unsigned idx ;
|
||||
const unsigned len = llength( dlp) ;
|
||||
|
||||
col = 0;
|
||||
dbo = 0;
|
||||
while (dbo != len) {
|
||||
unicode_t c;
|
||||
int width = utf8_to_unicode(dlp->l_text, dbo, len, &c);
|
||||
newcol = col;
|
||||
col = 0 ;
|
||||
idx = 0 ;
|
||||
while( idx < len) {
|
||||
unicode_t c ;
|
||||
unsigned width = utf8_to_unicode( dlp->l_text, idx, len, &c) ;
|
||||
|
||||
/* Take tabs, ^X and \xx hex characters into account */
|
||||
if (c == '\t')
|
||||
newcol |= tabmask;
|
||||
else if (c < 0x20 || c == 0x7F)
|
||||
++newcol;
|
||||
else if (c >= 0x80 && c <= 0xa0)
|
||||
newcol += 2;
|
||||
if( c == '\t')
|
||||
col |= tabmask ;
|
||||
else if( c < 0x20 || c == 0x7F)
|
||||
col += 1 ;
|
||||
else if( c >= 0x80 && c <= 0xA0)
|
||||
col += 2 ;
|
||||
|
||||
++newcol;
|
||||
if (newcol > curgoal)
|
||||
break;
|
||||
col = newcol;
|
||||
dbo += width;
|
||||
col += 1 ;
|
||||
if( col > curgoal)
|
||||
break ;
|
||||
|
||||
idx += width ;
|
||||
}
|
||||
return dbo;
|
||||
|
||||
return idx ;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -92,24 +90,26 @@ int gotoeol(int f, int n)
|
||||
*
|
||||
* @n: The specified line position at the current buffer.
|
||||
*/
|
||||
int gotoline(int f, int n)
|
||||
{
|
||||
int status;
|
||||
char arg[NSTRING]; /* Buffer to hold argument. */
|
||||
|
||||
int gotoline( int f, int n) {
|
||||
/* Get an argument if one doesnt exist. */
|
||||
if (f == FALSE) {
|
||||
if ((status =
|
||||
mlreply("Line to GOTO: ", arg, NSTRING)) != TRUE) {
|
||||
mlwrite("(Aborted)");
|
||||
return status;
|
||||
if( f == FALSE) {
|
||||
int status ;
|
||||
char *arg ; /* Buffer to hold argument. */
|
||||
|
||||
status = newmlarg( &arg, "Line to GOTO: ", 0) ;
|
||||
if( status != TRUE) {
|
||||
mloutstr( "(Aborted)") ;
|
||||
return status ;
|
||||
}
|
||||
n = atoi(arg);
|
||||
|
||||
n = atoi( arg) ;
|
||||
free( arg) ;
|
||||
}
|
||||
/* Handle the case where the user may be passed something like this:
|
||||
* em filename +
|
||||
* In this case we just go to the end of the buffer.
|
||||
*/
|
||||
|
||||
/* Handle the case where the user may be passed something like this:
|
||||
* em filename +
|
||||
* In this case we just go to the end of the buffer.
|
||||
*/
|
||||
if (n == 0)
|
||||
return gotoeob(f, n);
|
||||
|
||||
@@ -314,8 +314,8 @@ int setmark(int f, int n)
|
||||
{
|
||||
curwp->w_markp = curwp->w_dotp;
|
||||
curwp->w_marko = curwp->w_doto;
|
||||
mlwrite("(Mark set)");
|
||||
return TRUE;
|
||||
mloutstr( "(Mark set)") ;
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -329,10 +329,11 @@ int swapmark(int f, int n)
|
||||
struct line *odotp;
|
||||
int odoto;
|
||||
|
||||
if (curwp->w_markp == NULL) {
|
||||
mlwrite("No mark in this window");
|
||||
return FALSE;
|
||||
if( curwp->w_markp == NULL) {
|
||||
mloutstr( "No mark in this window") ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
odotp = curwp->w_dotp;
|
||||
odoto = curwp->w_doto;
|
||||
curwp->w_dotp = curwp->w_markp;
|
||||
|
||||
173
bind.c
173
bind.c
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "estruct.h"
|
||||
@@ -27,8 +28,18 @@
|
||||
#include "window.h"
|
||||
|
||||
|
||||
#if APROP
|
||||
static int buildlist( char *mstring) ;
|
||||
static int strinc( char *source, char *sub) ;
|
||||
#endif
|
||||
|
||||
static void cmdstr( int c, char *seq) ;
|
||||
static unsigned int getckey( int mflag) ;
|
||||
static unsigned int stock( char *keyname) ;
|
||||
static int unbindchar( unsigned c) ;
|
||||
static char *getfname( fn_t) ;
|
||||
|
||||
|
||||
int help(int f, int n)
|
||||
{ /* give me some help!!!!
|
||||
bring up a fake buffer and read the help file
|
||||
@@ -81,7 +92,9 @@ int deskey(int f, int n)
|
||||
|
||||
/* get the command sequence to describe
|
||||
change it to something we can print as well */
|
||||
cmdstr(c = getckey(FALSE), &outseq[0]);
|
||||
c = getckey( FALSE) ;
|
||||
mlwrite( ": describe-key 0x%x, ", c) ;
|
||||
cmdstr( c, &outseq[ 0]) ;
|
||||
|
||||
/* and dump it out */
|
||||
ostring(outseq);
|
||||
@@ -221,8 +234,7 @@ int unbindkey(int f, int n)
|
||||
*
|
||||
* int c; command key to unbind
|
||||
*/
|
||||
int unbindchar(int c)
|
||||
{
|
||||
static int unbindchar( unsigned c) {
|
||||
struct key_tab *ktp; /* pointer into the command table */
|
||||
struct key_tab *sktp; /* saved pointer into the command table */
|
||||
int found; /* matched command flag */
|
||||
@@ -262,39 +274,37 @@ int unbindchar(int c)
|
||||
* bring up a fake buffer and list the key bindings
|
||||
* into it with view mode
|
||||
*/
|
||||
int desbind(int f, int n)
|
||||
int desbind( int f, int n) {
|
||||
#if APROP
|
||||
{
|
||||
buildlist(TRUE, "");
|
||||
return TRUE;
|
||||
return buildlist( "") ;
|
||||
}
|
||||
|
||||
int apro(int f, int n)
|
||||
{ /* Apropos (List functions that match a substring) */
|
||||
char mstring[NSTRING]; /* string to match cmd names to */
|
||||
int status; /* status return */
|
||||
/* Apropos (List functions that match a substring) */
|
||||
int apro( int f, int n) {
|
||||
char *mstring ; /* string to match cmd names to */
|
||||
int status ; /* status return */
|
||||
|
||||
status = mlreply("Apropos string: ", mstring, NSTRING - 1);
|
||||
if (status != TRUE)
|
||||
return status;
|
||||
status = newmlarg( &mstring, "Apropos string: ", 0) ;
|
||||
if( status == TRUE) {
|
||||
status = buildlist( mstring) ;
|
||||
free( mstring) ;
|
||||
} else if( status == FALSE)
|
||||
status = buildlist( "") ; /* build list of all commands */
|
||||
|
||||
return buildlist(FALSE, mstring);
|
||||
return status ;
|
||||
}
|
||||
|
||||
/*
|
||||
* build a binding list (limited or full)
|
||||
*
|
||||
* int type; true = full list, false = partial list
|
||||
* char *mstring; match string if a partial list
|
||||
* char *mstring; match string if a partial list, "" matches all
|
||||
*/
|
||||
int buildlist(int type, char *mstring)
|
||||
static int buildlist( char *mstring) {
|
||||
#endif
|
||||
{
|
||||
struct window *wp; /* scanning pointer to windows */
|
||||
struct key_tab *ktp; /* pointer into the command table */
|
||||
struct name_bind *nptr; /* pointer into the name binding table */
|
||||
struct buffer *bp; /* buffer to put binding list into */
|
||||
int cpos; /* current position to use in outseq */
|
||||
char outseq[80]; /* output buffer for keystroke sequence */
|
||||
|
||||
/* split the current window to make room for the binding list */
|
||||
@@ -333,20 +343,20 @@ int buildlist(int type, char *mstring)
|
||||
wp->w_marko = 0;
|
||||
|
||||
/* build the contents of this window, inserting it line by line */
|
||||
nptr = &names[0];
|
||||
while (nptr->n_func != NULL) {
|
||||
|
||||
/* add in the command name */
|
||||
strcpy(outseq, nptr->n_name);
|
||||
cpos = strlen(outseq);
|
||||
for( nptr = &names[ 0] ; nptr->n_func != NULL ; nptr++) {
|
||||
int cpos ; /* current position to use in outseq */
|
||||
|
||||
#if APROP
|
||||
/* if we are executing an apropos command..... */
|
||||
if (type == FALSE &&
|
||||
/* and current string doesn't include the search string */
|
||||
strinc(outseq, mstring) == FALSE)
|
||||
goto fail;
|
||||
if( *mstring && strinc( nptr->n_name, mstring) == FALSE)
|
||||
continue ;
|
||||
#endif
|
||||
/* add in the command name */
|
||||
strncpy( outseq, nptr->n_name, sizeof outseq - 1) ;
|
||||
outseq[ sizeof outseq - 1] = '\0' ;
|
||||
cpos = strlen(outseq);
|
||||
|
||||
/* search down any keys bound to this */
|
||||
ktp = &keytab[0];
|
||||
while (ktp->k_fp != NULL) {
|
||||
@@ -375,9 +385,6 @@ int buildlist(int type, char *mstring)
|
||||
if (linstr(outseq) != TRUE)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
fail: /* and on to the next name */
|
||||
++nptr;
|
||||
}
|
||||
|
||||
curwp->w_bufp->b_mode |= MDVIEW; /* put this buffer view mode */
|
||||
@@ -401,34 +408,25 @@ int buildlist(int type, char *mstring)
|
||||
* char *source; string to search in
|
||||
* char *sub; substring to look for
|
||||
*/
|
||||
int strinc(char *source, char *sub)
|
||||
{
|
||||
char *sp; /* ptr into source */
|
||||
char *nxtsp; /* next ptr into source */
|
||||
char *tp; /* ptr into substring */
|
||||
|
||||
static int strinc( char *source, char *sub) {
|
||||
/* for each character in the source string */
|
||||
sp = source;
|
||||
while (*sp) {
|
||||
tp = sub;
|
||||
nxtsp = sp;
|
||||
for( ; *source ; source++) {
|
||||
char *nxtsp ; /* next ptr into source */
|
||||
char *tp ; /* ptr into substring */
|
||||
|
||||
nxtsp = source;
|
||||
|
||||
/* is the substring here? */
|
||||
while (*tp) {
|
||||
if (*nxtsp++ != *tp)
|
||||
break;
|
||||
else
|
||||
tp++;
|
||||
}
|
||||
for( tp = sub ; *tp ; tp++)
|
||||
if( *nxtsp++ != *tp)
|
||||
break ;
|
||||
|
||||
/* yes, return a success */
|
||||
if (*tp == 0)
|
||||
return TRUE;
|
||||
|
||||
/* no, onward */
|
||||
sp++;
|
||||
if( *tp == 0)
|
||||
return TRUE ;
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
return FALSE ;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -437,46 +435,44 @@ int strinc(char *source, char *sub)
|
||||
*
|
||||
* int mflag; going for a meta sequence?
|
||||
*/
|
||||
unsigned int getckey(int mflag)
|
||||
{
|
||||
unsigned int c; /* character fetched */
|
||||
char tok[NSTRING]; /* command incoming */
|
||||
static unsigned int getckey( int mflag) {
|
||||
unsigned int c ; /* character fetched */
|
||||
|
||||
/* check to see if we are executing a command line */
|
||||
if (clexec) {
|
||||
macarg(tok); /* get the next token */
|
||||
return stock(tok);
|
||||
}
|
||||
if( clexec) {
|
||||
char *tok ; /* command incoming */
|
||||
|
||||
tok = getnewtokval() ; /* get the next token */
|
||||
if( tok == NULL)
|
||||
c = 0 ; /* return dummy key on failure */
|
||||
else {
|
||||
c = stock( tok) ;
|
||||
free( tok) ;
|
||||
}
|
||||
} else { /* or the normal way */
|
||||
if( mflag)
|
||||
c = get1key() ;
|
||||
else
|
||||
c = getcmd() ;
|
||||
}
|
||||
|
||||
/* or the normal way */
|
||||
if (mflag)
|
||||
c = get1key();
|
||||
else
|
||||
c = getcmd();
|
||||
return c;
|
||||
return c ;
|
||||
}
|
||||
|
||||
/*
|
||||
* execute the startup file
|
||||
*
|
||||
* char *sfname; name of startup file (null if default)
|
||||
* char *fname; name of startup file (null if default)
|
||||
*/
|
||||
int startup(char *sfname)
|
||||
{
|
||||
char *fname; /* resulting file name to execute */
|
||||
int startup( const char *fname) {
|
||||
if( !fname || *fname == 0) /* use default if empty parameter */
|
||||
fname = rcfname ;
|
||||
|
||||
/* look up the startup file */
|
||||
if (*sfname != 0)
|
||||
fname = flook(sfname, TRUE);
|
||||
else
|
||||
fname = flook( rcfname, TRUE);
|
||||
fname = flook( fname, TRUE) ; /* look up the startup file */
|
||||
if( fname == NULL) /* if it isn't around, don't sweat it */
|
||||
return TRUE ;
|
||||
|
||||
/* if it isn't around, don't sweat it */
|
||||
if (fname == NULL)
|
||||
return TRUE;
|
||||
|
||||
/* otherwise, execute the sucker */
|
||||
return dofile(fname);
|
||||
return dofile( fname) ; /* otherwise, execute the sucker */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -485,8 +481,7 @@ int startup(char *sfname)
|
||||
* int c; sequence to translate
|
||||
* char *seq; destination string for sequence
|
||||
*/
|
||||
void cmdstr(int c, char *seq)
|
||||
{
|
||||
static void cmdstr( int c, char *seq) {
|
||||
char *ptr; /* pointer into current position in sequence */
|
||||
|
||||
ptr = seq;
|
||||
@@ -526,8 +521,7 @@ void cmdstr(int c, char *seq)
|
||||
*
|
||||
* int c; key to find what is bound to it
|
||||
*/
|
||||
int (*getbind(int c))(int, int)
|
||||
{
|
||||
fn_t getbind( unsigned c) {
|
||||
struct key_tab *ktp;
|
||||
|
||||
ktp = &keytab[0]; /* Look in key table. */
|
||||
@@ -586,8 +580,7 @@ int (*fncmatch(char *fname)) (int, int)
|
||||
*
|
||||
* char *keyname; name of key to translate to Command key form
|
||||
*/
|
||||
unsigned int stock(char *keyname)
|
||||
{
|
||||
static unsigned int stock( char *keyname) {
|
||||
unsigned int c; /* key sequence to return */
|
||||
|
||||
/* parse it up */
|
||||
@@ -627,7 +620,7 @@ unsigned int stock(char *keyname)
|
||||
*keyname -= 32;
|
||||
|
||||
/* the final sequence... */
|
||||
c |= *keyname;
|
||||
c |= *keyname & 0xFFU ;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
10
bind.h
10
bind.h
@@ -5,7 +5,6 @@
|
||||
|
||||
#if APROP
|
||||
int apro( int f, int n) ;
|
||||
int strinc( char *source, char *sub) ;
|
||||
#endif
|
||||
|
||||
/* Some global fuction declarations. */
|
||||
@@ -15,15 +14,10 @@ int help( int f, int n) ;
|
||||
int deskey( int f, int n) ;
|
||||
int bindtokey( int f, int n) ;
|
||||
int unbindkey( int f, int n) ;
|
||||
int unbindchar( int c) ;
|
||||
int desbind( int f, int n) ;
|
||||
int buildlist( int type, char *mstring) ;
|
||||
unsigned int getckey( int mflag) ;
|
||||
int startup( char *sfname) ;
|
||||
void cmdstr( int c, char *seq) ;
|
||||
fn_t getbind( int c) ;
|
||||
int startup( const char *fname) ;
|
||||
fn_t getbind( unsigned keycode) ;
|
||||
fn_t fncmatch( char *) ;
|
||||
unsigned int stock( char *keyname) ;
|
||||
char *transbind( char *skey) ;
|
||||
|
||||
#endif
|
||||
|
||||
40
bindable.c
40
bindable.c
@@ -11,17 +11,9 @@
|
||||
#include "file.h"
|
||||
#include "input.h"
|
||||
#include "lock.h"
|
||||
#include "mlout.h"
|
||||
#include "terminal.h"
|
||||
|
||||
#if VMS
|
||||
#include <ssdef.h>
|
||||
#define GOOD (SS$_NORMAL)
|
||||
#endif
|
||||
|
||||
#ifndef GOOD
|
||||
#define GOOD 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Fancy quit command, as implemented by Norm. If the any buffer has
|
||||
* changed do a write on that buffer and exit emacs, otherwise simply exit.
|
||||
@@ -40,10 +32,10 @@ int quickexit(int f, int n)
|
||||
&& (bp->b_flag & BFTRUNC) == 0 /* Not truncated P.K. */
|
||||
&& (bp->b_flag & BFINVS) == 0) { /* Real. */
|
||||
curbp = bp; /* make that buffer cur */
|
||||
mlwrite("(Saving %s)", bp->b_fname);
|
||||
mloutfmt( "(Saving %s)", bp->b_fname) ;
|
||||
#if PKCODE
|
||||
#else
|
||||
mlwrite("\n");
|
||||
mloutstr( "\n") ;
|
||||
#endif
|
||||
if ((status = filesave(f, n)) != TRUE) {
|
||||
curbp = oldcb; /* restore curbp */
|
||||
@@ -75,16 +67,16 @@ int quit(int f, int n)
|
||||
TTputc('\r');
|
||||
TTclose();
|
||||
TTkclose();
|
||||
exit(1);
|
||||
exit( EXIT_FAILURE) ;
|
||||
}
|
||||
#endif
|
||||
vttidy();
|
||||
if (f)
|
||||
exit(n);
|
||||
else
|
||||
exit(GOOD);
|
||||
exit( EXIT_SUCCESS) ;
|
||||
}
|
||||
mlwrite("");
|
||||
mloutstr( "") ;
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -96,10 +88,10 @@ int quit(int f, int n)
|
||||
int ctlxlp(int f, int n)
|
||||
{
|
||||
if (kbdmode != STOP) {
|
||||
mlwrite("%%Macro already active");
|
||||
mloutstr( "%Macro already active") ;
|
||||
return FALSE;
|
||||
}
|
||||
mlwrite("(Start macro)");
|
||||
mloutstr( "(Start macro)") ;
|
||||
kbdptr = &kbdm[0];
|
||||
kbdend = kbdptr;
|
||||
kbdmode = RECORD;
|
||||
@@ -113,11 +105,11 @@ int ctlxlp(int f, int n)
|
||||
int ctlxrp(int f, int n)
|
||||
{
|
||||
if (kbdmode == STOP) {
|
||||
mlwrite("%%Macro not active");
|
||||
mloutstr( "%Macro not active") ;
|
||||
return FALSE;
|
||||
}
|
||||
if (kbdmode == RECORD) {
|
||||
mlwrite("(End macro)");
|
||||
mloutstr( "(End macro)") ;
|
||||
kbdmode = STOP;
|
||||
}
|
||||
return TRUE;
|
||||
@@ -131,7 +123,7 @@ int ctlxrp(int f, int n)
|
||||
int ctlxe(int f, int n)
|
||||
{
|
||||
if (kbdmode != STOP) {
|
||||
mlwrite("%%Macro already active");
|
||||
mloutstr( "%Macro already active") ;
|
||||
return FALSE;
|
||||
}
|
||||
if (n <= 0)
|
||||
@@ -147,12 +139,10 @@ int ctlxe(int f, int n)
|
||||
* Beep the beeper. Kill off any keyboard macro, etc., that is in progress.
|
||||
* Sometimes called as a routine, to do general aborting of stuff.
|
||||
*/
|
||||
int ctrlg(int f, int n)
|
||||
{
|
||||
TTbeep();
|
||||
kbdmode = STOP;
|
||||
mlwrite("(Aborted)");
|
||||
return ABORT;
|
||||
int ctrlg( int f, int n) {
|
||||
kbdmode = STOP ;
|
||||
mloutfmt( "%B(Aborted)") ;
|
||||
return ABORT ;
|
||||
}
|
||||
|
||||
/* user function that does NOTHING */
|
||||
|
||||
122
buffer.c
122
buffer.c
@@ -17,10 +17,10 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "defines.h"
|
||||
#include "display.h"
|
||||
#include "estruct.h"
|
||||
#include "file.h"
|
||||
#include "input.h"
|
||||
#include "mlout.h"
|
||||
#include "window.h"
|
||||
|
||||
|
||||
@@ -55,17 +55,24 @@ static void l_to_a( char *buf, int width, long num) ;
|
||||
* if the use count is 0. Otherwise, they come
|
||||
* from some other window.
|
||||
*/
|
||||
int usebuffer(int f, int n)
|
||||
{
|
||||
struct buffer *bp;
|
||||
int s;
|
||||
bname_t bufn ;
|
||||
int usebuffer( int f, int n) {
|
||||
struct buffer *bp ;
|
||||
int status ;
|
||||
char *bufn ;
|
||||
|
||||
if ((s = mlreply("Use buffer: ", bufn, sizeof bufn)) != TRUE)
|
||||
return s;
|
||||
if ((bp = bfind(bufn, TRUE, 0)) == NULL)
|
||||
return FALSE;
|
||||
return swbuffer(bp);
|
||||
/* Get buffer name */
|
||||
status = newmlarg( &bufn, "Use buffer: ", sizeof( bname_t)) ;
|
||||
if( status != TRUE)
|
||||
return status ;
|
||||
|
||||
/* Find buffer in list */
|
||||
bp = bfind( bufn, TRUE, 0) ;
|
||||
free( bufn) ;
|
||||
if( bp == NULL)
|
||||
return FALSE ;
|
||||
|
||||
/* Switch to buffer */
|
||||
return swbuffer( bp) ;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -164,19 +171,26 @@ int swbuffer(struct buffer *bp)
|
||||
* if the buffer has been changed). Then free the header
|
||||
* line and the buffer header. Bound to "C-X K".
|
||||
*/
|
||||
int killbuffer(int f, int n)
|
||||
{
|
||||
struct buffer *bp;
|
||||
int s;
|
||||
bname_t bufn ;
|
||||
int killbuffer( int f, int n) {
|
||||
struct buffer *bp ;
|
||||
int status ;
|
||||
char *bufn ;
|
||||
|
||||
if ((s = mlreply("Kill buffer: ", bufn, sizeof bufn)) != TRUE)
|
||||
return s;
|
||||
if ((bp = bfind(bufn, FALSE, 0)) == NULL) /* Easy if unknown. */
|
||||
return TRUE;
|
||||
if (bp->b_flag & BFINVS) /* Deal with special buffers */
|
||||
return TRUE; /* by doing nothing. */
|
||||
return zotbuf(bp);
|
||||
/* Get buffer name */
|
||||
status = newmlarg( &bufn, "Kill buffer: ", sizeof( bname_t)) ;
|
||||
if( status != TRUE)
|
||||
return status ;
|
||||
|
||||
/* Find buffer in list */
|
||||
bp = bfind( bufn, FALSE, 0) ;
|
||||
free( bufn) ;
|
||||
if( bp == NULL) /* Easy if unknown. */
|
||||
return TRUE ;
|
||||
|
||||
if( bp->b_flag & BFINVS) /* Deal with special buffers */
|
||||
return TRUE ; /* by doing nothing. */
|
||||
|
||||
return zotbuf( bp) ;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -189,7 +203,7 @@ int zotbuf(struct buffer *bp)
|
||||
int s;
|
||||
|
||||
if (bp->b_nwnd != 0) { /* Error if on screen. */
|
||||
mlwrite("Buffer is being displayed");
|
||||
mloutstr("Buffer is being displayed");
|
||||
return FALSE;
|
||||
}
|
||||
if ((s = bclear(bp)) != TRUE) /* Blow text away. */
|
||||
@@ -215,31 +229,37 @@ int zotbuf(struct buffer *bp)
|
||||
*
|
||||
* int f, n; default Flag & Numeric arg
|
||||
*/
|
||||
int namebuffer(int f, int n)
|
||||
{
|
||||
struct buffer *bp; /* pointer to scan through all buffers */
|
||||
bname_t bufn ; /* buffer to hold buffer name */
|
||||
int namebuffer( int f, int n) {
|
||||
struct buffer *bp ; /* pointer to scan through all buffers */
|
||||
int status ;
|
||||
char *bufn ; /* buffer to hold buffer name */
|
||||
|
||||
/* prompt for and get the new buffer name */
|
||||
ask:if (mlreply("Change buffer name to: ", bufn, sizeof bufn) !=
|
||||
TRUE)
|
||||
return FALSE;
|
||||
/* prompt for and get the new buffer name */
|
||||
ask:
|
||||
status = newmlarg( &bufn, "Change buffer name to: ", sizeof( bname_t)) ;
|
||||
if( status != TRUE)
|
||||
return status ;
|
||||
|
||||
/* and check for duplicates */
|
||||
bp = bheadp;
|
||||
while (bp != NULL) {
|
||||
if (bp != curbp) {
|
||||
/* if the names the same */
|
||||
if (strcmp(bufn, bp->b_bname) == 0)
|
||||
goto ask; /* try again */
|
||||
/* and check for duplicates */
|
||||
bp = bheadp ;
|
||||
while( bp != NULL) {
|
||||
if( bp != curbp) {
|
||||
/* retry if the names are the same */
|
||||
if( strcmp( bufn, bp->b_bname) == 0) {
|
||||
free( bufn) ;
|
||||
goto ask ; /* try again */
|
||||
}
|
||||
}
|
||||
bp = bp->b_bufp; /* onward */
|
||||
|
||||
bp = bp->b_bufp ; /* onward */
|
||||
}
|
||||
|
||||
strcpy(curbp->b_bname, bufn); /* copy buffer name to structure */
|
||||
curwp->w_flag |= WFMODE; /* make mode line replot */
|
||||
mlerase();
|
||||
return TRUE;
|
||||
strcpy( curbp->b_bname, bufn) ; /* copy buffer name to structure */
|
||||
free( bufn) ;
|
||||
|
||||
curwp->w_flag |= WFMODE ; /* make mode line replot */
|
||||
mloutstr( "") ; /* erase message line */
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -310,6 +330,7 @@ static int makelist( int iflag)
|
||||
int s;
|
||||
int i;
|
||||
long nbytes; /* # of bytes in current buffer */
|
||||
long nlines ; /* # of lines in current buffer */
|
||||
char b[ 8 + 1] ;
|
||||
char line[MAXLINE];
|
||||
|
||||
@@ -318,7 +339,7 @@ static int makelist( int iflag)
|
||||
return s;
|
||||
strcpy(blistp->b_fname, "");
|
||||
if( addline("ACT MODES Size Buffer File") == FALSE
|
||||
|| addline("--- ----- ---- ------ ----") == FALSE)
|
||||
|| addline("‾‾‾ ‾‾‾‾‾ ‾‾‾‾ ‾‾‾‾‾‾ ‾‾‾‾") == FALSE)
|
||||
return FALSE;
|
||||
bp = bheadp; /* For all buffers */
|
||||
|
||||
@@ -380,11 +401,17 @@ static int makelist( int iflag)
|
||||
|
||||
/* Buffer size */
|
||||
nbytes = 0L; /* Count bytes in buf. */
|
||||
nlines = 0 ;
|
||||
lp = lforw(bp->b_linep);
|
||||
while (lp != bp->b_linep) {
|
||||
nbytes += (long) llength(lp) + 1L;
|
||||
nlines += 1 ;
|
||||
lp = lforw(lp);
|
||||
}
|
||||
|
||||
if( bp->b_mode & MDDOS)
|
||||
nbytes += nlines ;
|
||||
|
||||
l_to_a( b, sizeof b, nbytes) ; /* 8 digits string buffer size. */
|
||||
cp2 = &b[0];
|
||||
while ((c = *cp2++) != 0)
|
||||
@@ -528,8 +555,9 @@ struct buffer *bfind( const char *bname, int cflag, int bflag)
|
||||
bp->b_mode = gmode;
|
||||
bp->b_nwnd = 0;
|
||||
bp->b_linep = lp;
|
||||
strcpy(bp->b_fname, "");
|
||||
strcpy(bp->b_bname, bname);
|
||||
bp->b_fname[ 0] = '\0' ;
|
||||
strncpy( bp->b_bname, bname, sizeof( bname_t) - 1) ;
|
||||
bp->b_bname[ sizeof( bname_t) - 1] = '\0' ;
|
||||
#if CRYPT
|
||||
bp->b_key[0] = 0;
|
||||
#endif
|
||||
|
||||
16
defines.h
16
defines.h
@@ -1,3 +1,9 @@
|
||||
/* defines.h -- */
|
||||
|
||||
#ifndef __DEFINES_H__
|
||||
#define __DEFINES_H__
|
||||
|
||||
|
||||
/* Must define one of
|
||||
VMS | V7 | USG | BSD | MSDOS
|
||||
*/
|
||||
@@ -14,5 +20,11 @@
|
||||
#define CTLX 0x40000000 /* ^X flag, or'ed in */
|
||||
#define SPEC 0x80000000 /* special key (function keys) */
|
||||
|
||||
#define MAXCOL 500
|
||||
#define MAXROW 500
|
||||
/* Actual 380x134 on a 1920x1080 screen in landscape,
|
||||
if smaller font or portrait orientation limit to 400x150 */
|
||||
#define MAXCOL 400
|
||||
#define MAXROW 150
|
||||
|
||||
#endif
|
||||
|
||||
/* end of defines.h */
|
||||
|
||||
338
display.c
338
display.c
@@ -87,6 +87,7 @@ static void modeline(struct window *wp);
|
||||
static void mlputi(int i, int r);
|
||||
static void mlputli(long l, int r);
|
||||
static void mlputf(int s);
|
||||
static void mlputs( unsigned char *s) ;
|
||||
#if SIGWINCH
|
||||
static int newscreensize(int h, int w);
|
||||
#endif
|
||||
@@ -158,13 +159,17 @@ void vtfree(void)
|
||||
*/
|
||||
void vttidy(void)
|
||||
{
|
||||
mlerase();
|
||||
movecursor(term.t_nrow, 0);
|
||||
TTflush();
|
||||
mlerase() ; /* ends with movecursor( term.t_nrow, 0) and TTflush() */
|
||||
TTclose();
|
||||
TTkclose();
|
||||
#ifdef PKCODE
|
||||
write(1, "\r", 1);
|
||||
{
|
||||
int ret ;
|
||||
ret = write( 1, "\r", 1) ;
|
||||
if( ret != 1) {
|
||||
/* some error handling here */
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -238,6 +243,17 @@ static void vtputc(int c)
|
||||
++vtcol;
|
||||
}
|
||||
|
||||
static int vtputs( const char *s) {
|
||||
int n = 0 ;
|
||||
|
||||
while( *s) {
|
||||
vtputc( *s++) ;
|
||||
n += 1 ;
|
||||
}
|
||||
|
||||
return n ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Erase from the end of the software cursor to the end of the line on which
|
||||
* the software cursor is located.
|
||||
@@ -565,12 +581,14 @@ void updpos(void)
|
||||
i = 0;
|
||||
while (i < curwp->w_doto) {
|
||||
unicode_t c;
|
||||
int bytes;
|
||||
|
||||
bytes = utf8_to_unicode(lp->l_text, i, curwp->w_doto, &c);
|
||||
i += bytes;
|
||||
if (c == '\t')
|
||||
curcol |= tabmask;
|
||||
i += utf8_to_unicode( lp->l_text, i, curwp->w_doto, &c) ;
|
||||
if( c == '\t')
|
||||
curcol |= tabmask ;
|
||||
else if( c < 0x20 || c == 0x7F)
|
||||
curcol += 1 ; /* displayed as ^c */
|
||||
else if( c >= 0x80 && c <= 0xA0)
|
||||
curcol += 2 ; /* displayed as \xx */
|
||||
|
||||
++curcol;
|
||||
}
|
||||
@@ -1101,14 +1119,11 @@ static int updateline(int row, struct video *vp1, struct video *vp2)
|
||||
*/
|
||||
static void modeline(struct window *wp)
|
||||
{
|
||||
char *cp;
|
||||
int c;
|
||||
int n; /* cursor position count */
|
||||
struct buffer *bp;
|
||||
int i; /* loop index */
|
||||
int lchar; /* character to draw line in buffer with */
|
||||
int firstm; /* is this the first mode? */
|
||||
char tline[NLINE]; /* buffer for part of mode line */
|
||||
|
||||
n = wp->w_toprow + wp->w_ntrows; /* Location. */
|
||||
vscreen[n]->v_flag |= VFCHG | VFREQ | VFCOL; /* Redraw next time. */
|
||||
@@ -1144,66 +1159,43 @@ static void modeline(struct window *wp)
|
||||
else
|
||||
vtputc(lchar);
|
||||
|
||||
n = 2;
|
||||
vtputc( ' ') ;
|
||||
|
||||
cp = " " PROGRAM_NAME_LONG " " VERSION ": " ;
|
||||
while ((c = *cp++) != 0) {
|
||||
vtputc(c);
|
||||
++n;
|
||||
}
|
||||
if( n == term.t_nrow - 1)
|
||||
n = 3 + vtputs( PROGRAM_NAME_LONG " " VERSION ": ") ;
|
||||
else
|
||||
n = 3 ;
|
||||
|
||||
cp = &bp->b_bname[0];
|
||||
while ((c = *cp++) != 0) {
|
||||
vtputc(c);
|
||||
++n;
|
||||
}
|
||||
|
||||
strcpy(tline, " (");
|
||||
n += vtputs( bp->b_bname) ;
|
||||
n += vtputs( " (") ;
|
||||
|
||||
/* display the modes */
|
||||
|
||||
firstm = TRUE;
|
||||
if ((bp->b_flag & BFTRUNC) != 0) {
|
||||
firstm = FALSE;
|
||||
strcat(tline, "Truncated");
|
||||
}
|
||||
n += vtputs( "Truncated") ;
|
||||
} else
|
||||
firstm = TRUE ;
|
||||
|
||||
for (i = 0; i < NUMMODES; i++) /* add in the mode flags */
|
||||
if (wp->w_bufp->b_mode & (1 << i)) {
|
||||
if (firstm != TRUE)
|
||||
strcat(tline, " ");
|
||||
firstm = FALSE;
|
||||
strcat( tline, modename[ i]) ;
|
||||
}
|
||||
strcat(tline, ") ");
|
||||
n += vtputs( " ") ;
|
||||
else
|
||||
firstm = FALSE ;
|
||||
|
||||
cp = &tline[0];
|
||||
while ((c = *cp++) != 0) {
|
||||
vtputc(c);
|
||||
++n;
|
||||
}
|
||||
n += vtputs( modename[ i]) ;
|
||||
}
|
||||
|
||||
n += vtputs( ") ") ;
|
||||
|
||||
#if PKCODE
|
||||
if (bp->b_fname[0] != 0 && strcmp(bp->b_bname, bp->b_fname) != 0)
|
||||
if (bp->b_fname[0] != 0 && strcmp(bp->b_bname, bp->b_fname) != 0) {
|
||||
#else
|
||||
if (bp->b_fname[0] != 0) /* File name. */
|
||||
if (bp->b_fname[0] != 0) { /* File name. */
|
||||
n += vtputs( "File: ") ;
|
||||
#endif
|
||||
{
|
||||
#if PKCODE == 0
|
||||
cp = "File: ";
|
||||
|
||||
while ((c = *cp++) != 0) {
|
||||
vtputc(c);
|
||||
++n;
|
||||
}
|
||||
#endif
|
||||
|
||||
cp = &bp->b_fname[0];
|
||||
|
||||
while ((c = *cp++) != 0) {
|
||||
vtputc(c);
|
||||
++n;
|
||||
}
|
||||
|
||||
n += vtputs( bp->b_fname) ;
|
||||
vtputc(' ');
|
||||
++n;
|
||||
}
|
||||
@@ -1217,6 +1209,7 @@ static void modeline(struct window *wp)
|
||||
struct line *lp = wp->w_linep;
|
||||
int rows = wp->w_ntrows;
|
||||
char *msg = NULL;
|
||||
char tline[ 6] ; /* buffer for part of mode line */
|
||||
|
||||
vtcol = n - 7; /* strlen(" top ") plus a couple */
|
||||
while (rows--) {
|
||||
@@ -1238,7 +1231,7 @@ static void modeline(struct window *wp)
|
||||
}
|
||||
if (!msg) {
|
||||
struct line *lp;
|
||||
int numlines, predlines, ratio;
|
||||
int numlines, predlines ;
|
||||
|
||||
lp = lforw(bp->b_linep);
|
||||
numlines = 0;
|
||||
@@ -1253,22 +1246,28 @@ static void modeline(struct window *wp)
|
||||
if (wp->w_dotp == bp->b_linep) {
|
||||
msg = " Bot ";
|
||||
} else {
|
||||
ratio = 0;
|
||||
int ratio = 0 ;
|
||||
|
||||
if (numlines != 0)
|
||||
ratio =
|
||||
(100L * predlines) / numlines;
|
||||
if (ratio > 99)
|
||||
ratio = 99;
|
||||
sprintf(tline, " %2d%% ", ratio);
|
||||
|
||||
tline[ 0] = ' ' ;
|
||||
tline[ 1] = ratio / 10 + '0' ;
|
||||
tline[ 2] = ratio % 10 + '0' ;
|
||||
tline[ 3] = '%' ;
|
||||
tline[ 4] = ' ' ;
|
||||
tline[ 5] = 0 ;
|
||||
if( tline[ 1] == '0')
|
||||
tline[ 1] = ' ' ;
|
||||
|
||||
msg = tline;
|
||||
}
|
||||
}
|
||||
|
||||
cp = msg;
|
||||
while ((c = *cp++) != 0) {
|
||||
vtputc(c);
|
||||
++n;
|
||||
}
|
||||
n += vtputs( msg) ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1302,28 +1301,33 @@ void movecursor(int row, int col)
|
||||
* is not considered to be part of the virtual screen. It always works
|
||||
* immediately; the terminal buffer is flushed via a call to the flusher.
|
||||
*/
|
||||
void mlerase(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
movecursor(term.t_nrow, 0);
|
||||
if (discmd == FALSE)
|
||||
return;
|
||||
|
||||
void mlerase( void) {
|
||||
movecursor( term.t_nrow, 0) ;
|
||||
if( discmd != FALSE) {
|
||||
#if COLOR
|
||||
TTforg(7);
|
||||
TTbacg(0);
|
||||
TTforg( 7) ;
|
||||
TTbacg( 0) ;
|
||||
#endif
|
||||
if (eolexist == TRUE)
|
||||
TTeeol();
|
||||
else {
|
||||
for (i = 0; i < term.t_ncol - 1; i++)
|
||||
TTputc(' ');
|
||||
movecursor(term.t_nrow, 1); /* force the move! */
|
||||
movecursor(term.t_nrow, 0);
|
||||
if( eolexist == TRUE)
|
||||
TTeeol() ;
|
||||
else {
|
||||
for( ttcol = 0 ; ttcol < term.t_ncol ; ttcol++)
|
||||
TTputc( ' ') ;
|
||||
|
||||
movecursor( term.t_nrow, 0) ;
|
||||
}
|
||||
|
||||
mpresf = FALSE ;
|
||||
}
|
||||
|
||||
TTflush() ;
|
||||
}
|
||||
|
||||
static void mlputc( char c) {
|
||||
if( ttcol < term.t_ncol) {
|
||||
TTputc( c) ;
|
||||
++ttcol ;
|
||||
}
|
||||
TTflush();
|
||||
mpresf = FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1335,10 +1339,8 @@ void mlerase(void)
|
||||
* char *fmt; format string for output
|
||||
* char *arg; pointer to first argument to print
|
||||
*/
|
||||
void mlwrite(const char *fmt, ...)
|
||||
{
|
||||
void vmlwrite( const char *fmt, va_list ap) {
|
||||
int c; /* current char in format string */
|
||||
va_list ap;
|
||||
|
||||
/* if we are not currently echoing on the command line, abort this */
|
||||
if (discmd == FALSE) {
|
||||
@@ -1352,18 +1354,16 @@ void mlwrite(const char *fmt, ...)
|
||||
#endif
|
||||
|
||||
/* if we can not erase to end-of-line, do it manually */
|
||||
if (eolexist == FALSE) {
|
||||
mlerase();
|
||||
TTflush();
|
||||
}
|
||||
if( eolexist == FALSE)
|
||||
mlerase() ; /* ends with movecursor( term.t_nrow, 0) and TTflush() */
|
||||
else
|
||||
movecursor( term.t_nrow, 0) ;
|
||||
|
||||
movecursor(term.t_nrow, 0);
|
||||
va_start(ap, fmt);
|
||||
mpresf = *fmt ? TRUE : FALSE ; /* flag if line has content or not */
|
||||
while ((c = *fmt++) != 0) {
|
||||
if (c != '%') {
|
||||
TTputc(c);
|
||||
++ttcol;
|
||||
} else {
|
||||
if (c != '%')
|
||||
mlputc( c) ;
|
||||
else {
|
||||
c = *fmt++;
|
||||
switch (c) {
|
||||
case 'd':
|
||||
@@ -1383,43 +1383,36 @@ void mlwrite(const char *fmt, ...)
|
||||
break;
|
||||
|
||||
case 's':
|
||||
mlputs(va_arg(ap, char *));
|
||||
mlputs( (unsigned char *) va_arg( ap, char *)) ;
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
mlputf(va_arg(ap, int));
|
||||
break;
|
||||
|
||||
case 'B': /* ring a bell */
|
||||
TTbeep() ;
|
||||
break ;
|
||||
|
||||
default:
|
||||
TTputc(c);
|
||||
++ttcol;
|
||||
mlputc( c) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
/* if we can, erase to the end of screen */
|
||||
if (eolexist == TRUE)
|
||||
TTeeol();
|
||||
if( eolexist == TRUE && ttcol < term.t_ncol)
|
||||
TTeeol() ;
|
||||
|
||||
TTflush();
|
||||
mpresf = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Force a string out to the message line regardless of the
|
||||
* current $discmd setting. This is needed when $debug is TRUE
|
||||
* and for the write-message and clear-message-line commands
|
||||
*
|
||||
* char *s; string to force out
|
||||
*/
|
||||
void mlforce(char *s)
|
||||
{
|
||||
int oldcmd; /* original command display flag */
|
||||
|
||||
oldcmd = discmd; /* save the discmd value */
|
||||
discmd = TRUE; /* and turn display on */
|
||||
mlwrite(s); /* write the string out */
|
||||
discmd = oldcmd; /* and restore the original setting */
|
||||
void mlwrite( const char *fmt, ...) {
|
||||
va_list ap ;
|
||||
|
||||
va_start( ap, fmt) ;
|
||||
vmlwrite( fmt, ap) ;
|
||||
va_end( ap) ;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1427,13 +1420,31 @@ void mlforce(char *s)
|
||||
* the characters in the string all have width "1"; if this is not the case
|
||||
* things will get screwed up a little.
|
||||
*/
|
||||
void mlputs(char *s)
|
||||
{
|
||||
int c;
|
||||
static void mlputs( unsigned char *s) {
|
||||
unicode_t c ;
|
||||
|
||||
while ((c = *s++) != 0) {
|
||||
TTputc(c);
|
||||
++ttcol;
|
||||
while( ((c = *s++) != 0) && (ttcol < term.t_ncol)) {
|
||||
if( c == '\t') /* Don't render tabulation */
|
||||
c = ' ' ;
|
||||
else if( c > 0xC1 && c <= 0xF4) { /* Accept UTF-8 sequence */
|
||||
char utf[ 4] ;
|
||||
char cc ;
|
||||
int bytes ;
|
||||
|
||||
utf[ 0] = c ;
|
||||
utf[ 1] = cc = *s ;
|
||||
if( (c & 0x20) && ((cc & 0xC0) == 0x80)) { /* at least 3 bytes and a valid encoded char */
|
||||
utf[ 2] = cc = s[ 1] ;
|
||||
if( (c & 0x10) && ((cc & 0xC0) == 0x80)) /* at least 4 bytes and a valid encoded char */
|
||||
utf[ 3] = s[ 2] ;
|
||||
}
|
||||
|
||||
bytes = utf8_to_unicode( utf, 0, sizeof utf, (unicode_t *) &c) ;
|
||||
s += bytes - 1 ;
|
||||
}
|
||||
|
||||
TTputc( c) ;
|
||||
++ttcol ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1441,44 +1452,43 @@ void mlputs(char *s)
|
||||
* Write out an integer, in the specified radix. Update the physical cursor
|
||||
* position.
|
||||
*/
|
||||
static void mlputi(int i, int r)
|
||||
{
|
||||
int q;
|
||||
static char hexdigits[] = "0123456789ABCDEF";
|
||||
static void mlputi( int i, int r) {
|
||||
int q ;
|
||||
unsigned u ;
|
||||
static char hexdigits[] = "0123456789ABCDEF" ;
|
||||
|
||||
if (i < 0) {
|
||||
i = -i;
|
||||
TTputc('-');
|
||||
if( r == 16 || i >= 0)
|
||||
u = i ;
|
||||
else {
|
||||
u = -i ;
|
||||
mlputc( '-') ;
|
||||
}
|
||||
|
||||
q = i / r;
|
||||
q = u / r ;
|
||||
|
||||
if (q != 0)
|
||||
mlputi(q, r);
|
||||
if( q != 0)
|
||||
mlputi( q, r) ;
|
||||
|
||||
TTputc(hexdigits[i % r]);
|
||||
++ttcol;
|
||||
mlputc( hexdigits[ u % r]) ;
|
||||
}
|
||||
|
||||
/*
|
||||
* do the same except as a long integer.
|
||||
*/
|
||||
static void mlputli(long l, int r)
|
||||
{
|
||||
long q;
|
||||
static void mlputli( long l, int r) {
|
||||
long q ;
|
||||
|
||||
if (l < 0) {
|
||||
l = -l;
|
||||
TTputc('-');
|
||||
if( l < 0) {
|
||||
l = -l ;
|
||||
mlputc( '-') ;
|
||||
}
|
||||
|
||||
q = l / r;
|
||||
q = l / r ;
|
||||
|
||||
if (q != 0)
|
||||
mlputli(q, r);
|
||||
if( q != 0)
|
||||
mlputli( q, r) ;
|
||||
|
||||
TTputc((int) (l % r) + '0');
|
||||
++ttcol;
|
||||
mlputc( (int) (l % r) + '0') ;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1486,21 +1496,19 @@ static void mlputli(long l, int r)
|
||||
*
|
||||
* int s; scaled integer to output
|
||||
*/
|
||||
static void mlputf(int s)
|
||||
{
|
||||
int i; /* integer portion of number */
|
||||
int f; /* fractional portion of number */
|
||||
static void mlputf( int s) {
|
||||
int i ; /* integer portion of number */
|
||||
int f ; /* fractional portion of number */
|
||||
|
||||
/* break it up */
|
||||
i = s / 100;
|
||||
f = s % 100;
|
||||
i = s / 100 ;
|
||||
f = s % 100 ;
|
||||
|
||||
/* send out the integer portion */
|
||||
mlputi(i, 10);
|
||||
TTputc('.');
|
||||
TTputc((f / 10) + '0');
|
||||
TTputc((f % 10) + '0');
|
||||
ttcol += 3;
|
||||
mlputi( i, 10) ;
|
||||
mlputc('.') ;
|
||||
mlputc((f / 10) + '0') ;
|
||||
mlputc((f % 10) + '0') ;
|
||||
}
|
||||
|
||||
#if RAINBOW
|
||||
@@ -1544,8 +1552,12 @@ void sizesignal(int signr)
|
||||
|
||||
getscreensize(&w, &h);
|
||||
|
||||
if (h && w && (h - 1 != term.t_nrow || w != term.t_ncol))
|
||||
newscreensize(h, w);
|
||||
if( h > 0 && w > 0) {
|
||||
term.t_mrow = h = h < MAXROW ? h : MAXROW ;
|
||||
term.t_mcol = w = w < MAXCOL ? w : MAXCOL ;
|
||||
if( h - 1 != term.t_nrow || w != term.t_ncol)
|
||||
newscreensize( h, w) ;
|
||||
}
|
||||
|
||||
signal(SIGWINCH, sizesignal);
|
||||
errno = old_errno;
|
||||
@@ -1560,9 +1572,9 @@ static int newscreensize(int h, int w)
|
||||
return FALSE;
|
||||
}
|
||||
chg_width = chg_height = 0;
|
||||
if (h - 1 < term.t_mrow)
|
||||
if( h <= term.t_mrow)
|
||||
newsize(TRUE, h);
|
||||
if (w < term.t_mcol)
|
||||
if( w <= term.t_mcol)
|
||||
newwidth(TRUE, w);
|
||||
|
||||
update(TRUE);
|
||||
|
||||
12
display.h
12
display.h
@@ -1,6 +1,10 @@
|
||||
#ifndef _DISPLAY_H_
|
||||
#define _DISPLAY_H_
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "estruct.h"
|
||||
|
||||
extern int mpresf ; /* Stuff in message line */
|
||||
extern int scrollcount ; /* number of lines to scroll */
|
||||
extern int discmd ; /* display command flag */
|
||||
@@ -20,13 +24,17 @@ int updupd( int force) ;
|
||||
void upmode( void) ;
|
||||
void movecursor( int row, int col) ;
|
||||
void mlerase( void) ;
|
||||
void vmlwrite( const char *fmt, va_list ap) ;
|
||||
void mlwrite( const char *fmt, ...) ;
|
||||
void mlforce( char *s) ;
|
||||
void mlputs( char *s) ;
|
||||
void getscreensize( int *widthp, int *heightp) ;
|
||||
|
||||
#if UNIX
|
||||
#include <signal.h>
|
||||
#ifdef SIGWINCH
|
||||
extern int chg_width, chg_height ;
|
||||
|
||||
void sizesignal( int signr) ;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
4
ebind.c
4
ebind.c
@@ -301,8 +301,8 @@ struct key_tab keytab[NBINDS] = {
|
||||
{META | 'R', sreplace}
|
||||
,
|
||||
#if PKCODE
|
||||
{META | 'S', forwsearch}
|
||||
, /* alternative P.K. */
|
||||
{META | 'S', forwhunt}
|
||||
,
|
||||
#else
|
||||
#if BSD
|
||||
{META | 'S', bktoshell}
|
||||
|
||||
2
ebind.h
2
ebind.h
@@ -1,6 +1,6 @@
|
||||
/* Structure for the table of initial key bindings. */
|
||||
struct key_tab {
|
||||
int k_code ; /* Key code */
|
||||
unsigned k_code ; /* Key code */
|
||||
int (*k_fp)( int, int) ; /* Routine to handle it */
|
||||
} ;
|
||||
|
||||
|
||||
@@ -257,11 +257,11 @@
|
||||
|
||||
#else
|
||||
|
||||
#define isletter(c) isxletter((0xFF & (c)))
|
||||
#define isletter(c) __isxletter((0xFF & (c)))
|
||||
#define islower(c) isxlower((0xFF & (c)))
|
||||
#define isupper(c) isxupper((0xFF & (c)))
|
||||
|
||||
#define isxletter(c) (('a' <= c && LASTLL >= c) || ('A' <= c && LASTUL >= c) || (192<=c && c<=255))
|
||||
#define __isxletter(c) (('a' <= c && LASTLL >= c) || ('A' <= c && LASTUL >= c) || (192<=c /* && c<=255 */))
|
||||
#define isxlower(c) (('a' <= c && LASTLL >= c) || (224 <= c && 252 >= c))
|
||||
#define isxupper(c) (('A' <= c && LASTUL >= c) || (192 <= c && 220 >= c))
|
||||
|
||||
@@ -297,7 +297,7 @@ void release( void *ptr) ;
|
||||
#if CLEAN
|
||||
#define exit(a) cexit(a)
|
||||
|
||||
int cexit( int status) ;
|
||||
void cexit( int status) ;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
38
eval.h
38
eval.h
@@ -4,53 +4,27 @@
|
||||
|
||||
#define DEBUGM 1 /* $debug triggers macro debugging */
|
||||
|
||||
|
||||
#if DEBUGM
|
||||
/* Vars needed for macro debugging output. */
|
||||
extern char outline[] ; /* Global string to hold debug line text. */
|
||||
int mdbugout( char *fmt, ...) ;
|
||||
#endif
|
||||
|
||||
|
||||
/* Emacs global flag bit definitions (for gflags). */
|
||||
|
||||
#define GFREAD 1
|
||||
|
||||
extern int gflags ; /* global control flag */
|
||||
extern int macbug ; /* macro debuging flag */
|
||||
extern int cmdstatus ; /* last command status */
|
||||
extern int flickcode ; /* do flicker supression? */
|
||||
extern int rval ; /* return value of a subprocess */
|
||||
extern long envram ; /* # of bytes current in use by malloc */
|
||||
|
||||
/* Macro argument token types */
|
||||
|
||||
#define TKNUL 0 /* end-of-string */
|
||||
#define TKARG 1 /* interactive argument */
|
||||
#define TKBUF 2 /* buffer argument */
|
||||
#define TKVAR 3 /* user variables */
|
||||
#define TKENV 4 /* environment variables */
|
||||
#define TKFUN 5 /* function.... */
|
||||
#define TKDIR 6 /* directive */
|
||||
#define TKLBL 7 /* line label */
|
||||
#define TKLIT 8 /* numeric literal */
|
||||
#define TKSTR 9 /* quoted string literal */
|
||||
#define TKCMD 10 /* command name */
|
||||
|
||||
int gettyp( char *token) ;
|
||||
int readfirst_f( void) ;
|
||||
int is_it_cmd( char *token) ;
|
||||
|
||||
void varinit( void) ;
|
||||
char *gtfun( char *fname) ;
|
||||
char *gtusr( char *vname) ;
|
||||
char *gtenv( char *vname) ;
|
||||
int setvar( int f, int n) ;
|
||||
char *i_to_a( int i) ;
|
||||
char *getval( char *token) ;
|
||||
int stol( char *val) ;
|
||||
char *mkupper( char *str) ;
|
||||
char *mklower( char *str) ;
|
||||
int abs( int x) ;
|
||||
int ernd( void) ;
|
||||
int sindex( char *source, char *pattern) ;
|
||||
char *xlat( char *source, char *lookup, char *trans) ;
|
||||
|
||||
int clrmes( int f, int n) ;
|
||||
int writemsg( int f, int n) ;
|
||||
|
||||
#endif
|
||||
|
||||
13
exec.h
13
exec.h
@@ -12,21 +12,20 @@ int execproc( int f, int n) ;
|
||||
#endif
|
||||
|
||||
|
||||
extern char *execstr ; /* pointer to string to execute */
|
||||
extern boolean clexec ; /* command line execution flag */
|
||||
|
||||
|
||||
|
||||
void ue_system( const char *cmd) ;
|
||||
int namedcmd( int f, int n) ;
|
||||
int execcmd( int f, int n) ;
|
||||
char *token( char *src, char *tok, int size) ;
|
||||
int macarg( char *tok) ;
|
||||
int nextarg( const char *prompt, char *buffer, int size, int terminator) ;
|
||||
void gettoken( char *tok, int maxtoksize) ;
|
||||
boolean gettokval( char *tok, int maxtoksize) ;
|
||||
char *getnewtokval( void) ;
|
||||
int storemac( int f, int n) ;
|
||||
int execbuf( int f, int n) ;
|
||||
int execfile( int f, int n) ;
|
||||
int dofile( char *fname) ;
|
||||
int cbuf( int f, int n, int bufnum) ;
|
||||
int dofile( const char *fname) ;
|
||||
|
||||
int cbuf1( int f, int n) ;
|
||||
int cbuf2( int f, int n) ;
|
||||
int cbuf3( int f, int n) ;
|
||||
|
||||
10
execute.c
10
execute.c
@@ -8,7 +8,7 @@
|
||||
#include "random.h"
|
||||
#include "display.h"
|
||||
#include "file.h"
|
||||
#include "terminal.h"
|
||||
#include "mlout.h"
|
||||
#include "window.h"
|
||||
|
||||
int gasave = 256 ; /* global ASAVE size */
|
||||
@@ -100,9 +100,9 @@ int execute(int c, int f, int n)
|
||||
lastflag = thisflag;
|
||||
return status;
|
||||
}
|
||||
TTbeep();
|
||||
mlwrite("(Key not bound)"); /* complain */
|
||||
lastflag = 0; /* Fake last flags. */
|
||||
return FALSE;
|
||||
|
||||
lastflag = 0 ; /* Fake last flags. */
|
||||
mloutfmt( "%B(Key not bound)") ; /* Complain */
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
|
||||
383
file.c
383
file.c
@@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -24,7 +25,7 @@
|
||||
#include "input.h"
|
||||
#include "line.h"
|
||||
#include "lock.h"
|
||||
#include "log.h"
|
||||
#include "mlout.h"
|
||||
#include "window.h"
|
||||
|
||||
#if PKCODE
|
||||
@@ -48,8 +49,24 @@ static const char *eolname[] = {
|
||||
"MIXED"
|
||||
} ;
|
||||
|
||||
static const char *codename[] = {
|
||||
"ASCII",
|
||||
"UTF-8",
|
||||
"EXTENDED",
|
||||
"MIXED"
|
||||
} ;
|
||||
|
||||
boolean restflag = FALSE ; /* restricted use? */
|
||||
|
||||
|
||||
static int ifile( const char *fname) ;
|
||||
|
||||
|
||||
boolean resterr( void) {
|
||||
mloutfmt( "%B(That command is RESTRICTED)") ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a file into the current
|
||||
* buffer. This is really easy; all you do it
|
||||
@@ -57,16 +74,20 @@ boolean restflag = FALSE ; /* restricted use? */
|
||||
* "read a file into the current buffer" code.
|
||||
* Bound to "C-X C-R".
|
||||
*/
|
||||
int fileread(int f, int n)
|
||||
{
|
||||
int s;
|
||||
fname_t fname ;
|
||||
int fileread( int f, int n) {
|
||||
int status ;
|
||||
char *fname ;
|
||||
|
||||
if (restflag) /* don't allow this command if restricted */
|
||||
return resterr();
|
||||
if ((s = mlreply("Read file: ", fname, sizeof fname)) != TRUE)
|
||||
return s;
|
||||
return readin(fname, TRUE);
|
||||
if( restflag) /* don't allow this command if restricted */
|
||||
return resterr() ;
|
||||
|
||||
status = newmlarg( &fname, "Read file: ", sizeof( fname_t)) ;
|
||||
if( status == TRUE) {
|
||||
status = readin( fname, TRUE) ;
|
||||
free( fname) ;
|
||||
}
|
||||
|
||||
return status ;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -76,20 +97,26 @@ int fileread(int f, int n)
|
||||
* "insert a file into the current buffer" code.
|
||||
* Bound to "C-X C-I".
|
||||
*/
|
||||
int insfile(int f, int n)
|
||||
{
|
||||
int s;
|
||||
fname_t fname ;
|
||||
int insfile( int f, int n) {
|
||||
int status ;
|
||||
char *fname ;
|
||||
|
||||
if (restflag) /* don't allow this command if restricted */
|
||||
return resterr();
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return rdonly(); /* we are in read only mode */
|
||||
if ((s = mlreply("Insert file: ", fname, sizeof fname)) != TRUE)
|
||||
return s;
|
||||
if ((s = ifile(fname)) != TRUE)
|
||||
return s;
|
||||
return reposition(TRUE, -1);
|
||||
if( restflag) /* don't allow this command if restricted */
|
||||
return resterr() ;
|
||||
|
||||
if( curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return rdonly() ; /* we are in read only mode */
|
||||
|
||||
status = newmlarg( &fname, "Insert file: ", sizeof( fname_t)) ;
|
||||
if( status == TRUE) {
|
||||
status = ifile( fname) ;
|
||||
free( fname) ;
|
||||
}
|
||||
|
||||
if( status != TRUE)
|
||||
return status ;
|
||||
|
||||
return reposition( TRUE, -1) ;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -101,40 +128,49 @@ int insfile(int f, int n)
|
||||
* text, and switch to the new buffer.
|
||||
* Bound to C-X C-F.
|
||||
*/
|
||||
int filefind(int f, int n)
|
||||
{
|
||||
fname_t fname ; /* file user wishes to find */
|
||||
int s; /* status return */
|
||||
int filefind( int f, int n) {
|
||||
char *fname ; /* file user wishes to find */
|
||||
int status ; /* status return */
|
||||
|
||||
if (restflag) /* don't allow this command if restricted */
|
||||
return resterr();
|
||||
if ((s = mlreply("Find file: ", fname, sizeof fname)) != TRUE)
|
||||
return s;
|
||||
return getfile(fname, TRUE);
|
||||
if( restflag) /* don't allow this command if restricted */
|
||||
return resterr() ;
|
||||
|
||||
status = newmlarg( &fname, "Find file: ", sizeof( fname_t)) ;
|
||||
if( status == TRUE) {
|
||||
status = getfile( fname, TRUE) ;
|
||||
free( fname) ;
|
||||
}
|
||||
|
||||
return status ;
|
||||
}
|
||||
|
||||
int viewfile(int f, int n)
|
||||
{ /* visit a file in VIEW mode */
|
||||
fname_t fname ; /* file user wishes to find */
|
||||
int s; /* status return */
|
||||
struct window *wp; /* scan for windows that need updating */
|
||||
int viewfile( int f, int n) { /* visit a file in VIEW mode */
|
||||
char *fname ; /* file user wishes to find */
|
||||
int status ; /* status return */
|
||||
|
||||
if (restflag) /* don't allow this command if restricted */
|
||||
return resterr();
|
||||
if ((s = mlreply("View file: ", fname, sizeof fname)) != TRUE)
|
||||
return s;
|
||||
s = getfile(fname, FALSE);
|
||||
if (s) { /* if we succeed, put it in view mode */
|
||||
curwp->w_bufp->b_mode |= MDVIEW;
|
||||
if( restflag) /* don't allow this command if restricted */
|
||||
return resterr() ;
|
||||
|
||||
status = newmlarg( &fname, "View file: ", sizeof( fname_t)) ;
|
||||
if( status == TRUE) {
|
||||
status = getfile(fname, FALSE) ;
|
||||
free( fname) ;
|
||||
}
|
||||
|
||||
if( status == TRUE) { /* if we succeed, put it in view mode */
|
||||
struct window *wp ; /* scan for windows that need updating */
|
||||
|
||||
curwp->w_bufp->b_mode |= MDVIEW ;
|
||||
|
||||
/* scan through and update mode lines of all windows */
|
||||
wp = wheadp;
|
||||
while (wp != NULL) {
|
||||
wp->w_flag |= WFMODE;
|
||||
wp = wp->w_wndp;
|
||||
wp = wheadp ;
|
||||
while( wp != NULL) {
|
||||
wp->w_flag |= WFMODE ;
|
||||
wp = wp->w_wndp ;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
|
||||
return status ;
|
||||
}
|
||||
|
||||
#if CRYPT
|
||||
@@ -149,28 +185,29 @@ void cryptbufferkey( struct buffer *bp) {
|
||||
* int f; default flag
|
||||
* int n; numeric argument
|
||||
*/
|
||||
int set_encryption_key(int f, int n)
|
||||
{
|
||||
int status; /* return status */
|
||||
int odisinp; /* original vlaue of disinp */
|
||||
ekey_t key ; /* new encryption string */
|
||||
int set_encryption_key( int f, int n) {
|
||||
int status ; /* return status */
|
||||
int odisinp ; /* original value of disinp */
|
||||
char *key ; /* new encryption string */
|
||||
|
||||
/* turn command input echo off */
|
||||
odisinp = disinp;
|
||||
disinp = FALSE;
|
||||
odisinp = disinp ;
|
||||
disinp = FALSE ;
|
||||
|
||||
/* get the string to use as an encrytion string */
|
||||
status = mlreply("Encryption String: ", key, sizeof key - 1);
|
||||
disinp = odisinp;
|
||||
if (status != TRUE)
|
||||
return status;
|
||||
status = newmlarg( &key, "Encryption String: ", sizeof( ekey_t)) ;
|
||||
disinp = odisinp ;
|
||||
if( status != TRUE)
|
||||
return status ;
|
||||
|
||||
/* save it off and encrypt it*/
|
||||
strcpy(curbp->b_key, key);
|
||||
strncpy( curbp->b_key, key, sizeof( ekey_t) - 1) ;
|
||||
curbp->b_key[ sizeof( ekey_t) - 1] = '\0' ;
|
||||
free( key) ;
|
||||
cryptbufferkey( curbp) ;
|
||||
|
||||
logwrite(" "); /* clear it off the bottom line */
|
||||
return TRUE;
|
||||
mloutstr( "") ; /* clear the message line */
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
static int resetkey(void)
|
||||
@@ -231,23 +268,30 @@ int getfile( const char *fname, boolean lockfl)
|
||||
curwp->w_linep = lp;
|
||||
curwp->w_flag |= WFMODE | WFHARD;
|
||||
cknewwindow();
|
||||
logwrite("(Old buffer)");
|
||||
mloutstr( "(Old buffer)") ;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
makename(bname, fname); /* New buffer name. */
|
||||
while ((bp = bfind(bname, FALSE, 0)) != NULL) {
|
||||
char *new_bname ;
|
||||
|
||||
/* old buffer name conflict code */
|
||||
s = mlreply("Buffer name: ", bname, sizeof bname);
|
||||
if (s == ABORT) /* ^G to just quit */
|
||||
return s;
|
||||
if (s == FALSE) { /* CR to clobber it */
|
||||
makename(bname, fname);
|
||||
break;
|
||||
s = newmlarg( &new_bname, "Buffer name: ", sizeof( bname_t)) ;
|
||||
if( s == ABORT) /* ^G to just quit */
|
||||
return s ;
|
||||
else if (s == FALSE) { /* CR to clobber it */
|
||||
makename( bname, fname) ;
|
||||
break ;
|
||||
} else { /* TRUE */
|
||||
strncpy( bname, new_bname, sizeof bname - 1) ;
|
||||
bname[ sizeof bname - 1] = '\0' ;
|
||||
free( new_bname) ;
|
||||
}
|
||||
}
|
||||
|
||||
if (bp == NULL && (bp = bfind(bname, TRUE, 0)) == NULL) {
|
||||
logwrite("Cannot create buffer");
|
||||
mloutstr( "Cannot create buffer") ;
|
||||
return FALSE;
|
||||
}
|
||||
if (--curbp->b_nwnd == 0) { /* Undisplay. */
|
||||
@@ -285,7 +329,7 @@ int readin(const char *fname, boolean lockfl)
|
||||
eoltype found_eol ;
|
||||
int nbytes;
|
||||
int nline;
|
||||
char mesg[NSTRING];
|
||||
char *errmsg ;
|
||||
|
||||
#if (FILOCK && BSD) || SVR4
|
||||
if (lockfl && lockchk(fname) == ABORT)
|
||||
@@ -309,7 +353,8 @@ int readin(const char *fname, boolean lockfl)
|
||||
if ((s = bclear(bp)) != TRUE) /* Might be old. */
|
||||
return s;
|
||||
bp->b_flag &= ~(BFINVS | BFCHG);
|
||||
strcpy(bp->b_fname, fname);
|
||||
strncpy( bp->b_fname, fname, sizeof( fname_t) - 1) ;
|
||||
bp->b_fname[ sizeof( fname_t) - 1] = '\0' ;
|
||||
|
||||
/* let a user macro get hold of things...if he wants */
|
||||
execute(META | SPEC | 'R', FALSE, 1);
|
||||
@@ -318,12 +363,12 @@ int readin(const char *fname, boolean lockfl)
|
||||
goto out;
|
||||
|
||||
if (s == FIOFNF) { /* File not found. */
|
||||
logwrite("(New file)");
|
||||
mloutstr( "(New file)") ;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* read the file in */
|
||||
logwrite("(Reading file)");
|
||||
mloutstr( "(Reading file)") ;
|
||||
nline = 0;
|
||||
while ((s = ffgetline()) == FIOSUC) {
|
||||
nbytes = fpayload ;
|
||||
@@ -347,7 +392,7 @@ int readin(const char *fname, boolean lockfl)
|
||||
}
|
||||
|
||||
if( s == FIOERR)
|
||||
logwrite( "File read error") ;
|
||||
mloutstr( "File read error") ;
|
||||
|
||||
switch( ftype) {
|
||||
case FTYPE_DOS:
|
||||
@@ -365,28 +410,29 @@ int readin(const char *fname, boolean lockfl)
|
||||
break ;
|
||||
default:
|
||||
found_eol = EOL_MIXED ;
|
||||
curbp->b_mode |= MDVIEW ; /* add view mode as we have lost
|
||||
** information */
|
||||
curbp->b_mode |= MDVIEW ; /* force view mode as we have lost
|
||||
** EOL information */
|
||||
}
|
||||
|
||||
ffclose(); /* Ignore errors. */
|
||||
strcpy(mesg, "(");
|
||||
if (s == FIOERR) {
|
||||
strcat(mesg, "I/O ERROR, ");
|
||||
curbp->b_flag |= BFTRUNC;
|
||||
}
|
||||
if (s == FIOMEM) {
|
||||
strcat(mesg, "OUT OF MEMORY, ");
|
||||
curbp->b_flag |= BFTRUNC;
|
||||
}
|
||||
sprintf(&mesg[strlen(mesg)], "Read %d line", nline);
|
||||
if (nline != 1)
|
||||
strcat(mesg, "s");
|
||||
if( fcode == FCODE_UTF_8)
|
||||
curbp->b_mode |= MDUTF8 ;
|
||||
|
||||
strcat( mesg, ", eol = ") ;
|
||||
strcat( mesg, eolname[ found_eol]) ;
|
||||
strcat(mesg, ")");
|
||||
logwrite(mesg);
|
||||
if( s == FIOERR) {
|
||||
errmsg = "I/O ERROR, " ;
|
||||
curbp->b_flag |= BFTRUNC ;
|
||||
} else if( s == FIOMEM) {
|
||||
errmsg = "OUT OF MEMORY, " ;
|
||||
curbp->b_flag |= BFTRUNC ;
|
||||
} else
|
||||
errmsg = "" ;
|
||||
|
||||
mloutfmt( "(%sRead %d line%s, code/eol: %s/%s)",
|
||||
errmsg,
|
||||
nline,
|
||||
(nline != 1) ? "s" : "",
|
||||
codename[ fcode & (FCODE_MASK -1)],
|
||||
eolname[ found_eol]) ;
|
||||
ffclose(); /* Ignore errors. */
|
||||
|
||||
out:
|
||||
for (wp = wheadp; wp != NULL; wp = wp->w_wndp) {
|
||||
@@ -477,27 +523,35 @@ void unqname(char *name)
|
||||
* is more compatable with Gosling EMACS than
|
||||
* with ITS EMACS. Bound to "C-X C-W".
|
||||
*/
|
||||
int filewrite(int f, int n)
|
||||
{
|
||||
struct window *wp;
|
||||
int s;
|
||||
fname_t fname ;
|
||||
int filewrite( int f, int n) {
|
||||
int status ;
|
||||
char *fname ;
|
||||
|
||||
if (restflag) /* don't allow this command if restricted */
|
||||
return resterr();
|
||||
if ((s = mlreply("Write file: ", fname, sizeof fname)) != TRUE)
|
||||
return s;
|
||||
if ((s = writeout(fname)) == TRUE) {
|
||||
strcpy(curbp->b_fname, fname);
|
||||
curbp->b_flag &= ~BFCHG;
|
||||
wp = wheadp; /* Update mode lines. */
|
||||
while (wp != NULL) {
|
||||
if (wp->w_bufp == curbp)
|
||||
wp->w_flag |= WFMODE;
|
||||
wp = wp->w_wndp;
|
||||
}
|
||||
}
|
||||
return s;
|
||||
if( restflag) /* don't allow this command if restricted */
|
||||
return resterr() ;
|
||||
|
||||
status = newmlarg( &fname, "Write file: ", sizeof( fname_t)) ;
|
||||
if( status == TRUE) {
|
||||
status = writeout( fname) ;
|
||||
if( status == TRUE) {
|
||||
struct window *wp ;
|
||||
|
||||
strncpy( curbp->b_fname, fname, sizeof( fname_t) - 1) ;
|
||||
curbp->b_fname[ sizeof( fname_t) - 1] = '\0' ;
|
||||
curbp->b_flag &= ~BFCHG ;
|
||||
wp = wheadp ; /* Update mode lines. */
|
||||
while( wp != NULL) {
|
||||
if( wp->w_bufp == curbp)
|
||||
wp->w_flag |= WFMODE ;
|
||||
|
||||
wp = wp->w_wndp ;
|
||||
}
|
||||
}
|
||||
|
||||
free( fname) ;
|
||||
}
|
||||
|
||||
return status ;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -518,14 +572,14 @@ int filesave(int f, int n)
|
||||
if ((curbp->b_flag & BFCHG) == 0) /* Return, no changes. */
|
||||
return TRUE;
|
||||
if (curbp->b_fname[0] == 0) { /* Must have a name. */
|
||||
logwrite("No file name");
|
||||
mloutstr( "No file name") ;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* complain about truncated files */
|
||||
if ((curbp->b_flag & BFTRUNC) != 0) {
|
||||
if (mlyesno("Truncated file ... write it out") == FALSE) {
|
||||
logwrite("(Aborted)");
|
||||
mloutstr( "(Aborted)") ;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -563,16 +617,16 @@ int writeout( const char *fn)
|
||||
#endif
|
||||
|
||||
if ((s = ffwopen(fn)) != FIOSUC) { /* Open writes message. */
|
||||
logwrite( "Cannot open file for writing") ;
|
||||
mloutstr( "Cannot open file for writing") ;
|
||||
return FALSE;
|
||||
}
|
||||
logwrite("(Writing...)"); /* tell us were writing */
|
||||
mloutstr( "(Writing...)") ; /* tell us were writing */
|
||||
lp = lforw(curbp->b_linep); /* First line. */
|
||||
nline = 0; /* Number of lines. */
|
||||
while (lp != curbp->b_linep) {
|
||||
s = ffputline( &lp->l_text[0], llength(lp), curbp->b_mode & MDDOS) ;
|
||||
if( s != FIOSUC) {
|
||||
logwrite( "Write I/O error") ;
|
||||
mloutstr( "Write I/O error") ;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -583,11 +637,11 @@ int writeout( const char *fn)
|
||||
s = ffclose();
|
||||
if (s == FIOSUC) { /* No close error. */
|
||||
if (nline == 1)
|
||||
logwrite("(Wrote 1 line)");
|
||||
mloutstr( "(Wrote 1 line)") ;
|
||||
else
|
||||
logwrite("(Wrote %d lines)", nline);
|
||||
mloutfmt( "(Wrote %d lines)", nline) ;
|
||||
} else
|
||||
logwrite( "Error closing file") ;
|
||||
mloutstr( "Error closing file") ;
|
||||
} else /* Ignore close error */
|
||||
ffclose(); /* if a write error. */
|
||||
if (s != FIOSUC) /* Some sort of error. */
|
||||
@@ -604,28 +658,35 @@ int writeout( const char *fn)
|
||||
* as needing an update. You can type a blank line at the
|
||||
* prompt if you wish.
|
||||
*/
|
||||
int filename(int f, int n)
|
||||
{
|
||||
struct window *wp;
|
||||
int s;
|
||||
fname_t fname ;
|
||||
int filename( int f, int n) {
|
||||
struct window *wp ;
|
||||
int status ;
|
||||
char *fname ;
|
||||
|
||||
if (restflag) /* don't allow this command if restricted */
|
||||
return resterr();
|
||||
if ((s = mlreply("Name: ", fname, sizeof fname)) == ABORT)
|
||||
return s;
|
||||
if (s == FALSE)
|
||||
strcpy(curbp->b_fname, "");
|
||||
else
|
||||
strcpy(curbp->b_fname, fname);
|
||||
wp = wheadp; /* Update mode lines. */
|
||||
while (wp != NULL) {
|
||||
if (wp->w_bufp == curbp)
|
||||
wp->w_flag |= WFMODE;
|
||||
wp = wp->w_wndp;
|
||||
if( restflag) /* don't allow this command if restricted */
|
||||
return resterr() ;
|
||||
|
||||
status = newmlarg( &fname, "Name: ", sizeof( fname_t)) ;
|
||||
if( status == ABORT)
|
||||
return status ;
|
||||
else if( status == FALSE)
|
||||
curbp->b_fname[ 0] = '\0' ;
|
||||
else { /* TRUE */
|
||||
strncpy( curbp->b_fname, fname, sizeof( fname_t) - 1) ;
|
||||
curbp->b_fname[ sizeof( fname_t) - 1] = '\0' ;
|
||||
free( fname) ;
|
||||
}
|
||||
curbp->b_mode &= ~MDVIEW; /* no longer read only mode */
|
||||
return TRUE;
|
||||
|
||||
wp = wheadp ; /* Update mode lines. */
|
||||
while( wp != NULL) {
|
||||
if( wp->w_bufp == curbp)
|
||||
wp->w_flag |= WFMODE ;
|
||||
|
||||
wp = wp->w_wndp ;
|
||||
}
|
||||
|
||||
curbp->b_mode &= ~MDVIEW ; /* no longer read only mode */
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -633,8 +694,7 @@ int filename(int f, int n)
|
||||
* buffer, Called by insert file command. Return the final
|
||||
* status of the read.
|
||||
*/
|
||||
int ifile( const char *fname)
|
||||
{
|
||||
static int ifile( const char *fname) {
|
||||
struct line *lp0;
|
||||
struct line *lp1;
|
||||
struct line *lp2;
|
||||
@@ -642,7 +702,7 @@ int ifile( const char *fname)
|
||||
int s;
|
||||
int nbytes;
|
||||
int nline;
|
||||
char mesg[NSTRING];
|
||||
char *errmsg ;
|
||||
|
||||
bp = curbp; /* Cheap. */
|
||||
bp->b_flag |= BFCHG; /* we have changed */
|
||||
@@ -650,10 +710,10 @@ int ifile( const char *fname)
|
||||
if ((s = ffropen(fname)) == FIOERR) /* Hard file open. */
|
||||
goto out;
|
||||
if (s == FIOFNF) { /* File not found. */
|
||||
logwrite("(No such file)");
|
||||
mloutstr( "(No such file)") ;
|
||||
return FALSE;
|
||||
}
|
||||
logwrite("(Inserting file)");
|
||||
mloutstr( "(Inserting file)") ;
|
||||
|
||||
#if CRYPT
|
||||
s = resetkey();
|
||||
@@ -689,22 +749,21 @@ int ifile( const char *fname)
|
||||
}
|
||||
ffclose(); /* Ignore errors. */
|
||||
curwp->w_markp = lforw(curwp->w_markp);
|
||||
strcpy(mesg, "(");
|
||||
if (s == FIOERR) {
|
||||
strcat(mesg, "I/O ERROR, ");
|
||||
if( s == FIOERR) {
|
||||
errmsg = "I/O ERROR, " ;
|
||||
curbp->b_flag |= BFTRUNC ;
|
||||
} else if( s == FIOMEM) {
|
||||
errmsg = "OUT OF MEMORY, " ;
|
||||
curbp->b_flag |= BFTRUNC;
|
||||
}
|
||||
if (s == FIOMEM) {
|
||||
strcat(mesg, "OUT OF MEMORY, ");
|
||||
curbp->b_flag |= BFTRUNC;
|
||||
}
|
||||
sprintf(&mesg[strlen(mesg)], "Inserted %d line", nline);
|
||||
if (nline > 1)
|
||||
strcat(mesg, "s");
|
||||
strcat(mesg, ")");
|
||||
logwrite(mesg);
|
||||
} else
|
||||
errmsg = "" ;
|
||||
|
||||
mloutfmt( "(%sInserted %d line%s)",
|
||||
errmsg,
|
||||
nline,
|
||||
(nline > 1) ? "s" : "") ;
|
||||
|
||||
out:
|
||||
out:
|
||||
/* advance to the next line and mark the window for changes */
|
||||
curwp->w_dotp = lforw(curwp->w_dotp);
|
||||
curwp->w_flag |= WFHARD | WFMODE;
|
||||
|
||||
2
file.h
2
file.h
@@ -11,6 +11,7 @@ int set_encryption_key( int f, int n) ;
|
||||
#endif
|
||||
|
||||
extern boolean restflag ; /* restricted use? */
|
||||
boolean resterr( void) ; /* restricted error message */
|
||||
|
||||
int fileread( int f, int n) ;
|
||||
int insfile( int f, int n) ;
|
||||
@@ -24,6 +25,5 @@ int filewrite( int f, int n) ;
|
||||
int filesave( int f, int n) ;
|
||||
int writeout( const char *fn) ;
|
||||
int filename( int f, int n) ;
|
||||
int ifile( const char *fname) ;
|
||||
|
||||
#endif
|
||||
|
||||
26
fileio.c
26
fileio.c
@@ -21,14 +21,16 @@
|
||||
|
||||
#include "defines.h"
|
||||
#include "retcode.h"
|
||||
#include "utf8.h"
|
||||
|
||||
#if CRYPT
|
||||
boolean is_crypted ; /* currently encrypting? */
|
||||
#endif
|
||||
|
||||
char *fline = NULL ; /* dynamic return line */
|
||||
int flen = 0 ; /* current allocated length of fline */
|
||||
static int flen = 0 ; /* current allocated length of fline */
|
||||
int ftype ;
|
||||
int fcode ; /* encoding type FCODE_xxxxx */
|
||||
int fpayload ; /* actual length of fline content */
|
||||
|
||||
|
||||
@@ -45,6 +47,7 @@ fio_code ffropen( const char *fn)
|
||||
return FIOFNF;
|
||||
eofflag = FALSE;
|
||||
ftype = FTYPE_NONE ;
|
||||
fcode = FCODE_ASCII ;
|
||||
return FIOSUC;
|
||||
}
|
||||
|
||||
@@ -79,6 +82,7 @@ fio_code ffclose(void)
|
||||
}
|
||||
eofflag = FALSE;
|
||||
ftype = FTYPE_NONE ;
|
||||
fcode = FCODE_ASCII ;
|
||||
|
||||
#if MSDOS & CTRLZ
|
||||
fputc(26, ffp); /* add a ^Z at the end of the file */
|
||||
@@ -136,6 +140,7 @@ fio_code ffgetline(void)
|
||||
{
|
||||
int c; /* current character read */
|
||||
int i; /* current index into fline */
|
||||
int lcode = FCODE_ASCII ; /* line encoding, defaults to ASCII */
|
||||
|
||||
/* if we are at the end...return it */
|
||||
if (eofflag)
|
||||
@@ -156,6 +161,7 @@ fio_code ffgetline(void)
|
||||
i = 0;
|
||||
while ((c = fgetc(ffp)) != EOF && c != '\r' && c != '\n') {
|
||||
fline[i++] = c;
|
||||
lcode |= c ;
|
||||
/* if it's longer, get more room */
|
||||
if (i >= flen) {
|
||||
char *tmpline; /* temp storage for expanding line */
|
||||
@@ -173,6 +179,24 @@ fio_code ffgetline(void)
|
||||
}
|
||||
|
||||
fpayload = i ;
|
||||
lcode &= FCODE_MASK ;
|
||||
if( lcode && (fcode != FCODE_MIXED)) { /* line contains extended chars */
|
||||
/* Check if consistent UTF-8 encoding */
|
||||
int bytes ;
|
||||
int pos = 0 ;
|
||||
unicode_t uc ;
|
||||
|
||||
while( (pos < i) && (lcode != FCODE_MIXED)) {
|
||||
bytes = utf8_to_unicode( fline, pos, i, &uc) ;
|
||||
pos += bytes ;
|
||||
if( bytes > 1) /* Multi byte UTF-8 sequence */
|
||||
lcode |= FCODE_UTF_8 ;
|
||||
else if( uc > 127) /* Extended ASCII */
|
||||
lcode |= FCODE_EXTND ;
|
||||
}
|
||||
|
||||
fcode |= lcode ;
|
||||
}
|
||||
|
||||
/* test for any errors that may have occured */
|
||||
if (c == EOF) {
|
||||
|
||||
8
fileio.h
8
fileio.h
@@ -18,6 +18,12 @@ typedef enum {
|
||||
#define FTYPE_MAC 4
|
||||
/* FTYPE_MIXED [ 3, 5, 6, 7] */
|
||||
|
||||
#define FCODE_ASCII 0
|
||||
#define FCODE_MASK 0x80
|
||||
#define FCODE_UTF_8 0x81
|
||||
#define FCODE_EXTND 0x82
|
||||
#define FCODE_MIXED 0x83
|
||||
|
||||
#if CRYPT
|
||||
#include "retcode.h"
|
||||
|
||||
@@ -25,8 +31,8 @@ extern boolean is_crypted ; /* currently encrypting? */
|
||||
#endif
|
||||
|
||||
extern char *fline ; /* dynamic return line */
|
||||
extern int flen ; /* current allocated length of fline */
|
||||
extern int ftype ;
|
||||
extern int fcode ; /* encoding type */
|
||||
extern int fpayload ; /* actual length of fline content */
|
||||
|
||||
fio_code ffclose( void) ;
|
||||
|
||||
66
flook.c
66
flook.c
@@ -76,33 +76,44 @@ boolean fexist( const char *fname)
|
||||
*/
|
||||
char *flook( const char *fname, boolean hflag)
|
||||
{
|
||||
int i; /* index */
|
||||
unsigned i ; /* index */
|
||||
int len ;
|
||||
static char fspec[NSTRING]; /* full path spec to search */
|
||||
|
||||
#if ENVFUNC
|
||||
char *path; /* environmental PATH variable */
|
||||
#endif
|
||||
|
||||
len = sizeof fspec - strlen( fname) - 1 ;
|
||||
if( len < 0)
|
||||
return NULL ;
|
||||
|
||||
#if ENVFUNC
|
||||
if (hflag) {
|
||||
char *home; /* path to home directory */
|
||||
|
||||
home = getenv("HOME");
|
||||
if (home != NULL) {
|
||||
if( len > (int) strlen( home) + 1) {
|
||||
/* build home dir file spec */
|
||||
strcpy(fspec, home);
|
||||
strcat(fspec, "/");
|
||||
strcat(fspec, fname);
|
||||
strcpy( fspec, home) ;
|
||||
strcat(fspec, "/");
|
||||
strcat(fspec, fname);
|
||||
|
||||
/* and try it out */
|
||||
if( fexist( fspec))
|
||||
return fspec ;
|
||||
if( fexist( fspec))
|
||||
return fspec ;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* always try the current directory first */
|
||||
strcpy( fspec, fname) ;
|
||||
if( fexist( fspec))
|
||||
return fspec ;
|
||||
if( len >= 0) {
|
||||
strcpy( fspec, fname) ;
|
||||
if( fexist( fspec))
|
||||
return fspec ;
|
||||
}
|
||||
|
||||
#if ENVFUNC
|
||||
#if V7 | USG | BSD
|
||||
@@ -116,21 +127,29 @@ char *flook( const char *fname, boolean hflag)
|
||||
if (path != NULL)
|
||||
while (*path) {
|
||||
char *sp; /* pointer into path spec */
|
||||
int cnt ;
|
||||
|
||||
cnt = len ;
|
||||
/* build next possible file spec */
|
||||
sp = fspec;
|
||||
while (*path && (*path != PATHCHR))
|
||||
*sp++ = *path++;
|
||||
while( *path && (*path != PATHCHR)) {
|
||||
if( cnt-- > 0)
|
||||
*sp++ = *path ;
|
||||
|
||||
path += 1 ;
|
||||
}
|
||||
|
||||
if( cnt >= 0) {
|
||||
/* add a terminating dir separator if we need it */
|
||||
if (sp != fspec)
|
||||
*sp++ = '/';
|
||||
*sp = 0;
|
||||
strcat(fspec, fname);
|
||||
if (sp != fspec)
|
||||
*sp++ = '/';
|
||||
*sp = 0;
|
||||
strcat(fspec, fname);
|
||||
|
||||
/* and try it out */
|
||||
if( fexist( fspec))
|
||||
return fspec ;
|
||||
if( fexist( fspec))
|
||||
return fspec ;
|
||||
}
|
||||
|
||||
if (*path == PATHCHR)
|
||||
++path;
|
||||
@@ -138,14 +157,15 @@ char *flook( const char *fname, boolean hflag)
|
||||
#endif
|
||||
|
||||
/* look it up via the old table method */
|
||||
for( i = 2; i < PATHNAME_SIZE ; i++) {
|
||||
strcpy(fspec, pathname[i]);
|
||||
strcat(fspec, fname);
|
||||
for( i = 2; i < PATHNAME_SIZE ; i++)
|
||||
if( len >= (int) strlen( pathname[ i])) {
|
||||
strcpy( fspec, pathname[ i]) ;
|
||||
strcat( fspec, fname);
|
||||
|
||||
/* and try it out */
|
||||
if( fexist( fspec))
|
||||
return fspec ;
|
||||
}
|
||||
if( fexist( fspec))
|
||||
return fspec ;
|
||||
}
|
||||
|
||||
return NULL; /* no such luck */
|
||||
}
|
||||
|
||||
152
input.c
152
input.c
@@ -21,6 +21,7 @@
|
||||
#include "exec.h"
|
||||
#include "names.h"
|
||||
#include "terminal.h"
|
||||
#include "utf8.h"
|
||||
#include "wrapper.h"
|
||||
|
||||
#if PKCODE
|
||||
@@ -51,7 +52,11 @@ int ctlxc = CONTROL | 'X' ; /* current control X prefix char */
|
||||
int reptc = CONTROL | 'U' ; /* current universal repeat char */
|
||||
int abortc = CONTROL | 'G' ; /* current abort command char */
|
||||
|
||||
static const int quotec = 0x11 ; /* quote char during mlreply() */
|
||||
const int nlc = CONTROL | 'J' ; /* end of input char */
|
||||
|
||||
static const int quotec = 0x11 ; /* quote char during getstring() */
|
||||
|
||||
static void outstring( char *s) ;
|
||||
|
||||
/*
|
||||
* Ask a yes or no question in the message line. Return either TRUE, FALSE, or
|
||||
@@ -61,13 +66,10 @@ static const int quotec = 0x11 ; /* quote char during mlreply() */
|
||||
int mlyesno( const char *prompt)
|
||||
{
|
||||
char c; /* input character */
|
||||
char buf[ NSTRING] ; /* prompt to user */
|
||||
|
||||
for (;;) {
|
||||
/* build and prompt the user */
|
||||
strcpy(buf, prompt);
|
||||
strcat(buf, " (y/n)? ");
|
||||
mlwrite(buf);
|
||||
/* prompt the user */
|
||||
mlwrite( "%s (y/n)? ", prompt) ;
|
||||
|
||||
/* get the response */
|
||||
c = tgetc();
|
||||
@@ -83,6 +85,47 @@ int mlyesno( const char *prompt)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* newnextarg:
|
||||
* get the next argument
|
||||
*
|
||||
* char **outbufref ; buffer to put token into
|
||||
* const char *prompt ; prompt to use if we must be interactive
|
||||
* int size ; size of the buffer
|
||||
* int terminator ; terminating char to be used on interactive fetch
|
||||
*/
|
||||
static int newnextarg( char **outbufref, const char *prompt, int size,
|
||||
int terminator) {
|
||||
int status ;
|
||||
char *buf ;
|
||||
|
||||
/* if we are interactive, go get it! */
|
||||
if( clexec == FALSE) {
|
||||
if( size <= 1) {
|
||||
size = term.t_ncol - strlen( prompt) + 1 ;
|
||||
if( size < 24)
|
||||
size = 24 ;
|
||||
}
|
||||
|
||||
buf = malloc( size) ;
|
||||
if( buf == NULL)
|
||||
status = FALSE ;
|
||||
else {
|
||||
status = getstring( prompt, buf, size, terminator) ;
|
||||
if( TRUE != status) {
|
||||
free( buf) ;
|
||||
buf = NULL ;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
buf = getnewtokval() ;
|
||||
status = (buf == NULL) ? FALSE : TRUE ;
|
||||
}
|
||||
|
||||
*outbufref = buf ;
|
||||
return status ;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write a prompt into the message line, then read back a response. Keep
|
||||
* track of the physical position of the cursor. If we are in a keyboard
|
||||
@@ -91,14 +134,12 @@ int mlyesno( const char *prompt)
|
||||
* return. Handle erase, kill, and abort keys.
|
||||
*/
|
||||
|
||||
int mlreply( const char *prompt, char *buf, int nbuf)
|
||||
{
|
||||
return nextarg(prompt, buf, nbuf, ctoec('\n'));
|
||||
int newmlarg( char **outbufref, const char *prompt, int size) {
|
||||
return newnextarg( outbufref, prompt, size, nlc) ;
|
||||
}
|
||||
|
||||
int mlreplyt(const char *prompt, char *buf, int nbuf, int eolchar)
|
||||
{
|
||||
return nextarg(prompt, buf, nbuf, eolchar);
|
||||
int newmlargt( char **outbufref, const char *prompt, int size) {
|
||||
return newnextarg( outbufref, prompt, size, metac) ;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -115,18 +156,6 @@ int ectoc(int c)
|
||||
return c;
|
||||
}
|
||||
|
||||
/*
|
||||
* ctoec:
|
||||
* character to extended character
|
||||
* pull out the CONTROL and SPEC prefixes (if possible)
|
||||
*/
|
||||
int ctoec(int c)
|
||||
{
|
||||
if (c >= 0x00 && c <= 0x1F)
|
||||
c = CONTROL | (c + '@');
|
||||
return c;
|
||||
}
|
||||
|
||||
/*
|
||||
* get a command name from the command line. Command completion means
|
||||
* that pressing a <SPACE> will attempt to complete an unfinished command
|
||||
@@ -147,7 +176,7 @@ fn_t getname(void)
|
||||
|
||||
/* if we are executing a command line get the next arg and match it */
|
||||
if (clexec) {
|
||||
if (macarg(buf) != TRUE)
|
||||
if( TRUE != gettokval( buf, sizeof buf))
|
||||
return NULL;
|
||||
return fncmatch(&buf[0]);
|
||||
}
|
||||
@@ -457,6 +486,26 @@ handle_CSI:
|
||||
return CTLX | c;
|
||||
}
|
||||
|
||||
#ifdef CYGWIN
|
||||
/* Accept UTF-8 sequence */
|
||||
if( c <= 0xC1 || c > 0xF4)
|
||||
return c ;
|
||||
else {
|
||||
char utf[ 4] ;
|
||||
char cc ;
|
||||
|
||||
utf[ 0] = c ;
|
||||
utf[ 1] = cc = get1key() ;
|
||||
if( (c & 0x20) && ((cc & 0xC0) == 0x80)) { /* at least 3 bytes and a valid encoded char */
|
||||
utf[ 2] = cc = get1key() ;
|
||||
if( (c & 0x10) && ((cc & 0xC0) == 0x80)) /* at least 4 bytes and a valid encoded char */
|
||||
utf[ 3] = get1key() ;
|
||||
}
|
||||
|
||||
utf8_to_unicode( utf, 0, sizeof utf, (unicode_t *) &c) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* otherwise, just return it */
|
||||
return c;
|
||||
}
|
||||
@@ -492,7 +541,7 @@ int getstring( const char *prompt, char *buf, int nbuf, int eolchar)
|
||||
quotef = FALSE;
|
||||
|
||||
/* prompt the user for the input string */
|
||||
mlwrite(prompt);
|
||||
mlwrite( "%s", prompt);
|
||||
|
||||
for (;;) {
|
||||
#if COMPLC
|
||||
@@ -519,6 +568,11 @@ int getstring( const char *prompt, char *buf, int nbuf, int eolchar)
|
||||
mlwrite("");
|
||||
TTflush();
|
||||
|
||||
if( tmpf != NULL) {
|
||||
fclose( tmpf) ;
|
||||
unlink( tmp) ;
|
||||
}
|
||||
|
||||
/* if we default the buffer, return FALSE */
|
||||
if (buf[0] == 0)
|
||||
return FALSE;
|
||||
@@ -533,6 +587,11 @@ int getstring( const char *prompt, char *buf, int nbuf, int eolchar)
|
||||
/* Abort the input? */
|
||||
ctrlg(FALSE, 0);
|
||||
TTflush();
|
||||
if( tmpf != NULL) {
|
||||
fclose( tmpf) ;
|
||||
unlink( tmp) ;
|
||||
}
|
||||
|
||||
return ABORT;
|
||||
} else if ((c == 0x7F || c == 0x08) && quotef == FALSE) {
|
||||
/* rubout/erase */
|
||||
@@ -608,18 +667,21 @@ int getstring( const char *prompt, char *buf, int nbuf, int eolchar)
|
||||
if (nskip < 0) {
|
||||
buf[ocpos] = 0;
|
||||
#if UNIX
|
||||
if (tmpf != NULL)
|
||||
if (tmpf != NULL) {
|
||||
fclose(tmpf);
|
||||
strcpy(tmp, "/tmp/meXXXXXX");
|
||||
strcpy(ffbuf, "echo ");
|
||||
strcat(ffbuf, buf);
|
||||
if (!iswild)
|
||||
strcat(ffbuf, "*");
|
||||
strcat(ffbuf, " >");
|
||||
xmkstemp(tmp);
|
||||
strcat(ffbuf, tmp);
|
||||
strcat(ffbuf, " 2>&1");
|
||||
system(ffbuf);
|
||||
tmpf = NULL ;
|
||||
unlink( tmp) ;
|
||||
}
|
||||
|
||||
strcpy( tmp, "/tmp/meXXXXXX") ;
|
||||
xmkstemp( tmp) ;
|
||||
if( strlen( buf) < sizeof ffbuf - 26 - 1)
|
||||
sprintf( ffbuf, "echo %s%s >%s 2>&1", buf,
|
||||
!iswild ? "*" : "", tmp) ;
|
||||
else
|
||||
sprintf( ffbuf, "echo ERROR >%s 2>&1", tmp) ;
|
||||
|
||||
ue_system( ffbuf) ;
|
||||
tmpf = fopen(tmp, "r");
|
||||
#endif
|
||||
#if MSDOS
|
||||
@@ -692,7 +754,6 @@ int getstring( const char *prompt, char *buf, int nbuf, int eolchar)
|
||||
TTflush();
|
||||
#if UNIX
|
||||
rewind(tmpf);
|
||||
unlink(tmp);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -724,15 +785,14 @@ int getstring( const char *prompt, char *buf, int nbuf, int eolchar)
|
||||
}
|
||||
|
||||
/*
|
||||
* output a string of characters
|
||||
* output a string of characters when display input is enabled
|
||||
*
|
||||
* char *s; string to output
|
||||
*/
|
||||
void outstring(char *s)
|
||||
{
|
||||
if (disinp)
|
||||
while (*s)
|
||||
TTputc(*s++);
|
||||
static void outstring( char *s) {
|
||||
if( disinp)
|
||||
while( *s)
|
||||
TTputc( *s++) ;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -740,9 +800,9 @@ void outstring(char *s)
|
||||
*
|
||||
* char *s; string to output
|
||||
*/
|
||||
void ostring(char *s)
|
||||
void ostring( char *s)
|
||||
{
|
||||
if (discmd)
|
||||
while (*s)
|
||||
TTputc(*s++);
|
||||
TTputc( *s++ & 0xFF) ;
|
||||
}
|
||||
|
||||
8
input.h
8
input.h
@@ -14,23 +14,23 @@ extern int kbdm[] ; /* Holds kayboard macro data */
|
||||
extern int *kbdptr ; /* current position in keyboard buf */
|
||||
extern int *kbdend ; /* ptr to end of the keyboard */
|
||||
extern int disinp ; /* display input characters */
|
||||
|
||||
extern int metac; /* current meta character */
|
||||
extern int ctlxc; /* current control X prefix char */
|
||||
extern int reptc; /* current universal repeat char */
|
||||
extern int abortc; /* current abort command char */
|
||||
extern const int nlc ; /* end of input char */
|
||||
|
||||
|
||||
int mlyesno( const char *prompt) ;
|
||||
int mlreply( const char *prompt, char *buf, int nbuf) ;
|
||||
int mlreplyt( const char *prompt, char *buf, int nbuf, int eolchar) ;
|
||||
int newmlarg( char **outbufref, const char *prompt, int size) ;
|
||||
int newmlargt( char **outbufref, const char *prompt, int size) ;
|
||||
int ectoc( int c) ;
|
||||
int ctoec( int c) ;
|
||||
fn_t getname( void) ;
|
||||
int tgetc( void) ;
|
||||
int get1key( void) ;
|
||||
int getcmd( void) ;
|
||||
int getstring( const char *prompt, char *buf, int nbuf, int eolchar) ;
|
||||
void outstring( char *s) ;
|
||||
void ostring( char *s) ;
|
||||
|
||||
#endif
|
||||
|
||||
18
isearch.c
18
isearch.c
@@ -185,7 +185,7 @@ static int isearch(int f, int n)
|
||||
{
|
||||
int status; /* Search status */
|
||||
int col; /* prompt column */
|
||||
int cpos; /* character number in search string */
|
||||
unsigned cpos ; /* character number in search string */
|
||||
int c; /* current input character */
|
||||
int expc; /* function expanded input char */
|
||||
spat_t pat_save ; /* Saved copy of the old pattern str */
|
||||
@@ -198,7 +198,8 @@ static int isearch(int f, int n)
|
||||
cmd_reexecute = -1; /* We're not re-executing (yet?) */
|
||||
cmd_offset = 0; /* Start at the beginning of the buff */
|
||||
cmd_buff[0] = '\0'; /* Init the command buffer */
|
||||
strncpy( pat_save, pat, sizeof pat_save) ; /* Save the old pattern string */
|
||||
strncpy( pat_save, pat, sizeof pat_save - 1) ; /* Save the old pattern string */
|
||||
pat_save[ sizeof pat_save - 1] = '\0' ;
|
||||
curline = curwp->w_dotp; /* Save the current line pointer */
|
||||
curoff = curwp->w_doto; /* Save the current offset */
|
||||
init_direction = n; /* Save the initial search direction */
|
||||
@@ -208,7 +209,7 @@ static int isearch(int f, int n)
|
||||
start_over:
|
||||
|
||||
/* ask the user for the text of a pattern */
|
||||
col = promptpattern("ISearch: "); /* Prompt, remember the col */
|
||||
col = promptpattern( "ISearch") ; /* Prompt, remember the col */
|
||||
|
||||
cpos = 0; /* Start afresh */
|
||||
status = TRUE; /* Assume everything's cool */
|
||||
@@ -300,7 +301,7 @@ static int isearch(int f, int n)
|
||||
pat[cpos] = 0; /* null terminate the buffer */
|
||||
col = echo_char(c, col); /* Echo the character */
|
||||
if (!status) { /* If we lost last time */
|
||||
TTputc(BELL); /* Feep again */
|
||||
TTbeep() ; /* Feep again */
|
||||
TTflush(); /* see that the feep feeps */
|
||||
} else /* Otherwise, we must have won */ if (!(status = checknext(c, pat, n))) /* See if match */
|
||||
status = scanmore(pat, n); /* or find the next match */
|
||||
@@ -377,7 +378,7 @@ static int scanmore(char *patrn, int dir) /* search forward or back for a patter
|
||||
sts = scanner(patrn, FORWARD, PTEND); /* Nope. Go forward */
|
||||
|
||||
if (!sts) {
|
||||
TTputc(BELL); /* Feep if search fails */
|
||||
TTbeep() ; /* Feep if search fails */
|
||||
TTflush(); /* see that the feep feeps */
|
||||
}
|
||||
|
||||
@@ -397,7 +398,7 @@ static int scanmore(char *patrn, int dir) /* search forward or back for a patter
|
||||
*/
|
||||
static int match_pat(char *patrn) /* See if the pattern string matches string at "." */
|
||||
{
|
||||
int i; /* Generic loop index/offset */
|
||||
unsigned i ; /* Generic loop index/offset */
|
||||
int buffchar; /* character at current position */
|
||||
struct line *curline; /* current line during scan */
|
||||
int curoff; /* position within current line */
|
||||
@@ -431,10 +432,7 @@ static int promptpattern(char *prompt)
|
||||
{
|
||||
char tpat[NPAT + 20];
|
||||
|
||||
strcpy(tpat, prompt); /* copy prompt to output string */
|
||||
strcat(tpat, " ("); /* build new prompt string */
|
||||
expandp(pat, &tpat[strlen(tpat)], NPAT / 2); /* add old pattern */
|
||||
strcat(tpat, ")<Meta>: ");
|
||||
setprompt( tpat, NPAT / 2, prompt, pat) ;
|
||||
|
||||
/* check to see if we are executing a command line */
|
||||
if (!clexec) {
|
||||
|
||||
128
line.c
128
line.c
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "buffer.h"
|
||||
#include "estruct.h"
|
||||
#include "log.h"
|
||||
#include "mlout.h"
|
||||
#include "window.h"
|
||||
|
||||
|
||||
@@ -92,30 +92,52 @@ char *getkill( void) {
|
||||
* location. Error if you try and move out of the buffer. Set the flag if the
|
||||
* line pointer for dot changes.
|
||||
*/
|
||||
int backchar(int f, int n)
|
||||
{
|
||||
struct line *lp;
|
||||
int backchar( int f, int n) {
|
||||
if( n < 0)
|
||||
return forwchar( f, -n) ;
|
||||
|
||||
if (n < 0)
|
||||
return forwchar(f, -n);
|
||||
while (n--) {
|
||||
if (curwp->w_doto == 0) {
|
||||
if ((lp = lback(curwp->w_dotp)) == curbp->b_linep)
|
||||
return FALSE;
|
||||
curwp->w_dotp = lp;
|
||||
curwp->w_doto = llength(lp);
|
||||
curwp->w_flag |= WFMOVE;
|
||||
while( n--) {
|
||||
if( curwp->w_doto == 0) {
|
||||
struct line *lp ;
|
||||
|
||||
lp = lback( curwp->w_dotp) ;
|
||||
if( lp == curbp->b_linep)
|
||||
return FALSE ;
|
||||
|
||||
curwp->w_dotp = lp ;
|
||||
curwp->w_doto = llength( lp) ;
|
||||
curwp->w_flag |= WFMOVE ;
|
||||
} else {
|
||||
do {
|
||||
unsigned char c;
|
||||
curwp->w_doto--;
|
||||
c = lgetc(curwp->w_dotp, curwp->w_doto);
|
||||
if (is_beginning_utf8(c))
|
||||
break;
|
||||
} while (curwp->w_doto);
|
||||
unsigned pos ;
|
||||
|
||||
pos = curwp->w_doto -= 1 ;
|
||||
if( pos > 0) {
|
||||
unsigned char *p ;
|
||||
|
||||
p = (unsigned char *) &( (curwp->w_dotp)->l_text[ pos]) ;
|
||||
if( (*p & 0xC0) == 0x80) {
|
||||
unsigned char c ;
|
||||
int delta = 0 ;
|
||||
|
||||
c = *--p ;
|
||||
if( (c & 0xE0) == 0xC0) /* valid 2 bytes unicode seq */
|
||||
delta = 1 ;
|
||||
else if( ((c & 0xC0) == 0x80) && (pos > 1)) {
|
||||
c = *--p ;
|
||||
if( (c & 0xF0) == 0xE0) /* valid 3 bytes unicode seq */
|
||||
delta = 2 ;
|
||||
else if( ((c & 0xC0) == 0x80) && (pos > 2))
|
||||
if( (p[ -1] & 0xF8) == 0xF0) /* valid 4 bytes unicode seq */
|
||||
delta = 3 ;
|
||||
}
|
||||
|
||||
curwp->w_doto -= delta ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
return TRUE ;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -137,13 +159,11 @@ int forwchar(int f, int n)
|
||||
curwp->w_doto = 0;
|
||||
curwp->w_flag |= WFMOVE;
|
||||
} else {
|
||||
do {
|
||||
unsigned char c;
|
||||
curwp->w_doto++;
|
||||
c = lgetc(curwp->w_dotp, curwp->w_doto);
|
||||
if (is_beginning_utf8(c))
|
||||
break;
|
||||
} while (curwp->w_doto < len);
|
||||
unicode_t unc ;
|
||||
unsigned bytes ;
|
||||
|
||||
bytes = utf8_to_unicode( curwp->w_dotp->l_text, curwp->w_doto, len, &unc) ;
|
||||
curwp->w_doto += bytes ;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
@@ -164,7 +184,7 @@ struct line *lalloc(int used)
|
||||
if (size == 0) /* Assume that is an empty. */
|
||||
size = BLOCK_SIZE; /* Line is for type-in. */
|
||||
if ((lp = (struct line *)malloc(sizeof(struct line) + size)) == NULL) {
|
||||
logwrite( "(OUT OF MEMORY)") ;
|
||||
mloutstr( "(OUT OF MEMORY)") ;
|
||||
return NULL;
|
||||
}
|
||||
lp->l_size = size;
|
||||
@@ -253,6 +273,8 @@ int insspace(int f, int n)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int linsert_byte( int n, int c) ;
|
||||
|
||||
/*
|
||||
* linstr -- Insert a string at the current point
|
||||
*/
|
||||
@@ -261,15 +283,17 @@ int linstr( char *instr) {
|
||||
int status = TRUE ;
|
||||
|
||||
if( instr != NULL) {
|
||||
char tmpc ;
|
||||
unicode_t tmpc ;
|
||||
|
||||
while( (tmpc = *instr++)) {
|
||||
while( (tmpc = *instr++ & 0xFF)) {
|
||||
status =
|
||||
(tmpc == '\n' ? lnewline() : linsert( 1, tmpc)) ;
|
||||
(tmpc == '\n' ? lnewline() : linsert_byte( 1, tmpc)) ;
|
||||
|
||||
/* Insertion error? */
|
||||
if( status != TRUE)
|
||||
return logger( status, FALSE, "%%Out of memory while inserting") ;
|
||||
if( status != TRUE) {
|
||||
mloutstr( "%Out of memory while inserting") ;
|
||||
return status ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +330,7 @@ static int linsert_byte(int n, int c)
|
||||
lp1 = curwp->w_dotp; /* Current line */
|
||||
if (lp1 == curbp->b_linep) { /* At the end: special */
|
||||
if (curwp->w_doto != 0) {
|
||||
logwrite( "bug: linsert") ;
|
||||
mloutstr( "bug: linsert") ;
|
||||
return FALSE;
|
||||
}
|
||||
if ((lp2 = lalloc(n)) == NULL) /* Allocate new line */
|
||||
@@ -367,8 +391,7 @@ static int linsert_byte(int n, int c)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int linsert(int n, int c)
|
||||
{
|
||||
int linsert( int n, unicode_t c) {
|
||||
char utf8[6];
|
||||
int bytes, i ;
|
||||
|
||||
@@ -418,8 +441,10 @@ int lover( char *ostr) {
|
||||
(tmpc == '\n' ? lnewline() : lowrite(tmpc));
|
||||
|
||||
/* Insertion error? */
|
||||
if( status != TRUE)
|
||||
return logger( status, FALSE, "%%Out of memory while overwriting") ;
|
||||
if( status != TRUE) {
|
||||
mloutstr( "%Out of memory while overwriting") ;
|
||||
return status ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -594,14 +619,24 @@ char *getctext(void)
|
||||
int size; /* length of line to return */
|
||||
char *sp; /* string pointer into line */
|
||||
char *dp; /* string pointer into returned line */
|
||||
static char rline[NSTRING]; /* line to return */
|
||||
static int rsize = 0 ;
|
||||
static char *rline ; /* line to return */
|
||||
|
||||
/* find the contents of the current line and its length */
|
||||
lp = curwp->w_dotp;
|
||||
sp = lp->l_text;
|
||||
size = lp->l_used;
|
||||
if (size >= NSTRING)
|
||||
size = NSTRING - 1;
|
||||
if( size >= rsize) {
|
||||
if( rsize)
|
||||
free( rline) ;
|
||||
|
||||
rsize = size + 1 ;
|
||||
rline = malloc( rsize) ;
|
||||
if( rline == NULL) {
|
||||
rsize = 0 ;
|
||||
return "" ;
|
||||
}
|
||||
}
|
||||
|
||||
/* copy it across */
|
||||
dp = rline;
|
||||
@@ -807,3 +842,12 @@ int yank(int f, int n)
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* tell the user that this command is illegal while we are in
|
||||
* VIEW (read-only) mode
|
||||
*/
|
||||
boolean rdonly( void) {
|
||||
mloutfmt( "%B(Key illegal in VIEW mode)") ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
5
line.h
5
line.h
@@ -1,6 +1,7 @@
|
||||
#ifndef LINE_H_
|
||||
#define LINE_H_
|
||||
|
||||
#include "retcode.h"
|
||||
#include "utf8.h"
|
||||
|
||||
#define NLINE 256 /* # of bytes, input line */
|
||||
@@ -38,7 +39,7 @@ void lfree( struct line *lp) ;
|
||||
void lchange( int flag) ;
|
||||
int insspace( int f, int n) ;
|
||||
int linstr( char *instr) ;
|
||||
int linsert( int n, int c) ;
|
||||
int linsert( int n, unicode_t c) ;
|
||||
int lover( char *ostr) ;
|
||||
int lnewline( void) ;
|
||||
int ldelete( long n, int kflag) ;
|
||||
@@ -50,4 +51,6 @@ int kinsert( int c) ;
|
||||
int yank( int f, int n) ;
|
||||
struct line *lalloc( int) ; /* Allocate a line. */
|
||||
|
||||
boolean rdonly( void) ; /* Read Only error message */
|
||||
|
||||
#endif /* LINE_H_ */
|
||||
|
||||
38
log.c
38
log.c
@@ -1,38 +0,0 @@
|
||||
#include "log.h"
|
||||
|
||||
static void logdump( const char *buf, ...) {
|
||||
}
|
||||
|
||||
void (*logwrite)( const char *, ...) = logdump ;
|
||||
|
||||
static boolean logit( boolean retcode, boolean beep_f, const char *buf, ...) {
|
||||
return retcode ;
|
||||
}
|
||||
|
||||
boolean (*logger)( boolean, boolean, const char *, ...) = logit ;
|
||||
|
||||
/*
|
||||
* tell the user that this command is illegal while we are in
|
||||
* VIEW (read-only) mode
|
||||
*/
|
||||
boolean rdonly(void)
|
||||
{
|
||||
/* TTbeep();
|
||||
mlwrite("(Key illegal in VIEW mode)");
|
||||
return FALSE;
|
||||
*/
|
||||
return logger( FALSE, TRUE, "(Key illegal in VIEW mode)");
|
||||
}
|
||||
|
||||
|
||||
|
||||
boolean resterr(void)
|
||||
{
|
||||
/* TTbeep();
|
||||
mlwrite("(That command is RESTRICTED)");
|
||||
return FALSE;
|
||||
*/
|
||||
return logger( FALSE, TRUE, "(That command is RESTRICTED)");
|
||||
}
|
||||
|
||||
|
||||
8
log.h
8
log.h
@@ -1,8 +0,0 @@
|
||||
#include "retcode.h"
|
||||
|
||||
boolean rdonly( void) ;
|
||||
boolean resterr( void) ;
|
||||
|
||||
extern void (*logwrite)( const char *, ...) ;
|
||||
extern boolean (*logger)( boolean, boolean, const char *, ...) ;
|
||||
|
||||
109
main.c
109
main.c
@@ -4,7 +4,11 @@
|
||||
|
||||
/*
|
||||
* main.c
|
||||
|
||||
*
|
||||
* µEMACS 4.2
|
||||
*
|
||||
* Based on:
|
||||
*
|
||||
* uEmacs/PK 4.0
|
||||
*
|
||||
* Based on:
|
||||
@@ -53,10 +57,14 @@
|
||||
*
|
||||
* 4.0 Petri Kutvonen, 1-Sep-91
|
||||
*
|
||||
* This modified version is now called uEmacs/rf.
|
||||
* This modified version is now called uEMACS.
|
||||
*
|
||||
* 4.1 Renaud Fivet, 1-May-13
|
||||
*
|
||||
* Renamed as µEMACS to emphasize UTF-8 support.
|
||||
*
|
||||
* 4.2 Renaud Fivet, 2015-02-12
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
@@ -78,7 +86,7 @@
|
||||
#include "file.h"
|
||||
#include "input.h"
|
||||
#include "lock.h"
|
||||
#include "log.h"
|
||||
#include "mlout.h"
|
||||
#include "random.h"
|
||||
#include "search.h"
|
||||
#include "terminal.h"
|
||||
@@ -99,14 +107,14 @@ extern unsigned _stklen = 32766;
|
||||
static void emergencyexit(int signr)
|
||||
{
|
||||
quickexit(FALSE, 0);
|
||||
quit(TRUE, 0);
|
||||
quit( TRUE, 0) ; /* If quickexit fails (to save changes), do a force quit */
|
||||
}
|
||||
#endif
|
||||
|
||||
static void edinit( char *bname) ;
|
||||
|
||||
static void version( void) {
|
||||
fputs( PROGRAM_NAME_LONG " version " VERSION "\n", stdout) ;
|
||||
fputs( PROGRAM_NAME_PFX PROGRAM_NAME_LONG " version " VERSION "\n", stdout) ;
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +124,7 @@ static void usage( void) {
|
||||
" +<n> start at line <n>\n"
|
||||
" --help display this help and exit\n"
|
||||
" --version output version information and exit\n"
|
||||
" @cmdfile execute command file\n"
|
||||
" @cmdfile execute startup file\n"
|
||||
" -a|A process error file\n"
|
||||
" -e|E edit file\n"
|
||||
" -g|G<n> go to line <n>\n"
|
||||
@@ -126,18 +134,12 @@ static void usage( void) {
|
||||
" -r|R restrictive use\n"
|
||||
" -s|S<string> search string\n"
|
||||
" -v|V view file\n"
|
||||
" -x|Xcmdfile\n"
|
||||
" -x|X cmdfile execute command file\n"
|
||||
, stdout) ;
|
||||
}
|
||||
|
||||
|
||||
static boolean mllog( boolean retcode, boolean beep_f, const char *buf, ...) {
|
||||
if( beep_f)
|
||||
TTbeep() ;
|
||||
|
||||
mlwrite( buf) ;
|
||||
return retcode ;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int c = -1; /* command character */
|
||||
@@ -190,8 +192,7 @@ int main(int argc, char **argv)
|
||||
|
||||
/* Initialize the editor. */
|
||||
vtinit(); /* Display */
|
||||
logwrite = mlwrite ;
|
||||
logger = mllog ;
|
||||
mloutfmt = mlwrite ;
|
||||
edinit("main"); /* Buffers, windows */
|
||||
varinit(); /* user variables */
|
||||
|
||||
@@ -205,6 +206,9 @@ int main(int argc, char **argv)
|
||||
cryptflag = FALSE; /* no encryption by default */
|
||||
#endif
|
||||
|
||||
/* Insure screen is initialized before startup and goto/search */
|
||||
update( FALSE) ;
|
||||
|
||||
/* Parse the command line */
|
||||
for (carg = 1; carg < argc; ++carg) {
|
||||
/* Process Switches */
|
||||
@@ -252,6 +256,19 @@ int main(int argc, char **argv)
|
||||
case 'V':
|
||||
viewflag = TRUE;
|
||||
break;
|
||||
case 'x':
|
||||
case 'X':
|
||||
if( argv[ carg][ 2]) { /* -Xfilename */
|
||||
if( startup( &argv[ carg][ 2]) == TRUE)
|
||||
startflag = TRUE ; /* don't execute emacs.rc */
|
||||
} else if( argv[ carg + 1]) { /* -X filename */
|
||||
if( startup( &argv[ carg + 1][ 0]) == TRUE)
|
||||
startflag = TRUE ; /* don't execute emacs.rc */
|
||||
|
||||
carg += 1 ;
|
||||
}
|
||||
|
||||
break ;
|
||||
default: /* unknown switch */
|
||||
/* ignore this for now */
|
||||
break;
|
||||
@@ -273,7 +290,12 @@ int main(int argc, char **argv)
|
||||
unqname(bname);
|
||||
|
||||
/* set this to inactive */
|
||||
bp = bfind(bname, TRUE, 0);
|
||||
bp = bfind( bname, TRUE, 0) ;
|
||||
if( bp == NULL) {
|
||||
fputs( "Buffer creation failed!\n", stderr) ;
|
||||
exit( EXIT_FAILURE) ;
|
||||
}
|
||||
|
||||
strncpy( bp->b_fname, argv[ carg], sizeof bp->b_fname - 1) ; /* max filename length limited to NFILEN - 1 (79) */
|
||||
bp->b_fname[ sizeof bp->b_fname - 1] = 0 ;
|
||||
bp->b_active = FALSE;
|
||||
@@ -318,25 +340,29 @@ int main(int argc, char **argv)
|
||||
|
||||
/* if there are any files to read, read the first one! */
|
||||
bp = bfind("main", FALSE, 0);
|
||||
if (firstfile == FALSE && (gflags & GFREAD)) {
|
||||
if( bp == NULL) {
|
||||
/* "main" buffer has been created during early initialisation */
|
||||
fputs( "Initialisation failure!\n", stderr) ;
|
||||
exit( EXIT_FAILURE) ;
|
||||
}
|
||||
|
||||
if (firstfile == FALSE && readfirst_f()) {
|
||||
swbuffer(firstbp);
|
||||
zotbuf(bp);
|
||||
} else
|
||||
} else {
|
||||
bp->b_mode |= gmode;
|
||||
upmode() ;
|
||||
}
|
||||
|
||||
/* Deal with startup gotos and searches */
|
||||
if (gotoflag && searchflag) {
|
||||
update(FALSE);
|
||||
mlwrite("(Can not search and goto at the same time!)");
|
||||
} else if (gotoflag) {
|
||||
if (gotoline(TRUE, gline) == FALSE) {
|
||||
update(FALSE);
|
||||
mlwrite("(Bogus goto argument)");
|
||||
}
|
||||
} else if (searchflag) {
|
||||
if (forwhunt(FALSE, 0) == FALSE)
|
||||
update(FALSE);
|
||||
}
|
||||
if( gotoflag && searchflag)
|
||||
mloutstr( "(Can not search and goto at the same time!)") ;
|
||||
else if( gotoflag) {
|
||||
if( gotoline( TRUE, gline) == FALSE)
|
||||
mloutstr( "(Bogus goto argument)") ;
|
||||
} else if( searchflag)
|
||||
if( forwhunt( FALSE, 0))
|
||||
mloutfmt( "Found on line %d", getcline()) ;
|
||||
|
||||
/* Setup to process commands. */
|
||||
lastflag = 0; /* Fake last flags. */
|
||||
@@ -375,7 +401,7 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
/* if there is something on the command line, clear it */
|
||||
if (mpresf != FALSE) {
|
||||
mlerase();
|
||||
mloutstr( "") ;
|
||||
update(FALSE);
|
||||
#if CLRMSG
|
||||
if (c == ' ') /* ITS EMACS does this */
|
||||
@@ -403,9 +429,9 @@ int main(int argc, char **argv)
|
||||
n = n * 10 + (c - '0');
|
||||
}
|
||||
if ((n == 0) && (mflag == -1)) /* lonely - */
|
||||
mlwrite("Arg:");
|
||||
mloutstr( "Arg:") ;
|
||||
else
|
||||
mlwrite("Arg: %d", n * mflag);
|
||||
mloutfmt( "Arg: %d", n * mflag) ;
|
||||
|
||||
c = getcmd(); /* get the next key */
|
||||
}
|
||||
@@ -418,7 +444,7 @@ int main(int argc, char **argv)
|
||||
f = TRUE;
|
||||
n = 4; /* with argument of 4 */
|
||||
mflag = 0; /* that can be discarded. */
|
||||
mlwrite("Arg: 4");
|
||||
mloutstr( "Arg: 4") ;
|
||||
while (((c = getcmd()) >= '0' && c <= '9') || c == reptc
|
||||
|| c == '-') {
|
||||
if (c == reptc)
|
||||
@@ -447,8 +473,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
n = 10 * n + c - '0';
|
||||
}
|
||||
mlwrite("Arg: %d",
|
||||
(mflag >= 0) ? n : (n ? -n : -1));
|
||||
mloutfmt( "Arg: %d", (mflag >= 0) ? n : (n ? -n : -1)) ;
|
||||
}
|
||||
/*
|
||||
* Make arguments preceded by a minus sign negative and change
|
||||
@@ -479,8 +504,11 @@ static void edinit(char *bname)
|
||||
bp = bfind(bname, TRUE, 0); /* First buffer */
|
||||
blistp = bfind("*List*", TRUE, BFINVS); /* Buffer list buffer */
|
||||
wp = (struct window *)malloc(sizeof(struct window)); /* First window */
|
||||
if (bp == NULL || wp == NULL || blistp == NULL)
|
||||
exit(1);
|
||||
if (bp == NULL || wp == NULL || blistp == NULL) {
|
||||
fputs( "First initialisation failed!\n", stderr) ;
|
||||
exit( EXIT_FAILURE) ;
|
||||
}
|
||||
|
||||
curbp = bp; /* Make this current */
|
||||
wheadp = wp;
|
||||
curwp = wp;
|
||||
@@ -593,8 +621,7 @@ static void dspram( void)
|
||||
*
|
||||
* int status; return status of emacs
|
||||
*/
|
||||
int cexit(int status)
|
||||
{
|
||||
void cexit( int status) {
|
||||
struct buffer *bp; /* buffer list pointer */
|
||||
struct window *wp; /* window list pointer */
|
||||
struct window *tp; /* temporary window pointer */
|
||||
|
||||
15
mlout.c
Normal file
15
mlout.c
Normal file
@@ -0,0 +1,15 @@
|
||||
/* mlout.c -- implements mlout.h */
|
||||
|
||||
#include "mlout.h"
|
||||
|
||||
/* by default just use a stub */
|
||||
static void mloutdump( const char *buf, ...) {
|
||||
}
|
||||
|
||||
void (*mloutfmt)( const char *, ...) = mloutdump ;
|
||||
|
||||
void mloutstr( const char *str) {
|
||||
mloutfmt( (*str) ? "%s" : "", str) ;
|
||||
}
|
||||
|
||||
/* end of mlout.c */
|
||||
12
mlout.h
Normal file
12
mlout.h
Normal file
@@ -0,0 +1,12 @@
|
||||
/* mlout.h -- message line output interface */
|
||||
|
||||
#ifndef __MLOUT_H__
|
||||
#define __MLOUT_H__
|
||||
|
||||
extern void (*mloutfmt)( const char *, ...) ;
|
||||
|
||||
void mloutstr( const char *str) ;
|
||||
|
||||
#endif /* __MLOUT_H__ */
|
||||
|
||||
/* end of mlout.h */
|
||||
11
pklock.c
11
pklock.c
@@ -84,7 +84,16 @@ char *dolock( const char *fname)
|
||||
cuserid(locker);
|
||||
strcat(locker + strlen(locker), "@");
|
||||
gethostname(locker + strlen(locker), 64);
|
||||
write(fd, locker, strlen(locker));
|
||||
{
|
||||
int ret, locker_size ;
|
||||
|
||||
locker_size = strlen( locker) ;
|
||||
ret = write( fd, locker, locker_size) ;
|
||||
if( ret != locker_size) {
|
||||
/* some error handling here */
|
||||
}
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
6
posix.c
6
posix.c
@@ -1,4 +1,6 @@
|
||||
/* posix.c -- implements termio.h */
|
||||
/* posix.c -- posix implementation of termio.h */
|
||||
#ifdef POSIX
|
||||
|
||||
#include "termio.h"
|
||||
|
||||
/* posix.c
|
||||
@@ -13,8 +15,6 @@
|
||||
* fixed for termios rather than the old termio.. Linus Torvalds
|
||||
*/
|
||||
|
||||
#ifdef POSIX
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
|
||||
157
random.c
157
random.c
@@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "basic.h"
|
||||
@@ -21,7 +22,6 @@
|
||||
#include "execute.h"
|
||||
#include "input.h"
|
||||
#include "line.h"
|
||||
#include "log.h"
|
||||
#include "search.h"
|
||||
#include "terminal.h"
|
||||
#include "window.h"
|
||||
@@ -49,6 +49,9 @@ int thisflag ; /* Flags, this command */
|
||||
int lastflag ; /* Flags, last command */
|
||||
|
||||
|
||||
static int adjustmode( int kind, int global) ;
|
||||
static int cinsert( void) ;
|
||||
|
||||
/*
|
||||
* Set fill column to n.
|
||||
*/
|
||||
@@ -73,7 +76,8 @@ int showcpos(int f, int n)
|
||||
int numlines; /* # of lines in file */
|
||||
long predchars; /* # chars preceding point */
|
||||
int predlines; /* # lines preceding point */
|
||||
int curchar; /* character under cursor */
|
||||
unicode_t curchar ; /* character under cursor */
|
||||
unsigned bytes ; /* length of unicode sequence */
|
||||
int ratio;
|
||||
int col;
|
||||
int savepos; /* temp save for current offset */
|
||||
@@ -88,19 +92,23 @@ int showcpos(int f, int n)
|
||||
predchars = 0;
|
||||
predlines = 0;
|
||||
curchar = 0;
|
||||
bytes = 1 ;
|
||||
while (lp != curbp->b_linep) {
|
||||
/* if we are on the current line, record it */
|
||||
if (lp == curwp->w_dotp) {
|
||||
int len ;
|
||||
|
||||
predlines = numlines;
|
||||
predchars = numchars + curwp->w_doto;
|
||||
if ((curwp->w_doto) == llength(lp))
|
||||
curchar = '\n';
|
||||
len = llength( lp) ;
|
||||
if( (curwp->w_doto) == len)
|
||||
curchar = (curbp->b_mode & MDDOS) ? '\r' : '\n' ;
|
||||
else
|
||||
curchar = lgetc(lp, curwp->w_doto);
|
||||
bytes = utf8_to_unicode( lp->l_text, curwp->w_doto, len, &curchar) ;
|
||||
}
|
||||
/* on to the next line */
|
||||
++numlines;
|
||||
numchars += llength(lp) + 1;
|
||||
numchars += llength( lp) + ((curbp->b_mode & MDDOS) ? 2 : 1) ;
|
||||
lp = lforw(lp);
|
||||
}
|
||||
|
||||
@@ -125,9 +133,9 @@ int showcpos(int f, int n)
|
||||
ratio = (100L * predchars) / numchars;
|
||||
|
||||
/* summarize and report the info */
|
||||
mlwrite("Line %d/%d Col %d/%d Char %D/%D (%d%%) char = 0x%x",
|
||||
mlwrite("Line %d/%d Col %d/%d Char %D/%D (%d%%) char = %s%x",
|
||||
predlines + 1, numlines + 1, col, ecol,
|
||||
predchars, numchars, ratio, curchar);
|
||||
predchars, numchars, ratio, (bytes > 1) ? "\\u" : "0x", curchar);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -168,13 +176,13 @@ int getccol(int bflg)
|
||||
unicode_t c;
|
||||
|
||||
i += utf8_to_unicode(dlp->l_text, i, len, &c);
|
||||
if (c != ' ' && c != '\t' && bflg)
|
||||
if( bflg && c != ' ' && c != '\t') /* Request Stop at first non-blank */
|
||||
break;
|
||||
if (c == '\t')
|
||||
col |= tabmask;
|
||||
else if (c < 0x20 || c == 0x7F)
|
||||
else if (c < 0x20 || c == 0x7F) /* displayed as ^c */
|
||||
++col;
|
||||
else if (c >= 0xc0 && c <= 0xa0)
|
||||
else if (c >= 0x80 && c <= 0xa0) /* displayed as \xx */
|
||||
col += 2;
|
||||
++col;
|
||||
}
|
||||
@@ -522,7 +530,7 @@ int insert_newline(int f, int n)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int cinsert(void)
|
||||
static int cinsert(void)
|
||||
{ /* insert a newline and indentation for C */
|
||||
char *cptr; /* string pointer into text to copy */
|
||||
int tptr; /* index to scan into line */
|
||||
@@ -932,12 +940,11 @@ int delgmode(int f, int n)
|
||||
* int kind; true = set, false = delete
|
||||
* int global; true = global flag, false = current buffer flag
|
||||
*/
|
||||
int adjustmode(int kind, int global)
|
||||
{
|
||||
int i; /* loop index */
|
||||
static int adjustmode( int kind, int global) {
|
||||
unsigned i ; /* loop index */
|
||||
int status; /* error return on input */
|
||||
char prompt[50]; /* string to prompt user with */
|
||||
char cbuf[ NSTRING] ; /* buffer to recieve mode name into */
|
||||
char *cbuf ; /* buffer to recieve mode name into */
|
||||
|
||||
/* build the proper prompt string */
|
||||
if (global)
|
||||
@@ -952,7 +959,7 @@ int adjustmode(int kind, int global)
|
||||
|
||||
/* prompt the user and get an answer */
|
||||
|
||||
status = mlreply( prompt, cbuf, sizeof cbuf - 1) ;
|
||||
status = newmlarg( &cbuf, prompt, 0) ;
|
||||
if (status != TRUE)
|
||||
return status;
|
||||
|
||||
@@ -980,6 +987,7 @@ int adjustmode(int kind, int global)
|
||||
curwp->w_flag |= WFCOLR;
|
||||
#endif
|
||||
mlerase();
|
||||
free( cbuf) ;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -1002,59 +1010,16 @@ int adjustmode(int kind, int global)
|
||||
if (global == 0)
|
||||
upmode();
|
||||
mlerase(); /* erase the junk */
|
||||
free( cbuf) ;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
mlwrite("No such mode!");
|
||||
free( cbuf) ;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function simply clears the message line,
|
||||
* mainly for macro usage
|
||||
*
|
||||
* int f, n; arguments ignored
|
||||
*/
|
||||
int clrmes(int f, int n)
|
||||
{
|
||||
mlforce("");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function writes a string on the message line
|
||||
* mainly for macro usage
|
||||
*
|
||||
* int f, n; arguments ignored
|
||||
*/
|
||||
int writemsg(int f, int n)
|
||||
{
|
||||
char *sp; /* pointer into buf to expand %s */
|
||||
char *np; /* ptr into nbuf */
|
||||
int status;
|
||||
char buf[ NSTRING] ; /* buffer to recieve message into */
|
||||
char nbuf[ NSTRING * 2] ; /* buffer to expand string into */
|
||||
|
||||
if ((status =
|
||||
mlreply("Message to write: ", buf, sizeof buf - 1)) != TRUE)
|
||||
return status;
|
||||
|
||||
/* expand all '%' to "%%" so mlwrite won't expect arguments */
|
||||
sp = buf;
|
||||
np = nbuf;
|
||||
while (*sp) {
|
||||
*np++ = *sp;
|
||||
if (*sp++ == '%')
|
||||
*np++ = '%';
|
||||
}
|
||||
*np = '\0';
|
||||
|
||||
/* write the message out */
|
||||
mlforce(nbuf);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if CFENCE
|
||||
/*
|
||||
* the cursor is moved to a matching fence
|
||||
@@ -1222,32 +1187,36 @@ int fmatch(int ch)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int iovstring( int f, int n, const char *prompt, int (*fun)( char *)) {
|
||||
int status ; /* status return code */
|
||||
char *tstring ; /* string to add */
|
||||
|
||||
/* ask for string to insert */
|
||||
status = newmlargt( &tstring, prompt, 0) ; /* grab as big a token as screen allow */
|
||||
if( tstring == NULL)
|
||||
return status ;
|
||||
|
||||
if( f == FALSE)
|
||||
n = 1 ;
|
||||
else if( n < 0)
|
||||
n = -n ;
|
||||
|
||||
/* insert it */
|
||||
while( n-- && status == TRUE)
|
||||
status = fun( tstring) ;
|
||||
|
||||
free( tstring) ;
|
||||
return status ;
|
||||
}
|
||||
|
||||
/*
|
||||
* ask for and insert a string into the current
|
||||
* buffer at the current point
|
||||
*
|
||||
* int f, n; ignored arguments
|
||||
*/
|
||||
int istring(int f, int n)
|
||||
{
|
||||
int status; /* status return code */
|
||||
char tstring[ 512] ; /* string to add */
|
||||
|
||||
/* ask for string to insert */
|
||||
status =
|
||||
mlreplyt("String to insert<META>: ", tstring, sizeof tstring - 1, metac) ;
|
||||
if (status != TRUE)
|
||||
return status;
|
||||
|
||||
if (f == FALSE)
|
||||
n = 1;
|
||||
|
||||
if (n < 0)
|
||||
n = -n;
|
||||
|
||||
/* insert it */
|
||||
while (n-- && (status = linstr(tstring)));
|
||||
return status;
|
||||
int istring( int f, int n) {
|
||||
return iovstring( f, n, "String to insert<META>: ", linstr) ;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1256,24 +1225,8 @@ int istring(int f, int n)
|
||||
*
|
||||
* int f, n; ignored arguments
|
||||
*/
|
||||
int ovstring(int f, int n)
|
||||
{
|
||||
int status; /* status return code */
|
||||
char tstring[ NSTRING + 1] ; /* string to add */
|
||||
|
||||
/* ask for string to insert */
|
||||
status =
|
||||
mlreplyt( "String to overwrite<META>: ", tstring, NSTRING, metac) ;
|
||||
if (status != TRUE)
|
||||
return status;
|
||||
|
||||
if (f == FALSE)
|
||||
n = 1;
|
||||
|
||||
if (n < 0)
|
||||
n = -n;
|
||||
|
||||
/* insert it */
|
||||
while (n-- && (status = lover(tstring)));
|
||||
return status;
|
||||
int ovstring( int f, int n) {
|
||||
return iovstring( f, n, "String to overwrite<META>: ", lover) ;
|
||||
}
|
||||
|
||||
/* end of random.c */
|
||||
|
||||
4
random.h
4
random.h
@@ -29,7 +29,6 @@ int trim( int f, int n) ;
|
||||
#endif
|
||||
int openline( int f, int n) ;
|
||||
int insert_newline( int f, int n) ;
|
||||
int cinsert( void) ;
|
||||
int insbrace( int n, int c) ;
|
||||
int inspound( void) ;
|
||||
int deblank( int f, int n) ;
|
||||
@@ -41,9 +40,6 @@ int setemode( int f, int n) ;
|
||||
int delmode( int f, int n) ;
|
||||
int setgmode( int f, int n) ;
|
||||
int delgmode( int f, int n) ;
|
||||
int adjustmode( int kind, int global) ;
|
||||
int clrmes( int f, int n) ;
|
||||
int writemsg( int f, int n) ;
|
||||
int getfence( int f, int n) ;
|
||||
int fmatch( int ch) ;
|
||||
int istring( int f, int n) ;
|
||||
|
||||
8
region.c
8
region.c
@@ -15,7 +15,7 @@
|
||||
#include "buffer.h"
|
||||
#include "estruct.h"
|
||||
#include "line.h"
|
||||
#include "log.h"
|
||||
#include "mlout.h"
|
||||
#include "random.h"
|
||||
#include "window.h"
|
||||
|
||||
@@ -74,7 +74,7 @@ int copyregion(int f, int n)
|
||||
++loffs;
|
||||
}
|
||||
}
|
||||
logwrite("(region copied)");
|
||||
mloutstr( "(region copied)") ;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ int getregion(struct region *rp)
|
||||
long bsize;
|
||||
|
||||
if (curwp->w_markp == NULL) {
|
||||
logwrite("No mark set in this window");
|
||||
mloutstr( "No mark set in this window") ;
|
||||
return FALSE;
|
||||
}
|
||||
if (curwp->w_dotp == curwp->w_markp) {
|
||||
@@ -213,6 +213,6 @@ int getregion(struct region *rp)
|
||||
}
|
||||
}
|
||||
}
|
||||
logwrite("Bug: lost mark");
|
||||
mloutstr( "Bug: lost mark") ;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
100
search.c
100
search.c
@@ -70,7 +70,7 @@
|
||||
#include "estruct.h"
|
||||
#include "input.h"
|
||||
#include "line.h"
|
||||
#include "log.h"
|
||||
#include "mlout.h"
|
||||
#include "terminal.h"
|
||||
#include "window.h"
|
||||
|
||||
@@ -93,6 +93,9 @@ spat_t rpat ; /* replacement pattern */
|
||||
|
||||
|
||||
#if defined(MAGIC)
|
||||
|
||||
#define BELL 0x07 /* a bell character */
|
||||
|
||||
/*
|
||||
* Defines for the metacharacters in the regular expression
|
||||
* search routines.
|
||||
@@ -213,7 +216,7 @@ int forwsearch(int f, int n)
|
||||
if (status == TRUE)
|
||||
savematch();
|
||||
else
|
||||
mlwrite("Not found");
|
||||
mloutstr( "Not found") ;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
@@ -236,7 +239,7 @@ int forwhunt(int f, int n)
|
||||
* into MAGIC mode until after we entered the pattern.
|
||||
*/
|
||||
if (pat[0] == '\0') {
|
||||
mlwrite("No pattern set");
|
||||
mloutstr( "No pattern set") ;
|
||||
return FALSE;
|
||||
}
|
||||
#if MAGIC
|
||||
@@ -266,7 +269,7 @@ int forwhunt(int f, int n)
|
||||
if (status == TRUE)
|
||||
savematch();
|
||||
else
|
||||
mlwrite("Not found");
|
||||
mloutstr( "Not found") ;
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -314,7 +317,7 @@ int backsearch(int f, int n)
|
||||
if (status == TRUE)
|
||||
savematch();
|
||||
else
|
||||
mlwrite("Not found");
|
||||
mloutstr( "Not found") ;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
@@ -338,7 +341,7 @@ int backhunt(int f, int n)
|
||||
* into MAGIC mode until after we entered the pattern.
|
||||
*/
|
||||
if (tap[0] == '\0') {
|
||||
mlwrite("No pattern set");
|
||||
mloutstr( "No pattern set") ;
|
||||
return FALSE;
|
||||
}
|
||||
#if MAGIC
|
||||
@@ -368,7 +371,7 @@ int backhunt(int f, int n)
|
||||
if (status == TRUE)
|
||||
savematch();
|
||||
else
|
||||
mlwrite("Not found");
|
||||
mloutstr( "Not found") ;
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -510,8 +513,7 @@ static int amatch(struct magic *mcptr, int direct, struct line **pcwline, int *p
|
||||
mcptr++;
|
||||
|
||||
for (;;) {
|
||||
c = nextch(&curline, &curoff,
|
||||
direct ^ REVERSE);
|
||||
(void) nextch( &curline, &curoff, direct ^ REVERSE) ;
|
||||
|
||||
if (amatch
|
||||
(mcptr, direct, &curline, &curoff)) {
|
||||
@@ -680,6 +682,14 @@ int eq(unsigned char bc, unsigned char pc)
|
||||
return bc == pc;
|
||||
}
|
||||
|
||||
void setprompt( char *tpat, unsigned tpat_size, char *prompt, char *apat) {
|
||||
strncpy( tpat, prompt, 14) ; /* copy prompt to output string */
|
||||
tpat[ 14] = '\0' ; /* longest prompt is "Reverse Search" */
|
||||
strcat( tpat, " (") ; /* build new prompt string */
|
||||
expandp( apat, &tpat[ strlen( tpat)], tpat_size) ; /* add old pattern */
|
||||
strcat( tpat, ")<Meta>: ") ;
|
||||
}
|
||||
|
||||
/*
|
||||
* readpattern -- Read a pattern. Stash it in apat. If it is the
|
||||
* search string, create the reverse pattern and the magic
|
||||
@@ -695,19 +705,20 @@ static int readpattern(char *prompt, char *apat, int srch)
|
||||
{
|
||||
int status;
|
||||
char tpat[NPAT + 20];
|
||||
char *dynpat ; /* dynamically allocated pattern buffer */
|
||||
|
||||
strcpy(tpat, prompt); /* copy prompt to output string */
|
||||
strcat(tpat, " ("); /* build new prompt string */
|
||||
expandp(&apat[0], &tpat[strlen(tpat)], NPAT / 2); /* add old pattern */
|
||||
strcat(tpat, ")<Meta>: ");
|
||||
setprompt( tpat, NPAT / 2, prompt, apat) ;
|
||||
|
||||
/* Read a pattern. Either we get one,
|
||||
* or we just get the META charater, and use the previous pattern.
|
||||
* Then, if it's the search string, make a reversed pattern.
|
||||
* *Then*, make the meta-pattern, if we are defined that way.
|
||||
*/
|
||||
if ((status = mlreplyt(tpat, tpat, NPAT, metac)) == TRUE) {
|
||||
strcpy(apat, tpat);
|
||||
status = newmlargt( &dynpat, tpat, NPAT) ;
|
||||
if( status == TRUE) {
|
||||
strncpy( apat, dynpat, NPAT - 1) ;
|
||||
apat[ NPAT - 1] = 0 ;
|
||||
free( dynpat) ;
|
||||
if (srch) { /* If we are doing the search string. */
|
||||
/* Reverse string copy, and remember
|
||||
* the length for substitution purposes.
|
||||
@@ -738,7 +749,6 @@ static int readpattern(char *prompt, char *apat, int srch)
|
||||
void savematch(void)
|
||||
{
|
||||
char *ptr; /* pointer to last match string */
|
||||
int j;
|
||||
struct line *curline; /* line of last match */
|
||||
int curoff; /* offset " " */
|
||||
|
||||
@@ -751,6 +761,8 @@ void savematch(void)
|
||||
ptr = patmatch = malloc(matchlen + 1);
|
||||
|
||||
if (ptr != NULL) {
|
||||
unsigned j ;
|
||||
|
||||
curoff = matchoff;
|
||||
curline = matchline;
|
||||
|
||||
@@ -906,12 +918,12 @@ static int replaces(int kind, int f, int n)
|
||||
if (kind) {
|
||||
/* Get the query.
|
||||
*/
|
||||
pprompt:mlwrite(&tpat[0], &pat[0],
|
||||
&rpat[0]);
|
||||
qprompt:
|
||||
pprompt:
|
||||
mloutstr( tpat) ;
|
||||
qprompt:
|
||||
update(TRUE); /* show the proposed place to change */
|
||||
c = tgetc(); /* and input */
|
||||
mlwrite(""); /* and clear it */
|
||||
mloutstr( "") ; /* and clear it */
|
||||
|
||||
/* And respond appropriately.
|
||||
*/
|
||||
@@ -979,17 +991,17 @@ static int replaces(int kind, int f, int n)
|
||||
curwp->w_dotp = origline;
|
||||
curwp->w_doto = origoff;
|
||||
curwp->w_flag |= WFMOVE;
|
||||
|
||||
/* fallthrough */
|
||||
case BELL: /* abort! and stay */
|
||||
mlwrite("Aborted!");
|
||||
return FALSE;
|
||||
mloutstr( "Aborted!") ;
|
||||
return FALSE ;
|
||||
|
||||
default: /* bitch and beep */
|
||||
TTbeep();
|
||||
|
||||
/* fallthrough */
|
||||
case '?': /* help me */
|
||||
mlwrite
|
||||
("(Y)es, (N)o, (!)Do rest, (U)ndo last, (^G)Abort, (.)Abort back, (?)Help: ");
|
||||
mloutstr(
|
||||
"(Y)es, (N)o, (!)Do rest, (U)ndo last, (^G)Abort, (.)Abort back, (?)Help: ") ;
|
||||
goto qprompt;
|
||||
|
||||
} /* end of switch */
|
||||
@@ -1017,7 +1029,7 @@ static int replaces(int kind, int f, int n)
|
||||
|
||||
/* And report the results.
|
||||
*/
|
||||
mlwrite("%d substitutions", numsub);
|
||||
mloutfmt( "%d substitutions", numsub) ;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -1037,7 +1049,7 @@ int delins(int dlength, char *instr, int use_meta)
|
||||
* and insert its replacement.
|
||||
*/
|
||||
if ((status = ldelete((long) dlength, FALSE)) != TRUE)
|
||||
mlwrite("%%ERROR while deleting");
|
||||
mloutstr( "%ERROR while deleting") ;
|
||||
else
|
||||
#if MAGIC
|
||||
if ((rmagical && use_meta) &&
|
||||
@@ -1087,12 +1099,7 @@ int expandp(char *srcstr, char *deststr, int maxlength)
|
||||
*deststr++ = '^';
|
||||
*deststr++ = c ^ 0x40;
|
||||
maxlength -= 2;
|
||||
} else if (c == '%') {
|
||||
*deststr++ = '%';
|
||||
*deststr++ = '%';
|
||||
maxlength -= 2;
|
||||
} else { /* any other character */
|
||||
|
||||
*deststr++ = c;
|
||||
maxlength--;
|
||||
}
|
||||
@@ -1252,6 +1259,8 @@ static int mcstr(void)
|
||||
pchr = *++patptr;
|
||||
magical = TRUE;
|
||||
}
|
||||
|
||||
/* fallthrough */
|
||||
default:
|
||||
litcase:mcptr->mc_type =
|
||||
LITCHAR;
|
||||
@@ -1324,7 +1333,7 @@ static int rmcstr(void)
|
||||
rmcptr->mc_type = LITCHAR;
|
||||
if ((rmcptr->rstr =
|
||||
malloc(mj + 1)) == NULL) {
|
||||
mlwrite("%%Out of memory");
|
||||
mloutstr( "%Out of memory") ;
|
||||
status = FALSE;
|
||||
break;
|
||||
}
|
||||
@@ -1345,7 +1354,7 @@ static int rmcstr(void)
|
||||
* current character.
|
||||
*/
|
||||
if ((rmcptr->rstr = malloc(mj + 2)) == NULL) {
|
||||
mlwrite("%%Out of memory");
|
||||
mloutstr( "%Out of memory") ;
|
||||
status = FALSE;
|
||||
break;
|
||||
}
|
||||
@@ -1374,11 +1383,12 @@ static int rmcstr(void)
|
||||
if (rmagical && mj > 0) {
|
||||
rmcptr->mc_type = LITCHAR;
|
||||
if ((rmcptr->rstr = malloc(mj + 1)) == NULL) {
|
||||
mlwrite("%%Out of memory.");
|
||||
mloutstr( "%Out of memory") ;
|
||||
status = FALSE;
|
||||
} else {
|
||||
strncpy(rmcptr->rstr, patptr - mj, mj);
|
||||
rmcptr++;
|
||||
}
|
||||
strncpy(rmcptr->rstr, patptr - mj, mj);
|
||||
rmcptr++;
|
||||
}
|
||||
|
||||
rmcptr->mc_type = MCNIL;
|
||||
@@ -1461,7 +1471,7 @@ static int mceq(int bc, struct magic *mt)
|
||||
break;
|
||||
|
||||
default:
|
||||
mlwrite("mceq: what is %d?", mt->mc_type);
|
||||
mloutfmt( "mceq: what is %d?", mt->mc_type) ;
|
||||
result = FALSE;
|
||||
break;
|
||||
|
||||
@@ -1483,7 +1493,7 @@ static int cclmake(char **ppatptr, struct magic *mcptr)
|
||||
int pchr, ochr;
|
||||
|
||||
if ((bmap = clearbits()) == NULL) {
|
||||
mlwrite("%%Out of memory");
|
||||
mloutstr( "%Out of memory") ;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1503,7 +1513,7 @@ static int cclmake(char **ppatptr, struct magic *mcptr)
|
||||
mcptr->mc_type = CCL;
|
||||
|
||||
if ((ochr = *patptr) == MC_ECCL) {
|
||||
mlwrite("%%No characters in character class");
|
||||
mloutstr( "%No characters in character class") ;
|
||||
return FALSE;
|
||||
} else {
|
||||
if (ochr == MC_ESC)
|
||||
@@ -1533,6 +1543,7 @@ static int cclmake(char **ppatptr, struct magic *mcptr)
|
||||
*/
|
||||
case MC_ESC:
|
||||
pchr = *++patptr;
|
||||
/* falltrhough */
|
||||
default:
|
||||
setbit(pchr, bmap);
|
||||
break;
|
||||
@@ -1544,7 +1555,7 @@ static int cclmake(char **ppatptr, struct magic *mcptr)
|
||||
*ppatptr = patptr;
|
||||
|
||||
if (ochr == '\0') {
|
||||
mlwrite("%%Character class not ended");
|
||||
mloutstr( "%Character class not ended") ;
|
||||
free(bmap);
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1557,10 +1568,11 @@ static int cclmake(char **ppatptr, struct magic *mcptr)
|
||||
static int biteq(int bc, char *cclmap)
|
||||
{
|
||||
#if PKCODE
|
||||
bc = bc & 0xFF;
|
||||
#endif
|
||||
bc &= 0xFF ;
|
||||
#else
|
||||
if (bc >= HICHAR)
|
||||
return FALSE;
|
||||
#endif
|
||||
|
||||
return (*(cclmap + (bc >> 3)) & BIT(bc & 7)) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
4
search.h
4
search.h
@@ -5,8 +5,6 @@
|
||||
|
||||
#include "line.h"
|
||||
|
||||
#define BELL 0x07 /* a bell character */
|
||||
|
||||
typedef char spat_t[ 128] ; /* search pattern type */
|
||||
#define NPAT sizeof( spat_t) /* # of bytes, pattern */
|
||||
|
||||
@@ -41,6 +39,8 @@ int delins( int dlength, char *instr, int use_meta) ;
|
||||
int expandp( char *srcstr, char *deststr, int maxlength) ;
|
||||
int boundry( struct line *curline, int curoff, int dir) ;
|
||||
|
||||
void setprompt( char *tpat, unsigned tpat_size, char *prompt, char *apat) ;
|
||||
|
||||
#if MAGIC
|
||||
void mcclear( void) ;
|
||||
void rmcclear( void) ;
|
||||
|
||||
272
spawn.c
272
spawn.c
@@ -22,7 +22,6 @@
|
||||
#include "file.h"
|
||||
#include "flook.h"
|
||||
#include "input.h"
|
||||
#include "log.h"
|
||||
#include "terminal.h"
|
||||
#include "window.h"
|
||||
|
||||
@@ -42,8 +41,6 @@ extern short iochan; /* In "termio.c" */
|
||||
#if V7 | USG | BSD
|
||||
#include <signal.h>
|
||||
#ifdef SIGWINCH
|
||||
extern int chg_width, chg_height;
|
||||
extern void sizesignal(int);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -51,6 +48,7 @@ extern void sizesignal(int);
|
||||
#include <process.h>
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Create a subjob with a copy of the command intrepreter in it. When the
|
||||
* command interpreter exits, mark the screen as garbage so that you do a full
|
||||
@@ -69,12 +67,12 @@ int spawncli(int f, int n)
|
||||
|
||||
#if VMS
|
||||
movecursor(term.t_nrow, 0); /* In last line. */
|
||||
mlputs("(Starting DCL)\r\n");
|
||||
mlwrite("(Starting DCL)\r\n");
|
||||
TTflush(); /* Ignore "ttcol". */
|
||||
sgarbf = TRUE;
|
||||
sys(NULL);
|
||||
sleep(1);
|
||||
mlputs("\r\n(Returning from DCL)\r\n");
|
||||
mlwrite("\r\n(Returning from DCL)\r\n");
|
||||
TTflush();
|
||||
sleep(1);
|
||||
return TRUE;
|
||||
@@ -94,12 +92,12 @@ int spawncli(int f, int n)
|
||||
TTclose(); /* stty to old settings */
|
||||
TTkclose(); /* Close "keyboard" */
|
||||
if ((cp = getenv("SHELL")) != NULL && *cp != '\0')
|
||||
system(cp);
|
||||
ue_system( cp) ;
|
||||
else
|
||||
#if BSD
|
||||
system("exec /bin/csh");
|
||||
#else
|
||||
system("exec /bin/sh");
|
||||
ue_system( "exec /bin/sh") ;
|
||||
#endif
|
||||
sgarbf = TRUE;
|
||||
usleep( 2000000L) ;
|
||||
@@ -147,59 +145,32 @@ void rtfrmshell(void)
|
||||
* character to be typed, then mark the screen as garbage so a full repaint is
|
||||
* done. Bound to "C-X !".
|
||||
*/
|
||||
int spawn(int f, int n)
|
||||
{
|
||||
int s;
|
||||
char line[NLINE];
|
||||
int spawn( int f, int n) {
|
||||
int s ;
|
||||
char *line ;
|
||||
|
||||
/* don't allow this command if restricted */
|
||||
if (restflag)
|
||||
if( restflag)
|
||||
return resterr();
|
||||
|
||||
#if VMS
|
||||
if ((s = mlreply("!", line, NLINE)) != TRUE)
|
||||
return s;
|
||||
movecursor(term.t_nrow, 0);
|
||||
TTflush();
|
||||
s = sys(line); /* Run the command. */
|
||||
if (clexec == FALSE) {
|
||||
mlputs("\r\n\n(End)"); /* Pause. */
|
||||
TTflush();
|
||||
tgetc();
|
||||
}
|
||||
sgarbf = TRUE;
|
||||
return s;
|
||||
#endif
|
||||
#if MSDOS
|
||||
if ((s = mlreply("!", line, NLINE)) != TRUE)
|
||||
return s;
|
||||
movecursor(term.t_nrow, 0);
|
||||
TTkclose();
|
||||
shellprog(line);
|
||||
TTkopen();
|
||||
/* if we are interactive, pause here */
|
||||
if (clexec == FALSE) {
|
||||
mlputs("\r\n(End)");
|
||||
tgetc();
|
||||
}
|
||||
sgarbf = TRUE;
|
||||
return TRUE;
|
||||
#endif
|
||||
#if V7 | USG | BSD
|
||||
if ((s = mlreply("!", line, NLINE)) != TRUE)
|
||||
return s;
|
||||
s = newmlarg( &line, "!", 0) ;
|
||||
if( s != TRUE)
|
||||
return s ;
|
||||
|
||||
TTflush();
|
||||
TTclose(); /* stty to old modes */
|
||||
TTkclose();
|
||||
system(line);
|
||||
ue_system( line) ;
|
||||
free( line) ;
|
||||
fflush(stdout); /* to be sure P.K. */
|
||||
TTopen();
|
||||
|
||||
if (clexec == FALSE) {
|
||||
mlputs("(End)"); /* Pause. */
|
||||
mlwrite( "(End)") ; /* Pause. */
|
||||
TTflush();
|
||||
while ((s = tgetc()) != '\r' && s != ' ');
|
||||
mlputs("\r\n");
|
||||
mlwrite( "\r\n") ;
|
||||
}
|
||||
TTkopen();
|
||||
sgarbf = TRUE;
|
||||
@@ -213,54 +184,28 @@ int spawn(int f, int n)
|
||||
* done. Bound to "C-X $".
|
||||
*/
|
||||
|
||||
int execprg(int f, int n)
|
||||
{
|
||||
int s;
|
||||
char line[NLINE];
|
||||
int execprg( int f, int n) {
|
||||
int s ;
|
||||
char *line ;
|
||||
|
||||
/* don't allow this command if restricted */
|
||||
if (restflag)
|
||||
return resterr();
|
||||
|
||||
#if VMS
|
||||
if ((s = mlreply("!", line, NLINE)) != TRUE)
|
||||
return s;
|
||||
TTflush();
|
||||
s = sys(line); /* Run the command. */
|
||||
mlputs("\r\n\n(End)"); /* Pause. */
|
||||
TTflush();
|
||||
tgetc();
|
||||
sgarbf = TRUE;
|
||||
return s;
|
||||
#endif
|
||||
|
||||
#if MSDOS
|
||||
if ((s = mlreply("$", line, NLINE)) != TRUE)
|
||||
return s;
|
||||
movecursor(term.t_nrow, 0);
|
||||
TTkclose();
|
||||
execprog(line);
|
||||
TTkopen();
|
||||
/* if we are interactive, pause here */
|
||||
if (clexec == FALSE) {
|
||||
mlputs("\r\n(End)");
|
||||
tgetc();
|
||||
}
|
||||
sgarbf = TRUE;
|
||||
return TRUE;
|
||||
#endif
|
||||
if( restflag)
|
||||
return resterr() ;
|
||||
|
||||
#if V7 | USG | BSD
|
||||
if ((s = mlreply("!", line, NLINE)) != TRUE)
|
||||
return s;
|
||||
s = newmlarg( &line, "$", 0) ;
|
||||
if( s != TRUE)
|
||||
return s ;
|
||||
|
||||
TTputc('\n'); /* Already have '\r' */
|
||||
TTflush();
|
||||
TTclose(); /* stty to old modes */
|
||||
TTkclose();
|
||||
system(line);
|
||||
ue_system( line) ;
|
||||
free( line) ;
|
||||
fflush(stdout); /* to be sure P.K. */
|
||||
TTopen();
|
||||
mlputs("(End)"); /* Pause. */
|
||||
mlwrite( "(End)") ; /* Pause. */
|
||||
TTflush();
|
||||
while ((s = tgetc()) != '\r' && s != ' ');
|
||||
sgarbf = TRUE;
|
||||
@@ -272,48 +217,32 @@ int execprg(int f, int n)
|
||||
* Pipe a one line command into a window
|
||||
* Bound to ^X @
|
||||
*/
|
||||
int pipecmd(int f, int n)
|
||||
{
|
||||
int s; /* return status from CLI */
|
||||
struct window *wp; /* pointer to new window */
|
||||
struct buffer *bp; /* pointer to buffer to zot */
|
||||
char line[NLINE]; /* command line send to shell */
|
||||
static char bname[] = "command";
|
||||
|
||||
static char filnam[NSTRING] = "command";
|
||||
|
||||
#if MSDOS
|
||||
char *tmp;
|
||||
FILE *fp;
|
||||
int len;
|
||||
#endif
|
||||
int pipecmd( int f, int n) {
|
||||
int s ; /* return status from CLI */
|
||||
struct window *wp ; /* pointer to new window */
|
||||
struct buffer *bp ; /* pointer to buffer to zot */
|
||||
char *mlarg ;
|
||||
char *line ; /* command line send to shell */
|
||||
static char bname[] = "command" ;
|
||||
static char filnam[ NSTRING] = "command" ;
|
||||
|
||||
/* don't allow this command if restricted */
|
||||
if (restflag)
|
||||
return resterr();
|
||||
|
||||
#if MSDOS
|
||||
if ((tmp = getenv("TMP")) == NULL
|
||||
&& (tmp = getenv("TEMP")) == NULL)
|
||||
strcpy(filnam, "command");
|
||||
else {
|
||||
strcpy(filnam, tmp);
|
||||
len = strlen(tmp);
|
||||
if (len <= 0 || filnam[len - 1] != '\\'
|
||||
&& filnam[len - 1] != '/')
|
||||
strcat(filnam, "\\");
|
||||
strcat(filnam, "command");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if VMS
|
||||
mlwrite("Not available under VMS");
|
||||
return FALSE;
|
||||
#endif
|
||||
if( restflag)
|
||||
return resterr() ;
|
||||
|
||||
/* get the command to pipe in */
|
||||
if ((s = mlreply("@", line, NLINE)) != TRUE)
|
||||
return s;
|
||||
s = newmlarg( &mlarg, "@", 0) ;
|
||||
if( s != TRUE)
|
||||
return s ;
|
||||
|
||||
line = malloc( strlen( mlarg) + strlen( filnam) + 2) ;
|
||||
if( line == NULL) {
|
||||
free( mlarg) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
strcpy( line, mlarg) ;
|
||||
free( mlarg) ;
|
||||
|
||||
/* get rid of the command output buffer if it exists */
|
||||
if ((bp = bfind(bname, FALSE, 0)) != FALSE) {
|
||||
@@ -334,42 +263,29 @@ int pipecmd(int f, int n)
|
||||
}
|
||||
wp = wp->w_wndp;
|
||||
}
|
||||
if (zotbuf(bp) != TRUE)
|
||||
|
||||
return FALSE;
|
||||
if( zotbuf( bp) != TRUE) {
|
||||
free( line) ;
|
||||
return FALSE ;
|
||||
}
|
||||
}
|
||||
#if MSDOS
|
||||
strcat(line, " >>");
|
||||
strcat(line, filnam);
|
||||
movecursor(term.t_nrow, 0);
|
||||
TTkclose();
|
||||
shellprog(line);
|
||||
TTkopen();
|
||||
sgarbf = TRUE;
|
||||
if ((fp = fopen(filnam, "r")) == NULL) {
|
||||
s = FALSE;
|
||||
} else {
|
||||
fclose(fp);
|
||||
s = TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if V7 | USG | BSD
|
||||
TTflush();
|
||||
TTclose(); /* stty to old modes */
|
||||
TTkclose();
|
||||
strcat(line, ">");
|
||||
strcat(line, filnam);
|
||||
system(line);
|
||||
strcat( line, ">") ;
|
||||
strcat( line, filnam) ;
|
||||
ue_system( line) ;
|
||||
free( line) ;
|
||||
TTopen();
|
||||
TTkopen();
|
||||
TTflush();
|
||||
sgarbf = TRUE;
|
||||
s = TRUE;
|
||||
#endif
|
||||
|
||||
#else
|
||||
if (s != TRUE)
|
||||
return s;
|
||||
#endif
|
||||
|
||||
/* split the current window to make room for the command output */
|
||||
if (splitwind(FALSE, 1) == FALSE)
|
||||
@@ -396,32 +312,37 @@ int pipecmd(int f, int n)
|
||||
* filter a buffer through an external DOS program
|
||||
* Bound to ^X #
|
||||
*/
|
||||
int filter_buffer(int f, int n)
|
||||
{
|
||||
int s; /* return status from CLI */
|
||||
struct buffer *bp; /* pointer to buffer to zot */
|
||||
char line[NLINE]; /* command line send to shell */
|
||||
int filter_buffer( int f, int n) {
|
||||
int s ; /* return status from CLI */
|
||||
struct buffer *bp ; /* pointer to buffer to zot */
|
||||
char *mlarg ;
|
||||
char *line ; /* command line send to shell */
|
||||
fname_t tmpnam ; /* place to store real file name */
|
||||
static char bname1[] = "fltinp";
|
||||
static char bname1[] = "fltinp" ;
|
||||
|
||||
static char filnam1[] = "fltinp";
|
||||
static char filnam2[] = "fltout";
|
||||
static char filnam1[] = "fltinp" ;
|
||||
static char filnam2[] = "fltout" ;
|
||||
|
||||
/* don't allow this command if restricted */
|
||||
if (restflag)
|
||||
return resterr();
|
||||
if( restflag)
|
||||
return resterr() ;
|
||||
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return rdonly(); /* we are in read only mode */
|
||||
|
||||
#if VMS
|
||||
mlwrite("Not available under VMS");
|
||||
return FALSE;
|
||||
#endif
|
||||
if( curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return rdonly() ; /* we are in read only mode */
|
||||
|
||||
/* get the filter name and its args */
|
||||
if ((s = mlreply("#", line, NLINE)) != TRUE)
|
||||
return s;
|
||||
s = newmlarg( &mlarg, "#", 0) ;
|
||||
if( s != TRUE)
|
||||
return s ;
|
||||
|
||||
line = malloc( strlen( mlarg) + 16 + 1) ;
|
||||
if( line == NULL) {
|
||||
free( mlarg) ;
|
||||
return FALSE ;
|
||||
}
|
||||
|
||||
strcpy( line, mlarg) ;
|
||||
free( mlarg) ;
|
||||
|
||||
/* setup the proper file names */
|
||||
bp = curbp;
|
||||
@@ -429,20 +350,12 @@ int filter_buffer(int f, int n)
|
||||
strcpy(bp->b_fname, bname1); /* set it to our new one */
|
||||
|
||||
/* write it out, checking for errors */
|
||||
if (writeout(filnam1) != TRUE) {
|
||||
mlwrite("(Cannot write filter file)");
|
||||
strcpy(bp->b_fname, tmpnam);
|
||||
return FALSE;
|
||||
if( writeout( filnam1) != TRUE) {
|
||||
mlwrite( "(Cannot write filter file)") ;
|
||||
strcpy( bp->b_fname, tmpnam) ;
|
||||
free( line) ;
|
||||
return FALSE ;
|
||||
}
|
||||
#if MSDOS
|
||||
strcat(line, " <fltinp >fltout");
|
||||
movecursor(term.t_nrow - 1, 0);
|
||||
TTkclose();
|
||||
shellprog(line);
|
||||
TTkopen();
|
||||
sgarbf = TRUE;
|
||||
s = TRUE;
|
||||
#endif
|
||||
|
||||
#if V7 | USG | BSD
|
||||
TTputc('\n'); /* Already have '\r' */
|
||||
@@ -450,7 +363,8 @@ int filter_buffer(int f, int n)
|
||||
TTclose(); /* stty to old modes */
|
||||
TTkclose();
|
||||
strcat(line, " <fltinp >fltout");
|
||||
system(line);
|
||||
ue_system( line) ;
|
||||
free( line) ;
|
||||
TTopen();
|
||||
TTkopen();
|
||||
TTflush();
|
||||
@@ -460,7 +374,7 @@ int filter_buffer(int f, int n)
|
||||
|
||||
/* on failure, escape gracefully */
|
||||
if (s != TRUE || (readin(filnam2, FALSE) == FALSE)) {
|
||||
mlwrite("(Execution failed)");
|
||||
mlwrite( "(Execution failed)") ;
|
||||
strcpy(bp->b_fname, tmpnam);
|
||||
unlink(filnam1);
|
||||
unlink(filnam2);
|
||||
|
||||
39
tcap.c
39
tcap.c
@@ -126,22 +126,21 @@ static void tcapopen(void)
|
||||
char *t, *p;
|
||||
char tcbuf[1024];
|
||||
char *tv_stype;
|
||||
char err_str[72];
|
||||
int int_col, int_row;
|
||||
|
||||
#if PKCODE && USE_BROKEN_OPTIMIZATION
|
||||
if (!term_init_ok) {
|
||||
#endif
|
||||
if ((tv_stype = getenv("TERM")) == NULL) {
|
||||
puts("Environment variable TERM not defined!");
|
||||
exit(1);
|
||||
fputs( "Environment variable TERM not defined!\n", stderr) ;
|
||||
exit( EXIT_FAILURE) ;
|
||||
}
|
||||
|
||||
if ((tgetent(tcbuf, tv_stype)) != 1) {
|
||||
sprintf(err_str, "Unknown terminal type %s!",
|
||||
tv_stype);
|
||||
puts(err_str);
|
||||
exit(1);
|
||||
fputs( "Unknown terminal type ", stderr) ;
|
||||
fputs( tv_stype, stderr) ;
|
||||
fputs( "!\n", stderr) ;
|
||||
exit( EXIT_FAILURE) ;
|
||||
}
|
||||
|
||||
/* Get screen size from system, or else from termcap. */
|
||||
@@ -151,18 +150,24 @@ static void tcapopen(void)
|
||||
|
||||
if ((term.t_nrow <= 0)
|
||||
&& (term.t_nrow = (short) tgetnum("li") - 1) == -1) {
|
||||
puts("termcap entry incomplete (lines)");
|
||||
exit(1);
|
||||
fputs( "termcap entry incomplete (lines)\n", stderr) ;
|
||||
exit( EXIT_FAILURE) ;
|
||||
}
|
||||
|
||||
if ((term.t_ncol <= 0)
|
||||
&& (term.t_ncol = (short) tgetnum("co")) == -1) {
|
||||
puts("Termcap entry incomplete (columns)");
|
||||
exit(1);
|
||||
fputs( "Termcap entry incomplete (columns)\n", stderr) ;
|
||||
exit( EXIT_FAILURE) ;
|
||||
}
|
||||
#ifdef SIGWINCH
|
||||
term.t_mrow = MAXROW;
|
||||
term.t_mcol = MAXCOL;
|
||||
/* At initialization we use maximum size even if current OS window is smaller */
|
||||
term.t_mrow = MAXROW ;
|
||||
term.t_mcol = MAXCOL ;
|
||||
if( term.t_nrow >= term.t_mrow)
|
||||
term.t_nrow = term.t_mrow - 1 ;
|
||||
|
||||
if( term.t_ncol > term.t_mcol)
|
||||
term.t_ncol = term.t_mcol ;
|
||||
#else
|
||||
term.t_mrow = term.t_nrow > MAXROW ? MAXROW : term.t_nrow;
|
||||
term.t_mcol = term.t_ncol > MAXCOL ? MAXCOL : term.t_ncol;
|
||||
@@ -193,8 +198,8 @@ static void tcapopen(void)
|
||||
#endif
|
||||
|
||||
if (CL == NULL || CM == NULL || UP == NULL) {
|
||||
puts("Incomplete termcap entry\n");
|
||||
exit(1);
|
||||
fputs( "Incomplete termcap entry\n", stderr) ;
|
||||
exit( EXIT_FAILURE) ;
|
||||
}
|
||||
|
||||
if (CE == NULL) /* will we be able to use clear to EOL? */
|
||||
@@ -218,8 +223,8 @@ static void tcapopen(void)
|
||||
#endif
|
||||
|
||||
if (p >= &tcapbuf[TCAPSLEN]) {
|
||||
puts("Terminal description too big!\n");
|
||||
exit(1);
|
||||
fputs( "Terminal description too big!\n", stderr) ;
|
||||
exit( EXIT_FAILURE) ;
|
||||
}
|
||||
#if PKCODE && USE_BROKEN_OPTIMIZATION
|
||||
term_init_ok = 1;
|
||||
|
||||
18
termio.c
18
termio.c
@@ -1,3 +1,6 @@
|
||||
/* termio.c -- implements termio.h */
|
||||
#if !defined( POSIX) && !defined( MINGW32)
|
||||
|
||||
#include "termio.h"
|
||||
|
||||
/* TERMIO.C
|
||||
@@ -9,8 +12,6 @@
|
||||
* modified by Petri Kutvonen
|
||||
*/
|
||||
|
||||
#if !defined( POSIX) && !defined( MINGW32)
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -19,7 +20,6 @@
|
||||
#include "utf8.h"
|
||||
|
||||
|
||||
/* rfi */
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
@@ -57,12 +57,12 @@ int nxtchar = -1; /* character held from type ahead */
|
||||
#include <signal.h>
|
||||
#include <termio.h>
|
||||
#include <fcntl.h>
|
||||
int kbdflgs; /* saved keyboard fd flags */
|
||||
int kbdpoll; /* in O_NDELAY mode */
|
||||
int kbdqp; /* there is a char in kbdq */
|
||||
char kbdq; /* char we've already read */
|
||||
struct termio otermio; /* original terminal characteristics */
|
||||
struct termio ntermio; /* charactoristics to use inside */
|
||||
static int kbdflgs ; /* saved keyboard fd flags */
|
||||
static int kbdpoll ; /* in O_NDELAY mode */
|
||||
static int kbdqp ; /* there is a char in kbdq */
|
||||
static char kbdq ; /* char we've already read */
|
||||
static struct termio otermio ; /* original terminal characteristics */
|
||||
static struct termio ntermio ; /* characteristics to use inside */
|
||||
#if XONXOFF
|
||||
#define XXMASK 0016000
|
||||
#endif
|
||||
|
||||
@@ -10,6 +10,7 @@ insert-string %mypath
|
||||
newline
|
||||
insert-string &cat "Length of $PATH: " &len $PATH
|
||||
newline
|
||||
insert-string &cat "Length of %mypath: " &cat &len %mypath ~n
|
||||
; Insert string with escaped characters
|
||||
insert-string "hello, world~n"
|
||||
newline
|
||||
@@ -35,6 +36,9 @@ set %expect &len %nam
|
||||
newline
|
||||
set %nam &cat %nam %nam
|
||||
set %expect &tim %expect 2
|
||||
!if ¬ &les %expect 1024
|
||||
!break
|
||||
!endif
|
||||
!endwhile
|
||||
insert-string %nam
|
||||
newline
|
||||
|
||||
133
utf8.c
133
utf8.c
@@ -1,5 +1,9 @@
|
||||
/* utf8.c -- implements utf8.h, converts between unicode and UTF-8 */
|
||||
|
||||
#include "utf8.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
/*
|
||||
* utf8_to_unicode()
|
||||
*
|
||||
@@ -15,55 +19,60 @@
|
||||
*/
|
||||
unsigned utf8_to_unicode(char *line, unsigned index, unsigned len, unicode_t *res)
|
||||
{
|
||||
unsigned value;
|
||||
unsigned char c = line[index];
|
||||
unsigned bytes, mask, i;
|
||||
unicode_t value ;
|
||||
unsigned c = line[ index] & 0xFFU ;
|
||||
unsigned bytes, mask, i;
|
||||
|
||||
*res = c;
|
||||
line += index;
|
||||
len -= index;
|
||||
*res = c;
|
||||
|
||||
/*
|
||||
* 0xxxxxxx is valid utf8
|
||||
* 10xxxxxx is invalid UTF-8, we assume it is Latin1
|
||||
*/
|
||||
if (c < 0xc0)
|
||||
return 1;
|
||||
/*
|
||||
* 0xxxxxxx is valid one byte utf8
|
||||
* 10xxxxxx is invalid UTF-8 start byte, we assume it is Latin1
|
||||
* 1100000x is start of overlong encoding sequence
|
||||
* Sequence longer than 4 bytes are invalid
|
||||
* Last valid code is 0x10FFFF, encoding start with 0xF4
|
||||
*/
|
||||
if( c <= 0xC1 || c > 0xF4)
|
||||
return 1;
|
||||
|
||||
/* Ok, it's 11xxxxxx, do a stupid decode */
|
||||
mask = 0x20;
|
||||
bytes = 2;
|
||||
while (c & mask) {
|
||||
bytes++;
|
||||
mask >>= 1;
|
||||
}
|
||||
/* Ok, it's 11xxxxxx, do a stupid decode */
|
||||
mask = 0x20;
|
||||
bytes = 2;
|
||||
while( (c & mask) != 0) {
|
||||
bytes++;
|
||||
mask >>= 1;
|
||||
}
|
||||
|
||||
/* Invalid? Do it as a single byte Latin1 */
|
||||
if (bytes > 6)
|
||||
return 1;
|
||||
if (bytes > len)
|
||||
return 1;
|
||||
/* bytes is in range [2..4] as c was in range [C2..F4] */
|
||||
len -= index;
|
||||
if (bytes > len)
|
||||
return 1;
|
||||
|
||||
value = c & (mask-1);
|
||||
value = c & (mask-1);
|
||||
|
||||
/* Ok, do the bytes */
|
||||
for (i = 1; i < bytes; i++) {
|
||||
c = line[i];
|
||||
if ((c & 0xc0) != 0x80)
|
||||
return 1;
|
||||
value = (value << 6) | (c & 0x3f);
|
||||
}
|
||||
*res = value;
|
||||
return bytes;
|
||||
/* Ok, do the bytes */
|
||||
line += index;
|
||||
for (i = 1; i < bytes; i++) {
|
||||
c = line[i] & 0xFFU ;
|
||||
if ((c & 0xc0) != 0x80)
|
||||
return 1;
|
||||
value = (value << 6) | (c & 0x3f);
|
||||
}
|
||||
|
||||
if( value > 0x10FFFF) /* Avoid 110000 - 13FFFF */
|
||||
return 1 ;
|
||||
|
||||
*res = value;
|
||||
return bytes;
|
||||
}
|
||||
|
||||
static void reverse_string(char *begin, char *end)
|
||||
{
|
||||
do {
|
||||
char a = *begin, b = *end;
|
||||
*end = a; *begin = b;
|
||||
begin++; end--;
|
||||
} while (begin < end);
|
||||
do {
|
||||
char a = *begin, b = *end;
|
||||
*end = a; *begin = b;
|
||||
begin++; end--;
|
||||
} while (begin < end);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -77,22 +86,34 @@ static void reverse_string(char *begin, char *end)
|
||||
* possible sequence, while utf8_to_unicode() accepts both Latin1 and
|
||||
* overlong utf-8 sequences.
|
||||
*/
|
||||
unsigned unicode_to_utf8(unsigned int c, char *utf8)
|
||||
{
|
||||
int bytes = 1;
|
||||
unsigned unicode_to_utf8( unicode_t c, char *utf8) {
|
||||
unsigned bytes = 1 ;
|
||||
|
||||
*utf8 = c;
|
||||
if (c > 0x7f) {
|
||||
int prefix = 0x40;
|
||||
char *p = utf8;
|
||||
do {
|
||||
*p++ = 0x80 + (c & 0x3f);
|
||||
bytes++;
|
||||
prefix >>= 1;
|
||||
c >>= 6;
|
||||
} while (c > prefix);
|
||||
*p = c - 2*prefix;
|
||||
reverse_string(utf8, p);
|
||||
}
|
||||
return bytes;
|
||||
assert( c <= 0x10FFFF) ;
|
||||
|
||||
#ifdef NDEBUG
|
||||
if( c > 0x10FFFF) /* Let's assume this is due to sign extension */
|
||||
c &= 0xFF ;
|
||||
#endif
|
||||
|
||||
if( c <= 0x7f)
|
||||
*utf8 = (char) c ;
|
||||
else {
|
||||
unsigned prefix = 0x40 ;
|
||||
char *p = utf8 ;
|
||||
do {
|
||||
*p++ = (char) (0x80 + (c & 0x3f)) ;
|
||||
bytes++ ;
|
||||
prefix >>= 1 ;
|
||||
c >>= 6 ;
|
||||
} while( c >= prefix) ;
|
||||
|
||||
*p = (char) (c - 2 * prefix) ;
|
||||
reverse_string( utf8, p) ;
|
||||
}
|
||||
|
||||
return bytes ;
|
||||
}
|
||||
|
||||
|
||||
/* end of utf8.c */
|
||||
|
||||
11
utf8.h
11
utf8.h
@@ -1,15 +1,10 @@
|
||||
#ifndef UTF8_H
|
||||
#define UTF8_H
|
||||
|
||||
typedef unsigned int unicode_t;
|
||||
typedef unsigned int unicode_t ;
|
||||
|
||||
unsigned utf8_to_unicode( char *line, unsigned index, unsigned len,
|
||||
unicode_t *res) ;
|
||||
unsigned unicode_to_utf8( unsigned int c, char *utf8) ;
|
||||
|
||||
static inline int is_beginning_utf8( unsigned char c)
|
||||
{
|
||||
return (c & 0xc0) != 0x80;
|
||||
}
|
||||
unicode_t *res) ;
|
||||
unsigned unicode_to_utf8( unicode_t c, char *utf8) ;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
# define PROGRAM_NAME "em"
|
||||
#endif
|
||||
|
||||
#define PROGRAM_NAME_LONG "uEMACS"
|
||||
# define PROGRAM_NAME_PFX "\xC2"
|
||||
# define PROGRAM_NAME_LONG "\xB5""EMACS" /* UTF-8 µEMACS */
|
||||
|
||||
#define VERSION "4.1.1"
|
||||
# define VERSION "4.2.1"
|
||||
|
||||
#endif /* VERSION_H_ */
|
||||
|
||||
4
window.c
4
window.c
@@ -599,10 +599,10 @@ int newsize(int f, int n)
|
||||
|
||||
/* if the command defaults, assume the largest */
|
||||
if (f == FALSE)
|
||||
n = term.t_mrow + 1;
|
||||
n = term.t_mrow ;
|
||||
|
||||
/* make sure it's in range */
|
||||
if (n < 3 || n > term.t_mrow + 1) {
|
||||
if (n < 3 || n > term.t_mrow) {
|
||||
mlwrite("%%Screen size out of range");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
4
window.h
4
window.h
@@ -21,8 +21,8 @@ struct window {
|
||||
struct line *w_markp; /* Line containing "mark" */
|
||||
int w_doto; /* Byte offset for "." */
|
||||
int w_marko; /* Byte offset for "mark" */
|
||||
char w_toprow; /* Origin 0 top row of window */
|
||||
char w_ntrows; /* # of rows of text in window */
|
||||
int w_toprow ; /* Origin 0 top row of window */
|
||||
int w_ntrows ; /* # of rows of text in window */
|
||||
char w_force; /* If NZ, forcing row. */
|
||||
char w_flag; /* Flags. */
|
||||
#if COLOR
|
||||
|
||||
12
word.c
12
word.c
@@ -16,7 +16,7 @@
|
||||
#include "buffer.h"
|
||||
#include "estruct.h"
|
||||
#include "line.h"
|
||||
#include "log.h"
|
||||
#include "mlout.h"
|
||||
#include "random.h"
|
||||
#include "region.h"
|
||||
#include "window.h"
|
||||
@@ -428,7 +428,7 @@ int fillpara(int f, int n)
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return rdonly(); /* we are in read only mode */
|
||||
if (fillcol == 0) { /* no fill column set */
|
||||
logwrite("No fill column set");
|
||||
mloutstr( "No fill column set") ;
|
||||
return FALSE;
|
||||
}
|
||||
#if PKCODE
|
||||
@@ -527,14 +527,14 @@ int justpara(int f, int n)
|
||||
if (curbp->b_mode & MDVIEW) /* don't allow this command if */
|
||||
return rdonly(); /* we are in read only mode */
|
||||
if (fillcol == 0) { /* no fill column set */
|
||||
logwrite("No fill column set");
|
||||
mloutstr( "No fill column set") ;
|
||||
return FALSE;
|
||||
}
|
||||
justflag = TRUE;
|
||||
leftmarg = curwp->w_doto;
|
||||
if (leftmarg + 10 > fillcol) {
|
||||
leftmarg = 0;
|
||||
logwrite("Column too narrow");
|
||||
mloutstr( "Column too narrow") ;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -719,8 +719,8 @@ int wordcount(int f, int n)
|
||||
else
|
||||
avgch = 0;
|
||||
|
||||
logwrite("Words %D Chars %D Lines %d Avg chars/word %f",
|
||||
nwords, nchars, nlines + 1, avgch);
|
||||
mloutfmt( "Words %D Chars %D Lines %d Avg chars/word %f",
|
||||
nwords, nchars, nlines + 1, avgch) ;
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef MINGW32
|
||||
@@ -20,11 +21,14 @@ static void die( const char *err) {
|
||||
/* Function copyright: git */
|
||||
void xmkstemp( char *template) {
|
||||
int fd ;
|
||||
mode_t o_mask ;
|
||||
|
||||
o_mask = umask( 0177) ;
|
||||
fd = mkstemp( template) ;
|
||||
if( fd < 0)
|
||||
die( "Unable to create temporary file") ;
|
||||
|
||||
umask( o_mask) ;
|
||||
close( fd) ;
|
||||
}
|
||||
|
||||
|
||||
2
wrapper.h
Executable file → Normal file
2
wrapper.h
Executable file → Normal file
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
void xmkstemp( char *template) ;
|
||||
void xmkstemp( char *fname_template) ;
|
||||
|
||||
void *xmalloc( size_t size) ;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* wscreen.c -- windows screen console */
|
||||
/* wscreen.c -- windows screen console for MINGW32 */
|
||||
#include "wscreen.h"
|
||||
|
||||
#ifdef MINGW32
|
||||
@@ -112,6 +112,6 @@ void wtitle( const char *title) {
|
||||
SetConsoleTitle( title) ;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif /* MINGW32 */
|
||||
|
||||
/* end of wscreen.c */
|
||||
|
||||
Reference in New Issue
Block a user