Rev 13381 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
10 | reyssat | 1 | /* Copyright (C) 1998-2003 XIAO, Gang of Universite de Nice - Sophia Antipolis |
2 | * |
||
3 | * This program is free software; you can redistribute it and/or modify |
||
4 | * it under the terms of the GNU General Public License as published by |
||
5 | * the Free Software Foundation; either version 2 of the License, or |
||
6 | * (at your option) any later version. |
||
7 | * |
||
8 | * This program is distributed in the hope that it will be useful, |
||
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
11 | * GNU General Public License for more details. |
||
12 | * |
||
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 |
||
15 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
||
16 | */ |
||
17 | |||
8155 | bpr | 18 | /* Subroutines to process matrices |
19 | * messages: inconsistent_columns |
||
20 | */ |
||
8185 | bpr | 21 | #include "wims.h" |
10 | reyssat | 22 | |
7673 | bpr | 23 | /* Translate error-laden raw matrix input into a standard form. */ |
10 | reyssat | 24 | void rawmatrix(char *p) |
25 | { |
||
12240 | bpr | 26 | char *p1; |
27 | char lbuf[MAX_LINELEN+1], obuf[MAX_LINELEN+1]; |
||
28 | int n, i, c=0, change=0; |
||
10 | reyssat | 29 | |
12240 | bpr | 30 | obuf[0]=0; |
31 | p1=find_word_start(p); if(p1>p) ovlstrcpy(p,p1); |
||
32 | strip_enclosing_par(p); strip_trailing_spaces(p); |
||
33 | if(*p==0) return; |
||
34 | rows2lines(p); n=linenum(p); |
||
35 | if(itemnum(p)<=1 && wordnum(p)>=2*n) change=1; |
||
36 | for(i=1;i<=n;i++) { |
||
37 | fnd_line(p,i,lbuf); |
||
38 | p1=find_word_start(lbuf); if(p1>lbuf) ovlstrcpy(lbuf,p1); |
||
39 | strip_enclosing_par(lbuf); |
||
40 | if(lbuf[0]==0) continue; |
||
13430 | bpr | 41 | /* Uniformize column separator to comma */ |
12240 | bpr | 42 | if(change) words2items(lbuf); |
43 | rawmath(lbuf); |
||
44 | if(i==1) { |
||
45 | ovlstrcpy(obuf,lbuf); |
||
46 | c=itemnum(lbuf); |
||
47 | } |
||
48 | else { |
||
49 | if(strlen(obuf)+strlen(lbuf)>=MAX_LINELEN-1) |
||
50 | user_error("cmd_output_too_long"); |
||
13381 | bpr | 51 | if(c!=itemnum(lbuf)) { |
52 | force_setvar("wims_warn_rawmatrix","inconsistent_columns"); |
||
53 | return; |
||
54 | } |
||
55 | snprintf(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), |
||
7673 | bpr | 56 | "\n%s",lbuf); |
13381 | bpr | 57 | } |
12240 | bpr | 58 | } |
59 | ovlstrcpy(p,obuf); |
||
10 | reyssat | 60 | } |