Skip to content

Commit 3e6fa4f

Browse files
authored
Merge pull request #1232 from xexyl/uuid-fixes
Fixes for -u uuidfile/-U uuidstr options Please NOTE: This commit, while recommended, is not mandatory for IOCCC28. Existing submissions under the previously released mkiocccentry toolkit remain valid.
2 parents 3b74a9f + e90a94e commit 3e6fa4f

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

mkiocccentry.c

+18-18
Original file line numberDiff line numberDiff line change
@@ -4369,24 +4369,23 @@ get_contest_id(bool *testp, char const *uuidfile, char *uuidstr)
43694369
/*
43704370
* if -U UUID not used check if -u uuidfile was used
43714371
*/
4372-
if (uuidstr == NULL) {
4373-
if (uuidfile != NULL) {
4374-
if (is_read(uuidfile)) {
4372+
if (uuidfile != NULL) {
4373+
if (is_read(uuidfile)) {
4374+
errno = 0; /* pre-clear errno for warnp() */
4375+
uuidfp = fopen(uuidfile, "r");
4376+
if (uuidfp == NULL) {
4377+
warnp(__func__, "failed to open uuidfile, will prompt instead");
4378+
} else {
4379+
uuidstr = readline_dup(&linep, true, NULL, uuidfp);
43754380
errno = 0; /* pre-clear errno for warnp() */
4376-
uuidfp = fopen(uuidfile, "r");
4377-
if (uuidfp == NULL) {
4378-
warnp(__func__, "failed to open uuidfile, will prompt instead");
4379-
} else {
4380-
uuidstr = readline_dup(&linep, true, NULL, uuidfp);
4381-
errno = 0; /* pre-clear errno for warnp() */
4382-
if (fclose(uuidfp) != 0) {
4383-
warnp(__func__, "failed to fclose(uuidfp)");
4384-
}
4385-
if (uuidstr != NULL) {
4386-
if (valid_contest_id(uuidstr)) {
4387-
if (strcmp(uuidstr, "test") == 0) {
4381+
if (fclose(uuidfp) != 0) {
4382+
warnp(__func__, "failed to fclose(uuidfp)");
4383+
}
4384+
if (uuidstr != NULL) {
4385+
if (valid_contest_id(uuidstr)) {
4386+
if (strcmp(uuidstr, "test") == 0) {
43884387

4389-
/*
4388+
/*
43904389
* report test mode
43914390
*/
43924391
para("",
@@ -4409,7 +4408,7 @@ get_contest_id(bool *testp, char const *uuidfile, char *uuidstr)
44094408
warn(__func__, "-u uuidfile not readable, will prompt instead");
44104409
}
44114410
}
4412-
} else if (valid_contest_id(uuidstr)) {
4411+
if (uuidstr != NULL && valid_contest_id(uuidstr)) {
44134412
/*
44144413
* case: IOCCC contest ID is test, quick return
44154414
*/
@@ -4735,7 +4734,8 @@ mk_submission_dir(char const *workdir, char const *ioccc_id, int submit_slot,
47354734
}
47364735
fpara(stderr,
47374736
"",
4738-
"You need to move that directory, or remove it, or use a different workdir.",
4737+
"You need to move that directory, or remove it, use the -x option",
4738+
"or use a different workdir.",
47394739
"",
47404740
NULL);
47414741
err(161, __func__, "submission directory exists: %s", submission_dir);

0 commit comments

Comments
 (0)