I'm in a little over my head, but that is normal. Life is for learning.
Nobody has provided an up-to-date version of the 'file' utility, so I decided to do it myself. What we have is almost ten years old. Due to bitrot, newer versions have not even been buildable on OS/2. I opened a few tickets on the file bugtracker and version 5.48 now not only compiles but it fixes a couple of longstanding OS/2-related bugs.
Most of what I know is how to type "autoreconf", "configure", and "make". Maybe someone can answer a few beginner's questions--
Q1:
in tests/Makefile.am is a piece of shell script that includes the line
m=$$m${PATH_SEPARATOR}$$j; \
which confuses sh.exe because our path separator is a semicolon.
What seems to fix it is quoting the line:
m="$$m${PATH_SEPARATOR}$$j"; \
Is that the correct way to fix it? This must be a common situation. Before I suggest a fix to the maintainer I'd like to know it is the right fix.
Q2:
compiling the file_os2_apptype function causes two warnings:
../../src/apptype.c: In function 'file_os2_apptype':
../../src/apptype.c:61:27: warning: '%s' directive writing up to 255 bytes into a region of size between 3 and 260 [-Wformat-overflow=]
61 | (void)sprintf(path, "%s%s%s%s", drive,
| ^~
62 | (*dir == '\0') ? "./" : dir,
63 | fname,
| ~~~~~
../../src/apptype.c:61:8: note: 'sprintf' output between 1 and 768 bytes into a destination of size 260
61 | (void)sprintf(path, "%s%s%s%s", drive,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
62 | (*dir == '\0') ? "./" : dir,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63 | fname,
| ~~~~~~
64 | (*ext == '\0') ? "." : ext);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
I think I can see the reason-- the _MAX_PATH is less than the total of _MAX_DRIVE, _MAX_DIR, _MAX_FNAME, etc. Can I safely ignore those warnings? I suspect they have been around for years. The relevant code is
#include <stdlib.h>
#include <string.h>
#ifdef __EMX__
#include <io.h>
#define INCL_DOSSESMGR
#define INCL_DOSERRORS
#define INCL_DOSFILEMGR
#include <os2.h>
typedef ULONG APPTYPE;
file_protected int
file_os2_apptype(struct magic_set *ms, const char *fn, const struct buffer *b)
{
APPTYPE rc, type;
char path[_MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR],
fname[_MAX_FNAME], ext[_MAX_EXT];
char *filename;
FILE *fp;
if (fn)
filename = strdup(fn);
else if ((filename = tempnam("./", "tmp")) == NULL) {
file_error(ms, errno, "cannot create tempnam");
return -1;
}
/* qualify the filename to prevent extraneous searches */
_splitpath(filename, drive, dir, fname, ext);
(void)sprintf(path, "%s%s%s%s", drive,
(*dir == '\0') ? "./" : dir,
fname,
(*ext == '\0') ? "." : ext);
Q3:
when I do a "make install" it gives a red-letter warning:
warning: remember to run 'libtool --finish /usr/local/lib'
What does that do and when should it be done? Before I package it or after the user installs it? It doesn't seem to change anything that I can see, so I'm ignoring the warning for now.
Considering what I don't know, the whole process has been surprisingly easy. It makes me suspicious.
The attached file is what I plan to upload to Hobbes, unless someone can find anything wrong with it.
All suggestions are welcome.