X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=support%2Fmkversion.c;fp=newversion.c;h=8164a8fecc02f927068332b48a22695e3985761d;hb=ccc6cda312fea9f0468ee65b8f368e9653e1380b;hp=bdba48079379b6c1c0f919c8809293d6fc45e840;hpb=726f63884db0132f01745f1fb4465e6621088ccf;p=platform%2Fupstream%2Fbash.git diff --git a/newversion.c b/support/mkversion.c similarity index 81% rename from newversion.c rename to support/mkversion.c index bdba480..8164a8f 100644 --- a/newversion.c +++ b/support/mkversion.c @@ -20,12 +20,16 @@ You should have received a copy of the GNU General Public License along 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 #include "posixstat.h" #include +#include "bashansi.h" char *progname; char *dir; +char *status; FILE *must_open (); @@ -44,6 +48,7 @@ main (argc, argv) progname = argv[0]; + status = dir = (char *)0; while (arg_index < argc && argv[arg_index][0] == '-') { if (strcmp (argv[arg_index], "-dist") == 0) @@ -80,6 +85,15 @@ main (argc, argv) 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]); @@ -89,16 +103,16 @@ main (argc, argv) 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. */ @@ -162,7 +176,7 @@ main (argc, argv) /* 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); @@ -173,9 +187,19 @@ main (argc, argv) 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); @@ -203,37 +227,37 @@ main (argc, argv) } 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) @@ -243,15 +267,15 @@ get_float_from_file (filename, var) 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)