Skip to content

Resequence exit codes in jparse/util #1193

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
# Major changes to the IOCCC entry toolkit


## Release 2.3.45 2025-02-28

Fix and improve warning of `-y` and `-Y` in `mkiocccentry`.

The code did not explicitly check for `-Y`; it just used the implicit `-y` from
`-Y`. That is fixed and now if not `-q` show a simple summary but always show
the longer warning to be sure that they know. As for `-Y` it really ought to be
used only for the test script but even `-y` should be used with **EXTREME**
caution.

It is hoped this is the last update to `mkiocccentry(1)` prior to the soft code
freeze today.

Update `MKIOCCCENTRY_VERSION` to `"1.2.36 2025-02-28"`.

TODO: finish work on the `chkentry_test.sh` script.

Resequence exit codes in `jparse/util.c`. It appears that this was not done or
something went wrong when doing so (as running `make seqcexit` updated the exit
codes and this comes from after running it in `jparse/` and committing and then
syncing from `jparse` to `jparse/`).


## Release 2.3.44 2025-02-27

Prepare for code freeze (28 February 2025) with some final changes, some
Expand Down
56 changes: 28 additions & 28 deletions jparse/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -11271,7 +11271,7 @@ main(int argc, char **argv)
fts.max_depth = 5;
paths_found = find_paths(paths, "test_jparse", -1, &cwd, false, &fts);
if (paths_found == NULL) {
err(208, __func__, "didn't find any paths in the paths array");
err(210, __func__, "didn't find any paths in the paths array");
not_reached();
}

Expand All @@ -11285,7 +11285,7 @@ main(int argc, char **argv)
/* get next string pointer */
name = dyn_array_value(paths_found, char *, j);
if (name == NULL) { /* paranoia */
err(209, __func__, "found NULL pointer at paths_found[%ju]", (uintmax_t)j);
err(211, __func__, "found NULL pointer at paths_found[%ju]", (uintmax_t)j);
not_reached();
}

Expand Down Expand Up @@ -11332,7 +11332,7 @@ main(int argc, char **argv)
fts.max_depth = 3;
paths_found = find_paths(paths, "test_jparse", -1, &cwd, false, &fts);
if (paths_found == NULL) {
err(208, __func__, "didn't find any paths in the paths array");
err(212, __func__, "didn't find any paths in the paths array");
not_reached();
}

Expand All @@ -11346,7 +11346,7 @@ main(int argc, char **argv)
/* get next string pointer */
name = dyn_array_value(paths_found, char *, j);
if (name == NULL) { /* paranoia */
err(209, __func__, "found NULL pointer at paths_found[%ju]", (uintmax_t)j);
err(213, __func__, "found NULL pointer at paths_found[%ju]", (uintmax_t)j);
not_reached();
}

Expand Down Expand Up @@ -11395,7 +11395,7 @@ main(int argc, char **argv)
fts.max_depth = 0;
paths_found = find_paths(paths, "test_jparse", -1, &cwd, false, &fts);
if (paths_found == NULL) {
err(208, __func__, "didn't find any paths in the paths array");
err(214, __func__, "didn't find any paths in the paths array");
not_reached();
}

Expand All @@ -11409,7 +11409,7 @@ main(int argc, char **argv)
/* get next string pointer */
name = dyn_array_value(paths_found, char *, j);
if (name == NULL) { /* paranoia */
err(209, __func__, "found NULL pointer at paths_found[%ju]", (uintmax_t)j);
err(215, __func__, "found NULL pointer at paths_found[%ju]", (uintmax_t)j);
not_reached();
}

Expand Down Expand Up @@ -11460,7 +11460,7 @@ main(int argc, char **argv)
fts.max_depth = 3;
paths_found = find_paths(paths, "test_jparse", -1, &cwd, false, &fts);
if (paths_found != NULL) {
err(208, __func__, "bogus range of min/max directories found directories");
err(216, __func__, "bogus range of min/max directories found directories");
not_reached();
}

Expand Down Expand Up @@ -11489,7 +11489,7 @@ main(int argc, char **argv)
fts.match_case = true;
paths_found = find_paths(paths, "test_jparse", -1, &cwd, false, &fts);
if (paths_found != NULL) {
err(210, __func__, "found unexpected socket under test_jparse/");
err(217, __func__, "found unexpected socket under test_jparse/");
not_reached();
}

Expand Down Expand Up @@ -11521,7 +11521,7 @@ main(int argc, char **argv)
fts.match_case = true;
paths_found = find_paths(paths, "test_jparse", -1, &cwd, false, &fts);
if (paths_found != NULL) {
err(211, __func__, "found unexpected character device under test_jparse/");
err(218, __func__, "found unexpected character device under test_jparse/");
not_reached();
}

