Hi all,
I just committed a change, to enable mingwex to be compiled for wince too.
Well, a subset of mingwex, for now.
I introduced a new mingwex/wince subdir for code that is wince specific.
Code in that subdir adds functions that exist on desktop versions of windows
but don't exist in coredll.
mingwex is compiled into a static lib, so we can add code here, more or
less without
worrying about bloat. Of course, we should try to put one function per
file, so the linker
sucks the less possible in.
The functions I have put there were required by 2 projects I am working
on, and I can
only guess they will be needed by a lot of other projects, so it makes
sense to not duplicate
this code everywhere. Note that for the time related functions, I didn't
export tzname, etc,
and all the usually DATA members, because this being a static lib, all
hell would brake lose
when different images (exes, dlls) would each access their version of
those members.
If we turn out to realize that we need them very bad in a lot of
projects, we will need
to move those time related functions into a dll, an then we will be able
to export the DATA
members without worry.
Well, enough talk, patch below.
Cheers,
Pedro Alves
---
src/mingw/ChangeLog.mingw32ce
2006-10-22 Pedro Alves <[EMAIL PROTECTED]>
* configure.in [AC_CONFIG_SUBDIRS]: Add mingwex.
* configure : Regenerate.
* mingwex/Makefile.in (VPATH): Add wince subdir.
(WINCE_DISTFILES): New.
(WINCE_OBJS): New.
(LIB_OBJS): Special case for wince. Build WINCE_OBJS.
(dist): Install WINCE_DISTFILES.
* mingwex/wince: New subdir.
* mingwex/wince/time.c: New file.
* mingwex/wince/freopen.c: New file.
* mingwex/wince/unlink.c: New file.
* mingwex/wince/tempnam.c: New file.
* mingwex/wince/wcsftime.c: New file.
* mingwex/wince/gmtime.c: New file.
* mingwex/wince/asctime.c: New file.
* mingwex/wince/mktime.c: New file.
* mingwex/wince/localtime.c: New file.
* mingwex/wince/strftime.c: New file.
* include/time.h (time, mktime, asctime,
ctime, gmtime, localtime, strftime, wcsftime): Expose on __COREDLL__.
* include/stdio.h (freopen, _tempnam,
tempnam, _wtempnam): Likewise.
* include/io.h: Expose the header. Needed for unlink.
(_unlink, unlink): Expose functions on __COREDLL__.
Index: configure.in
===================================================================
--- configure.in (revisão 747)
+++ configure.in (cópia de trabalho)
@@ -54,18 +54,8 @@
W32API_INCLUDE='-I $(srcdir)/../w32api/include'
-AC_CONFIG_SUBDIRS(profile)
+AC_CONFIG_SUBDIRS(profile mingwex)
-dnl case "$target_os" in
-dnl *cegcc* | *mingw32ce*)
-dnl #subdirs not ported yet.
-dnl AC_CONFIG_SUBDIRS(profile)
-dnl ;;
-dnl *)
-dnl AC_CONFIG_SUBDIRS(profile mingwex)
-dnl ;;
-dnl esac
-
case "$target_os" in
*cygwin*)
MNO_CYGWIN=-mno-cygwin
Index: mingwex/Makefile.in
===================================================================
--- mingwex/Makefile.in (revisão 745)
+++ mingwex/Makefile.in (cópia de trabalho)
@@ -4,7 +4,7 @@
# This makefile requires GNU make.
srcdir = @srcdir@
-VPATH = $(srcdir):$(srcdir)/math:$(srcdir)/stdio:$(srcdir)/complex
+VPATH =
$(srcdir):$(srcdir)/math:$(srcdir)/stdio:$(srcdir)/complex:$(srcdir)/wince
objdir = .
target_alias = @target_alias@
@@ -83,6 +83,10 @@
csinl.c csinh.c csinhf.c csinhl.c csqrt.c csqrtf.c csqrtl.c \
ctan.c ctanf.c ctanl.c ctanh.c ctanhf.c ctanhl.c
+WINCE_DISTFILES = \
+ asctime.c freopen.c gmtime.c localtime.c mktime.c strftime.c time.c \
+ tempnam.c unlink.c wcsftime.c
+
CC = @CC@
# FIXME: Which is it, CC or CC_FOR_TARGET?
CC_FOR_TARGET = $(CC)
@@ -179,10 +183,17 @@
cprojf.o cprojl.o creal.o crealf.o creall.o csin.o csinf.o \
csinl.o csinh.o csinhf.o csinhl.o csqrt.o csqrtf.o csqrtl.o \
ctan.o ctanf.o ctanl.o ctanh.o ctanhf.o ctanhl.o
+WINCE_OBJS = \
+ asctime.o freopen.o gmtime.o localtime.o mktime.o strftime.o time.o \
+ tempnam.o unlink.o wcsftime.o
+ifneq (,$(findstring wince,$(target_alias)))
+LIB_OBJS = $(WINCE_OBJS)
+else
LIB_OBJS = $(Q8_OBJS) $(CTYPE_OBJS) $(STDLIB_OBJS) $(STDLIB_STUB_OBJS) \
$(STDIO_OBJS) $(MATH_OBJS) $(FENV_OBJS) \
$(POSIX_OBJS) $(REPLACE_OBJS) $(COMPLEX_OBJS)
+endif
LIBS = $(LIBMINGWEX_A)
DLLS =
@@ -261,4 +272,9 @@
@for i in $(COMPLEX_DISTFILES); do\
cp -p $(srcdir)/complex/$$i $(distdir)/mingwex/complex/$$i ; \
done
+ mkdir $(distdir)/mingwex/wince
+ chmod 755 $(distdir)/mingwex/wince
+ @for i in $(WINCE_DISTFILES); do\
+ cp -p $(srcdir)/complex/$$i $(distdir)/mingwex/wince/$$i ; \
+ done
Index: mingwex/wince/time.c
===================================================================
--- mingwex/wince/time.c (revisão 0)
+++ mingwex/wince/time.c (revisão 0)
@@ -0,0 +1,27 @@
+#include <time.h>
+#include <windows.h>
+
+time_t
+time (time_t * timer)
+{
+ SYSTEMTIME systime;
+ struct tm tmtime;
+ time_t tt;
+
+ GetLocalTime (&systime);
+
+ tmtime.tm_year = systime.wYear - 1900;
+ tmtime.tm_mon = systime.wMonth - 1;
+ tmtime.tm_mday = systime.wDay;
+ tmtime.tm_wday = systime.wDayOfWeek;
+ tmtime.tm_hour = systime.wHour;
+ tmtime.tm_min = systime.wMinute;
+ tmtime.tm_sec = systime.wSecond;
+
+ tt = mktime (&tmtime);
+
+ if (timer)
+ *timer = tt;
+
+ return tt;
+}
Mudanças de propriedades em: mingwex/wince/time.c
___________________________________________________________________
Nome: svn:eol-style
+ native
Index: mingwex/wince/freopen.c
===================================================================
--- mingwex/wince/freopen.c (revisão 0)
+++ mingwex/wince/freopen.c (revisão 0)
@@ -0,0 +1,24 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define MAX_MODE 64
+
+FILE *
+freopen (const char *__restrict__ filename,
+ const char *__restrict__ mode, FILE * __restrict__ stream)
+{
+ size_t sizef = strlen (filename) + 1;
+ size_t sizem = strlen (mode) + 1;
+
+ wchar_t wfilename[MAX_PATH];
+ wchar_t wmode[MAX_MODE];
+
+ if (sizem > MAX_MODE || sizef > MAX_PATH)
+ return NULL;
+
+ mbstowcs (wfilename, filename, sizef);
+ mbstowcs (wmode, mode, sizem);
+
+ return _wfreopen (wfilename, wmode, stream);
+}
Mudanças de propriedades em: mingwex/wince/freopen.c
___________________________________________________________________
Nome: svn:eol-style
+ native
Index: mingwex/wince/unlink.c
===================================================================
--- mingwex/wince/unlink.c (revisão 0)
+++ mingwex/wince/unlink.c (revisão 0)
@@ -0,0 +1,12 @@
+#include <stdio.h>
+#include <windows.h>
+
+int
+_unlink (const char *file)
+{
+ wchar_t wfile[MAX_PATH];
+ size_t conv = mbstowcs (wfile, file, MAX_PATH);
+ if (conv > 0 && conv < MAX_PATH && DeleteFileW (wfile))
+ return 0;
+ return -1;
+}
Mudanças de propriedades em: mingwex/wince/unlink.c
___________________________________________________________________
Nome: svn:eol-style
+ native
Index: mingwex/wince/tempnam.c
===================================================================
--- mingwex/wince/tempnam.c (revisão 0)
+++ mingwex/wince/tempnam.c (revisão 0)
@@ -0,0 +1,54 @@
+#include <stdio.h>
+#include <windows.h>
+
+typedef void *(*dupfun_t) (wchar_t *);
+
+static void *
+tempnam_imp (const wchar_t * dir, const wchar_t * prefix, dupfun_t dupfun)
+{
+ wchar_t tmpbuf[MAX_PATH];
+ wchar_t tmp_dir[MAX_PATH];
+
+ DWORD ret = GetTempPathW (MAX_PATH, tmp_dir);
+ if (ret > 0 && ret <= MAX_PATH)
+ {
+ dir = tmp_dir;
+ }
+
+ if (!dir || !*dir || !(GetFileAttributes (dir) & FILE_ATTRIBUTE_DIRECTORY))
+ {
+ dir = _wP_tmpdir;
+ }
+
+ if (GetTempFileNameW (dir, prefix, 0, tmpbuf))
+ {
+ DeleteFileW (tmpbuf);
+ return dupfun (tmpbuf);
+ }
+ return NULL;
+}
+
+static void *
+wcstombs_dup (wchar_t * str)
+{
+ size_t len = wcslen (str) + 1;
+ char *s = malloc (len);
+ wcstombs (s, str, len);
+ return s;
+}
+
+wchar_t *
+_wtempnam (const wchar_t * dir, const wchar_t * prefix)
+{
+ return tempnam_imp (dir, prefix, (dupfun_t) wcsdup);
+}
+
+char *
+_tempnam (const char *dir, const char *prefix)
+{
+ wchar_t wdir[MAX_PATH];
+ wchar_t wprefix[MAX_PATH];
+ mbstowcs (wdir, dir, MAX_PATH);
+ mbstowcs (wprefix, prefix, MAX_PATH);
+ return tempnam_imp (wdir, wprefix, wcstombs_dup);
+}
Mudanças de propriedades em: mingwex/wince/tempnam.c
___________________________________________________________________
Nome: svn:eol-style
+ native
Index: mingwex/wince/wcsftime.c
===================================================================
--- mingwex/wince/wcsftime.c (revisão 0)
+++ mingwex/wince/wcsftime.c (revisão 0)
@@ -0,0 +1,21 @@
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+
+size_t
+wcsftime (wchar_t *const ws, const size_t maxsize,
+ const wchar_t *const wformat, const struct tm * const t)
+{
+ size_t format_size = wcslen (wformat) + 1;
+ char *format = malloc (format_size);
+ char *s = malloc (maxsize);
+ size_t ret;
+
+ wcstombs (format, wformat, format_size);
+ ret = strftime (s, maxsize, format, t);
+ if (ret >= 0)
+ ret = mbstowcs (ws, s, ret);
+ free (format);
+ free (s);
+ return ret;
+}
Mudanças de propriedades em: mingwex/wince/wcsftime.c
___________________________________________________________________
Nome: svn:eol-style
+ native
Index: mingwex/wince/gmtime.c
===================================================================
--- mingwex/wince/gmtime.c (revisão 0)
+++ mingwex/wince/gmtime.c (revisão 0)
@@ -0,0 +1,78 @@
+#include <windows.h>
+#include <stdio.h>
+#include <time.h>
+
+static struct tm mytm;
+
+static const int DMonth[13] =
+ { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
+
+static const int monthCodes[12] = { 6, 2, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 };
+
+static int
+calc_day_of_week (const struct tm *nTM)
+{
+ int day;
+
+ day = (nTM->tm_year % 100);
+ day += day / 4;
+ day += monthCodes[nTM->tm_mon];
+ day += nTM->tm_mday;
+ while (day >= 7)
+ day -= 7;
+
+ return day;
+}
+
+struct tm *
+gmtime (const time_t * timer)
+{
+ unsigned long x = *timer;
+ int imin, ihrs, iday, iyrs;
+ int sec, min, hrs, day, mon, yrs;
+ int lday, qday, jday, mday;
+
+ imin = x / 60; // whole minutes since 1/1/70
+ sec = x - (60 * imin); // leftover seconds
+ ihrs = imin / 60; // whole hours since 1/1/70
+ min = imin - 60 * ihrs; // leftover minutes
+ iday = ihrs / 24; // whole days since 1/1/70
+ hrs = ihrs - 24 * iday; // leftover hours
+ iday = iday + 365 + 366; // whole days since 1/1/68
+ lday = iday / ((4 * 365) + 1); // quadyr = 4 yr period = 1461 days
+ qday = iday % ((4 * 365) + 1); // days since current quadyr began
+ if (qday >= (31 + 29)) // if past feb 29 then
+ lday = lday + 1; // add this quadyrs leap day to the
+ // # of quadyrs (leap days) since 68
+ iyrs = (iday - lday) / 365; // whole years since 1968
+ jday = iday - (iyrs * 365) - lday; // days since 1 /1 of current year.
+ if (qday <= 365 && qday >= 60) // if past 2/29 and a leap year then
+ jday = jday + 1; // add a leap day to the # of whole
+ // days since 1/1 of current year
+ yrs = iyrs + 1968; // compute year
+ mon = 13; // estimate month ( +1)
+ mday = 366; // max days since 1/1 is 365
+ while (jday < mday) // mday = # of days passed from 1/1
+ { // until first day of current month
+ mon = mon - 1; // mon = month (estimated)
+ mday = DMonth[mon]; // # elapsed days at first of mon
+ if ((mon > 2) && (yrs % 4) == 0) // if past 2/29 and leap year then
+ mday = mday + 1; // add leap day
+ // compute month by decrementing
+ } // month until found
+
+ day = jday - mday + 1; // compute day of month
+
+ mytm.tm_sec = sec;
+ mytm.tm_min = min;
+ mytm.tm_hour = hrs;
+ mytm.tm_mday = day;
+ mytm.tm_mon = mon;
+ mytm.tm_year = yrs - 1900;
+
+ mytm.tm_wday = calc_day_of_week (&mytm);
+ mytm.tm_yday = jday;
+ mytm.tm_isdst = 0;
+
+ return &mytm;
+}
Mudanças de propriedades em: mingwex/wince/gmtime.c
___________________________________________________________________
Nome: svn:eol-style
+ native
Index: mingwex/wince/asctime.c
===================================================================
--- mingwex/wince/asctime.c (revisão 0)
+++ mingwex/wince/asctime.c (revisão 0)
@@ -0,0 +1,22 @@
+#include <windows.h>
+#include <stdio.h>
+#include <time.h>
+
+static const char const wday_name[7][3] =
+ { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
+
+static const char const mon_name[12][3] = {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+};
+
+char *
+asctime (const struct tm *timeptr)
+{
+ static char result[26];
+ sprintf (result, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n",
+ wday_name[timeptr->tm_wday], mon_name[timeptr->tm_mon],
+ timeptr->tm_mday, timeptr->tm_hour, timeptr->tm_min,
+ timeptr->tm_sec, 1900 + timeptr->tm_year);
+ return result;
+}
Mudanças de propriedades em: mingwex/wince/asctime.c
___________________________________________________________________
Nome: svn:eol-style
+ native
Index: mingwex/wince/mktime.c
===================================================================
--- mingwex/wince/mktime.c (revisão 0)
+++ mingwex/wince/mktime.c (revisão 0)
@@ -0,0 +1,38 @@
+#include <windows.h>
+#include <stdio.h>
+#include <time.h>
+
+static const int month_to_day[12] =
+ { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
+
+time_t
+mktime (struct tm *t)
+{
+ short month, year;
+ time_t result;
+
+ month = t->tm_mon;
+ year = t->tm_year + month / 12 + 1900;
+ month %= 12;
+ if (month < 0)
+ {
+ year -= 1;
+ month += 12;
+ }
+ result = (year - 1970) * 365 + (year - 1969) / 4 + month_to_day[month];
+ result = (year - 1970) * 365 + month_to_day[month];
+ if (month <= 1)
+ year -= 1;
+ result += (year - 1968) / 4;
+ result -= (year - 1900) / 100;
+ result += (year - 1600) / 400;
+ result += t->tm_mday;
+ result -= 1;
+ result *= 24;
+ result += t->tm_hour;
+ result *= 60;
+ result += t->tm_min;
+ result *= 60;
+ result += t->tm_sec;
+ return (result);
+}
Mudanças de propriedades em: mingwex/wince/mktime.c
___________________________________________________________________
Nome: svn:eol-style
+ native
Index: mingwex/wince/localtime.c
===================================================================
--- mingwex/wince/localtime.c (revisão 0)
+++ mingwex/wince/localtime.c (revisão 0)
@@ -0,0 +1,7 @@
+#include <time.h>
+
+struct tm *
+localtime (const time_t * timer)
+{
+ return gmtime (timer);
+}
Mudanças de propriedades em: mingwex/wince/localtime.c
___________________________________________________________________
Nome: svn:eol-style
+ native
Index: mingwex/wince/strftime.c
===================================================================
--- mingwex/wince/strftime.c (revisão 0)
+++ mingwex/wince/strftime.c (revisão 0)
@@ -0,0 +1,457 @@
+#include <windows.h>
+#include <stdio.h>
+#include <time.h>
+
+/* strftime() - taken from OpenBSD. */
+
+#define IN_NONE 0
+#define IN_SOME 1
+#define IN_THIS 2
+#define IN_ALL 3
+#define CHAR_BIT 8
+
+#define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)
+#define TYPE_SIGNED(type) (((type) -1) < 0)
+
+#define INT_STRLEN_MAXIMUM(type) \
+ ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))
+
+#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
+
+#define MONSPERYEAR 12
+#define DAYSPERWEEK 7
+#define TM_YEAR_BASE 1900
+#define HOURSPERDAY 24
+#define DAYSPERNYEAR 365
+#define DAYSPERLYEAR 366
+
+static char wildabbr[] = "WILDABBR";
+
+static char *tzname[2] =
+{
+ wildabbr,
+ wildabbr
+};
+
+
+#define Locale (&C_time_locale)
+
+struct lc_time_T
+{
+ const char *mon[MONSPERYEAR];
+ const char *month[MONSPERYEAR];
+ const char *wday[DAYSPERWEEK];
+ const char *weekday[DAYSPERWEEK];
+ const char *X_fmt;
+ const char *x_fmt;
+ const char *c_fmt;
+ const char *am;
+ const char *pm;
+ const char *date_fmt;
+};
+
+static const struct lc_time_T C_time_locale = {
+ {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+ }, {
+ "January", "February", "March", "April", "May", "June",
+ "July", "August", "September", "October", "November", "December"
+ }, {
+ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
+ }, {
+ "Sunday", "Monday", "Tuesday", "Wednesday",
+ "Thursday", "Friday", "Saturday"
+ },
+
+ /* X_fmt */
+ "%H:%M:%S",
+
+ /*
+ ** x_fmt
+ ** C99 requires this format.
+ ** Using just numbers (as here) makes Quakers happier;
+ ** it's also compatible with SVR4.
+ */
+ "%m/%d/%y",
+
+ /*
+ ** c_fmt
+ ** C99 requires this format.
+ ** Previously this code used "%D %X", but we now conform to C99.
+ ** Note that
+ ** "%a %b %d %H:%M:%S %Y"
+ ** is used by Solaris 2.3.
+ */
+ "%a %b %e %T %Y",
+
+ /* am */
+ "AM",
+
+ /* pm */
+ "PM",
+
+ /* date_fmt */
+ "%a %b %e %H:%M:%S %Z %Y"
+};
+
+
+static char *
+_add (const char *str, char *pt, const char *const ptlim)
+{
+ while (pt < ptlim && (*pt = *str++) != '\0')
+ ++pt;
+ return pt;
+}
+
+
+static char *
+_conv (const int n, const char *const format, char *const pt,
+ const char *const ptlim)
+{
+ char buf[INT_STRLEN_MAXIMUM (int) + 1];
+
+ (void) _snprintf (buf, sizeof (buf), format, n);
+ return _add (buf, pt, ptlim);
+}
+
+
+static char *
+_fmt (const char *format, const struct tm *const t, char *pt,
+ const char *const ptlim, int *warnp)
+{
+ for (; *format; ++format)
+ {
+ if (*format == '%')
+ {
+ label:
+ switch (*++format)
+ {
+ case '\0':
+ --format;
+ break;
+ case 'A':
+ pt = _add ((t->tm_wday < 0 ||
+ t->tm_wday >= DAYSPERWEEK) ?
+ "?" : Locale->weekday[t->tm_wday], pt, ptlim);
+ continue;
+ case 'a':
+ pt = _add ((t->tm_wday < 0 ||
+ t->tm_wday >= DAYSPERWEEK) ?
+ "?" : Locale->wday[t->tm_wday], pt, ptlim);
+ continue;
+ case 'B':
+ pt = _add ((t->tm_mon < 0 ||
+ t->tm_mon >= MONSPERYEAR) ?
+ "?" : Locale->month[t->tm_mon], pt, ptlim);
+ continue;
+ case 'b':
+ case 'h':
+ pt = _add ((t->tm_mon < 0 ||
+ t->tm_mon >= MONSPERYEAR) ?
+ "?" : Locale->mon[t->tm_mon], pt, ptlim);
+ continue;
+ case 'C':
+ /*
+ ** %C used to do a...
+ ** _fmt("%a %b %e %X %Y", t);
+ ** ...whereas now POSIX 1003.2 calls for
+ ** something completely different.
+ ** (ado, 1993-05-24)
+ */
+ pt = _conv ((t->tm_year + TM_YEAR_BASE) / 100,
+ "%02d", pt, ptlim);
+ continue;
+ case 'c':
+ {
+ int warn2 = IN_SOME;
+
+ pt = _fmt (Locale->c_fmt, t, pt, ptlim, warnp);
+ if (warn2 == IN_ALL)
+ warn2 = IN_THIS;
+ if (warn2 > *warnp)
+ *warnp = warn2;
+ }
+ continue;
+ case 'D':
+ pt = _fmt ("%m/%d/%y", t, pt, ptlim, warnp);
+ continue;
+ case 'd':
+ pt = _conv (t->tm_mday, "%02d", pt, ptlim);
+ continue;
+ case 'E':
+ case 'O':
+ /*
+ ** C99 locale modifiers.
+ ** The sequences
+ ** %Ec %EC %Ex %EX %Ey %EY
+ ** %Od %oe %OH %OI %Om %OM
+ ** %OS %Ou %OU %OV %Ow %OW %Oy
+ ** are supposed to provide alternate
+ ** representations.
+ */
+ goto label;
+ case 'e':
+ pt = _conv (t->tm_mday, "%2d", pt, ptlim);
+ continue;
+ case 'F':
+ pt = _fmt ("%Y-%m-%d", t, pt, ptlim, warnp);
+ continue;
+ case 'H':
+ pt = _conv (t->tm_hour, "%02d", pt, ptlim);
+ continue;
+ case 'I':
+ pt = _conv ((t->tm_hour % 12) ?
+ (t->tm_hour % 12) : 12, "%02d", pt, ptlim);
+ continue;
+ case 'j':
+ pt = _conv (t->tm_yday + 1, "%03d", pt, ptlim);
+ continue;
+ case 'k':
+ /*
+ ** This used to be...
+ ** _conv(t->tm_hour % 12 ?
+ ** t->tm_hour % 12 : 12, 2, ' ');
+ ** ...and has been changed to the below to
+ ** match SunOS 4.1.1 and Arnold Robbins'
+ ** strftime version 3.0. That is, "%k" and
+ ** "%l" have been swapped.
+ ** (ado, 1993-05-24)
+ */
+ pt = _conv (t->tm_hour, "%2d", pt, ptlim);
+ continue;
+#ifdef KITCHEN_SINK
+ case 'K':
+ /*
+ ** After all this time, still unclaimed!
+ */
+ pt = _add ("kitchen sink", pt, ptlim);
+ continue;
+#endif /* defined KITCHEN_SINK */
+ case 'l':
+ /*
+ ** This used to be...
+ ** _conv(t->tm_hour, 2, ' ');
+ ** ...and has been changed to the below to
+ ** match SunOS 4.1.1 and Arnold Robbin's
+ ** strftime version 3.0. That is, "%k" and
+ ** "%l" have been swapped.
+ ** (ado, 1993-05-24)
+ */
+ pt = _conv ((t->tm_hour % 12) ?
+ (t->tm_hour % 12) : 12, "%2d", pt, ptlim);
+ continue;
+ case 'M':
+ pt = _conv (t->tm_min, "%02d", pt, ptlim);
+ continue;
+ case 'm':
+ pt = _conv (t->tm_mon + 1, "%02d", pt, ptlim);
+ continue;
+ case 'n':
+ pt = _add ("\n", pt, ptlim);
+ continue;
+ case 'p':
+ pt = _add ((t->tm_hour >= (HOURSPERDAY / 2)) ?
+ Locale->pm : Locale->am, pt, ptlim);
+ continue;
+ case 'R':
+ pt = _fmt ("%H:%M", t, pt, ptlim, warnp);
+ continue;
+ case 'r':
+ pt = _fmt ("%I:%M:%S %p", t, pt, ptlim, warnp);
+ continue;
+ case 'S':
+ pt = _conv (t->tm_sec, "%02d", pt, ptlim);
+ continue;
+ case 's':
+ {
+ struct tm tm;
+ char buf[INT_STRLEN_MAXIMUM (time_t) + 1];
+ time_t mkt;
+
+ tm = *t;
+ mkt = mktime (&tm);
+ if (TYPE_SIGNED (time_t))
+ (void) _snprintf (buf, sizeof buf, "%ld", (long) mkt);
+ else
+ (void) _snprintf (buf, sizeof buf,
+ "%lu", (unsigned long) mkt);
+ pt = _add (buf, pt, ptlim);
+ }
+ continue;
+ case 'T':
+ pt = _fmt ("%H:%M:%S", t, pt, ptlim, warnp);
+ continue;
+ case 't':
+ pt = _add ("\t", pt, ptlim);
+ continue;
+ case 'U':
+ pt = _conv ((t->tm_yday + DAYSPERWEEK -
+ t->tm_wday) / DAYSPERWEEK, "%02d", pt, ptlim);
+ continue;
+ case 'u':
+ /*
+ ** From Arnold Robbins' strftime version 3.0:
+ ** "ISO 8601: Weekday as a decimal number
+ ** [1 (Monday) - 7]"
+ ** (ado, 1993-05-24)
+ */
+ pt = _conv ((t->tm_wday == 0) ?
+ DAYSPERWEEK : t->tm_wday, "%d", pt, ptlim);
+ continue;
+ case 'V': /* ISO 8601 week number */
+ case 'G': /* ISO 8601 year (four digits) */
+ case 'g': /* ISO 8601 year (two digits) */
+ {
+ int year;
+ int yday;
+ int wday;
+ int w;
+
+ year = t->tm_year + TM_YEAR_BASE;
+ yday = t->tm_yday;
+ wday = t->tm_wday;
+ for (;;)
+ {
+ int len;
+ int bot;
+ int top;
+
+ len = isleap (year) ? DAYSPERLYEAR : DAYSPERNYEAR;
+ /*
+ ** What yday (-3 ... 3) does
+ ** the ISO year begin on?
+ */
+ bot = ((yday + 11 - wday) % DAYSPERWEEK) - 3;
+ /*
+ ** What yday does the NEXT
+ ** ISO year begin on?
+ */
+ top = bot - (len % DAYSPERWEEK);
+ if (top < -3)
+ top += DAYSPERWEEK;
+ top += len;
+ if (yday >= top)
+ {
+ ++year;
+ w = 1;
+ break;
+ }
+ if (yday >= bot)
+ {
+ w = 1 + ((yday - bot) / DAYSPERWEEK);
+ break;
+ }
+ --year;
+ yday += isleap (year) ? DAYSPERLYEAR : DAYSPERNYEAR;
+ }
+ if (*format == 'V')
+ pt = _conv (w, "%02d", pt, ptlim);
+ else if (*format == 'g')
+ {
+ *warnp = IN_ALL;
+ pt = _conv (year % 100, "%02d", pt, ptlim);
+ }
+ else
+ pt = _conv (year, "%04d", pt, ptlim);
+ }
+ continue;
+ case 'v':
+ pt = _fmt ("%e-%b-%Y", t, pt, ptlim, warnp);
+ continue;
+ case 'W':
+ pt = _conv ((t->tm_yday + DAYSPERWEEK -
+ (t->tm_wday ?
+ (t->tm_wday - 1) :
+ (DAYSPERWEEK - 1))) / DAYSPERWEEK,
+ "%02d", pt, ptlim);
+ continue;
+ case 'w':
+ pt = _conv (t->tm_wday, "%d", pt, ptlim);
+ continue;
+ case 'X':
+ pt = _fmt (Locale->X_fmt, t, pt, ptlim, warnp);
+ continue;
+ case 'x':
+ {
+ int warn2 = IN_SOME;
+
+ pt = _fmt (Locale->x_fmt, t, pt, ptlim, &warn2);
+ if (warn2 == IN_ALL)
+ warn2 = IN_THIS;
+ if (warn2 > *warnp)
+ *warnp = warn2;
+ }
+ continue;
+ case 'y':
+ *warnp = IN_ALL;
+ pt = _conv ((t->tm_year + TM_YEAR_BASE) % 100,
+ "%02d", pt, ptlim);
+ continue;
+ case 'Y':
+ pt = _conv (t->tm_year + TM_YEAR_BASE, "%04d", pt, ptlim);
+ continue;
+ case 'Z':
+ if (t->tm_isdst >= 0)
+ pt = _add (tzname[t->tm_isdst != 0], pt, ptlim);
+ /*
+ ** C99 says that %Z must be replaced by the
+ ** empty string if the time zone is not
+ ** determinable.
+ */
+ continue;
+ case 'z':
+ {
+ int diff;
+ char const *sign;
+
+ if (t->tm_isdst < 0)
+ continue;
+ continue;
+ if (diff < 0)
+ {
+ sign = "-";
+ diff = -diff;
+ }
+ else
+ sign = "+";
+ pt = _add (sign, pt, ptlim);
+ diff /= 60;
+ pt = _conv ((diff / 60) * 100 + diff % 60, "%04d", pt, ptlim);
+ }
+ continue;
+ case '+':
+ pt = _fmt (Locale->date_fmt, t, pt, ptlim, warnp);
+ continue;
+ case '%':
+ default:
+ break;
+ }
+ }
+ if (pt == ptlim)
+ break;
+ *pt++ = *format;
+ }
+ return pt;
+}
+
+
+size_t
+strftime (char *const s, const size_t maxsize,
+ const char *const format, const struct tm * const t)
+{
+ char *p;
+ int warn;
+
+ warn = IN_NONE;
+ p = _fmt (((format == NULL) ? "%c" : format), t, s, s + maxsize, &warn);
+
+ if (p == s + maxsize)
+ {
+ if (maxsize > 0)
+ s[maxsize - 1] = '\0';
+ return 0;
+ }
+ *p = '\0';
+ return p - s;
+}
Mudanças de propriedades em: mingwex/wince/strftime.c
___________________________________________________________________
Nome: svn:eol-style
+ native
Index: include/io.h
===================================================================
--- include/io.h (revisão 745)
+++ include/io.h (cópia de trabalho)
@@ -8,15 +8,9 @@
*
*/
-#ifdef __COREDLL__
-# include_next <io.h>
-#else /* __COREDLL__ */
-
#ifndef _IO_H_
#define _IO_H_
-#ifndef __COREDLL__
-
/* All the headers include this file. */
#include <_mingw.h>
@@ -27,6 +21,8 @@
#include <sys/types.h> /* To get time_t. */
#include <stdint.h> /* For intptr_t. */
+#ifndef __COREDLL__
+
/*
* Attributes of files as returned by _findfirst et al.
*/
@@ -38,7 +34,6 @@
#define _A_SUBDIR 0x00000010
#define _A_ARCH 0x00000020
-
#ifndef RC_INVOKED
#ifndef _FSIZE_T_DEFINED
@@ -118,6 +113,8 @@
#define _WFINDDATA_T_DEFINED
#endif
+#endif /* __COREDLL__ */
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -129,6 +126,9 @@
* and 0 if a match was found. Call _findclose when you are finished.
*/
/* FIXME: Should these all use intptr_t, as per recent MSDN docs? */
+
+#ifndef __COREDLL__
+
_CRTIMP long __cdecl _findfirst (const char*, struct _finddata_t*);
_CRTIMP int __cdecl _findnext (long, struct _finddata_t*);
_CRTIMP int __cdecl _findclose (long);
@@ -140,6 +140,8 @@
_CRTIMP int __cdecl _rmdir (const char*);
_CRTIMP int __cdecl _chmod (const char*, int);
+#endif /* __COREDLL__ */
+
#ifdef __MSVCRT__
_CRTIMP __int64 __cdecl _filelengthi64(int);
_CRTIMP long __cdecl _findfirsti64(const char*, struct _finddatai64_t*);
@@ -163,14 +165,14 @@
#ifndef _NO_OLDNAMES
-#ifndef _UWIN
+#if !defined (_UWIN) && !defined (__COREDLL__)
_CRTIMP int __cdecl chdir (const char*);
_CRTIMP char* __cdecl getcwd (char*, int);
_CRTIMP int __cdecl mkdir (const char*);
_CRTIMP char* __cdecl mktemp (char*);
_CRTIMP int __cdecl rmdir (const char*);
_CRTIMP int __cdecl chmod (const char*, int);
-#endif /* _UWIN */
+#endif /* _UWIN && __COREDLL__ */
#endif /* Not _NO_OLDNAMES */
@@ -197,6 +199,8 @@
extern "C" {
#endif
+#ifndef __COREDLL__
+
_CRTIMP int __cdecl _access (const char*, int);
_CRTIMP int __cdecl _chsize (int, long);
_CRTIMP int __cdecl _close (int);
@@ -241,8 +245,11 @@
_CRTIMP long __cdecl _tell (int);
/* Should umask be in sys/stat.h and/or sys/types.h instead? */
_CRTIMP int __cdecl _umask (int);
+#endif /* __COREDLL__ */
_CRTIMP int __cdecl _unlink (const char*);
+#ifndef __COREDLL__
_CRTIMP int __cdecl _write (int, const void*, unsigned int);
+#endif /* __COREDLL__ */
/* Wide character versions. Also declared in wchar.h. */
/* Not in crtdll.dll */
@@ -274,6 +281,7 @@
*/
#ifndef _UWIN
+#ifndef __COREDLL__
_CRTIMP int __cdecl access (const char*, int);
_CRTIMP int __cdecl chsize (int, long );
_CRTIMP int __cdecl close (int);
@@ -290,8 +298,11 @@
_CRTIMP int __cdecl sopen (const char*, int, int, ...);
_CRTIMP long __cdecl tell (int);
_CRTIMP int __cdecl umask (int);
+#endif /* __COREDLL__ */
_CRTIMP int __cdecl unlink (const char*);
+#ifndef __COREDLL__
_CRTIMP int __cdecl write (int, const void*, unsigned int);
+#endif /* __COREDLL__ */
#endif /* _UWIN */
/* Wide character versions. Also declared in wchar.h. */
@@ -317,8 +328,4 @@
#endif /* Not RC_INVOKED */
-#endif /* __COREDLL__ */
-
#endif /* _IO_H_ not defined */
-
-#endif /* Not __COREDLL__ */
Index: include/stdio.h
===================================================================
--- include/stdio.h (revisão 747)
+++ include/stdio.h (cópia de trabalho)
@@ -196,9 +196,7 @@
* File Operations
*/
_CRTIMP FILE* __cdecl fopen (const char*, const char*);
-#ifndef __COREDLL__
_CRTIMP FILE* __cdecl freopen (const char*, const char*, FILE*);
-#endif
_CRTIMP int __cdecl fflush (FILE*);
_CRTIMP int __cdecl fclose (FILE*);
@@ -208,17 +206,19 @@
_CRTIMP int __cdecl rename (const char*, const char*);
_CRTIMP FILE* __cdecl tmpfile (void);
_CRTIMP char* __cdecl tmpnam (char*);
-
+#endif /* __COREDLL__ */
#ifndef __STRICT_ANSI__
_CRTIMP char* __cdecl _tempnam (const char*, const char*);
+#ifndef __COREDLL__
_CRTIMP int __cdecl _rmtmp(void);
-
+#endif /* __COREDLL__ */
#ifndef NO_OLDNAMES
_CRTIMP char* __cdecl tempnam (const char*, const char*);
-_CRTIMP int __cdecl rmtmp(void);
-#endif
+#ifndef __COREDLL__
+CRTIMP int __cdecl rmtmp(void);
+#endif /* __COREDLL__ */
+#endif /* NO_OLDNAMES */
#endif /* __STRICT_ANSI__ */
-#endif /* Not __COREDLL__ */
_CRTIMP int __cdecl setvbuf (FILE*, char*, int, size_t);
@@ -522,6 +522,7 @@
#endif /* __MSVCRT__ */
#ifdef __COREDLL__
+_CRTIMP wchar_t* __cdecl _wtempnam (const wchar_t*, const wchar_t*);
__CRT_INLINE wint_t __cdecl getwc(FILE* f) { return fgetwc(f); }
__CRT_INLINE wint_t __cdecl putwc(wint_t c, FILE* f) { return fputwc(c, f);
}
#endif
Index: include/time.h
===================================================================
--- include/time.h (revisão 745)
+++ include/time.h (cópia de trabalho)
@@ -83,9 +83,9 @@
#ifndef __COREDLL__
_CRTIMP clock_t __cdecl clock (void);
+#endif
_CRTIMP time_t __cdecl time (time_t*);
_CRTIMP time_t __cdecl mktime (struct tm*);
-#endif
_CRTIMP double __cdecl difftime (time_t, time_t);
/*
@@ -98,14 +98,12 @@
* Fault and crap out your program. Guess how I know. Hint: stat called on
* a directory gives 'invalid' times in st_atime etc...
*/
-#ifndef __COREDLL__
_CRTIMP char* __cdecl asctime (const struct tm*);
_CRTIMP char* __cdecl ctime (const time_t*);
_CRTIMP struct tm* __cdecl gmtime (const time_t*);
_CRTIMP struct tm* __cdecl localtime (const time_t*);
_CRTIMP size_t __cdecl strftime (char*, size_t, const char*, const
struct tm*);
-#endif
#ifndef __STRICT_ANSI__
@@ -210,9 +208,7 @@
#endif
#endif /* __MSVCRT__ */
#endif /* __STRICT_ANSI__ */
-#ifndef __COREDLL__
_CRTIMP size_t __cdecl wcsftime (wchar_t*, size_t, const wchar_t*,
const struct tm*);
-#endif
#define _WTIME_DEFINED
#endif /* _WTIME_DEFINED */
Index: moldname.def.in
===================================================================
--- moldname.def.in (revisão 747)
+++ moldname.def.in (cópia de trabalho)
@@ -130,16 +130,20 @@
swab
#ifndef __COREDLL__
tell
+#endif /* __COREDLL__ */
tempnam
#if (__MSVCRT__)
timezone DATA
#endif
+#ifndef __COREDLL__
; export tzname for both. See <time.h>
tzname DATA
tzset
umask
ungetch
+#endif /* __COREDLL__ */
unlink
+#ifndef __COREDLL__
utime
#endif /* __COREDLL__ */
wcsdup
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Cegcc-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/cegcc-devel