with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+#include "config.h"
+
#include <sys/types.h>
#include "posixstat.h"
#include <stdio.h>
+#include "bashansi.h"
char *progname;
char *dir;
+char *status;
FILE *must_open ();
progname = argv[0];
+ status = dir = (char *)0;
while (arg_index < argc && argv[arg_index][0] == '-')
{
if (strcmp (argv[arg_index], "-dist") == 0)
exit (1);
}
}
+ else if (strcmp (argv[arg_index], "-status") == 0)
+ {
+ status = argv[++arg_index];
+ if (status == 0)
+ {
+ fprintf (stderr, "%s: `-status' requires an argument\n", progname);
+ exit (1);
+ }
+ }
else
{
fprintf (stderr, "%s: unknown option: %s\n", progname, argv[arg_index]);
arg_index++;
}
- if (get_float_from_file (".distribution", &distver) == 0)
+ if (get_float_from_file (".distribution", &distver, 1) == 0)
dot_dist_needs_making++;
- if (get_int_from_file (".patchlevel", &patchlevel) == 0)
+ if (get_int_from_file (".patchlevel", &patchlevel, 1) == 0)
{
patchlevel = 0;
patch_inc = 0;
}
- if (get_int_from_file (".build", &buildver) == 0)
+ if (get_int_from_file (".build", &buildver, 0) == 0)
buildver = 0;
/* Setting distribution version. */
/* Output the leading comment. */
fprintf (file,
"/* Version control for the shell. This file gets changed when you say\n\
- `make newversion' to the Makefile. It is created by newversion.aux. */\n");
+ `make newversion' to the Makefile. It is created by mkversion. */\n");
fprintf (file, "\n/* The distribution version number of this shell. */\n");
fprintf (file, "#define DISTVERSION \"%.2f\"\n", distver);
fprintf (file, "\n/* The last built version of this shell. */\n");
fprintf (file, "#define BUILDVERSION %d\n", buildver);
+ if (status)
+ {
+ fprintf (file, "\n/* The release status of this shell. */\n");
+ fprintf (file, "#define RELSTATUS \"%s\"\n", status);
+ }
+
fprintf (file, "\n/* A version string for use by sccs and the what command. */\n\n");
- fprintf (file, "#define SCCSVERSION \"@(#)Bash version %.2f.%d(%d) GNU\"\n\n",
- distver, patchlevel, buildver);
+ if (status)
+ fprintf (file, "#define SCCSVERSION \"@(#)Bash version %.2f.%d(%d) %s GNU\"\n\n",
+ distver, patchlevel, buildver, status);
+ else
+ fprintf (file, "#define SCCSVERSION \"@(#)Bash version %.2f.%d(%d) GNU\"\n\n",
+ distver, patchlevel, buildver);
fclose (file);
}
char *
-makename (fn)
+makename (fn, from_srcdir)
char *fn;
{
char *ret;
- int dlen = 0;
+ int dlen;
- if (dir)
- dlen = strlen (dir) + 1;
+ dlen = (from_srcdir && dir) ? strlen (dir) + 1 : 0;
ret = (char *)malloc (dlen + strlen (fn) + 1);
if (ret == 0)
{
fprintf (stderr, "%s: malloc failed\n", progname);
exit (1);
}
- if (dir)
+ if (from_srcdir && dir)
sprintf (ret, "%s/%s", dir, fn);
else
- strcpy (ret, fn);
+ (void)strcpy (ret, fn);
return ret;
}
-get_float_from_file (filename, var)
+get_float_from_file (filename, var, from_srcdir)
char *filename;
float *var;
+ int from_srcdir;
{
FILE *stream;
int result;
char *name;
- name = makename (filename);
+ name = makename (filename, from_srcdir);
stream = fopen (name, "r");
free (name);
if (stream == (FILE *)NULL)
return (result == 1);
}
-get_int_from_file (filename, var)
+get_int_from_file (filename, var, from_srcdir)
char *filename;
- int *var;
+ int *var, from_srcdir;
{
FILE *stream;
int result;
char *name;
- name = makename (filename);
+ name = makename (filename, from_srcdir);
stream = fopen (name, "r");
free (name);
if (stream == (FILE *)NULL)