internal-coding-error code dedupe

This commit is contained in:
John Kerl 2016-10-14 20:06:03 -04:00
parent 5d9ed86b9c
commit 23edecaab5
3 changed files with 3 additions and 15 deletions

View file

@ -45,11 +45,7 @@ lrec_writer_t* lrec_writer_alloc(cli_writer_opts_t* popts) {
// ----------------------------------------------------------------
lrec_writer_t* lrec_writer_alloc_or_die(cli_writer_opts_t* popts) {
lrec_writer_t* plrec_writer = lrec_writer_alloc(popts);
if (plrec_writer == NULL) {
fprintf(stderr, "%s: internal coding error detected in file \"%s\" at line %d.\n",
MLR_GLOBALS.bargv0, __FILE__, __LINE__);
exit(1);
}
MLR_INTERNAL_CODING_ERROR_IF(plrec_writer == NULL);
return plrec_writer;
}

View file

@ -35,11 +35,7 @@ void multi_lrec_writer_output_srec(multi_lrec_writer_t* pmlw, lrec_t* poutrec, c
if (pstate == NULL) {
pstate = mlr_malloc_or_die(sizeof(lrec_writer_and_fp_t));
pstate->plrec_writer = lrec_writer_alloc(pmlw->pwriter_opts);
if (pstate->plrec_writer == NULL) {
fprintf(stderr, "%s: internal coding error detected in file \"%s\" at line %d.\n",
MLR_GLOBALS.bargv0, __FILE__, __LINE__);
exit(1);
}
MLR_INTERNAL_CODING_ERROR_IF(pstate->plrec_writer == NULL);
pstate->filename_or_command = mlr_strdup_or_die(filename_or_command);
char* mode_string = get_mode_string(file_output_mode);
char* mode_desc = get_mode_desc(file_output_mode);

View file

@ -29,11 +29,7 @@ int do_stream_chained(char* prepipe, slls_t* filenames, lrec_reader_t* plrec_rea
{
FILE* output_stream = stdout;
if (pmapper_list->length < 1) { // Should not have been allowed by the CLI parser.
fprintf(stderr, "%s: internal coding error detected at file %s line %d.\n",
MLR_GLOBALS.bargv0, __FILE__, __LINE__);
exit(1);
}
MLR_INTERNAL_CODING_ERROR_IF(pmapper_list->length < 1); // Should not have been allowed by the CLI parser.
context_t ctx = { .nr = 0, .fnr = 0, .filenum = 0, .filename = NULL, .force_eof = FALSE };
int ok = 1;