From dba7d25709e781c8fb2a6afbb45e63b2c1af8e13 Mon Sep 17 00:00:00 2001 From: Andreas Scherer Date: Fri, 2 Apr 2021 08:41:50 +0000 Subject: [CTIE] More concise 'find/fopen' logic. git-svn-id: svn://tug.org/texlive/trunk@58700 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/ctiedir/ChangeLog | 4 +++ Build/source/texk/web2c/ctiedir/ctie-k.ch | 44 ++++++++++++------------------- 2 files changed, 21 insertions(+), 27 deletions(-) (limited to 'Build') diff --git a/Build/source/texk/web2c/ctiedir/ChangeLog b/Build/source/texk/web2c/ctiedir/ChangeLog index 74c3f1e9386..732e882ea3b 100644 --- a/Build/source/texk/web2c/ctiedir/ChangeLog +++ b/Build/source/texk/web2c/ctiedir/ChangeLog @@ -1,3 +1,7 @@ +2021-03-10 Andreas Scherer + + * ctie-k.ch: More concise 'find/fopen' logic. + 2020-07-24 Andreas Scherer * ctie-k.ch: Format types in boldface prior to their definition. diff --git a/Build/source/texk/web2c/ctiedir/ctie-k.ch b/Build/source/texk/web2c/ctiedir/ctie-k.ch index ccd8f157b59..e9ac5959b6e 100644 --- a/Build/source/texk/web2c/ctiedir/ctie-k.ch +++ b/Build/source/texk/web2c/ctiedir/ctie-k.ch @@ -329,10 +329,8 @@ variable) to search for this file.@.CWEBINPUTS@> @x l.534 Replace with kpse_find_file if ((new_inc->the_file=fopen(new_inc->file_name, "r"))!=NULL) { @y - fullname=kpse_find_cweb(new_inc->file_name); - if (fullname) - new_inc->the_file=fopen(fullname, "r"); - if (fullname!=NULL && new_inc->the_file!=NULL) { + if ((fullname=kpse_find_cweb(new_inc->file_name))!=NULL @| + && (new_inc->the_file=fopen(fullname, "r"))!=NULL) { free(fullname); @z @@ -434,8 +432,9 @@ interface. @x l.731 Use binary mode for output files out_file=fopen(out_name, "w"); + if (out_file==NULL) { @y - out_file=fopen(out_name, "wb"); + if ((out_file=fopen(out_name, "wb"))==NULL) { @z @x l.739 @@ -466,20 +465,15 @@ the file. { string fullname; - fullname = kpse_find_cweb(input_organisation[0]->file_name); - if (fullname) - input_organisation[0]->the_file = fopen(fullname, "r"); - - if (fullname==NULL || input_organisation[0]->the_file==NULL) { - if (fullname) { + if ((fullname = kpse_find_cweb(input_organisation[0]->file_name))!=NULL) { + if ((input_organisation[0]->the_file = fopen(fullname, "r"))==NULL) pfatal_error("! Cannot open master file ", input_organisation[0]->file_name); - } else { - fatal_error(-1, "! Cannot find master file ", - input_organisation[0]->file_name); - } + free(fullname); + } @+ else { + fatal_error(-1, "! Cannot find master file ", + input_organisation[0]->file_name); } - else free(fullname); @.Cannot open master file@> @.Cannot find master file@> @z @@ -505,20 +499,16 @@ the file. i=1; while (ifile_name); - if (fullname) - input_organisation[i]->the_file = fopen(fullname, "r"); - - if (fullname==NULL || input_organisation[i]->the_file==NULL) { - if (fullname) { + if ((fullname = kpse_find_cweb(input_organisation[i]->file_name)) + !=NULL) { + if ((input_organisation[i]->the_file = fopen(fullname, "r"))==NULL) pfatal_error("! Cannot open change file ", input_organisation[i]->file_name); - } else { - fatal_error(-1, "! Cannot find change file ", - input_organisation[i]->file_name); - } + free(fullname); + } @+ else { + fatal_error(-1, "! Cannot find change file ", + input_organisation[i]->file_name); } - else free(fullname); @.Cannot open change file@> @.Cannot find change file@> @z -- cgit v1.2.3