texlive[72193] Build/source/texk/web2c/texprofdir: TeXprof: adding
commits+mruckert at tug.org
commits+mruckert at tug.org
Thu Sep 5 15:06:19 CEST 2024
Revision: 72193
https://tug.org/svn/texlive?view=revision&revision=72193
Author: mruckert
Date: 2024-09-05 15:06:19 +0200 (Thu, 05 Sep 2024)
Log Message:
-----------
TeXprof: adding --help and --version options
Modified Paths:
--------------
trunk/Build/source/texk/web2c/texprofdir/doc/texprof.hnt
trunk/Build/source/texk/web2c/texprofdir/doc/texprof.pdf
trunk/Build/source/texk/web2c/texprofdir/doc/texprofile.hnt
trunk/Build/source/texk/web2c/texprofdir/doc/texprofile.pdf
trunk/Build/source/texk/web2c/texprofdir/texprof.w
trunk/Build/source/texk/web2c/texprofdir/texprofile.w
Modified: trunk/Build/source/texk/web2c/texprofdir/doc/texprof.hnt
===================================================================
(Binary files differ)
Modified: trunk/Build/source/texk/web2c/texprofdir/doc/texprof.pdf
===================================================================
(Binary files differ)
Modified: trunk/Build/source/texk/web2c/texprofdir/doc/texprofile.hnt
===================================================================
(Binary files differ)
Modified: trunk/Build/source/texk/web2c/texprofdir/doc/texprofile.pdf
===================================================================
(Binary files differ)
Modified: trunk/Build/source/texk/web2c/texprofdir/texprof.w
===================================================================
--- trunk/Build/source/texk/web2c/texprofdir/texprof.w 2024-09-05 08:31:00 UTC (rev 72192)
+++ trunk/Build/source/texk/web2c/texprofdir/texprof.w 2024-09-05 13:06:19 UTC (rev 72193)
@@ -105,7 +105,7 @@
\let\mc=\ninerm % medium caps for names like SAIL
\def\Prote{{\tenrm P\kern-0.1em R\kern-0.15em\raise.11ex\hbox{o}%
\kern-0.22em T\kern-0.05em E}}
-\def\texprof{{\TeX}prof}
+\def\texprof{{\TeX}prof}
\ifpdftex
\sanitizecommand{\texprof}{TeXprof}
\sanitizecommand{\eTeX}{eTeX}
@@ -227,13 +227,13 @@
capabilities. To be useful nowadays, the profiling capability is not the only
extension of Donald Knuth's original implementation of \TeX.
-To obtain the present \CEE/ program, Donald Knuth's \PASCAL\ program was
-modified in a first step using most of the \eTeX\ extensions by
+To obtain the present \CEE/ program, Donald Knuth's \PASCAL\ program was
+modified in a first step using most of the \eTeX\ extensions by
Peter Breitenlohner and Phil Taylor.
@^Breitenlohner, Peter@>
@^Taylor, Phil@>
Then further extensions were added using the \Prote\ change file
-of Thierry Laronde.
+of Thierry Laronde.
@^Laronde, Thierry@>
Then the constants defining the size of \TeX's data structures,
notably the size of the |mem| array, were increased considerable. All these
Modified: trunk/Build/source/texk/web2c/texprofdir/texprofile.w
===================================================================
--- trunk/Build/source/texk/web2c/texprofdir/texprofile.w 2024-09-05 08:31:00 UTC (rev 72192)
+++ trunk/Build/source/texk/web2c/texprofdir/texprofile.w 2024-09-05 13:06:19 UTC (rev 72193)
@@ -25,8 +25,8 @@
% dealings in this Software without prior written authorization from the
% copyright holders.
-\input btxmac.tex
-\input hintmac.tex
+%\input btxmac.tex
+\input profilemac.tex
%% defining how to display certain C identifiers
@@ -123,9 +123,9 @@
}
\bigskip
-{\raggedright\advance\rightskip 3.5pc
+{\raggedright\advance\rightskip 3.5pc plus 35pt
\def\:{\discretionary{}{}{}}
-Internet page {\tt http:\://hint.\:userweb.\:mwn.\:de/}
+The internet page {\tt http:\://hint.\:userweb.\:mwn.\:de/}
may contain current information about this book, downloadable software,
and news.
@@ -234,7 +234,7 @@
@<read the input file@>=
if (input_file_name==NULL)
- explain_usage("no input file given");
+ commandline_error("no input file given");
in = fopen(input_file_name,"rb");
if (in==NULL)
{ char *tmp=malloc(strlen(input_file_name)+7);
@@ -622,8 +622,10 @@
int cur_depth;
@
-@ @d POP_BIT 0x80
+@
+ at d POP_BIT 0x80
+
@<read timing data@>=
ALLOCATE(file_time,file_num);
ALLOCATE(cmd_time,cmd_num);
@@ -728,8 +730,7 @@
The table of |cmd_name|s is defined in the appendix.
-
-@ @<store pop |d|@>=
+@<store pop |d|@>=
stamps[i].c=system_macro_pop;
stamps[i].d=cur_depth-d;
#ifdef DEBUG
@@ -1248,7 +1249,7 @@
case 'p':{ char *endptr;
percent_limit=strtod(option+1, &endptr);
if (endptr==option+1)
- explain_usage("-pMM<n> without a numeric argument <n>");
+ commandline_error("-p<n> without a numeric argument <n>");
else
option=endptr-1;
}
@@ -1317,9 +1318,9 @@
case 't': { char *endptr;
tt=strtol(option+1, &endptr,10)+1;
if (endptr==option+1)
- explain_usage("-t<n> without a numeric argument <n>");
+ commandline_error("-t<n> without a numeric argument <n>");
else if (tt<2 || tt>101)
- explain_usage("-t<n> with n out of bounds");
+ commandline_error("-t<n> with <n> out of bounds");
option=endptr-1;
}
break;
@@ -1651,17 +1652,7 @@
\section{Processing the Command Line}
-The proper use of the command line is explained here:
-@<explain usage@>=
-"Use: "@;
-"texprofile [-options] <input file>\n"@;
-"options:\n"@;
-@<explain table options@>@;
-"\n"
-@<explain format options@>@;
-@
-
@<process the command line@>=
i=1;
while (i<argc)
@@ -1671,7 +1662,7 @@
while (*option!=0)
{ switch(*option)
{ @<process options@>@;
- default: explain_usage("unknown option");
+ default: commandline_error("unknown option");
}
option++;
}
@@ -1679,14 +1670,73 @@
else if (input_file_name==NULL)
input_file_name=argv[i];
else
- explain_usage("multiple input files given");
+ commandline_error("multiple input files given");
i++;
}
@
+Sometimes an error means that the program should also explain how to use it.
+@<functions@>=
+void explain_usage(void)
+{ fprintf(stderr,
+ "Use: "@;
+ "texprofile [-options] <input file>\n"@;
+ "options:\n"@;
+ @<explain general options@>@;
+ "\n"
+ @<explain table options@>@;
+ "\n"
+ @<explain format options@>@;
+ "\n"
+ );
+ exit(1);
+}
+@
+A simple option that most users will use occasionaly is the {\tt -?} option.
+This option can also be look like {\tt --help}, {\tt -help} or {\tt -h}.
+
+@<process options@>=
+case 'h':
+case '?': explain_usage(); break;
+@
+
+@<explain general options@>=
+"-? display this help and exit\n"@;
+"--help display this help and exit\n"@;
+@
+
+The help option should also be available as a long option:
+
+@<process options@>=
+case '-':
+ option++;
+ @<process long options@>@;
+ else commandline_error("unknown long option");
+ break;
+@
+
+@<process long options@>=
+ if (strcmp(option,"help")==0) explain_usage();
+@
+
+The only other long option currently supported is the {\tt --version} option.
+
+ at d VERSION_STR "texprofile version 1.0"
+
+@<process long options@>=
+ if (strcmp(option,"version")==0)
+ { printf(VERSION_STR "\n");
+ exit(1);
+ }
+@
+
+@<explain general options@>=
+"--version output version information and exit\n"@;
+@
+
\section{Error Handling}
If an error occurs this program will print an error message
and terminate. There is no attempt to recover from errors.
@@ -1693,23 +1743,27 @@
@<error handling@>=
int error(char *msg)
-{ fprintf(stderr,"ERROR: %s\n", msg);
+{ fprintf(stderr,"texprofile: %s\n", msg);
exit(1);
return 0;
}
@
-Sometimes an error means that the program should also explain how to use it.
+The program is a little bit more verbose if there is an error in the
+command line.
-@<functions@>=
-void explain_usage(char *msg)
-{ fprintf(stderr,"ERROR: %s\n", msg);
- fprintf(stderr,@<explain usage@>@+);
+@<error handling@>=
+int commandline_error(char *msg)
+{ fprintf(stderr,"texprofile: %s\n", msg);
+ fprintf(stderr,"Try 'texprofile --help' for more information.\n");
exit(1);
+ return 0;
}
@
+
+
The input file should start with a marker: the ASCII codes of ``TEX PROF''.
The same marker is used later to separate the different sections of the file.
More information about the tex-live-commits
mailing list.