Mercurial > vim
annotate src/osdef.sh @ 9828:e84e45786691 v7.4.2189
commit https://github.com/vim/vim/commit/f71d7b9ee5ceba75f70c30845332ddd728fd16c6
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 9 22:14:05 2016 +0200
patch 7.4.2189
Problem: Cannot detect encoding in a fifo.
Solution: Extend the stdin way of detecting encoding to fifo. Add a test
for detecting encoding on stdin and fifo. (Ken Takata)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 09 Aug 2016 22:15:06 +0200 |
parents | c4f8b1d48f20 |
children | befdf44737d1 |
rev | line source |
---|---|
7 | 1 #! /bin/sh |
2 # | |
3 # osdef.sh -- copy osdef.h.in to osdef.h while removing declarations | |
4 # found in the system header files. Caution: weird sed magic going on here. | |
5 # Warnings are printed if sed did not survive. | |
6 # | |
7 # (C) Michael Schroeder, Juergen Weigert | |
8 # | |
9 # osdef.h.in has been split into osdef1.h.in and osdef2.h.in, because some | |
10 # sed's could not handle the amount of commands (is 50 commands the limit?). | |
11 # | |
12 # 31.10.95 jw. | |
13 | |
14 if test -z "$CC"; then | |
15 CC=cc | |
16 fi | |
17 if test -z "$srcdir"; then | |
18 srcdir=. | |
19 fi | |
20 | |
21 rm -f core* *.core | |
22 | |
23 cat << EOF > osdef0.c | |
24 #ifndef __APPLE__ | |
25 # define select select_declared_wrong | |
26 #endif | |
27 #define tgetstr tgetstr_declared_wrong | |
28 #include "auto/config.h" | |
29 #include "os_unix.h" /* bring in most header files, more follow below */ | |
30 #include "os_unixx.h" /* bring in header files for os_unix.c */ | |
31 | |
32 #ifdef HAVE_TERMCAP_H | |
33 # include <termcap.h> /* only for term.c */ | |
34 #endif | |
35 | |
36 #ifdef HAVE_FCNTL_H | |
37 # include <fcntl.h> /* only used in a few files */ | |
38 #endif | |
39 | |
40 #ifdef HAVE_SYS_STATFS_H | |
41 # include <sys/types.h> | |
42 # include <sys/statfs.h> /* only for memfile.c */ | |
43 #endif | |
44 | |
45 #ifdef HAVE_X11 | |
46 # include <X11/Intrinsic.h> | |
47 #endif | |
48 EOF | |
49 | |
5436 | 50 $CC -I. -I$srcdir -E osdef0.c >osdef0.cc |
7 | 51 |
52 # insert a space in front of each line, so that a function name at the | |
53 # start of the line is matched with "[)*, ]\1[ (]" | |
54 sed < osdef0.cc -e '/\(..*\)/s// \1/' > osdef0.ccc | |
55 | |
7722
c4f8b1d48f20
commit https://github.com/vim/vim/commit/e240c2da796531e807ea9df78bdbcc7b1012870c
Christian Brabandt <cb@256bit.org>
parents:
5436
diff
changeset
|
56 sed < $srcdir/osdef1.h.in -n -e '/^extern/s@.*[)* ][)* ]*\([a-zA-Z_][a-zA-Z0-9_]*\)(.*@/[)*, ][(]*\1[)]*[ (]/i\\\ |
c4f8b1d48f20
commit https://github.com/vim/vim/commit/e240c2da796531e807ea9df78bdbcc7b1012870c
Christian Brabandt <cb@256bit.org>
parents:
5436
diff
changeset
|
57 \\/\\[^a-zA-Z_\\]\1(\\/d@p' > osdef11.sed |
7 | 58 |
7722
c4f8b1d48f20
commit https://github.com/vim/vim/commit/e240c2da796531e807ea9df78bdbcc7b1012870c
Christian Brabandt <cb@256bit.org>
parents:
5436
diff
changeset
|
59 sed < $srcdir/osdef2.h.in -n -e '/^extern/s@.*[)* ][)* ]*\([a-zA-Z_][a-zA-Z0-9_]*\)(.*@/[)*, ][(]*\1[)]*[ (]/i\\\ |
c4f8b1d48f20
commit https://github.com/vim/vim/commit/e240c2da796531e807ea9df78bdbcc7b1012870c
Christian Brabandt <cb@256bit.org>
parents:
5436
diff
changeset
|
60 \\/\\[^a-zA-Z_\\]\1(\\/d@p' > osdef21.sed |
7 | 61 |
62 cat << EOF > osdef2.sed | |
63 1i\\ | |
64 /* | |
65 1i\\ | |
66 * osdef.h is automagically created from osdef?.h.in by osdef.sh -- DO NOT EDIT | |
67 1i\\ | |
68 */ | |
69 EOF | |
70 | |
71 cat osdef0.ccc | sed -n -f osdef11.sed >> osdef2.sed | |
72 sed -f osdef2.sed < $srcdir/osdef1.h.in > auto/osdef.h | |
73 | |
74 cat osdef0.ccc | sed -n -f osdef21.sed > osdef2.sed | |
75 sed -f osdef2.sed < $srcdir/osdef2.h.in >> auto/osdef.h | |
76 | |
77 rm osdef0.c osdef0.cc osdef0.ccc osdef11.sed osdef21.sed osdef2.sed | |
78 | |
79 if test -f core*; then | |
80 file core* | |
81 echo " Sorry, your sed is broken. Call the system administrator." | |
82 echo " Meanwhile, you may try to compile Vim with an empty osdef.h file." | |
83 echo " If you compiler complains about missing prototypes, move the needed" | |
84 echo " ones from osdef1.h.in and osdef2.h.in to osdef.h." | |
85 exit 1 | |
86 fi | |
87 cat $srcdir/osdef1.h.in $srcdir/osdef2.h.in >osdefX.h.in | |
88 if eval test "`diff auto/osdef.h osdefX.h.in | wc -l`" -eq 4; then | |
89 echo " Hmm, sed is very pessimistic about your system header files." | |
90 echo " But it did not dump core -- strange! Let's continue carefully..." | |
91 echo " If this fails, you may want to remove offending lines from osdef.h" | |
92 echo " or try with an empty osdef.h file, if your compiler can do without" | |
93 echo " function declarations." | |
94 fi | |
95 rm osdefX.h.in |