[lwatch-cvs] files/src strpcre.c,1.19,1.20
Brought to you by:
arturcz
|
From: <os...@us...> - 2004-01-12 21:10:31
|
Update of /cvsroot/lwatch/files/src
In directory sc8-pr-cvs1:/tmp/cvs-serv22964/src
Modified Files:
strpcre.c
Log Message:
Working truncating lines.
Index: strpcre.c
===================================================================
RCS file: /cvsroot/lwatch/files/src/strpcre.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** strpcre.c 12 Jan 2004 18:42:36 -0000 1.19
--- strpcre.c 12 Jan 2004 21:10:28 -0000 1.20
***************
*** 165,176 ****
char* cut_line(char *output, char *input,int real_len)
{
! int to_cut=real_len-win_width;
! printf("%d - %d = %d\n",real_len,win_width,to_cut);
! if (to_cut<1) {output=input; return output;}
strncpy(output,input,strlen(input));
! output[strlen(input)-to_cut+1]=0;
! while (to_cut) {
! to_cut--;
}
return output;
}
--- 165,188 ----
char* cut_line(char *output, char *input,int real_len)
{
! int to_cut=real_len-win_width, n=strlen(input), m=0;
strncpy(output,input,strlen(input));
! output[strlen(input)]=0;
! // printf("%d - %d = %d\n",real_len,win_width,to_cut);
! if (to_cut<1) return output;
! while (to_cut>0) {
! switch (output[n]) {
! case '\n':
! case '\0': break;
! case '0' ... '9': if (m<2) m++; else {to_cut-=m+1; m=0;}
! break;
! case '^': if (m!=2) to_cut-=m+1;
! m=0;
! break;
! default: to_cut--; break;
! }
! n--;
}
+ output[n+1]='\n';
+ output[n+2]=0;
return output;
}
|