Rev 3718 | Rev 8155 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3718 | Rev 7673 | ||
---|---|---|---|
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 |
|
18 | /* Subroutines to process matrices */ |
19 |
|
19 | /* messages: inconsistent_columns */ |
20 | 20 | ||
21 |
|
21 | /* Translate error-laden raw matrix input into a standard form. */ |
22 | void rawmatrix(char *p) |
22 | void rawmatrix(char *p) |
23 | { |
23 | { |
24 | char *p1; |
24 | char *p1; |
25 | char lbuf[MAX_LINELEN+1], obuf[MAX_LINELEN+1]; |
25 | char lbuf[MAX_LINELEN+1], obuf[MAX_LINELEN+1]; |
26 | int n, i, c=0, change=0; |
26 | int n, i, c=0, change=0; |
Line 30... | Line 30... | ||
30 | strip_enclosing_par(p); strip_trailing_spaces(p); |
30 | strip_enclosing_par(p); strip_trailing_spaces(p); |
31 | if(*p==0) return; |
31 | if(*p==0) return; |
32 | rows2lines(p); n=linenum(p); |
32 | rows2lines(p); n=linenum(p); |
33 | if(itemnum(p)<=1 && wordnum(p)>=2*n) change=1; |
33 | if(itemnum(p)<=1 && wordnum(p)>=2*n) change=1; |
34 | for(i=1;i<=n;i++) { |
34 | for(i=1;i<=n;i++) { |
35 |
|
35 | fnd_line(p,i,lbuf); |
36 |
|
36 | p1=find_word_start(lbuf); if(p1>lbuf) ovlstrcpy(lbuf,p1); |
37 |
|
37 | strip_enclosing_par(lbuf); |
38 |
|
38 | if(lbuf[0]==0) continue; |
39 |
|
39 | /* Uniformize column separator to comma */ |
40 |
|
40 | if(change) words2items(lbuf); |
41 |
|
41 | rawmath(lbuf); |
42 |
|
42 | if(i==1) { |
43 |
|
43 | ovlstrcpy(obuf,lbuf); |
44 |
|
44 | c=itemnum(lbuf); |
45 |
|
45 | } |
46 |
|
46 | else { |
47 |
|
47 | if(strlen(obuf)+strlen(lbuf)>=MAX_LINELEN-1) |
48 |
|
48 | user_error("cmd_output_too_long"); |
49 |
|
49 | if(c!=itemnum(lbuf)) { |
50 |
|
50 | force_setvar("wims_warn_rawmatrix","inconsistent_columns"); |
51 |
|
51 | return; |
52 |
|
52 | } |
53 |
|
53 | snprintf(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf), |
54 |
|
54 | "\n%s",lbuf); |
55 |
|
55 | } |
56 | } |
56 | } |
57 | ovlstrcpy(p,obuf); |
57 | ovlstrcpy(p,obuf); |
58 | } |
58 | } |
59 | 59 |