Subversion Repositories wimsdev

Rev

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

Rev 8185 Rev 12240
Line 21... Line 21...
21
#include "wims.h"
21
#include "wims.h"
22
 
22
 
23
/* Translate error-laden raw matrix input into a standard form. */
23
/* Translate error-laden raw matrix input into a standard form. */
24
void rawmatrix(char *p)
24
void rawmatrix(char *p)
25
{
25
{
26
    char *p1;
26
  char *p1;
27
    char lbuf[MAX_LINELEN+1], obuf[MAX_LINELEN+1];
27
  char lbuf[MAX_LINELEN+1], obuf[MAX_LINELEN+1];
28
    int n, i, c=0, change=0;
28
  int n, i, c=0, change=0;
29
 
29
 
30
    obuf[0]=0;
30
  obuf[0]=0;
31
    p1=find_word_start(p); if(p1>p) ovlstrcpy(p,p1);
31
  p1=find_word_start(p); if(p1>p) ovlstrcpy(p,p1);
32
    strip_enclosing_par(p); strip_trailing_spaces(p);
32
  strip_enclosing_par(p); strip_trailing_spaces(p);
33
    if(*p==0) return;
33
  if(*p==0) return;
34
    rows2lines(p); n=linenum(p);
34
  rows2lines(p); n=linenum(p);
35
    if(itemnum(p)<=1 && wordnum(p)>=2*n) change=1;
35
  if(itemnum(p)<=1 && wordnum(p)>=2*n) change=1;
36
    for(i=1;i<=n;i++) {
36
  for(i=1;i<=n;i++) {
37
     fnd_line(p,i,lbuf);
37
    fnd_line(p,i,lbuf);
38
     p1=find_word_start(lbuf); if(p1>lbuf) ovlstrcpy(lbuf,p1);
38
    p1=find_word_start(lbuf); if(p1>lbuf) ovlstrcpy(lbuf,p1);
39
     strip_enclosing_par(lbuf);
39
    strip_enclosing_par(lbuf);
40
     if(lbuf[0]==0) continue;
40
    if(lbuf[0]==0) continue;
41
/* Uniformize column separator to comma */
41
/* Uniformize column separator to comma */
42
     if(change) words2items(lbuf);
42
    if(change) words2items(lbuf);
43
     rawmath(lbuf);
43
    rawmath(lbuf);
44
     if(i==1) {
44
    if(i==1) {
45
         ovlstrcpy(obuf,lbuf);
45
      ovlstrcpy(obuf,lbuf);
46
         c=itemnum(lbuf);
46
      c=itemnum(lbuf);
47
     }
47
    }
48
     else {
48
    else {
49
         if(strlen(obuf)+strlen(lbuf)>=MAX_LINELEN-1)
49
      if(strlen(obuf)+strlen(lbuf)>=MAX_LINELEN-1)
50
           user_error("cmd_output_too_long");
50
        user_error("cmd_output_too_long");
51
         if(c!=itemnum(lbuf)) {
51
        if(c!=itemnum(lbuf)) {
52
          force_setvar("wims_warn_rawmatrix","inconsistent_columns");
52
          force_setvar("wims_warn_rawmatrix","inconsistent_columns");
53
          return;
53
          return;
54
         }
54
        }
55
         snprintf(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf),
55
        snprintf(obuf+strlen(obuf),sizeof(obuf)-strlen(obuf),
56
               "\n%s",lbuf);
56
               "\n%s",lbuf);
57
     }
57
      }
58
    }
58
  }
59
    ovlstrcpy(p,obuf);
59
  ovlstrcpy(p,obuf);
60
}
60
}
61
 
-