Expand Down Expand Up @@ -11554,7 +11554,7 @@ main(int argc, char **argv)
fts.match_case = true;
paths_found = find_paths(paths, "test_jparse", -1, &cwd, false, &fts);
if (paths_found != NULL) {
err(212, __func__, "found unexpected block device under test_jparse/");
err(219, __func__, "found unexpected block device under test_jparse/");
not_reached();
}

Expand All @@ -11581,7 +11581,7 @@ main(int argc, char **argv)
fts.match_case = false;
paths_found = find_paths(paths, "test_jparse", -1, &cwd, false, &fts);
if (paths_found != NULL) {
err(213, __func__, "found unexpected FIFO under test_jparse/");
err(220, __func__, "found unexpected FIFO under test_jparse/");
not_reached();
}

Expand Down Expand Up @@ -11621,15 +11621,15 @@ main(int argc, char **argv)
for (j = 0; j < len; ++j) {
name = dyn_array_value(paths_found, char *, j);
if (name == NULL) {
err(214, __func__, "found NULL pointer in paths_found (not file, directory or symlink) array");
err(221, __func__, "found NULL pointer in paths_found (not file, directory or symlink) array");
not_reached();
}
warn(__func__, "path is not a file, directory or symlink: %s", name);
}
/*
* make it an error
*/
err(215, __func__, "found unexpected file type under test_jparse/");
err(222, __func__, "found unexpected file type under test_jparse/");
not_reached();
}

Expand Down Expand Up @@ -11669,7 +11669,7 @@ main(int argc, char **argv)
relpath = "foobar";
touch(relpath, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (!exists(relpath)) {
err(216, __func__, "file %s does not exist after touch()", relpath);
err(223, __func__, "file %s does not exist after touch()", relpath);
not_reached();
}

Expand All @@ -11693,17 +11693,17 @@ main(int argc, char **argv)
for (j = 0; j < len; ++j) {
name = dyn_array_value(paths_found, char *, j);
if (name == NULL) {
err(217, __func__, "found NULL pointer in paths_found (any) array");
err(224, __func__, "found NULL pointer in paths_found (any) array");
not_reached();
}
if (strcmp(relpath, name) != 0) {
err(218, __func__, "found non-matching file in list: %s != %s", name, relpath);
err(225, __func__, "found non-matching file in list: %s != %s", name, relpath);
not_reached();
}
fdbg(stderr, DBG_MED, "found file %s as case-sensitive search", name);
}
} else {
err(219, __func__, "couldn't find any file called \"%s\" as case-sensitive search", relpath);
err(226, __func__, "couldn't find any file called \"%s\" as case-sensitive search", relpath);
not_reached();
}

Expand Down Expand Up @@ -11742,18 +11742,18 @@ main(int argc, char **argv)
for (j = 0; j < len; ++j) {
name = dyn_array_value(paths_found, char *, j);
if (name == NULL) {
err(220, __func__, "found NULL pointer in paths_found (any) array");
err(227, __func__, "found NULL pointer in paths_found (any) array");
not_reached();
}
if (strcasecmp(relpath, name) != 0) {
err(221, __func__, "found non-matching file in list: %s != %s", name, relpath);
err(228, __func__, "found non-matching file in list: %s != %s", name, relpath);
not_reached();
}

fdbg(stderr, DBG_MED, "found %s by case-insensitive search", name);
}
} else {
err(222, __func__, "couldn't find any file called \"%s\" by case-insensitive search", relpath);
err(229, __func__, "couldn't find any file called \"%s\" by case-insensitive search", relpath);
not_reached();
}

