存档

文章标签 ‘Linux’

debian包的结构和解包打包-从打包ubuntu12.10 linuxqq说起

2013年1月9日 sigma 6 条评论 174,902 views

作为2B青年,果断在mac下装了linux。今天想装QQ,发现报错了。

daohoo@daohoo-mbp:~/Downloads$ sudo dpkg -i linuxqq_v1.0.2-beta1_i386.deb
[sudo] password for daohoo:
dpkg: error processing linuxqq_v1.0.2-beta1_i386.deb (--install):
 parsing file '/var/lib/dpkg/tmp.ci/control' near line 7 package 'linuxqq':
 error in Version string 'v1.0.2-beta1': version number does not start with digit
Errors were encountered while processing:
 linuxqq_v1.0.2-beta1_i386.deb

根据错误信息显示,不能安装的原因是新版的ubuntu要求版本号为数字开头,SB的腾讯却用v开头。因此,我猜想,只要重新打包即可(之前我通过重新打包的方法,也改过android QQ的尾巴)。过程如下:

1.ar解包:

daohoo@daohoo-mbp:~/Downloads/linuxqq$ ar vx linuxqq_1.0.2_i386.deb
x - debian-binary
x - control.tar.gz
x - data.tar.gz

2.tar解包control信息:

daohoo@daohoo-mbp:~/Downloads/linuxqq$ tar -zxvf control.tar.gz
./
./conffiles
./control

3.修改control文件:

sed -i "s/v1.0/1.0/g" control

4.重新tar打包control.tar.gz

tar -zcvf control.tar.gz ./conffiles ./control

5.ar重新打包debian包:

ar rcs linuxqq.deb debian-binary control.tar.gz data.tar.gz

6.安装:

sudo dpkg -i linuxqq.deb

BTW:介绍一下关于debian包的结构: 阅读全文…

分类: 折腾 标签: ,

Ubuntu/Debian从源码编译debian包

2012年12月1日 sigma 没有评论 22,951 views

Ubuntu源里有的软件:

ubuntu源里有的软件,理论上不用自己编译debian包,但是有时候,我们想对源里的软件做些修改,打些patch,就可以用这种方法,具体为:

1.获取源文件

源码包中通常包含3个文件,分别以dsc,orig.tar.gz和diff.gz为后缀名。
其中 .orig.tar.gz 是软件原始源码包,没有经过任何修改; .diff.gz 是将源码包 debian 化的文件,包含一些补丁和编译规则;.dsc 描述了源码包的信息,上述命令是解压源码和打补丁的综合操作。
使用apt-get source命令来获取源码包,它会将源码包下载到用户当前目录,并在命令执行过程中,调用dpkg-source命令,根据dsc文件中的信息,将源码包解压到同名目录中,应用程序的源代码就在这里面。
sudo apt-get source tree
另外,有时想用的源码包不是最新版本的,而是一些老版本。可以在新立得里面先强制版本。之后在执行命令。或者直接去old_archive.ubuntu.com上找老版本的dsc,orig.tar.gz,diff.gz等。
要强调的是,在下载源码包前,必须确保安装了dpkg-dev(执行”apt-get install dpkg-dev”来安装),否则,只会下载源码包的3个文件,但不会解压缩源码包。当然你也可以自己用dpkg-source命令去解压缩源码包:
dpkg-source -x tree-1.5.1.2.dsc 阅读全文…

分类: 贝壳 标签: , , ,

Linux on MIPS的syscall及id列表

2012年11月2日 sigma 没有评论 123,703 views

Linux on MIPS的syscall及id列表:

<?xml version="1.0"?>
<!-- Copyright (C) 2011 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved.  -->
<!DOCTYPE feature SYSTEM "gdb-syscalls.dtd">
<!-- This file was generated using the following file:
/usr/src/linux/arch/mips/include/asm/unistd.h
The file mentioned above belongs to the Linux Kernel.  -->
<syscalls_info>
<syscall name="syscall" number="4000"/>
<syscall name="exit" number="4001"/>
<syscall name="fork" number="4002"/>
<syscall name="read" number="4003"/>
<syscall name="write" number="4004"/>
<syscall name="open" number="4005"/>
<syscall name="close" number="4006"/>
<syscall name="waitpid" number="4007"/>
<syscall name="creat" number="4008"/>
<syscall name="link" number="4009"/>
<syscall name="unlink" number="4010"/>
<syscall name="execve" number="4011"/>
<syscall name="chdir" number="4012"/>
<syscall name="time" number="4013"/>
<syscall name="mknod" number="4014"/>
<syscall name="chmod" number="4015"/>
<syscall name="lchown" number="4016"/>
<syscall name="break" number="4017"/>
<syscall name="lseek" number="4019"/>
<syscall name="getpid" number="4020"/>
<syscall name="mount" number="4021"/>
<syscall name="umount" number="4022"/>
<syscall name="setuid" number="4023"/>
<syscall name="getuid" number="4024"/>
<syscall name="stime" number="4025"/>
<syscall name="ptrace" number="4026"/>
<syscall name="alarm" number="4027"/>
<syscall name="pause" number="4029"/>
<syscall name="utime" number="4030"/>
<syscall name="stty" number="4031"/>
<syscall name="gtty" number="4032"/>
<syscall name="access" number="4033"/>
<syscall name="nice" number="4034"/>
<syscall name="ftime" number="4035"/>
<syscall name="sync" number="4036"/>
<syscall name="kill" number="4037"/>
<syscall name="rename" number="4038"/>
<syscall name="mkdir" number="4039"/>
<syscall name="rmdir" number="4040"/>
<syscall name="dup" number="4041"/>
<syscall name="pipe" number="4042"/>
<syscall name="times" number="4043"/>
<syscall name="prof" number="4044"/>
<syscall name="brk" number="4045"/>
<syscall name="setgid" number="4046"/>
<syscall name="getgid" number="4047"/>
<syscall name="signal" number="4048"/>
<syscall name="geteuid" number="4049"/>
<syscall name="getegid" number="4050"/>
<syscall name="acct" number="4051"/>
<syscall name="umount2" number="4052"/>
<syscall name="lock" number="4053"/>
<syscall name="ioctl" number="4054"/>
<syscall name="fcntl" number="4055"/>
<syscall name="mpx" number="4056"/>
<syscall name="setpgid" number="4057"/>
<syscall name="ulimit" number="4058"/>
<syscall name="umask" number="4060"/>
<syscall name="chroot" number="4061"/>
<syscall name="ustat" number="4062"/>
<syscall name="dup2" number="4063"/>
<syscall name="getppid" number="4064"/>
<syscall name="getpgrp" number="4065"/>
<syscall name="setsid" number="4066"/>
<syscall name="sigaction" number="4067"/>
<syscall name="sgetmask" number="4068"/>
<syscall name="ssetmask" number="4069"/>
<syscall name="setreuid" number="4070"/>
<syscall name="setregid" number="4071"/>
<syscall name="sigsuspend" number="4072"/>
<syscall name="sigpending" number="4073"/>
<syscall name="sethostname" number="4074"/>
<syscall name="setrlimit" number="4075"/>
<syscall name="getrlimit" number="4076"/>
<syscall name="getrusage" number="4077"/>
<syscall name="gettimeofday" number="4078"/>
<syscall name="settimeofday" number="4079"/>
<syscall name="getgroups" number="4080"/>
<syscall name="setgroups" number="4081"/>
<syscall name="symlink" number="4083"/>
<syscall name="readlink" number="4085"/>
<syscall name="uselib" number="4086"/>
<syscall name="swapon" number="4087"/>
<syscall name="reboot" number="4088"/>
<syscall name="readdir" number="4089"/>
<syscall name="mmap" number="4090"/>
<syscall name="munmap" number="4091"/>
<syscall name="truncate" number="4092"/>
<syscall name="ftruncate" number="4093"/>
<syscall name="fchmod" number="4094"/>
<syscall name="fchown" number="4095"/>
<syscall name="getpriority" number="4096"/>
<syscall name="setpriority" number="4097"/>
<syscall name="profil" number="4098"/>
<syscall name="statfs" number="4099"/>
<syscall name="fstatfs" number="4100"/>
<syscall name="ioperm" number="4101"/>
<syscall name="socketcall" number="4102"/>
<syscall name="syslog" number="4103"/>
<syscall name="setitimer" number="4104"/>
<syscall name="getitimer" number="4105"/>
<syscall name="stat" number="4106"/>
<syscall name="lstat" number="4107"/>
<syscall name="fstat" number="4108"/>
<syscall name="iopl" number="4110"/>
<syscall name="vhangup" number="4111"/>
<syscall name="idle" number="4112"/>
<syscall name="vm86" number="4113"/>
<syscall name="wait4" number="4114"/>
<syscall name="swapoff" number="4115"/>
<syscall name="sysinfo" number="4116"/>
<syscall name="ipc" number="4117"/>
<syscall name="fsync" number="4118"/>
<syscall name="sigreturn" number="4119"/>
<syscall name="clone" number="4120"/>
<syscall name="setdomainname" number="4121"/>
<syscall name="uname" number="4122"/>
<syscall name="modify_ldt" number="4123"/>
<syscall name="adjtimex" number="4124"/>
<syscall name="mprotect" number="4125"/>
<syscall name="sigprocmask" number="4126"/>
<syscall name="create_module" number="4127"/>
<syscall name="init_module" number="4128"/>
<syscall name="delete_module" number="4129"/>
<syscall name="get_kernel_syms" number="4130"/>
<syscall name="quotactl" number="4131"/>
<syscall name="getpgid" number="4132"/>
<syscall name="fchdir" number="4133"/>
<syscall name="bdflush" number="4134"/>
<syscall name="sysfs" number="4135"/>
<syscall name="personality" number="4136"/>
<syscall name="afs_syscall" number="4137"/>
<syscall name="setfsuid" number="4138"/>
<syscall name="setfsgid" number="4139"/>
<syscall name="_llseek" number="4140"/>
<syscall name="getdents" number="4141"/>
<syscall name="_newselect" number="4142"/>
<syscall name="flock" number="4143"/>
<syscall name="msync" number="4144"/>
<syscall name="readv" number="4145"/>
<syscall name="writev" number="4146"/>
<syscall name="cacheflush" number="4147"/>
<syscall name="cachectl" number="4148"/>
<syscall name="sysmips" number="4149"/>
<syscall name="getsid" number="4151"/>
<syscall name="fdatasync" number="4152"/>
<syscall name="_sysctl" number="4153"/>
<syscall name="mlock" number="4154"/>
<syscall name="munlock" number="4155"/>
<syscall name="mlockall" number="4156"/>
<syscall name="munlockall" number="4157"/>
<syscall name="sched_setparam" number="4158"/>
<syscall name="sched_getparam" number="4159"/>
<syscall name="sched_setscheduler" number="4160"/>
<syscall name="sched_getscheduler" number="4161"/>
<syscall name="sched_yield" number="4162"/>
<syscall name="sched_get_priority_max" number="4163"/>
<syscall name="sched_get_priority_min" number="4164"/>
<syscall name="sched_rr_get_interval" number="4165"/>
<syscall name="nanosleep" number="4166"/>
<syscall name="mremap" number="4167"/>
<syscall name="accept" number="4168"/>
<syscall name="bind" number="4169"/>
<syscall name="connect" number="4170"/>
<syscall name="getpeername" number="4171"/>
<syscall name="getsockname" number="4172"/>
<syscall name="getsockopt" number="4173"/>
<syscall name="listen" number="4174"/>
<syscall name="recv" number="4175"/>
<syscall name="recvfrom" number="4176"/>
<syscall name="recvmsg" number="4177"/>
<syscall name="send" number="4178"/>
<syscall name="sendmsg" number="4179"/>
<syscall name="sendto" number="4180"/>
<syscall name="setsockopt" number="4181"/>
<syscall name="shutdown" number="4182"/>
<syscall name="socket" number="4183"/>
<syscall name="socketpair" number="4184"/>
<syscall name="setresuid" number="4185"/>
<syscall name="getresuid" number="4186"/>
<syscall name="query_module" number="4187"/>
<syscall name="poll" number="4188"/>
<syscall name="nfsservctl" number="4189"/>
<syscall name="setresgid" number="4190"/>
<syscall name="getresgid" number="4191"/>
<syscall name="prctl" number="4192"/>
<syscall name="rt_sigreturn" number="4193"/>
<syscall name="rt_sigaction" number="4194"/>
<syscall name="rt_sigprocmask" number="4195"/>
<syscall name="rt_sigpending" number="4196"/>
<syscall name="rt_sigtimedwait" number="4197"/>
<syscall name="rt_sigqueueinfo" number="4198"/>
<syscall name="rt_sigsuspend" number="4199"/>
<syscall name="pread64" number="4200"/>
<syscall name="pwrite64" number="4201"/>
<syscall name="chown" number="4202"/>
<syscall name="getcwd" number="4203"/>
<syscall name="capget" number="4204"/>
<syscall name="capset" number="4205"/>
<syscall name="sigaltstack" number="4206"/>
<syscall name="sendfile" number="4207"/>
<syscall name="getpmsg" number="4208"/>
<syscall name="putpmsg" number="4209"/>
<syscall name="mmap2" number="4210"/>
<syscall name="truncate64" number="4211"/>
<syscall name="ftruncate64" number="4212"/>
<syscall name="stat64" number="4213"/>
<syscall name="lstat64" number="4214"/>
<syscall name="fstat64" number="4215"/>
<syscall name="pivot_root" number="4216"/>
<syscall name="mincore" number="4217"/>
<syscall name="madvise" number="4218"/>
<syscall name="getdents64" number="4219"/>
<syscall name="fcntl64" number="4220"/>
<syscall name="gettid" number="4222"/>
<syscall name="readahead" number="4223"/>
<syscall name="setxattr" number="4224"/>
<syscall name="lsetxattr" number="4225"/>
<syscall name="fsetxattr" number="4226"/>
<syscall name="getxattr" number="4227"/>
<syscall name="lgetxattr" number="4228"/>
<syscall name="fgetxattr" number="4229"/>
<syscall name="listxattr" number="4230"/>
<syscall name="llistxattr" number="4231"/>
<syscall name="flistxattr" number="4232"/>
<syscall name="removexattr" number="4233"/>
<syscall name="lremovexattr" number="4234"/>
<syscall name="fremovexattr" number="4235"/>
<syscall name="tkill" number="4236"/>
<syscall name="sendfile64" number="4237"/>
<syscall name="futex" number="4238"/>
<syscall name="sched_setaffinity" number="4239"/>
<syscall name="sched_getaffinity" number="4240"/>
<syscall name="io_setup" number="4241"/>
<syscall name="io_destroy" number="4242"/>
<syscall name="io_getevents" number="4243"/>
<syscall name="io_submit" number="4244"/>
<syscall name="io_cancel" number="4245"/>
<syscall name="exit_group" number="4246"/>
<syscall name="lookup_dcookie" number="4247"/>
<syscall name="epoll_create" number="4248"/>
<syscall name="epoll_ctl" number="4249"/>
<syscall name="epoll_wait" number="4250"/>
<syscall name="remap_file_pages" number="4251"/>
<syscall name="set_tid_address" number="4252"/>
<syscall name="restart_syscall" number="4253"/>
<syscall name="fadvise64" number="4254"/>
<syscall name="statfs64" number="4255"/>
<syscall name="fstatfs64" number="4256"/>
<syscall name="timer_create" number="4257"/>
<syscall name="timer_settime" number="4258"/>
<syscall name="timer_gettime" number="4259"/>
<syscall name="timer_getoverrun" number="4260"/>
<syscall name="timer_delete" number="4261"/>
<syscall name="clock_settime" number="4262"/>
<syscall name="clock_gettime" number="4263"/>
<syscall name="clock_getres" number="4264"/>
<syscall name="clock_nanosleep" number="4265"/>
<syscall name="tgkill" number="4266"/>
<syscall name="utimes" number="4267"/>
<syscall name="mbind" number="4268"/>
<syscall name="get_mempolicy" number="4269"/>
<syscall name="set_mempolicy" number="4270"/>
<syscall name="mq_open" number="4271"/>
<syscall name="mq_unlink" number="4272"/>
<syscall name="mq_timedsend" number="4273"/>
<syscall name="mq_timedreceive" number="4274"/>
<syscall name="mq_notify" number="4275"/>
<syscall name="mq_getsetattr" number="4276"/>
<syscall name="vserver" number="4277"/>
<syscall name="waitid" number="4278"/>
<syscall name="add_key" number="4280"/>
<syscall name="request_key" number="4281"/>
<syscall name="keyctl" number="4282"/>
<syscall name="set_thread_area" number="4283"/>
<syscall name="inotify_init" number="4284"/>
<syscall name="inotify_add_watch" number="4285"/>
<syscall name="inotify_rm_watch" number="4286"/>
<syscall name="migrate_pages" number="4287"/>
<syscall name="openat" number="4288"/>
<syscall name="mkdirat" number="4289"/>
<syscall name="mknodat" number="4290"/>
<syscall name="fchownat" number="4291"/>
<syscall name="futimesat" number="4292"/>
<syscall name="fstatat64" number="4293"/>
<syscall name="unlinkat" number="4294"/>
<syscall name="renameat" number="4295"/>
<syscall name="linkat" number="4296"/>
<syscall name="symlinkat" number="4297"/>
<syscall name="readlinkat" number="4298"/>
<syscall name="fchmodat" number="4299"/>
<syscall name="faccessat" number="4300"/>
<syscall name="pselect6" number="4301"/>
<syscall name="ppoll" number="4302"/>
<syscall name="unshare" number="4303"/>
<syscall name="splice" number="4304"/>
<syscall name="sync_file_range" number="4305"/>
<syscall name="tee" number="4306"/>
<syscall name="vmsplice" number="4307"/>
<syscall name="move_pages" number="4308"/>
<syscall name="set_robust_list" number="4309"/>
<syscall name="get_robust_list" number="4310"/>
<syscall name="kexec_load" number="4311"/>
<syscall name="getcpu" number="4312"/>
<syscall name="epoll_pwait" number="4313"/>
<syscall name="ioprio_set" number="4314"/>
<syscall name="ioprio_get" number="4315"/>
<syscall name="utimensat" number="4316"/>
<syscall name="signalfd" number="4317"/>
<syscall name="timerfd" number="4318"/>
<syscall name="eventfd" number="4319"/>
<syscall name="fallocate" number="4320"/>
<syscall name="timerfd_create" number="4321"/>
<syscall name="timerfd_gettime" number="4322"/>
<syscall name="timerfd_settime" number="4323"/>
<syscall name="signalfd4" number="4324"/>
<syscall name="eventfd2" number="4325"/>
<syscall name="epoll_create1" number="4326"/>
<syscall name="dup3" number="4327"/>
<syscall name="pipe2" number="4328"/>
<syscall name="inotify_init1" number="4329"/>
<syscall name="preadv" number="4330"/>
<syscall name="pwritev" number="4331"/>
<syscall name="rt_tgsigqueueinfo" number="4332"/>
<syscall name="perf_event_open" number="4333"/>
<syscall name="accept4" number="4334"/>
<syscall name="recvmmsg" number="4335"/>
<syscall name="fanotify_init" number="4336"/>
<syscall name="fanotify_mark" number="4337"/>
<syscall name="prlimit64" number="4338"/>
</syscalls_info>

