nl.pl

来自「网络时间协议NTP 源码 版本v4.2.0b 该源码用于linux平台下」· PL 代码 · 共 38 行

PL
38
字号
#! /usr/local/bin/perl -w$found = 0;$last = 0;$debug = 0;while (<>) {    next if /^#/;    next if /^\s*$/;    if (/^struct req_pkt/) {	$found = 1;    }    if (/^struct info_dns_assoc/) {	$last = 1;    }    if ($found) {	if (/^(struct\s*\w*)\s*{\s*$/) {	    $type = $1;	    print STDERR "type = '$type'\n" if $debug;	    printf "  printf(\"sizeof($type) = %%d\\n\", \n\t (int) sizeof($type));\n";	    next;	}	if (/\s*\w+\s+(\w*)\s*(\[.*\])?\s*;\s*$/) {	    $field = $1;	    print STDERR "\tfield = '$field'\n" if $debug;	    printf "  printf(\"offsetof($field) = %%d\\n\", \n\t (int) offsetof($type, $field));\n";	    next;	}	if (/^}\s*;\s*$/) {	    printf "  printf(\"\\n\");\n\n";	    $found = 0 if $last;	    next;	}	print STDERR "Unmatched line: $_";	exit 1;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?