~ubuntu-branches/ubuntu/precise/bc/precise-updates

« back to all changes in this revision

Viewing changes to bc/execute.c

  • Committer: Bazaar Package Importer
  • Author(s): Ian Jackson
  • Date: 2006-04-04 17:21:02 UTC
  • Revision ID: james.westby@ubuntu.com-20060404172102-64vnydii80rn39jt
Tags: 1.06-19ubuntu1
Make dc notice read and write errors on its input and output.
I grepped for mentions of the strings `putc', `print', `getc', `FILE',
`stdin', `stdout' and `stderr' and added calls to new error-checking
functions unless it was clear from the immediately-surrounding code
that the program was exiting nonzero, or would exit nonzero if the
call failed.  I ignored hits in lib/getopt*, which seems to
pervasively ignore write errors when printing usage messages, in the
hope that these were correct.  I _think_ I got them all.  -iwj.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
{
45
45
  had_sigint = TRUE;
46
46
  printf ("\n");
 
47
  checkferror_output(stdout);
47
48
  rt_error ("interrupted execution");
48
49
}
49
50
 
110
111
              }
111
112
            out_char ('\n');
112
113
          }
 
114
        checkferror_output(stdout);
113
115
      }
114
116
#endif
115
117
 
224
226
                }
225
227
            }
226
228
        fflush (stdout);
 
229
        checkferror_output(stdout);
227
230
        break;
228
231
 
229
232
      case 'R' : /* Return from function */
259
262
        if (inst == 'W') out_char ('\n');
260
263
        store_var (4);  /* Special variable "last". */
261
264
        fflush (stdout);
 
265
        checkferror_output(stdout);
262
266
        pop ();
263
267
        break;
264
268
 
335
339
      case 'w' : /* Write a string to the output. */
336
340
        while ((ch = byte(&pc)) != '"') out_schar (ch);
337
341
        fflush (stdout);
 
342
        checkferror_output(stdout);
338
343
        break;
339
344
                   
340
345
      case 'x' : /* Exchange Top of Stack with the one under the tos. */
541
546
  if (interactive)
542
547
    {
543
548
      signal (SIGINT, use_quit);
544
 
      if (had_sigint)
 
549
      if (had_sigint) {
545
550
        printf ("Interruption completed.\n");
 
551
        checkferror_output(stdout);
 
552
      }
546
553
    }
547
554
}
548
555
 
575
582
      if (in_ch == '\n')
576
583
        in_ch = getchar();
577
584
    }
 
585
  checkferror_input(stdin);
578
586
 
579
587
  /* Classify and preprocess the input character. */
580
588
  if (isdigit((int)in_ch))