X86的syscall表在这里有:

http://syscalls.kernelgrok.com/

分类: 沙子 标签: , ,

pdf嵌入字体

2012年5月12日 sigma 4 条评论 23,656 views

在论文提交final script时,一般都要求论文中所有的字体都嵌入到pdf中,一般来说,IEEE提供了一个叫做EXPRESS的工具,可以检查是否符合规范,包括字体是否嵌入。但是,有时候,我们通过latex编译出来的pdf,不能通过EXPRESS检查,并且大部分都是因为字体原因,那么,本文将介绍如何在linux pdflatex编译时能够潜入所有字体。

首先,linux下本身提供了一个检查pdf字体信息的工具,pdffonts。比如查看test.pdf的字体:

pdffonts test.pdf

结果应该是类似下面的:

name                                 type              emb sub uni object ID
------------------------------------ ----------------- --- --- --- ---------
JNARJV+NimbusRomNo9L-Medi            Type 1            yes yes no       6  0
NBINYZ+NimbusRomNo9L-Regu            Type 1            yes yes no       7  0
CBDPEB+NimbusRomNo9L-ReguItal        Type 1            yes yes no       8  0
ZYBBWF+CMSY10                        Type 1            yes yes no       9  0
QVCFWU+NimbusRomNo9L-MediItal        Type 1            yes yes no      10  0
IJIDBD+CMMI10                        Type 1            yes yes no      11  0
MTWRTR+CMR10                         Type 1            yes yes no      16  0
Arial                                TrueType          no  no  no      35  0
Arial,Italic                         TrueType          no  no  no      36  0
WXQMOP+CMMIB10                       Type 1            yes yes no      46  0
Helvetica                            Type 1            no  no  no      51  0
DWKNIZ+CMMI7                         Type 1            yes yes no      55  0
IXNPPI+CMEX10                        Type 1            yes yes no      56  0
EUDIGL+CMR7                          Type 1            yes yes no      57  0
CLXNUD+CMSY7                         Type 1            yes yes no      58  0
RURLFQ+CMMIB7                        Type 1            yes yes no      62  0
LDBHLR+CMBX10                        Type 1            yes yes no      63  0
YJCSYX+CMMI5                         Type 1            yes yes no      69  0
Helvetica                            Type 1            no  no  no      74  0
Helvetica                            Type 1            no  no  no      79  0

