Skip to content
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

Protoize CL and ECL #391

Merged
merged 6 commits into from
Apr 15, 2024
Merged

Protoize CL and ECL #391

merged 6 commits into from
Apr 15, 2024

Conversation

olebole
Copy link
Member

@olebole olebole commented Apr 8, 2024

This is done on an Ubuntu Trusty machine, with the command

protoize -g -l -N -c "-I${iraf}unix/hlib/libc" *.c

There was already an attempt to protoize CL and ECL in the NOIRLab tree (f46b827), but this was not applicable, because the source trees deviate now significantly here because of #32 and a number of other bug fixes and clean-ups that were applied here but not in the NOIRLab tree. Also, it was incomplete, there are quite a number of prototypes missing. However, I checked this commit completely for potential bug fixes to be applied here (no findings for here; but NOIRLab obviously has some bugs...). The joys of missing coordination and a forked source tree.

The protoize tool is unfortunately removed from the gcc distribution after Ubuntu Trusty, so we had to use a VM to finally get this done. It seems that there are no more missing prototypes in IRAF; at least protoize didn't convert any other C file.

Another change here is that in sys/libc, the memory allocation functions should be declared in a more recent way, i.e. the memory is of type void * instead of char *.

This way, we found one bug in pkg/ecl/pfiles.c#L911-L915 (traceable back to version 2.8, 1989!):

    for (d=0;  d < size_arr;  d++) {
	*q = memneed (btoi(len));
	strncpy (*q++, *p++, len-1);
	*(q+len-1) = '\0' ;
    }

(with char **p, **p;)
Obviously, the last line should force-add a '\0' at the end of each string (in case the length exceeded the maximum), but that is somehow different. NOIRLabs change

diff --git a/pkg/ecl/pfiles.c b/pkg/ecl/pfiles.c
index 08de7aa92..585d9954a 100644
--- a/pkg/ecl/pfiles.c
+++ b/pkg/ecl/pfiles.c
@@ -910,7 +948,7 @@ pfilecopy (register struct pfile *pfp)
    for (d=0;  d < size_arr;  d++) {
        *q = memneed (btoi(len));
        strncpy (*q++, *p++, len-1);
-       *(q+len-1) = '\0' ;
+       *(q+len-1) = (char *)'\0' ;
    }

just silences the warning, but doesn't resolve the bug. IMO correct is

    for (d=0;  d < size_arr; d++, q++, p++) {
	*q = memneed (btoi(len));
	strncpy (*q, *p, len-1);
	(*q)[len-1] = '\0';
    }

@mjfitzpatrick, you should change this in your fork as well.

We also take the opportunity here to fix few other (minor) warnings.

@olebole olebole force-pushed the protoize-ecl branch 9 times, most recently from e72b754 to 189d0b3 Compare April 8, 2024 14:29
@olebole olebole merged commit 0f82aa4 into iraf-community:main Apr 15, 2024
4 checks passed
@olebole olebole deleted the protoize-ecl branch April 15, 2024 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant