diff --git a/CHANGES b/CHANGES index 07eddd4..f441b49 100644 --- a/CHANGES +++ b/CHANGES @@ -75,6 +75,11 @@ The following are the changes from calc version 2.14.3.5 to date: Added int.h as a central place for calc integer types and integer macros. + Removed `-R release_file` and `-r release_file` command + line options from `ver_calc`. Add `-h` option. Updated + comments in "README.RELEASE", which serves as the contents + of the calc command "help release". + The following are the changes from calc version 2.14.3.4 to 2.14.3.5: diff --git a/README.RELEASE b/README.RELEASE index 62604dc..fea1ab3 100644 --- a/README.RELEASE +++ b/README.RELEASE @@ -16,6 +16,10 @@ The top version level (e.g., 2) refers to the internal representation of values. Any library or hardware linked/built for calc 2 will be able to use values from other 2.x.y.z versions. +When top version level is 2, the symbol "CALC2_COMPAT" is defined +by "version.h". See "version.h" for constants used to define the +calc version. + The top 2 levels (e.g., 2.14) refers to a specific compatible set of builtin functions. Calc interpreted code (such as calc resource files) written for, say calc 2.14, will be able to use the same set of builtin @@ -32,9 +36,32 @@ neither a change to the internal representation format (a top level version change), nor were there new calc builtins introduced in such a top 3 level release. -There are 3 classes of changes to the calc source tree: -alpha => untagged GitHub commit +The program "ver_calc" will print information about the compiled +calc version as defined "version.h" when "ver_calc" was compiled: + + usage: ./ver_calc [-h] [-V] + + -h print this message and exit non-zero + -V print 3-level version (def: print 4-level version) + +Also "calc -v" will print the calc version as defined "version.h" when +"calc" was compiled. + +The master branch: + + The public repository of calc source code is: + + http://github.com/lcn2/calc + + On that GitHub site you may find released version of calc, + "production", "tested" and "alpha". All commits on the master + branch that are not associated with a release are "alpha". + + Any "alpha" commit is likely future code for a future + "tested" or "production" version of calc. + +alpha ==> untagged GitHub commit Any untagged commit to the GitHub master branch should be considered as alpha code that may make calc unstable. @@ -43,7 +70,17 @@ alpha => untagged GitHub commit there is a risk that picking up such a change could negatively impact the code. -tested => tagged GitHub pre-release commit + NOTE: The calc version found in "version.h", and printed + by both "ver_calc [-V]" and "calc -v" for an untagged + commit is the previous "tested" or "production" version + of calc. Any "alpha" changes that remain are code + for some future version of calc. + + At the last stage of the release process, "version.h" + will be updated as well as the top level version range + listed in "CHANGES". + +tested ==> tagged GitHub pre-release commit A new version of calc has been released and has recently passed regression testing on at least to different platforms and chip @@ -63,7 +100,7 @@ tested => tagged GitHub pre-release commit At the bottom of a given release is a "> Assets" that may be opened to reveal down-loadable files. -production => tagged GitHub release commit +production ==> tagged GitHub release commit A new version of calc has been released and has undergone extensive testing over time over a number of platforms. @@ -87,14 +124,14 @@ production => tagged GitHub release commit A historical note and apology: -In the past, some version number changes were made that did not fully -reflect the above version number or change class. Moreover older terms -such as "stable" and "unstable" were misleading and did not properly -reflect the nature of the change. Sorry! The purpose of this document -is to try and bring a better level of conformity to source code updates, -tagged releases and version numbers. + In the past, some version number changes were made that did not + fully reflect the above version number or change class. Moreover + older terms such as "stable" and "unstable" were misleading and + did not properly reflect the nature of the change. Sorry! The + purpose of this document is to try and bring a better level of + conformity to source code updates, tagged releases and version numbers. -## Copyright (C) 2021 Landon Curt Noll +## Copyright (C) 2021,2023 Landon Curt Noll ## ## Calc is open software; you can redistribute it and/or modify it under ## the terms of the version 2.1 of the GNU Lesser General Public License diff --git a/version.c b/version.c index 276f9a2..261102d 100644 --- a/version.c +++ b/version.c @@ -53,7 +53,7 @@ static char *program; /* - * calc version constants + * calc version constants */ int calc_major_ver = MAJOR_VER; int calc_minor_ver = MINOR_VER; @@ -130,7 +130,7 @@ version(void) * save the versions string into a newly malloced buffer */ len = strlen(verbuf); - stored_version = (char *)malloc(len+1); + stored_version = (char *)calloc(len+1, sizeof(verbuf[0])); if (stored_version == NULL) { fprintf(stderr, "%s: cannot malloc version string\n", program); exit(70); @@ -148,59 +148,14 @@ version(void) /* - * print_rpm_version - print just the version string, rpm style - * - * This function prints a version string, rpm style: - * - * x.y.z.w-r - * - * where 'r' comes from the content of the release file. - */ -void -print_rpm_version(char *release) -{ - FILE *file; /* open file */ - char buf[BUFSIZ+1]; /* release file buffer */ - char *p; - - /* - * obtain the release - */ - file = fopen(release, "r"); - if (file == NULL) { - fprintf(stderr, "%s: cannot open %s: %s\n", - program, release, strerror(errno)); - exit(71); - } - buf[BUFSIZ] = '\0'; - if (fgets(buf, BUFSIZ, file) == NULL) { - fprintf(stderr, "%s: cannot read %s: %s\n", - program, release, strerror(errno)); - exit(72); - } - p = strchr(buf, '\n'); - if (p != NULL) { - *p = '\0'; - } - - /* - * form the version buffer - */ - printf("%d.%d.%d.%d-%s\n", calc_major_ver, calc_minor_ver, - calc_major_patch, calc_minor_patch, buf); - return; -} - - -/* - * print_rpm_major - print just the major part version string + * print_3_level_version - print just the major part version string * * This function prints the major part version string: * * x.y.z */ void -print_rpm_major(void) +print_3_level_version(void) { /* * form the version buffer @@ -211,50 +166,6 @@ print_rpm_major(void) } -/* - * print_rpm_release - print just the rpm release - * - * This function prints the rpm release: - * - * r - * - * where 'r' comes from the content of the release file. - */ -void -print_rpm_release(char *release) -{ - FILE *file; /* open file */ - char buf[BUFSIZ+1]; /* release file buffer */ - char *p; - - /* - * obtain the release - */ - file = fopen(release, "r"); - if (file == NULL) { - fprintf(stderr, "%s: cannot open %s: %s\n", - program, release, strerror(errno)); - exit(73); - } - buf[BUFSIZ] = '\0'; - if (fgets(buf, BUFSIZ, file) == NULL) { - fprintf(stderr, "%s: cannot read %s: %s\n", - program, release, strerror(errno)); - exit(74); - } - p = strchr(buf, '\n'); - if (p != NULL) { - *p = '\0'; - } - - /* - * form the version buffer - */ - printf("%s\n", buf); - return; -} - - /* * version - print the calc version */ @@ -263,21 +174,27 @@ int main(int argc, char *argv[]) { program = argv[0]; - if (argc == 3 && strcmp(argv[1], "-r") == 0) { - print_rpm_version(argv[2]); - - } else if (argc == 3 && strcmp(argv[1], "-R") == 0) { - print_rpm_release(argv[2]); - - } else if (argc == 2 && strcmp(argv[1], "-V") == 0) { - print_rpm_major(); + /* + * case: -V - print 3-level version + */ + if (argc == 2 && strcmp(argv[1], "-V") == 0) { + print_3_level_version(); + /* + * case: no args - print 4-level version + */ } else if (argc == 1) { printf("%s\n", version()); + /* + * case: -h or wrong number of args or invalid options + */ } else { fprintf(stderr, - "usage: %s [-V] [-R release_file] [-r release_file]\n", + "usage: %s [-V | -h]\n" + "\n" + " -h print this message and exit non-zero\n" + " -V print 3-level version (def: print 4-level version)\n", program); exit(75); }