ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/rmtxop.c
(Generate patch)

Comparing ray/src/util/rmtxop.c (file contents):
Revision 2.13 by greg, Mon Aug 12 01:20:26 2019 UTC vs.
Revision 2.15 by greg, Mon Aug 12 16:55:24 2019 UTC

# Line 229 | Line 229 | op_right2left(ROPMAT *mop)
229          int     rpos = 0;
230                                          /* find end of list */
231          while (mop[rpos].binop)
232 <                rpos++;
232 >                if (mop[rpos++].binop != '.') {
233 >                        fputs(
234 >                "Right-to-left evaluation only for matrix multiplication!\n",
235 >                                        stderr);
236 >                        return(NULL);
237 >                }
238          mright = loadop(mop+rpos);
239          while (rpos-- > 0) {
240                  if (mright == NULL)
# Line 313 | Line 318 | main(int argc, char *argv[])
318          int     i;
319                                          /* get options and arguments */
320          for (i = 1; i < argc; i++) {
316                if (nmats >= nall)
317                        mop = grow_moparray(mop, nall += 2);
321                  if (argv[i][0] && !argv[i][1] &&
322                                  strchr(".+*/", argv[i][0]) != NULL) {
323 <                        if (mop[nmats].inspec == NULL || mop[nmats].binop) {
324 <                                fprintf(stderr, "%s: missing matrix argument\n",
325 <                                                argv[0]);
323 >                        if (!nmats || mop[nmats-1].binop) {
324 >                                fprintf(stderr,
325 >                        "%s: missing matrix argument before '%c' operation\n",
326 >                                                argv[0], argv[i][0]);
327                                  return(1);
328                          }
329 <                        mop[nmats++].binop = argv[i][0];
329 >                        mop[nmats-1].binop = argv[i][0];
330                  } else if (argv[i][0] != '-' || !argv[i][1]) {
331                          if (argv[i][0] == '-') {
332                                  if (stdin_used++) {
# Line 341 | Line 345 | main(int argc, char *argv[])
345                          int     n = argc-1 - i;
346                          switch (argv[i][1]) {   /* get option */
347                          case 'v':
348 <                                verbose = !verbose;
348 >                                verbose++;
349                                  break;
350                          case 'f':
351                                  switch (argv[i][2]) {
# Line 382 | Line 386 | main(int argc, char *argv[])
386                                  goto userr;
387                          }
388                  }
389 +                if (nmats >= nall)
390 +                        mop = grow_moparray(mop, nall += 2);
391          }
392          if (mop[0].inspec == NULL)      /* nothing to do? */
393                  goto userr;
394 +        if (mop[nmats-1].binop) {
395 +                fprintf(stderr,
396 +                        "%s: missing matrix argument after '%c' operation\n",
397 +                                argv[0], mop[nmats-1].binop);
398 +                return(1);
399 +        }
400                                          /* favor quicker concatenation */
401 <        mres = prefer_right2left(mop) ? op_right2left(mop) : op_left2right(mop);
402 <        if (!mres)
401 >        mop[nmats].mtx = prefer_right2left(mop) ? op_right2left(mop)
402 >                                                : op_left2right(mop);
403 >        if (mop[nmats].mtx == NULL)
404 >                return(1);
405 >                                        /* apply trailing unary operations */
406 >        mop[nmats].inspec = "trailing_ops";
407 >        mres = loadop(mop+nmats);
408 >        if (mres == NULL)
409                  return(1);
410                                          /* write result to stdout */
411          if (outfmt == DTfromHeader)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines