📄 dkdelent.c
字号:
/*
Copyright (c) 2003, Dan Kranz and Arnold Rom
All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
copyright notice, this list of conditions and the following
disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials
provided with the distribution.
* The names of its contributors may not be used to endorse or
promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* delent() removes all first,lnextl lines from block and updates
the value of nline.
Input first,lnextl reflects physical block line sequence; i.e.
first,lnextl was generated via seqlst. Vacancies result at the
bottom of block.
*/
#include <stdio.h>
#include <stdlib.h>
#include <roots.h>
void delent(void *block, long *cpl, long *nline,
long *first, unsigned short *lnextl)
{
long all, hole, lines, df[2], sf[2], nkeep;
long lguard=MAXLIN;
static long c_1 = 1;
if (*first==0) return;
--lnextl;
/* Initialize the process */
all = (*cpl) * (*nline);
lines = *first - 1;
for (hole = *first; hole != 0; hole = *(lnextl+hole)) {
if (!lguard--) {
RootsSOS("delent() Bad input list!");
abort();
}
/* Set leading destination byte */
df[0] = lines * (*cpl) + 1;
/* Skip sequential holes */
while ( *(lnextl+hole) == hole+1)
hole = *(lnextl+hole);
/* Leave if hole is at bottom of block */
if (hole == 0) {
*nline = lines;
return;
}
/* Identify source length in lines and bytes */
nkeep = *(lnextl+hole) - (hole+1);
if ( *(lnextl+hole) == 0) nkeep = *nline-hole;
lines += nkeep;
/* Move keepers up */
sf[0] = (*cpl) * hole + 1;
sf[1] = (*cpl) * nkeep;
df[1] = (*cpl) * nkeep;
lgmove(block,&all,sf, block,&all,df, &c_1,(BYTE*)"\0");
}
*nline = lines;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -