英语学习:单复数宏
在tcpdump的代码里对单复数的判断还有宏定义,第一次看到。这个单复数的语义还是非常的重要,尤其是用在合同/法律/等需要严格定义的地方。
#define PLURAL_SUFFIX(n) \
(((n) != 1) ? "s" : "")
使用
(void)fprintf(stderr, "%u packet%s dropped by kernel", stats.ps_drop,
PLURAL_SUFFIX(stats.ps_drop));
当然这位代码搜索也带来了麻烦,如果是直接按照下面这个来搜,肯定是搜不到:
tcpdump -i lo udp and port 8080 -v --buffer-size=409600 -v -s0 -w /root/borisl/udp.pcap
tcpdump: listening on lo, link-type EN10MB (Ethernet), capture size 262144 bytes
^C182283 packets captured
364566 packets received by filter
0 packets dropped by kernel /// 按这个搜索代码
这里的0个也判断为了复数。
there are 0 packets
there is 0 packet
there is 0 packets
which one is correct?
chatGPT:
The correct sentence is:
There are 0 packets
This is because "packets" is a plural noun, and "are" is the correct verb to use with plural nouns. Even though the number is zero, the noun "packets" remains plural.
The other sentences are incorrect:
"There is 0 packet" is incorrect because "packet" is singular, but the number zero typically implies a plural context.
"There is 0 packets" is incorrect because "is" should be used with singular nouns, and "packets" is plural.
So, the correct usage is "There are 0 packets."