summaryrefslogtreecommitdiff
path: root/support/mnu/dupcent.c
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/mnu/dupcent.c
Initial commit
Diffstat (limited to 'support/mnu/dupcent.c')
-rw-r--r--support/mnu/dupcent.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/support/mnu/dupcent.c b/support/mnu/dupcent.c
new file mode 100644
index 0000000000..791094a4c6
--- /dev/null
+++ b/support/mnu/dupcent.c
@@ -0,0 +1,41 @@
+
+/* Program DUPCENT duplicates the per cent character */
+/* ************************************************* */
+/* 30.1.1993 Petr Olsak */
+
+/* Program types the input file to terminal, but all per cent characters
+ are duplicated. The DOS line can look as:
+ dupcent param1 param2
+ where
+ param1 ... the input file name (including the path if needed)
+ param2 (optionally) ... the text, which is included before each line
+ The program is used for OPTIONS/SAVE item in TeX menu system (for example).
+*/
+
+#include <stdio.h>
+#include <string.h>
+
+#define FGETC(INPUT) (feof(INPUT)||i>=127 ? '\n' : fgetc(INPUT))
+
+FILE *input;
+char r[128];
+
+main(int argc, char *argv[])
+{
+ register int i;
+
+ input = fopen(argv[1], "r");
+ if (input != NULL ) while (!feof(input))
+ {
+ i = 0;
+ lab1: while ((r[i]=FGETC(input)) != '\n' && r[i] != '%') i++;
+ if (feof(input) && r[i-1]==-1) r[--i] = '\n' ;
+ if (r[i]=='%') { r[++i]='%'; i++; goto lab1;}
+ r[i]=0;
+ if (argv[2] == NULL || r[0]==0) printf ("%s\n", r);
+ else printf ("%s %s\n", argv[2], r);
+ }
+ return 0;
+
+}
+