On 12/11/17 14:14, Marc Espie wrote:
>> @@ -37,6 +37,16 @@ SRCS=     cl_funcs.c cl_main.c cl_read.c cl_
>>  
>>  LINKS=      ${BINDIR}/vi ${BINDIR}/ex
>>  LINKS+=     ${BINDIR}/vi ${BINDIR}/view
>> +
>> +options_def.h: common/options.awk common/options.c
>> +    awk -f ${.CURDIR}/../common/options.awk ${.CURDIR}/../common/options.c \
>> +            > options_def.h
>> +
> Don't do that. This will always generate a file even if awk fails, that
> you will then have to clean manually.
> 
> Use an idiom like this:
>> +options_def.h: common/options.awk common/options.c
>> +    awk -f ${.CURDIR}/../common/options.awk ${.CURDIR}/../common/options.c \
>> +            > [email protected] && mv [email protected] $@
> 
Updated diff

Index: build/Makefile
===================================================================
RCS file: /cvs/src/usr.bin/vi/build/Makefile,v
retrieving revision 1.24
diff -u -p -a -u -r1.24 Makefile
--- build/Makefile      30 Mar 2016 06:38:46 -0000      1.24
+++ build/Makefile      11 Dec 2017 16:44:06 -0000
@@ -4,7 +4,7 @@
 PROG=  vi
 
 # Modern curses (ncurses)
-CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../include
+CFLAGS+=-I${.CURDIR} -I${.CURDIR}/../include -I.
 LDADD+=-lcurses
 DPADD+= ${LIBCURSES}
 
@@ -37,6 +37,17 @@ SRCS=        cl_funcs.c cl_main.c cl_read.c cl_
 
 LINKS= ${BINDIR}/vi ${BINDIR}/ex
 LINKS+=        ${BINDIR}/vi ${BINDIR}/view
+
+options_def.h: common/options.awk common/options.c
+       awk -f ${.CURDIR}/../common/options.awk ${.CURDIR}/../common/options.c \
+               > [email protected] && mv [email protected] $@ || rm [email protected]
+
+ex_def.h: ex/ex.awk ex/ex_cmd.c
+       awk -f ${.CURDIR}/../ex/ex.awk ${.CURDIR}/../ex/ex_cmd.c > [email protected] \
+               && mv [email protected] $@ || rm [email protected]
+
+BUILDFIRST = options_def.h ex_def.h
+CLEANFILES += options_def.h ex_def.h
 
 .PATH: ${.CURDIR}/../vi ${.CURDIR}/../ex ${.CURDIR}/../cl ${.CURDIR}/../common 
${.CURDIR}/../docs/USD.doc/vi.man
 
Index: common/options.awk
===================================================================
RCS file: /cvs/src/usr.bin/vi/common/options.awk,v
retrieving revision 1.3
diff -u -p -a -u -r1.3 options.awk
--- common/options.awk  29 Jan 2001 01:58:31 -0000      1.3
+++ common/options.awk  11 Dec 2017 16:44:06 -0000
@@ -1,11 +1,16 @@
 #      $OpenBSD: options.awk,v 1.3 2001/01/29 01:58:31 niklas Exp $
 
 #      @(#)options.awk 10.1 (Berkeley) 6/8/95
- 
+
+BEGIN {
+       printf("enum {\n");
+       first = 1;
+}
 /^\/\* O_[0-9A-Z_]*/ {
-       printf("#define %s %d\n", $2, cnt++);
+       printf("\t%s%s,\n", $2, first ? " = 0" : "");
+       first = 0;
        next;
 }
 END {
-       printf("#define O_OPTIONCOUNT %d\n", cnt);
+       printf("\tO_OPTIONCOUNT\n};\n");
 }
Index: ex/ex.awk
===================================================================
RCS file: /cvs/src/usr.bin/vi/ex/ex.awk,v
retrieving revision 1.2
diff -u -p -a -u -r1.2 ex.awk
--- ex/ex.awk   29 Jan 2001 01:58:40 -0000      1.2
+++ ex/ex.awk   11 Dec 2017 16:44:06 -0000
@@ -1,8 +1,16 @@
 #      $OpenBSD: ex.awk,v 1.2 2001/01/29 01:58:40 niklas Exp $
 
 #      @(#)ex.awk      10.1 (Berkeley) 6/8/95
- 
+
+BEGIN {
+       printf("enum {");
+       first = 1;
+}
 /^\/\* C_[0-9A-Z_]* \*\/$/ {
-       printf("#define %s %d\n", $2, cnt++);
+       printf("%s\n\t%s%s", first ? "" : ",", $2, first ? " = 0" : "");
+       first = 0;
        next;
+}
+END {
+       printf("\n};\n");
 }
