Subversion Repositories wimsdev

Rev

Rev 10 | Rev 3717 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 10 Rev 3247
Line 13... Line 13...
13
 *  You should have received a copy of the GNU General Public License
13
 *  You should have received a copy of the GNU General Public License
14
 *  along with this program; if not, write to the Free Software
14
 *  along with this program; if not, write to the Free Software
15
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16
 */
16
 */
17
 
17
 
18
unsigned char t_buf[4][MAX_LINELEN+1];
18
char t_buf[4][MAX_LINELEN+1];
19
char maskbuf[MAX_LINELEN+1];
19
char maskbuf[MAX_LINELEN+1];
20
 
20
 
21
        /* internal routine. */
21
        /* internal routine. */
22
void _text_cut(char *p, char *w)
22
void _text_cut(char *p, char *w)
23
{
23
{
Line 203... Line 203...
203
        i=min; min=max; max=i; j=0;
203
        i=min; min=max; max=i; j=0;
204
    }
204
    }
205
    else j=1;
205
    else j=1;
206
    for(i=k=0; i<min; i++) {
206
    for(i=k=0; i<min; i++) {
207
        if(maskbuf[i]=='0') continue;
207
        if(maskbuf[i]=='0') continue;
208
        if(t_buf[0][i]>t_buf[1][i]) p[k++]=t_buf[0][i];
208
        if((unsigned char)t_buf[0][i]>(unsigned char)t_buf[1][i])
-
 
209
          p[k++]=t_buf[0][i];
209
        else p[k++]=t_buf[1][i];
210
        else p[k++]=t_buf[1][i];
210
    }
211
    }
211
    for(;i<max;i++) {
212
    for(;i<max;i++) {
212
        if(maskbuf[i]!='0') p[k++]=t_buf[j][i];
213
        if(maskbuf[i]!='0') p[k++]=t_buf[j][i];
213
    }
214
    }
Line 225... Line 226...
225
    if(min>max) {
226
    if(min>max) {
226
        i=min; min=max; max=i;
227
        i=min; min=max; max=i;
227
    }
228
    }
228
    for(i=k=0; i<min; i++) {
229
    for(i=k=0; i<min; i++) {
229
        if(maskbuf[i]=='0') continue;
230
        if(maskbuf[i]=='0') continue;
230
        if(t_buf[0][i]<t_buf[1][i]) p[k++]=t_buf[0][i];
231
        if((unsigned char)t_buf[0][i]< (unsigned char)t_buf[1][i])
-
 
232
          p[k++]=t_buf[0][i];
231
        else p[k++]=t_buf[1][i];
233
        else p[k++]=t_buf[1][i];
232
    }
234
    }
233
    p[k]=0;
235
    p[k]=0;
234
}
236
}
235
 
237
 
236
        /* extract chars in buf[0] which occur in buf[1]. */
238
        /* extract chars in buf[0] which occur in buf[1]. */
237
void text_occur(char *p)
239
void text_occur(char *p)
238
{
240
{
239
    int i,j,n;
241
    int i,j,n;
240
    unsigned char *pp;
-
 
241
    char buf[MAX_LINELEN+1];
242
    char buf[MAX_LINELEN+1];
242
    memset(buf,0,sizeof(buf));
243
    memset(buf,0,sizeof(buf));
243
    _text_cut(p,"in");
244
    _text_cut(p,"in");
244
    n=strlen(t_buf[1]);
245
    n=strlen(t_buf[1]);
245
    for(i=0;i<n;i++) {
246
    for(i=0;i<n;i++) {
-
 
247
        char *pp;
246
        if(maskbuf[i]=='0') continue;
248
        if(maskbuf[i]=='0') continue;
247
        pp=strchr(t_buf[0],t_buf[1][i]);
249
        pp=strchr(t_buf[0],t_buf[1][i]);
248
        if(pp!=NULL) buf[pp - t_buf[0]]=1;
250
        if(pp!=NULL) buf[pp - t_buf[0]]=1;
249
    }
251
    }
250
    n=strlen(t_buf[0]);
252
    n=strlen(t_buf[0]);