Expand All @@ -11763,7 +11763,7 @@ main(int argc, char **argv)
errno = 0; /* pre-clear errno for errp() */
if (unlink(relpath) != 0) {
if (errno != ENOENT) {
errp(223, __func__, "unable to delete file %s", relpath);
errp(230, __func__, "unable to delete file %s", relpath);
not_reached();
}
} else {
Expand Down Expand Up @@ -11805,7 +11805,7 @@ main(int argc, char **argv)
* make sure it exists
*/
if (!exists(relpath)) {
err(224, __func__, "file %s does not exist", relpath);
err(231, __func__, "file %s does not exist", relpath);
not_reached();
}

Expand Down Expand Up @@ -11843,7 +11843,7 @@ main(int argc, char **argv)
for (j = 0; j < len; ++j) {
name = dyn_array_value(paths_found, char *, j);
if (name == NULL) {
err(225, __func__, "found NULL pointer in paths_found (any) array");
err(232, __func__, "found NULL pointer in paths_found (any) array");
not_reached();
}
fdbg(stderr, DBG_MED, "found file %s as case-sensitive search", name);
Expand Down Expand Up @@ -11892,11 +11892,11 @@ main(int argc, char **argv)
for (j = 0; j < len; ++j) {
name = dyn_array_value(paths_found, char *, j);
if (name == NULL) {
err(226, __func__, "found NULL pointer in paths_found array");
err(233, __func__, "found NULL pointer in paths_found array");
not_reached();
}
if (strcasecmp(relpath, name) != 0) {
err(227, __func__, "found non-matching file: %s != %s", name, relpath);
err(234, __func__, "found non-matching file: %s != %s", name, relpath);
not_reached();
}
fdbg(stderr, DBG_MED, "found %s by case-insensitive search", name);
Expand All @@ -11905,7 +11905,7 @@ main(int argc, char **argv)
/*
* as it is a case-insensitive it should always succeed
*/
err(228, __func__, "couldn't find any file called %s by case-insensitive search", relpath);
err(235, __func__, "couldn't find any file called %s by case-insensitive search", relpath);
not_reached();
}

Expand Down Expand Up @@ -11935,7 +11935,7 @@ main(int argc, char **argv)
free(fname);
fname = NULL;
} else {
err(229, __func__, "couldn't find %s in tree", relpath);
err(236, __func__, "couldn't find %s in tree", relpath);
not_reached();
}

Expand All @@ -11946,7 +11946,7 @@ main(int argc, char **argv)
errno = 0; /* pre-clear errno for errp() */
if (unlink(relpath) != 0) {
if (errno != ENOENT) {
errp(230, __func__, "unable to delete file %s", relpath);
errp(237, __func__, "unable to delete file %s", relpath);
not_reached();
}
} else {
Expand Down
55 changes: 34 additions & 21 deletions mkiocccentry.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,39 +567,52 @@ main(int argc, char *argv[])
print("Welcome to mkiocccentry version: %s\n", MKIOCCCENTRY_VERSION);
}


/*
* warn (if not -q/quiet mode) user that with -i answers (or -y) we will
* always answer yes. This is especially important (in fact absolutely
* essential for -i answers) because if there was a change in file set(s)
* then the answers file would be entirely useless!
* warn about -Y option
*/
if (answer_yes && !quiet) {
if (force_yes) {
para("",
"WARNING: you've chosen to answer YES to ALL prompts. If this was",
"unintentional, run the program again without specifying -Y. We cannot",
"stress the importance of this enough! Well OK, we can overstress most things",
"but you get the point; do not use the -Y option without EXTREME caution!",
"",
"Hint: this option is mostly useful for mkiocccentry_test.sh; if you REALLY",
"want to answer yes you should use -y instead which will allow you to still",
"verify certain things.",
"",
NULL);

/*
* we could use msg() but this performs more checks which is very
* important for this
* if not quiet give a shorter warning as well
*/
print("%s", "Notice: we will always answer yes to questions.");
if (!quiet) {
print("%s", "Notice: we will ALWAYS answer YES to questions.\n");
}
} else if (answer_yes) {
/* warn about -y option */
para("",
"WARNING: you've chosen to answer yes to ALMOST ALL prompts. If this was",
"unintentional, run the program again without specifying -y. We cannot",
"stress the importance of this enough! Well OK, we can overstress most things",
"but you get the point; do not use the -y option without EXTREME caution!",
"",
NULL);
/*
* if not quiet give a shorter warning as well
*/
if (!quiet) {
print("%s", "Notice: we will answer YES to MOST questions.\n");
}
}



/*
* save our version
*/
info.mkiocccentry_ver = MKIOCCCENTRY_VERSION;
dbg(DBG_HIGH, "info.mkiocccentry_ver: %s", info.mkiocccentry_ver);

/* warn about -y option */
if (answer_yes) {
para("",
"WARNING: you've chosen to answer yes to almost all prompts. If this was",
"unintentional, run the program again without specifying -y. We cannot",
"stress the importance of this enough! Well OK, we can overstress most things",
"but you get the point; do not use the -y option without EXTREME caution!",
"",
NULL);
}

/* if the user requested to ignore warnings, and now -E, then ignore this once and warn them :) */
if (ignore_warnings) {
para("",
Expand Down
4 changes: 2 additions & 2 deletions soup/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
*
* NOTE: This should match the latest Release string in CHANGES.md
*/
#define MKIOCCCENTRY_REPO_VERSION "2.3.45 2025-02-27" /* special release format: major.minor[.patch] YYYY-MM-DD */
#define MKIOCCCENTRY_REPO_VERSION "2.3.46 2025-02-28" /* special release format: major.minor[.patch] YYYY-MM-DD */


/*
Expand All @@ -99,7 +99,7 @@
/*
* official mkiocccentry versions (mkiocccentry itself and answers)
*/
#define MKIOCCCENTRY_VERSION "1.2.35 2025-02-27" /* format: major.minor YYYY-MM-DD */
#define MKIOCCCENTRY_VERSION "1.2.36 2025-02-28" /* format: major.minor YYYY-MM-DD */
#define MKIOCCCENTRY_ANSWERS_VERSION "MKIOCCCENTRY_ANSWERS_IOCCC28-1.0" /* answers file version */
#define MKIOCCCENTRY_ANSWERS_EOF "ANSWERS_EOF" /* answers file EOF marker */

Expand Down
Loading