Index: include/ex_def.h
===================================================================
RCS file: include/ex_def.h
diff -N include/ex_def.h
--- include/ex_def.h    19 Nov 2015 07:53:31 -0000      1.5
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,76 +0,0 @@
-/*     $OpenBSD: ex_def.h,v 1.5 2015/11/19 07:53:31 bentley Exp $      */
-
-#define C_SCROLL 0
-#define C_BANG 1
-#define C_HASH 2
-#define C_SUBAGAIN 3
-#define C_STAR 4
-#define C_SHIFTL 5
-#define C_EQUAL 6
-#define C_SHIFTR 7
-#define C_AT 8
-#define C_APPEND 9
-#define C_ABBR 10
-#define C_ARGS 11
-#define C_BG 12
-#define C_CHANGE 13
-#define C_CD 14
-#define C_CHDIR 15
-#define C_COPY 16
-#define C_DELETE 17
-#define C_DISPLAY 18
-#define C_EDIT 19
-#define C_EX 20
-#define C_EXUSAGE 21
-#define C_FILE 22
-#define C_FG 23
-#define C_GLOBAL 24
-#define C_HELP 25
-#define C_INSERT 26
-#define C_JOIN 27
-#define C_K 28
-#define C_LIST 29
-#define C_MOVE 30
-#define C_MARK 31
-#define C_MAP 32
-#define C_MKEXRC 33
-#define C_NEXT 34
-#define C_NUMBER 35
-#define C_OPEN 36
-#define C_PRINT 37
-#define C_PRESERVE 38
-#define C_PREVIOUS 39
-#define C_PUT 40
-#define C_QUIT 41
-#define C_READ 42
-#define C_RECOVER 43
-#define C_RESIZE 44
-#define C_REWIND 45
-#define C_SUBSTITUTE 46
-#define C_SCRIPT 47
-#define C_SET 48
-#define C_SHELL 49
-#define C_SOURCE 50
-#define C_STOP 51
-#define C_SUSPEND 52
-#define C_T 53
-#define C_TAG 54
-#define C_TAGNEXT 55
-#define C_TAGPOP 56
-#define C_TAGPREV 57
-#define C_TAGTOP 58
-#define C_UNDO 59
-#define C_UNABBREVIATE 60
-#define C_UNMAP 61
-#define C_V 62
-#define C_VERSION 63
-#define C_VISUAL_EX 64
-#define C_VISUAL_VI 65
-#define C_VIUSAGE 66
-#define C_WRITE 67
-#define C_WN 68
-#define C_WQ 69
-#define C_XIT 70
-#define C_YANK 71
-#define C_Z 72
-#define C_SUBTILDE 73
Index: include/options_def.h
===================================================================
RCS file: include/options_def.h
diff -N include/options_def.h
--- include/options_def.h       3 Jul 2017 07:01:14 -0000       1.8
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,75 +0,0 @@
-/*     $OpenBSD: options_def.h,v 1.8 2017/07/03 07:01:14 bentley Exp $ */
-
-enum {
-       O_ALTWERASE = 0,
-       O_AUTOINDENT,
-       O_AUTOPRINT,
-       O_AUTOWRITE,
-       O_BACKUP,
-       O_BEAUTIFY,
-       O_CDPATH,
-       O_CEDIT,
-       O_COLUMNS,
-       O_COMMENT,
-       O_EDCOMPATIBLE,
-       O_ESCAPETIME,
-       O_ERRORBELLS,
-       O_EXRC,
-       O_EXTENDED,
-       O_FILEC,
-       O_FLASH,
-       O_HARDTABS,
-       O_ICLOWER,
-       O_IGNORECASE,
-       O_KEYTIME,
-       O_LEFTRIGHT,
-       O_LINES,
-       O_LIST,
-       O_LOCKFILES,
-       O_MAGIC,
-       O_MATCHTIME,
-       O_MESG,
-       O_NOPRINT,
-       O_NUMBER,
-       O_OCTAL,
-       O_OPEN,
-       O_PARAGRAPHS,
-       O_PATH,
-       O_PRINT,
-       O_PROMPT,
-       O_READONLY,
-       O_RECDIR,
-       O_REMAP,
-       O_REPORT,
-       O_RULER,
-       O_SCROLL,
-       O_SEARCHINCR,
-       O_SECTIONS,
-       O_SECURE,
-       O_SHELL,
-       O_SHELLMETA,
-       O_SHIFTWIDTH,
-       O_SHOWMATCH,
-       O_SHOWMODE,
-       O_SIDESCROLL,
-       O_TABSTOP,
-       O_TAGLENGTH,
-       O_TAGS,
-       O_TERM,
-       O_TERSE,
-       O_TILDEOP,
-       O_TIMEOUT,
-       O_TTYWERASE,
-       O_VERBOSE,
-       O_W1200,
-       O_W300,
-       O_W9600,
-       O_WARN,
-       O_WINDOW,
-       O_WINDOWNAME,
-       O_WRAPLEN,
-       O_WRAPMARGIN,
-       O_WRAPSCAN,
-       O_WRITEANY,
-       O_OPTIONCOUNT,
-};

Reply via email to