Package: evolver / 2.70+ds-8

upstream-source-C2help2man.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
Description: source: format usages and helps
 Attempt to format the help message of the evolver front-end program
 wrt UN*X customs in view to employ help2man(1) to generate manpages.
 The help option entries have been updated wrt the evolver.1 manpage.
 A version option `-V' has been introduced, this option displays the
 Surface Evolver version (first line), the copyright (second line), and
 the actual front-end banner which shows useful compilation information
 (second paragraph). Both the help option `-h' and the version option `-V'
 exit after displaying. Meant to be submitted to the upstream maintainer.
Origin: debian
Forwarded: by email
Author: Jerome Benoit <calculus@rezozer.net>
Last-Update: 2016-07-28

--- a/src/tmain.c
+++ b/src/tmain.c
@@ -101,7 +101,9 @@
 * purpose: program entry point
 */
 int main(int argc,char *argv[]) 
-{ int pause_flag=0;  /* whether to pause after banner message */
+{ int banner_exit_flag=0;   /* whether to exit after preamble message */
+	int pause_flag=0;  /* whether to pause after banner message */
+	char evolver_invocation_short_name[31]="evolver-SUFFIX-EXTRASUFFIX_EXE";
 
   msgmax = 2000; 
   if ( !msg ) msg = my_list_calloc(1,msgmax,ETERNAL_BLOCK); 
@@ -109,7 +111,80 @@
 
   outfd = stdout;
   erroutfd = stderr;
-  sprintf(msg,"Surface Evolver %s, %d-bit\n",VERSION,8*(int)sizeof(int*));
+
+	{	char *dum = strrchr(argv[0],PATHCHAR);
+		if (dum == NULL) dum = argv[0];
+		else if (*dum == PATHCHAR) ++dum;
+		if (!(strncmp(dum,"evolver",7)))
+		{ snprintf(evolver_invocation_short_name,31,"%s",dum);
+#if defined(WIN32) || defined(_WIN64) /* guessed code foe Windows systms */
+			dum = strrchr(evolver_invocation_short_name,'.');
+			if ((dum != NULL) && (!(strncmp(dum,".exe",4)))) *dum = '\0';
+#endif
+		}
+		else
+		{	*(evolver_invocation_short_name+7) = '\0'; }
+	}
+
+  /* preparse command line options */
+#if defined(SGI_MULTI) || defined(THREADS)
+#define HELP_USAGE_MULTIPROCESS " [-pN]"
+#else
+#define HELP_USAGE_MULTIPROCESS ""
+#endif
+	if ( argc > 0 )
+	{	int pargc = argc;
+		char **pargv = argv;
+		pargv++; pargc--;
+		while (  pargc && (pargv[0] != NULL) && (pargv[0][0] == '-') )
+		{	switch ( pargv[0][1] )
+			{	default : break;
+				case 'h' :
+						sprintf(msg, "Usage: %s [-a][-d][-e][-i][-m][-q][-w][-x][-y][-h][-V] [-f FILE]" HELP_USAGE_MULTIPROCESS " [DATAFILE]\n",
+							evolver_invocation_short_name); outstring(msg);
+						outstring("Options:\n");
+						outstring("  -a       Autoconvert to named quantities when needed (default is on);\n");
+						outstring("           use `-a-' to deactivate autoconversion.\n");
+						outstring("  -d       Begin with parser debugging on (equivalent to `debug' runtime command);\n");
+						outstring("           beware of copious output.\n");
+						outstring("  -e       Echo stdin to stdout; meant for testing piped input.\n");
+						outstring("  -f FILE  After loading DATAFILE, read commands from file, then command line prompt.\n");
+						outstring("  -i       Preserve DATAFILE numbers for element id's, rather than renumbering.\n");
+						outstring("  -m       Begin with memory debugging on (equivalent to `memdebug' runtime command);\n");
+						outstring("           beware of copious output.\n");
+#if defined(SGI_MULTI) || defined(THREADS)
+						outstring("  -pN      Run with N concurrent processes.\n");
+#endif
+						outstring("  -q       Convert to named quantities at start (equivalent to `convert_to_quantities'\n");
+						outstring("           runtime command).\n");
+						outstring("  -w       Exit immediately after any warning or error message; meant for batch runs.\n");
+						outstring("  -x       Exit immediately after any error message; meant for batch runs.\n");
+						outstring("  -y       Break to user prompt after any warning message.\n");
+						outstring("  -h       Display this help, then exit.\n");
+						outstring("  -V       Display the version and the banner, then exit.\n");
+						outstring("\n");
+						outstring("Report bugs to Ken Brakke <brakke@susqu.edu>\n");
+						my_exit(0);
+					break;
+				case 'V' :
+						sprintf(msg,
+								"%s - Surface Evolver %s"
+								"\n",
+							evolver_invocation_short_name,
+							evolver_version
+							); outstring(msg);
+						outstring("Copyright (C) 1989-2016 Ken Brakke <brakke@susqu.edu>\n");
+						outstring("\n");
+						outstring("*Banner*\n");
+						banner_exit_flag = 1;
+					break;
+			}
+		pargv++; pargc--;
+		}
+	}
+#undef HELP_USAGE_MULTIPROCESS
+
+  sprintf(msg,"Surface Evolver %s, %d-bit.\n",VERSION,8*(int)sizeof(int*));
   outstring(msg);
 #ifdef LONG_ID
   if ( sizeof(int*) == 8 )
@@ -135,15 +210,22 @@
 #elif defined(LONGDOUBLE)
   sprintf(msg,"Compiled for %d-byte long double, %d digits precision.\n",(int)sizeof(REAL),DPREC);
   outstring(msg);
+#elif defined(FLOAT)
+#else
+  sprintf(msg,"Compiled for double, %d digits precision.\n",DPREC);
+  outstring(msg);
 #endif
-  outstring("\n");
 
 #ifdef MPI_EVOLVER
   MPI_Barrier(MPI_COMM_WORLD); /* wait for everybody to print */
 #endif
 
+	if ( banner_exit_flag )
+	{	my_exit(0); }
 
- if ( sizeof(element_id) > sizeof(REAL) )
+  outstring("\n");
+
+	if ( sizeof(element_id) > sizeof(REAL) )
     kb_error(3102,"Bad datatype sizes: element_id is %d bytes, but REAL is %d.\n",
       UNRECOVERABLE);
       
@@ -193,13 +275,12 @@
           FreeConsole();
 #endif
             break;
-          case 'E': err_tok_gen_flag = 1;
-                    break;
+          case 'E': err_tok_gen_flag = 1; break;
           case 'a': auto_convert_flag = (argv[0][2]=='-') ? 0 : 1; break;
           case 'q': option_q = (argv[0][2]=='-') ? 0 : 1; break; 
           case 'Q': quiet_load_flag = 1; break;
           case 'e': echo_flag = 1; break;
-		  case 'Z': pause_flag = 1; break;  /* chance to attach debugger */
+          case 'Z': pause_flag = 1; break;  /* chance to attach debugger */
 #ifdef MPI_EVOLVER
           case 'z': mpi_debug = 1; break;
 #endif
@@ -251,17 +332,13 @@
                 }
 #if defined(SGI_MULTI) || defined (THREADS)
                 if ( procs_requested < 1 )
-                  { kb_error(1321, 
-                      "-p with nonpositive number. Threads set to 1.\n",
-                                    WARNING);
+                  { kb_error(1321,"-p with nonpositive number. Threads set to 1.\n",WARNING);
                      procs_requested = 1;
                   }
                 if ( procs_requested > MAXPROCS )
-                { sprintf(errmsg,
-    "This Evolver only compiled for a maximum of %d threads.\n",MAXPROCS);
+                { sprintf(errmsg,"This Evolver only compiled for a maximum of %d threads.\n",MAXPROCS);
                    kb_error(2551,errmsg,WARNING);
-                  sprintf(errmsg,
-     "Threads set to %d. Recompile with -DMAXPROCS=%d if you want more.\n",
+                  sprintf(errmsg,"Threads set to %d. Recompile with -DMAXPROCS=%d if you want more.\n",
                     MAXPROCS,procs_requested);
                   erroutstring(errmsg);
                   procs_requested = MAXPROCS;
@@ -273,41 +350,28 @@
 #else
                 kb_error(1322,"-p option not effective.  This Evolver not compiled for multithreading.\n", WARNING);
 #endif
-                break; 
+                break;
           case 'A' : cpu_affinity_flag = 1; break;
           case 'x' : exit_after_error = 1; break;
           case 'w' : exit_after_warning = exit_after_error = 1; break;
           case 'y' : break_after_warning = 1; break;
           case 'm' : memdebug = 1; break;
           case 'l' : just_lex_flag = 1; break;
-          default:
-                 sprintf(msg,"Illegal option: %s\n",argv[0]); outstring(msg);
-          case 'h' :
-                 outstring("Legal options: \n"); 
-                 outstring("  -ffilename          take commands from file\n"); 
-                 outstring("  -i                     use id numbers as in datafile\n"); 
-                 outstring("  -q                     convert to named quantities\n"); 
-                 outstring("  -a                     auto convert to named quantities when needed\n"); 
-                 outstring("  -x                     exit after error\n"); 
-                 outstring("  -w                     exit after warning\n"); 
-                 outstring("  -y                     break after warning\n"); 
-                 outstring("  -d                     parser debugging on\n"); 
-                 outstring("  -m                     memory debugging on\n"); 
-#ifdef SGI_MULTI
-                 outstring("  -pn                    use n processes \n"); 
-#endif
-#if defined(THREADS)
-                 outstring("  -pn                    use n worker threads \n"); 
-#endif
-                 outstring("  -h                     print this help\n"); 
-                 break;
+          case 'h' : /* preparse case */ break;
+					case 'V' : /* preparse case */ break;
+          default :
+							sprintf(msg,"Illegal option: %s\n",argv[0]); outstring(msg);
+							outstring("\n");
+							sprintf(msg,"Try '%s -h' for more information\n",evolver_invocation_short_name); outstring(msg);
+							my_exit(1);
+							break;
             }
         argv++; argc--;
      }
   }
 
   if ( pause_flag )
-  { 
+  {
     #ifdef MPI_EVOLVER
       MPI_Barrier(MPI_COMM_WORLD);   // to get all banners printed first
       if ( this_task == MASTER_TASK )  // only master gets input, but all tasks wait on master anyway.