mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Windows/Cygwin requires onerous special handling and the definition of additional _imp__* symbols to import/export symbols between dynamically linked binaries. Its support in AST used a lot of macros and code obfuscation. In the features/common test for this, AT&T called this the "Microsoft import/export nonsense". They're right, it's nonsense. Somehow, Microsoft's POSIX layer, SFU/Interix, always managed without it. No one has time to maintain this (especially considering how incredibly sluggish Cygwin is). And in fact, it had already fallen victim to bit rot; I confirmed this in my early experiments with reintroducing dynamic library support. No one has time to fix it, either. So, my apologies to any Cygwin fans; ksh 93u+m will never support dynamically loadable built-ins on Cygwin, even when I do manage to reintroduce dynamic linking properly.
100 lines
3.3 KiB
C
100 lines
3.3 KiB
C
/***********************************************************************
|
|
* *
|
|
* This software is part of the ast package *
|
|
* Copyright (c) 1985-2011 AT&T Intellectual Property *
|
|
* Copyright (c) 2020-2022 Contributors to ksh 93u+m *
|
|
* and is licensed under the *
|
|
* Eclipse Public License, Version 1.0 *
|
|
* by AT&T Intellectual Property *
|
|
* *
|
|
* A copy of the License is available at *
|
|
* http://www.eclipse.org/org/documents/epl-v10.html *
|
|
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
|
|
* *
|
|
* Information and Software Systems Research *
|
|
* AT&T Research *
|
|
* Florham Park NJ *
|
|
* *
|
|
* Glenn Fowler <gsf@research.att.com> *
|
|
* David Korn <dgk@research.att.com> *
|
|
* Phong Vo <kpv@research.att.com> *
|
|
* *
|
|
***********************************************************************/
|
|
/*
|
|
* strftime implementation
|
|
*/
|
|
|
|
#define strftime ______strftime
|
|
|
|
#include <ast.h>
|
|
#include <tm.h>
|
|
|
|
#undef strftime
|
|
|
|
#undef _def_map_ast
|
|
#include <ast_map.h>
|
|
|
|
#undef _lib_strftime /* we can pass X/Open */
|
|
|
|
#if _lib_strftime
|
|
|
|
NoN(strftime)
|
|
|
|
#else
|
|
|
|
extern size_t
|
|
strftime(char* buf, size_t len, const char* format, const struct tm* tm)
|
|
{
|
|
register char* s;
|
|
time_t t;
|
|
Tm_t tl;
|
|
|
|
memset(&tl, 0, sizeof(tl));
|
|
|
|
/*
|
|
* nl_langinfo() may call strftime() with bogus tm except for
|
|
* one value -- what a way to go
|
|
*/
|
|
|
|
if (tm->tm_sec < 0 || tm->tm_sec > 60 ||
|
|
tm->tm_min < 0 || tm->tm_min > 59 ||
|
|
tm->tm_hour < 0 || tm->tm_hour > 23 ||
|
|
tm->tm_wday < 0 || tm->tm_wday > 6 ||
|
|
tm->tm_mday < 1 || tm->tm_mday > 31 ||
|
|
tm->tm_mon < 0 || tm->tm_mon > 11 ||
|
|
tm->tm_year < 0 || tm->tm_year > (2138 - 1900))
|
|
{
|
|
if (tm->tm_sec >= 0 && tm->tm_sec <= 60)
|
|
tl.tm_sec = tm->tm_sec;
|
|
if (tm->tm_min >= 0 && tm->tm_min <= 59)
|
|
tl.tm_min = tm->tm_min;
|
|
if (tm->tm_hour >= 0 && tm->tm_hour <= 23)
|
|
tl.tm_hour = tm->tm_hour;
|
|
if (tm->tm_wday >= 0 && tm->tm_wday <= 6)
|
|
tl.tm_wday = tm->tm_wday;
|
|
if (tm->tm_mday >= 0 && tm->tm_mday <= 31)
|
|
tl.tm_mday = tm->tm_mday;
|
|
if (tm->tm_mon >= 0 && tm->tm_mon <= 11)
|
|
tl.tm_mon = tm->tm_mon;
|
|
if (tm->tm_year >= 0 && tm->tm_year <= (2138 - 1900))
|
|
tl.tm_year = tm->tm_year;
|
|
}
|
|
else
|
|
{
|
|
tl.tm_sec = tm->tm_sec;
|
|
tl.tm_min = tm->tm_min;
|
|
tl.tm_hour = tm->tm_hour;
|
|
tl.tm_mday = tm->tm_mday;
|
|
tl.tm_mon = tm->tm_mon;
|
|
tl.tm_year = tm->tm_year;
|
|
tl.tm_wday = tm->tm_wday;
|
|
tl.tm_yday = tm->tm_yday;
|
|
tl.tm_isdst = tm->tm_isdst;
|
|
}
|
|
t = tmtime(&tl, TM_LOCALZONE);
|
|
if (!(s = tmfmt(buf, len, format, &t)))
|
|
return 0;
|
|
return s - buf;
|
|
}
|
|
|
|
#endif
|