可以看到,有些字体emb选项为no,表示没有嵌入。 阅读全文…

分类: 贝壳 标签: , , , ,

Vimdiff逐行比较

2012年4月27日 sigma 1 条评论 7,974 views

平时,我们用vimdiff都是基于最大匹配,但有时我们希望能够逐行比较,这个不能直接实现,但是可以通过diff的patchexpr实现,具体介绍可以看vim文档:

http://vimdoc.sourceforge.net/htmldoc/diff.html

下面给出一个vim逐行比较的patch,将下面内容复制到一个文件diffbyline.vim,并且放到plugin目录下(这个脚本是我很早从网络搜到的,现在忘了来源了,哪位看到来源,请告知,我好说明):

" File:         diffbyline.vim
" Created:      2010 Sep 28
" Last Change:  2010 Oct 02
" Rev Days:     3
" Author:	Andy Wokula <anwoku@yahoo.de>

" :SetLineByLineDiff[!]
"
"   set the 'diffexpr' to enable a trivial line-by-line diff algorithm (the
"   diff program has no option for this).  Reset 'diffexpr' with [!].

com! -bar -bang SetLineByLineDiff  call s:SetDiffExpr(<bang>0)

func! s:SetDiffExpr(bang)
    if !a:bang
	set diffexpr=DiffLineByLine()
	echo "'diffexpr' changed to enable line-by-line diff"
    else
	" XXX restore the previous value
	set diffexpr&
	echo "'diffexpr' restored"
    endif
