我注意到在地区文件的顶部有47个空白行:
xb@dnxb:/usr/share/X11/locale$ hexdump -Cv locale.alias | head
00000000 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a |................|
00000010 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a |................|
00000020 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 23 |...............#|
00000030 0a 23 09 54 68 69 73 20 66 69 6c 65 20 63 6f 6e |.#.This file con|
00000040 74 61 69 6e 73 20 61 6c 69 61 73 20 6e 61 6d 65 |tains alias name|
00000050 20 6f 66 20 6c 6f 63 61 6c 65 2e 0a 23 09 45 61 | of locale..#.Ea|
00000060 63 68 20 61 6c 69 61 73 20 6e 61 6d 65 20 69 73 |ch alias name is|
00000070 20 64 65 73 63 72 69 62 65 64 20 77 69 74 68 69 | described withi|
00000080 6e 20 6f 6e 65 20 6c 69 6e 65 2e 0a 23 09 54 68 |n one line..#.Th|
00000090 65 20 66 69 72 73 74 20 77 6f 72 64 20 69 73 20 |e first word is |
xb@dnxb:/usr/share/X11/locale$ hexdump -Cv locale.dir | head
00000000 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a |................|
00000010 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a |................|
00000020 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 23 |...............#|
00000030 0a 23 09 54 68 69 73 20 66 69 6c 65 20 63 6f 6e |.#.This file con|
00000040 74 61 69 6e 73 20 6c 6f 63 61 6c 65 20 64 61 74 |tains locale dat|
00000050 61 62 61 73 65 20 66 69 6c 65 20 6e 61 6d 65 73 |abase file names|
00000060 0a 23 09 54 68 65 20 66 69 72 73 74 20 77 6f 72 |.#.The first wor|
00000070 64 20 69 73 20 74 68 65 20 6c 6f 63 61 6c 65 20 |d is the locale |
00000080 64 61 74 61 62 61 73 65 20 66 69 6c 65 20 6e 61 |database file na|
00000090 6d 65 20 61 6e 64 0a 23 09 74 68 65 20 73 65 63 |me and.#.the sec|
xb@dnxb:/usr/share/X11/locale$ hexdump -Cv compose.dir | head
00000000 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a |................|
00000010 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a |................|
00000020 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 23 |...............#|
00000030 0a 23 09 54 68 69 73 20 66 69 6c 65 20 63 6f 6e |.#.This file con|
00000040 74 61 69 6e 73 20 63 6f 6d 70 6f 73 65 20 74 61 |tains compose ta|
00000050 62 6c 65 20 66 69 6c 65 20 6e 61 6d 65 73 2e 0a |ble file names..|
00000060 23 09 54 68 65 20 66 69 72 73 74 20 77 6f 72 64 |#.The first word|
00000070 20 69 73 20 74 68 65 20 63 6f 6d 70 6f 73 65 20 | is the compose |
00000080 74 61 62 6c 65 20 66 69 6c 65 20 6e 61 6d 65 0a |table file name.|
00000090 23 09 61 6e 64 20 74 68 65 20 73 65 63 6f 6e 64 |#.and the second|
xb@dnxb:/usr/share/X11/locale$ hexdump -Cv C/XLC_LOCALE | head
00000000 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a |................|
00000010 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a |................|
00000020 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 0a 23 |...............#|
00000030 20 20 58 4c 6f 63 61 6c 65 20 44 61 74 61 62 61 | XLocale Databa|
00000040 73 65 20 53 61 6d 70 6c 65 20 66 6f 72 20 43 2e |se Sample for C.|
00000050 0a 23 20 0a 0a 23 20 0a 23 20 09 58 4c 43 5f 46 |.# ..# .# .XLC_F|
00000060 4f 4e 54 53 45 54 20 63 61 74 65 67 6f 72 79 0a |ONTSET category.|
00000070 23 20 0a 58 4c 43 5f 46 4f 4e 54 53 45 54 0a 23 |# .XLC_FONTSET.#|
00000080 20 09 66 73 30 20 63 6c 61 73 73 20 28 37 20 62 | .fs0 class (7 b|
00000090 69 74 20 41 53 43 49 49 29 0a 66 73 30 09 7b 0a |it ASCII).fs0.{.|
xb@dnxb:/usr/share/X11/locale$ 如果我只看到vi文件并看到空白页,我可能不会向下滚动,只有当我cat它时才会注意到这一点。我检查了这个规格,但似乎没有提到任何关于47空行的内容。在地区文件的开头,这47行空白行的用途是什么?
发布于 2018-04-27 16:37:20
我很确定它没有任何原因,这是那些文件的生成方式的一个副作用。如果您查看一下locale.alias的来源,您会发现它们丢失了(注意左边的数字是添加的行号,它们实际上不在文件中):
1 XCOMM
2 XCOMM This file contains alias name of locale.
3 XCOMM Each alias name is described within one line.
4 XCOMM The first word is the alias name (simplified locale name)
5 XCOMM the second word is full locale name.
6 XCOMM
7 XCOMM
8 POSIX: C
9 POSIX-UTF2: C如果您查看通过相当一部分C预处理器和sed来生成文件的Makefile.am:
locale.alias: locale.alias.pre
$(AM_V_GEN)$(RAWCPP) $(RAWCPPFLAGS) $(CPP_FILES_FLAGS) < $(srcdir)/locale.alias.pre | $(CPP_SED_MAGIC) > locale.alias.l1
$(SED) -e '/^[^#][^ ]*:/s/://' -e '/^[^#].*[ ].*:/d' \
< locale.alias.l1 > locale.alias.l2
cat locale.alias.l2 locale.alias.l1 > locale.alias如果您查看Makefile.in,CPP_SED_MAGIC是:
CPP_SED_MAGIC = $(SED) -e '/^\# *[0-9][0-9]* *.*$/d' \
-e '/^\#line *[0-9][0-9]* *.*$/d' \
-e '/^[ ]*XCOMM$/s/XCOMM/\#/' \
-e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/\#/' \
-e '/^[ ]*XHASH/s/XHASH/\#/' \
-e 's,X11_LOCALEDATADIR,$(X11_LOCALEDATADIR),g' \
-e '/\@\@$/s/\@\@$/\\/'除其他外,它用空行替换C预处理器发出的所有行号注释。所以他们就是从这里来的。
https://unix.stackexchange.com/questions/440463
复制相似问题