summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorAndreas Scherer <andreas_tex@freenet.de>2020-06-07 15:37:44 +0000
committerAndreas Scherer <andreas_tex@freenet.de>2020-06-07 15:37:44 +0000
commit004df680339fe22612e027793221d8cb4d11eec0 (patch)
tree88d5258b1e0eb4d8b17c4b537290a32ca003cf8b /Build
parent488c5d94d7fc969aa9ace08e38038c6bf0d1e952 (diff)
[CWEB] Handle special 'files' as secondary output.
git-svn-id: svn://tug.org/texlive/trunk@55464 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/web2c/ChangeLog4
-rw-r--r--Build/source/texk/web2c/ctangleboot.cin125
-rw-r--r--Build/source/texk/web2c/cwebdir/ChangeLog4
-rw-r--r--Build/source/texk/web2c/cwebdir/ctang-w2c.ch59
4 files changed, 176 insertions, 16 deletions
diff --git a/Build/source/texk/web2c/ChangeLog b/Build/source/texk/web2c/ChangeLog
index d12aaf67c03..1e5196684f4 100644
--- a/Build/source/texk/web2c/ChangeLog
+++ b/Build/source/texk/web2c/ChangeLog
@@ -1,5 +1,9 @@
2020-06-07 Andreas Scherer <https://ascherer.github.io>
+ * ctangleboot.cin: Handle special 'files' as secondary output.
+
+2020-06-07 Andreas Scherer <https://ascherer.github.io>
+
* ctangleboot.cin,
* cwebboot.cin: Check accessibility to output files.
diff --git a/Build/source/texk/web2c/ctangleboot.cin b/Build/source/texk/web2c/ctangleboot.cin
index 0f8cb2ea068..57f51f416f2 100644
--- a/Build/source/texk/web2c/ctangleboot.cin
+++ b/Build/source/texk/web2c/ctangleboot.cin
@@ -289,12 +289,12 @@ extern void print_stats(void);
extern void cb_show_banner(void);
#line 128 "cwebdir/ctangle.w"
-/*:15*//*104:*/
-#line 839 "cwebdir/ctang-w2c.ch"
+/*:15*//*108:*/
+#line 886 "cwebdir/ctang-w2c.ch"
extern char cb_banner[];
-/*:104*/
+/*:108*/
#line 67 "cwebdir/ctangle.w"
/*16:*/
@@ -524,12 +524,12 @@ ccode['\'']= ord;
#line 1116 "cwebdir/ctangle.w"
section_text[0]= ' ';
-/*:71*//*105:*/
-#line 842 "cwebdir/ctang-w2c.ch"
+/*:71*//*109:*/
+#line 889 "cwebdir/ctang-w2c.ch"
strncpy(cb_banner,banner,max_banner-1);
-/*:105*/
+/*:109*/
#line 98 "cwebdir/ctangle.w"
;
common_init();
@@ -828,8 +828,112 @@ cur_end= (cur_repl+1)->tok_start;
while(stack_ptr> stack)get_output();
flush_buffer();fclose(C_file);C_file= NULL;
/*102:*/
-#line 816 "cwebdir/ctang-w2c.ch"
+#line 821 "cwebdir/ctang-w2c.ch"
+
+if(0==strcmp("/dev/stdout",output_file_name))
+/*104:*/
+#line 846 "cwebdir/ctang-w2c.ch"
+{
+/*107:*/
+#line 873 "cwebdir/ctang-w2c.ch"
+
+char in_buf[BUFSIZ+1];
+int in_size,comparison= true;
+if((check_file= fopen(check_file_name,"r"))==NULL)
+fatal("! Cannot open output file ",check_file_name);
+
+
+/*:107*/
+#line 847 "cwebdir/ctang-w2c.ch"
+
+do{
+in_size= fread(in_buf,1,BUFSIZ,check_file);
+in_buf[in_size]= '\0';
+fprintf(stdout,"%s",in_buf);
+}while(!feof(check_file));
+fclose(check_file);check_file= NULL;
+/*103:*/
+#line 838 "cwebdir/ctang-w2c.ch"
+
+if(comparison)
+remove(check_file_name);
+else{
+remove(output_file_name);
+rename(check_file_name,output_file_name);
+}
+/*:103*/
+#line 854 "cwebdir/ctang-w2c.ch"
+
+}
+
+/*:104*/
+#line 823 "cwebdir/ctang-w2c.ch"
+
+else if(0==strcmp("/dev/stderr",output_file_name))
+/*105:*/
+#line 857 "cwebdir/ctang-w2c.ch"
+{
+/*107:*/
+#line 873 "cwebdir/ctang-w2c.ch"
+
+char in_buf[BUFSIZ+1];
+int in_size,comparison= true;
+if((check_file= fopen(check_file_name,"r"))==NULL)
+fatal("! Cannot open output file ",check_file_name);
+
+
+/*:107*/
+#line 858 "cwebdir/ctang-w2c.ch"
+
+do{
+in_size= fread(in_buf,1,BUFSIZ,check_file);
+in_buf[in_size]= '\0';
+fprintf(stderr,"%s",in_buf);
+}while(!feof(check_file));
+fclose(check_file);check_file= NULL;
+/*103:*/
+#line 838 "cwebdir/ctang-w2c.ch"
+
+if(comparison)
+remove(check_file_name);
+else{
+remove(output_file_name);
+rename(check_file_name,output_file_name);
+}
+
+/*:103*/
+#line 865 "cwebdir/ctang-w2c.ch"
+
+}
+
+/*:105*/
+#line 825 "cwebdir/ctang-w2c.ch"
+
+else if(0==strcmp("/dev/null",output_file_name))
+/*106:*/
+#line 868 "cwebdir/ctang-w2c.ch"
+{
+int comparison= true;
+/*103:*/
+#line 838 "cwebdir/ctang-w2c.ch"
+
+if(comparison)
+remove(check_file_name);
+else{
+remove(output_file_name);
+rename(check_file_name,output_file_name);
+}
+
+/*:103*/
+#line 870 "cwebdir/ctang-w2c.ch"
+
+}
+
+/*:106*/
+#line 827 "cwebdir/ctang-w2c.ch"
+
+else{
if((C_file= fopen(output_file_name,"r"))!=NULL){
/*99:*/
#line 782 "cwebdir/ctang-w2c.ch"
@@ -859,10 +963,10 @@ fclose(C_file);C_file= NULL;
fclose(check_file);check_file= NULL;
/*:99*/
-#line 818 "cwebdir/ctang-w2c.ch"
+#line 830 "cwebdir/ctang-w2c.ch"
/*103:*/
-#line 825 "cwebdir/ctang-w2c.ch"
+#line 838 "cwebdir/ctang-w2c.ch"
if(comparison)
remove(check_file_name);
@@ -872,10 +976,11 @@ rename(check_file_name,output_file_name);
}
/*:103*/
-#line 819 "cwebdir/ctang-w2c.ch"
+#line 831 "cwebdir/ctang-w2c.ch"
}else
rename(check_file_name,output_file_name);
+}
/*:102*/
#line 330 "cwebdir/ctang-w2c.ch"
diff --git a/Build/source/texk/web2c/cwebdir/ChangeLog b/Build/source/texk/web2c/cwebdir/ChangeLog
index ea272b92180..72a93185f46 100644
--- a/Build/source/texk/web2c/cwebdir/ChangeLog
+++ b/Build/source/texk/web2c/cwebdir/ChangeLog
@@ -1,5 +1,9 @@
2020-06-07 Andreas Scherer <https://ascherer.github.io>
+ * ctang-w2c.ch: Handle special 'files' as secondary output.
+
+2020-06-07 Andreas Scherer <https://ascherer.github.io>
+
* comm-w2c.ch,
* ctang-w2c.ch,
* cweav-w2c.ch,
diff --git a/Build/source/texk/web2c/cwebdir/ctang-w2c.ch b/Build/source/texk/web2c/cwebdir/ctang-w2c.ch
index a137092b111..8b980daa5c0 100644
--- a/Build/source/texk/web2c/cwebdir/ctang-w2c.ch
+++ b/Build/source/texk/web2c/cwebdir/ctang-w2c.ch
@@ -813,12 +813,25 @@ else {
rename(check_file_name,C_file_name);
}
-@ @<Update the secondary results...@>=
-if((C_file=fopen(output_file_name,"r"))!=NULL) {
- @<Set up the comparison of temporary output@>@;
- @<Create the secondary output depending on the comparison@>@;
-} else
- rename(check_file_name,output_file_name); /* This was the first run */
+@ The author of a \.{CWEB} program may want to write the \\{secondary} output
+instead of to a file (in \.{@@(...@@>}) to \.{/dev/null} or \.{/dev/stdout} or
+\.{/dev/stderr}. We must take care of the \\{temporary} output already written
+to a file and finally get rid of that file.
+
+@<Update the secondary results...@>=
+if(0==strcmp("/dev/stdout",output_file_name))
+ @<Redirect temporary output to \.{/dev/stdout}@>@;
+else if(0==strcmp("/dev/stderr",output_file_name))
+ @<Redirect temporary output to \.{/dev/stderr}@>@;
+else if(0==strcmp("/dev/null",output_file_name))
+ @<Redirect temporary output to \.{/dev/null}@>@;
+else { /* Hopefully a \\{regular} output file */
+ if((C_file=fopen(output_file_name,"r"))!=NULL) {
+ @<Set up the comparison of temporary output@>@;
+ @<Create the secondary output depending on the comparison@>@;
+ } else
+ rename(check_file_name,output_file_name); /* This was the first run */
+}
@ Again, we use a call to |remove| before |rename|.
@@ -830,6 +843,40 @@ else {
rename(check_file_name,output_file_name);
}
+@ @<Redirect temporary output to \.{/dev/stdout}@>={
+ @<Setup system redirection@>@;
+ do {
+ in_size = fread(in_buf,1,BUFSIZ,check_file);
+ in_buf[in_size]='\0';
+ fprintf(stdout,"%s",in_buf);
+ } while(!feof(check_file));@/
+ fclose(check_file); check_file=NULL;
+ @<Create the secondary output...@>@;
+}
+
+@ @<Redirect temporary output to \.{/dev/stderr}@>={
+ @<Setup system redirection@>@;
+ do {
+ in_size = fread(in_buf,1,BUFSIZ,check_file);
+ in_buf[in_size]='\0';
+ fprintf(stderr,"%s",in_buf);
+ } while(!feof(check_file));@/
+ fclose(check_file); check_file=NULL;
+ @<Create the secondary output...@>@;
+}
+
+@ @<Redirect temporary output to \.{/dev/null}@>={
+ int comparison=true;
+ @<Create the secondary output...@>@;
+}
+
+@ @<Setup system redirection@>=
+char in_buf[BUFSIZ+1];
+int in_size,comparison=true;
+if((check_file=fopen(check_file_name,"r"))==NULL)
+ fatal("! Cannot open output file ",check_file_name);
+@.Cannot open output file@>
+
@* Put ``version'' information in a single spot.
Don't do this at home, kids! Push our local macro to the variable in \.{COMMON}
for printing the |banner| and the |versionstring| from there.