endfunc

func! DiffLineByLine()
    let result = []	" diff output lines
    let oldlines = readfile(v:fname_in)
    let newlines = readfile(v:fname_new)

    let len_oldlines = len(oldlines)
    let len_newlines = len(newlines)
    let len_common = min([len_oldlines, len_newlines])

    " different number of lines allowed
    "	first common lines -> change(s) only
    "	rest -> append (er, no, see below)

    let idx = 0
    let change_start = -1
    while idx < len_common
	if oldlines[idx] !=# newlines[idx]
	    " XXX above test is case sensitive and ignores 'diffopt'
	    if change_start == -1
		let change_start = idx
	    endif
	    let change_end = idx
	elseif change_start >= 0
	    " line-idx is just after a block of changed lines

	    " prepare a diff block
	    if change_start < change_end
		let range = (1+change_start). ",". (1+change_end)
	    else
		let range = 1+change_start
	    endif
	    let ed_cmd = range. "c". range
	    call add(result, ed_cmd)
	    call extend(result, map(oldlines[change_start : change_end], '"< ". v:val'))
	    call add(result, '---')
	    call extend(result, map(newlines[change_start : change_end], '"> ". v:val'))

	    let change_start = -1
	endif
	let idx += 1
    endwhile

    if change_start >= 0

	" XXX extract to function? (paragraph copied from above)
	if change_start < change_end
	    let range = (1+change_start). ",". (1+change_end)
	else
	    let range = 1+change_start
	endif
	let ed_cmd = range. "c". range
	call add(result, ed_cmd)
	call extend(result, map(oldlines[change_start : change_end], '"< ". v:val'))
	call add(result, '---')
	call extend(result, map(newlines[change_start : change_end], '"> ". v:val'))

    endif

    if len_oldlines < len_newlines
        let append_start = len_oldlines
        let append_end = len_newlines - 1
        let old_range = append_start	" append below this line
        if append_start < append_end
            let new_range = (1+append_start). ",". (1+append_end)
        else
            let new_range = 1+append_start
        endif
        let ed_cmd = old_range. "a". new_range
        call add(result, ed_cmd)
        call extend(result, map(newlines[append_start : append_end], '"> ". v:val'))

    elseif len_oldlines > len_newlines
        let delete_start = len_newlines
        let delete_end = len_oldlines - 1
        let new_range = delete_start	" delete below this line
        if delete_start < delete_end
            let old_range = (1+delete_start). ",". (1+delete_end)
        else
            let old_range = 1+delete_start
        endif
        let ed_cmd = old_range. "d". new_range
        call add(result, ed_cmd)
        call extend(result, map(oldlines[delete_start : delete_end], '"< ". v:val'))

    endif

    " Decho result
    " XXX strange: :D echo prints at least two result lists, first is
    "	['1c1', '< line1', '---', '> line2'] and belongs nowhere (is this an
    "	internal diff test by Vim?)

    call writefile(result, v:fname_out)

endfunc

使用方法:

  • 在diff界面,输入:SetLineByLineDiff,跳到逐行模式,再输入一次,回到普通模式。
  • 或者加个SetLineByLineDiff选项,如:vimdiff +SetLineByLineDiff a.c b.c
分类: 贝壳 标签: , ,

无觅相关文章插件,快速提升流量