Compatibility implementation of stpncpy for older systems

Ryan Schmidt <[email protected]>
Newsgroups org.kernel.vger.dash
Message-ID <[email protected]>
Hello! dash 0.5.12 and the latest code in your git repository fails to build on older versions of macOS (Mac OS X 10.6.x and older). Using its default compiler (Apple's gcc 4.2.1) first this warning appears:

jobs.c: In function 'sprint_status':
jobs.c:434: warning: implicit declaration of function 'stpncpy'
jobs.c:434: warning: incompatible implicit declaration of built-in function 'stpncpy'

Then it fails at link time:

Undefined symbols:
  "_stpncpy", referenced from:
      _sprint_status in jobs.o
ld: symbol(s) not found

Using a newer compiler (llvm.org's clang 11.1.0) the warning is:

jobs.c:434:7: warning: implicitly declaring library function 'stpncpy' with type 'char *(char *, const char *, unsigned long)' [-Wimplicit-function-declaration]
                s = stpncpy(s, strsignal(st), 32);
                    ^
jobs.c:434:7: note: include the header <string.h> or explicitly provide a declaration for 'stpncpy'

And then a similar failure at link time:

Undefined symbols for architecture x86_64:
  "_stpncpy", referenced from:
      _sprint_status in jobs.o
ld: symbol(s) not found for architecture x86_64

The newer clang suggests including <string.h> because it knows the standard says that stpncpy would be declared there, but it won't help on Mac OS X 10.6.x and earlier because stpncpy was introduced in Mac OS X 10.7.

Would it be reasonable to add a compatibility implementation of stpncpy to dash? This and other changes were proposed here:

https://lore.kernel.org/dash/[email protected]/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.