Changeset 494
- Timestamp:
- Aug 1, 2003, 8:42:12 AM (22 years ago)
- Location:
- trunk/src/emx
- Files:
-
- 3 added
- 15 deleted
- 63 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/include/386/builtin.h
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r493 r494 87 87 } 88 88 89 /* Quick routines similar to div() and friends, but inline */ 90 91 static __inline__ long __ldivmod (long num, long den, long *rem) 92 { 93 long q, r; 94 __asm__ ("cltd; idivl %2" 95 : "=a" (q), "=&d" (r) 96 : "r?m" (den), "a" (num)); 97 *rem = r; 98 return q; 99 } 100 101 static __inline__ unsigned long __uldivmod (unsigned long num, 102 unsigned long den, unsigned long *rem) 103 { 104 unsigned long q, r; 105 __asm__ ("xorl %%edx,%%edx; divl %2" 106 : "=a" (q), "=&d" (r) 107 : "r?m" (den), "a" (num)); 108 *rem = r; 109 return q; 110 } 111 112 /* 113 Divide a 64-bit integer by a 32-bit one: 114 115 A*2^32 + B A B + (A mod 32) 116 ---------- = --- * 2^32 + ---------------- 117 C C C 118 */ 119 static __inline__ long long __lldivmod (long long num, long den, long *rem) 120 { 121 long long q; 122 long r; 123 __asm__ (" movl %%eax,%%esi;" 124 " movl %%edx,%%eax;" 125 " pushl %%edx;" 126 " cltd;" 127 " idivl %2;" 128 " ;" 129 /* Now ensure remainder is smallest of possible two values (negative and 130 positive). For this we compare the remainder with positive and negative 131 denominator/2; if it is smaller than one and bigger than another we 132 consider it optimal, otherwise it can be made smaller by adding or 133 subtracting denominator to it. This is done to ensure no overflow 134 will occur at next division. */ 135 " movl %2,%%ecx;" 136 " sarl $1,%%ecx;" /* ecx = den/2 */ 137 " cmpl %%ecx,%%edx;" 138 " setl %%bl;" 139 " negl %%ecx;" 140 " cmpl %%ecx,%%edx;" 141 " setl %%bh;" 142 " xorb %%bh,%%bl;" 143 " jnz 1f;" /* Remainder is between -den/2...den/2 */ 144 " ;" 145 /* If remainder has same sign as denominator, we have to do r -= den; q++; 146 otherwise we have to do r += den; q--; */ 147 " movl %2,%%ebx;" /* ebx = den */ 148 " xorl %%edx,%%ebx;" /* r ^ den */ 149 " js 0f;" /* Different signs */ 150 " subl %2,%%edx;" /* r -= den */ 151 " addl $1,%%eax;" /* q++ */ 152 " adcl $0,%%edx;" 153 " jmp 1f;" 154 " ;" 155 "0: addl %2,%%edx;" /* r += den */ 156 " subl $1,%%eax;" /* q-- */ 157 " sbbl $0,%%edx;" 158 " ;" 159 "1: xchgl %%eax,%%esi;" 160 " idivl %2;" 161 " ;" 162 " movl %%edx,%1;" 163 " cltd;" 164 " addl %%esi,%%edx;" 165 " ;" 166 /* Check if numerator has the same sign as remainder; if they have different 167 sign we should make the remainder have same sign as numerator to comply 168 with ANSI standard, which says we always should truncate the quotient 169 towards zero. */ 170 " popl %%ebx;" /* ebx = num >> 32 */ 171 " xorl %1,%%ebx;" /* sign(r) ^ sign(num) */ 172 " jns 3f;" /* jump if same sign */ 173 " ;" 174 /* If remainder has same sign as denominator, we have to do r -= den; q++; 175 otherwise we have to do r += den; q--; */ 176 " movl %2,%%ebx;" 177 " xorl %1,%%ebx;" /* r ^ den */ 178 " js 2f;" /* Different signs */ 179 " subl %2,%1;" /* r -= den */ 180 " addl $1,%%eax;" /* q++ */ 181 " adcl $0,%%edx;" 182 " jmp 3f;" 183 " ;" 184 "2: addl %2,%1;" /* r += den */ 185 " subl $1,%%eax;" /* q-- */ 186 " sbbl $0,%%edx;" 187 " ;" 188 "3: ;" 189 : "=A" (q), "=&c" (r) 190 : "r" (den), "A" (num) 191 : "ebx", "esi"); 192 *rem = r; 193 return q; 194 } 195 196 /* 197 Same as __lldivmod except that if A < C, we can do just one division 198 instead of two because the result is always a 32-bit integer. 199 */ 200 static __inline__ unsigned long long __ulldivmod (unsigned long long num, 201 unsigned long den, unsigned long *rem) 202 { 203 unsigned long long q; 204 unsigned long r; 205 __asm__ (" movl %%eax,%1;" 206 " movl %%edx,%%eax;" 207 " xorl %%edx,%%edx;" 208 " divl %2;" 209 " xchgl %%eax,%%ecx;" 210 " divl %2;" 211 " xchgl %%edx,%1;" 212 : "=A" (q), "=c" (r) 213 : "r?m" (den), "A" (num)); 214 *rem = r; 215 return q; 216 } 217 89 218 #if defined (__cplusplus) 90 219 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/ctype.h
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r493 r494 1 /* ctype.h (emx+gcc) */ 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 4 5 For conditions of distribution and use, see the file COPYING. 6 7 Character type querying. 8 */ 2 9 3 10 #ifndef _CTYPE_H … … 8 15 #endif 9 16 10 extern unsigned char _ctype[]; 17 #include <sys/locale.h> 11 18 12 #define _UPPER 0x01 13 #define _LOWER 0x02 14 #define _DIGIT 0x04 15 #define _XDIGIT 0x08 16 #define _CNTRL 0x10 17 #define _SPACE 0x20 18 #define _PUNCT 0x40 19 #define _PRINT 0x80 19 static inline int isalnum (int _c) 20 { return __locale_ctype.cflags [_c & 0xff] & (__UPPER|__LOWER|__DIGIT); } 20 21 21 #if defined (__cplusplus) 22 static inline int isalpha (int _c) 23 { return __locale_ctype.cflags [_c & 0xff] & (__UPPER|__LOWER); } 22 24 23 extern inline int isalnum (int _c) 24 { return (_ctype+1)[(unsigned char)_c] & (_UPPER|_LOWER|_DIGIT); } 25 extern inline int isalpha (int _c) 26 { return (_ctype+1)[(unsigned char)_c] & (_UPPER|_LOWER); } 27 extern inline int iscntrl (int _c) 28 { return (_ctype+1)[(unsigned char)_c] & (_CNTRL); } 29 extern inline int isdigit (int _c) 30 { return (_ctype+1)[(unsigned char)_c] & (_DIGIT); } 31 extern inline int isgraph (int _c) 32 { return (_ctype+1)[(unsigned char)_c] & (_PUNCT|_UPPER|_LOWER|_DIGIT); } 33 extern inline int islower (int _c) 34 { return (_ctype+1)[(unsigned char)_c] & (_LOWER); } 35 extern inline int isprint (int _c) 36 { return (_ctype+1)[(unsigned char)_c] & (_PRINT); } 37 extern inline int ispunct (int _c) 38 { return (_ctype+1)[(unsigned char)_c] & (_PUNCT); } 39 extern inline int isspace (int _c) 40 { return (_ctype+1)[(unsigned char)_c] & (_SPACE); } 41 extern inline int isupper (int _c) 42 { return (_ctype+1)[(unsigned char)_c] & (_UPPER); } 43 extern inline int isxdigit (int _c) 44 { return (_ctype+1)[(unsigned char)_c] & (_XDIGIT); } 25 static inline int iscntrl (int _c) 26 { return __locale_ctype.cflags [_c & 0xff] & (__CNTRL); } 45 27 46 #else 28 static inline int isdigit (int _c) 29 { return __locale_ctype.cflags [_c & 0xff] & (__DIGIT); } 47 30 48 #define isalnum(c) ((_ctype+1)[(unsigned char)c] & (_UPPER|_LOWER|_DIGIT)) 49 #define isalpha(c) ((_ctype+1)[(unsigned char)c] & (_UPPER|_LOWER)) 50 #define iscntrl(c) ((_ctype+1)[(unsigned char)c] & (_CNTRL)) 51 #define isdigit(c) ((_ctype+1)[(unsigned char)c] & (_DIGIT)) 52 #define isgraph(c) ((_ctype+1)[(unsigned char)c] & (_PUNCT|_UPPER|_LOWER|_DIGIT)) 53 #define islower(c) ((_ctype+1)[(unsigned char)c] & (_LOWER)) 54 #define isprint(c) ((_ctype+1)[(unsigned char)c] & (_PRINT)) 55 #define ispunct(c) ((_ctype+1)[(unsigned char)c] & (_PUNCT)) 56 #define isspace(c) ((_ctype+1)[(unsigned char)c] & (_SPACE)) 57 #define isupper(c) ((_ctype+1)[(unsigned char)c] & (_UPPER)) 58 #define isxdigit(c) ((_ctype+1)[(unsigned char)c] & (_XDIGIT)) 31 static inline int isgraph (int _c) 32 { return __locale_ctype.cflags [_c & 0xff] & (__PUNCT|__UPPER|__LOWER|__DIGIT); } 59 33 60 int (isalnum)(int); 61 int (isalpha)(int); 62 int (iscntrl)(int); 63 int (isdigit)(int); 64 int (isgraph)(int); 65 int (islower)(int); 66 int (isprint)(int); 67 int (ispunct)(int); 68 int (isspace)(int); 69 int (isupper)(int); 70 int (isxdigit)(int); 34 static inline int islower (int _c) 35 { return __locale_ctype.cflags [_c & 0xff] & (__LOWER); } 71 36 72 int toupper (int); 73 int tolower (int); 74 int _toupper (int); 75 int _tolower (int); 37 static inline int isprint (int _c) 38 { return __locale_ctype.cflags [_c & 0xff] & (__PRINT); } 76 39 77 #endif 40 static inline int ispunct (int _c) 41 { return __locale_ctype.cflags [_c & 0xff] & (__PUNCT); } 78 42 79 #if !defined (_CTYPE_FUN) 80 extern __inline__ int _toupper (int _c) { return (_c-'a'+'A'); } 81 extern __inline__ int _tolower (int _c) { return (_c-'A'+'a'); } 82 extern __inline__ int toupper(int _c) 83 {return (islower(_c) ? _toupper(_c) : _c);} 84 extern __inline__ int tolower(int _c) 85 {return (isupper(_c) ? _tolower(_c) : _c);} 86 #endif 43 static inline int isspace (int _c) 44 { return __locale_ctype.cflags [_c & 0xff] & (__SPACE); } 45 46 static inline int isupper (int _c) 47 { return __locale_ctype.cflags [_c & 0xff] & (__UPPER); } 48 49 static inline int isxdigit (int _c) 50 { return __locale_ctype.cflags [_c & 0xff] & (__XDIGIT); } 51 52 static inline int toupper (int _c) 53 { return __locale_ctype.upcase [_c & 0xff]; } 54 55 static inline int tolower (int _c) 56 { return __locale_ctype.locase [_c & 0xff]; } 87 57 88 58 #if !defined (__STRICT_ANSI__) && !defined (_POSIX_SOURCE) 89 59 90 int (toascii)(int); 91 int (isascii)(int); 60 static inline int isascii (int _c) 61 { return (unsigned)_c <= 0x7f; } 92 62 93 #define isascii(c) ((unsigned)(c) <= 0x7f)94 #define toascii(c) ((c) & 0x7f) 63 static inline int toascii (int _c) 64 { return _c & 0x7f; } 95 65 96 66 #endif 97 98 67 99 68 #if defined (__cplusplus) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/emx/syscalls.h
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r493 r494 179 179 int __mkdir (__const__ char *name); 180 180 int __newthread (int tid); 181 int __nls_ctype (unsigned char *buf);182 void __nls_memupr (unsigned char *buf, size_t size);183 181 int __open (__const__ char *name, int flags, unsigned long size); 184 182 int __pause (void); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/emx/thread.h
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r493 r494 37 37 unsigned int _th_rand; /* Used by rand() */ 38 38 void * _th_store; /* Pointer to user data */ 39 int _th_mblen_shift; /* Shift state for mblen() */40 int _th_mbtowc_shift; /* Shift state for mbtowc() */41 int _th_wctomb_shift; /* Shift state for wctomb() */42 39 char _th_vollabel[12]; /* Used by _getvol() */ 43 40 char _th_error[28]; /* Used by strerror() */ … … 46 43 char _th_ttyname[32]; /* Used by ttyname() */ 47 44 char _th_inetntoa[16]; /* Used by inetntoa() */ 48 int _th_reserved[97 1]; /* 4096 bytes, total */45 int _th_reserved[974]; /* 4096 bytes, total */ 49 46 }; 50 47 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/locale.h
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r493 r494 1 /* locale.h (emx+gcc) */ 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 4 5 For conditions of distribution and use, see the file COPYING. 6 7 POSIX locale implementation. 8 */ 2 9 3 10 #ifndef _LOCALE_H … … 8 15 #endif 9 16 10 #if !defined (NULL) 11 #if defined (__cplusplus) 12 #define NULL 0 13 #else 14 #define NULL ((void *)0) 15 #endif 16 #endif 17 /* lconv and categories */ 18 #include <sys/locale.h> 17 19 18 #define LC_ALL 0 19 #define LC_COLLATE 1 20 #define LC_CTYPE 2 21 #define LC_MONETARY 3 22 #define LC_NUMERIC 4 23 #define LC_TIME 5 24 25 #define LC_C "C" 26 #define LC_C_FRANCE "FRAN" 27 #define LC_C_GERMANY "GERM" 28 #define LC_C_ITALY "ITAL" 29 #define LC_C_SPAIN "SPAI" 30 #define LC_C_UK "UK" 31 #define LC_C_USA "USA" 32 33 struct lconv 34 { 35 char *decimal_point; 36 char *thousands_sep; 37 char *grouping; 38 char *int_curr_symbol; 39 char *currency_symbol; 40 char *mon_decimal_point; 41 char *mon_thousands_sep; 42 char *mon_grouping; 43 char *positive_sign; 44 char *negative_sign; 45 char int_frac_digits; 46 char frac_digits; 47 char p_cs_precedes; 48 char p_sep_by_space; 49 char n_cs_precedes; 50 char n_sep_by_space; 51 char p_sign_posn; 52 char n_sign_posn; 53 }; 54 55 56 char *setlocale (int, __const__ char *); 57 58 struct lconv *_localeconv (int); 59 struct lconv *localeconv (void); 60 61 #if defined (__CHAR_UNSIGNED__) 62 #define localeconv() _localeconv (255) 63 #else 64 #define localeconv() _localeconv (127) 65 #endif 20 /* Set current locale, if __locale is not NULL. Returns previous locale. */ 21 extern char *setlocale (int category, __const__ char *locale); 22 /* Get information about current locale. */ 23 extern struct lconv *localeconv (void); 66 24 67 25 #if defined (__cplusplus) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/stdlib.h
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r493 r494 79 79 int (*)(__const__ void *, __const__ void *)); 80 80 div_t div (int, int); 81 ldiv_t ldiv (long, long); 81 82 void exit (int) __attribute__ ((__noreturn__)); 82 83 char *getenv (__const__ char *); 83 ldiv_t ldiv (long, long);84 84 int mblen (__const__ char *, size_t); 85 85 size_t mbstowcs (wchar_t *, __const__ char *, size_t); … … 149 149 extern char **environ; 150 150 151 extern __const__ char * __const__ sys_errlist[];152 extern __const__ int sys_nerr;153 154 151 extern __const__ unsigned char _osminor; 155 152 extern __const__ unsigned char _osmajor; … … 159 156 160 157 unsigned alarm (unsigned); 161 int 158 int brk(const void *); 162 159 int chdir (__const__ char *); 163 160 char *gcvt (double, int, char *); … … 169 166 int putenv (__const__ char *); 170 167 int rmdir (__const__ char *); 171 void 168 void *sbrk(intptr_t); 172 169 unsigned sleep (unsigned); 173 170 void swab (__const__ void *, void *, size_t); … … 181 178 void srandom (unsigned); /* BSD */ 182 179 180 char *itoa (int, char *, int); 181 char *ltoa (long, char *, int); 182 char *ultoa (unsigned long, char *, int); 183 char *lltoa (long long, char *, int); 184 char *ulltoa (unsigned long long, char *, int); 185 183 186 #endif 184 187 … … 188 191 189 192 extern char **_environ; 190 extern __const__ char * __const__ _sys_errlist[];191 extern __const__ int _sys_nerr;192 193 193 194 unsigned _alarm (unsigned); 194 int 195 int _brk(const void *); 195 196 int _chdir (__const__ char *); 196 197 char *_gcvt (double, int, char *); … … 201 202 int _putenv (__const__ char *); 202 203 int _rmdir (__const__ char *); 203 void 204 void *_sbrk(intptr_t); 204 205 unsigned _sleep (unsigned); 205 206 void _swab (__const__ void *, void *, size_t); … … 217 218 void _exit (int) __attribute__ ((__noreturn__)); 218 219 int _filesys (__const__ char *, char *, size_t); 219 int _fncmp (__const__ unsigned char *, __const__ unsigned char *);220 220 char **_fnexplode (__const__ char *); 221 221 void _fnexplodefree (char **); … … 239 239 _lldiv_t _lldiv (long long, long long); 240 240 char *_lltoa (long long, char *, int); 241 _uldiv_t _uldiv (unsigned long, unsigned long); 242 _ulldiv_t _ulldiv (unsigned long long, unsigned long long); 243 char *_itoa (int, char *, int); 241 244 char *_ltoa (long, char *, int); 245 char *_ultoa (unsigned long, char *, int); 246 char *_lltoa (long long, char *, int); 247 char *_ulltoa (unsigned long long, char *, int); 242 248 void _makepath (char *, __const__ char *, __const__ char *, 243 249 __const__ char *, __const__ char *); … … 258 264 unsigned long long _strtoull (__const__ char *, char **, int); 259 265 char _swchar (void); 260 _uldiv_t _uldiv (unsigned long, unsigned long);261 _ulldiv_t _ulldiv (unsigned long long, unsigned long long);262 char *_ulltoa (unsigned long long, char *, int);263 char *_ultoa (unsigned long, char *, int);264 266 void _wildcard (int *, char ***); 265 267 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/sys/errno.h
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r493 r494 47 47 #define _SYS_ERRNO_H /* bird: emx */ 48 48 49 #if !defined(_KERNEL) && !defined(__ASSEMBLER__) && !defined(_ERRNO) /* bird: emx */ 50 #include <sys/cdefs.h> 51 __BEGIN_DECLS 52 #define _ERRNO /* bird: emx */ 53 extern int * _errno(void); /* bird: emx */ 54 __END_DECLS 55 #define errno (* _errno()) /* bird: emx */ 49 #if !defined (_ERRNO) && !defined (__ASSEMBLER__) 50 #define _ERRNO 51 extern int *_errno (void); 52 #define errno (*_errno ()) 53 #endif 54 55 #ifndef __ASSEMBLER__ 56 extern __const__ char * __const__ sys_errlist[]; 57 extern __const__ int sys_nerr; 56 58 #endif 57 59 … … 189 191 #endif /* _POSIX_SOURCE */ 190 192 191 #ifdef _KERNEL192 /* pseudo-errors returned inside kernel to modify return to process */193 #define ERESTART (-1) /* restart syscall */194 #define EJUSTRETURN (-2) /* don't modify regs, just return */195 #define ENOIOCTL (-3) /* ioctl not handled by this layer */196 #define EDIRIOCTL (-4) /* do direct ioctl in GEOM */197 193 #endif 198 199 #endif -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/sys/param.h
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r493 r494 180 180 #endif 181 181 182 #if defined (__cplusplus) && (__GNUC__ >= 2) 183 # define MIN(a,b) (((a)<?(b)) 184 #else 185 # define MIN(a,b) (((a)<(b))?(a):(b)) 186 #endif 187 #if defined (__cplusplus) && (__GNUC__ >= 2) 188 # define MAX(a,b) (((a)>?(b)) 189 #else 190 # define MAX(a,b) (((a)>(b))?(a):(b)) 191 #endif 182 192 183 193 #if defined (__cplusplus) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/utils.h
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r493 r494 44 44 #endif 45 45 46 #ifndef MIN 47 #define MIN(a,b) (((a)<(b))?(a):(b)) 48 #define imin(x,y) MIN((x),(y)) 49 #define MAX(a,b) (((a)>(b))?(a):(b)) 50 #endif 51 #ifndef min 52 #define min(a,b) (((a)<(b))?(a):(b)) 53 #endif 46 /* MIN/MAX */ 47 #include <sys/param.h> 54 48 /* timercmp */ 55 49 #include <sys/time.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/emxbind/emxbind.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r493 r494 471 471 file_name (out_fname, (dll_flag ? "dll" : "exe"), 472 472 (opt_o != NULL ? opt_o : inp_fname)); 473 if ( _fncmp (inp_fname, out_fname) == 0)473 if (strcasecmp (inp_fname, out_fname) == 0) 474 474 error ("The input and output files have the same name"); 475 475 break; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/emxbind/emxbind.h
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r493 r494 21 21 22 22 #include "a_out.h" 23 #include <sys/param.h> 23 24 24 25 #if defined (EXTERN) … … 432 433 433 434 #define round_4(X) ((((X)-1) & ~3) + 4) 434 435 /* Round up to the next multiple of the page size (0x1000). */436 437 #define round_page(X) ((((X)-1) & ~0xfff) + 0x1000)438 435 439 436 /* Divide by the page size, rounding down. */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/emxbind/exec.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r493 r494 106 106 static struct grow header = GROW_INIT; 107 107 108 109 /* Return the minimum of A and B. */110 111 #define min(a,b) (((a) < (b)) ? (a) : (b))112 108 113 109 /* Compute the virtual end address of a memory object of an LX … … 838 834 while (size > 0) 839 835 { 840 n = min(size, BUFSIZ);836 n = MIN (size, BUFSIZ); 841 837 my_read (buf, n, src); 842 838 my_write (buf, n, &out_file); … … 857 853 while (count > 0) 858 854 { 859 n = min(count, BUFSIZ);855 n = MIN (count, BUFSIZ); 860 856 my_write (buf, n, &out_file); 861 857 count -= n; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/emxcat/emxcat.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r493 r494 526 526 (FAT). */ 527 527 528 return _fncmp (*(const char * const *)p1,529 *(const char * const *)p2);528 return strcasecmp (*(const char * const *)p1, 529 *(const char * const *)p2); 530 530 } 531 531 … … 611 611 612 612 for (j = i; j < argc; ++j) 613 if ( _fncmp (output_fname, argv[j]) != 0)613 if (strcasecmp (output_fname, argv[j]) != 0) 614 614 read_file (argv[j], pass); 615 615 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/emxload/emxload.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r493 r494 336 336 337 337 for (i = 0; i < procs; ++i) 338 if (table[i].name != NULL && _fncmp (table[i].name, req->name) == 0)338 if (table[i].name != NULL && strcasecmp (table[i].name, req->name) == 0) 339 339 { 340 340 if (req->req_code != _EMXLOAD_LOAD) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/emxomf/emxomfar.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r493 r494 382 382 _remext (bak_fname); 383 383 _defext (bak_fname, "bak"); 384 if ( _fncmp (lib_fname, bak_fname) == 0)384 if (strcasecmp (lib_fname, bak_fname) == 0) 385 385 { 386 386 fprintf (stderr, "Cannot update backup file\n"); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/alias/alias.smak
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r493 r494 27 27 @$(call DO.STDALIAS,_strcasecmp,__std_stricmp,$.strcasecmp.o) 28 28 @$(call DO.STDALIAS,_strncasecmp,__std_strnicmp,$.strncasecmp.o) 29 @$(call DO.STDALIAS,_itoa,__std_ltoa,$.itoa.o) 30 @$(call DO.STDALIAS,__itoa,__std_ltoa,$._itoa.o) 29 31 @$(foreach x,$(ALIAS.FUNCS),\ 30 32 $(call DO.STDALIAS,_$x,__std_$x,$.$x.o)$(NL)) … … 32 34 $(call DO.STDALIAS,__$x,__std_$x,$._$x.o)$(NL)) 33 35 $(AR) $(ARFLAGS) $@ $(addprefix $.,\ 34 strcasecmp.o strncasecmp.o \36 strcasecmp.o strncasecmp.o itoa.o _itoa.o \ 35 37 $(addsuffix .o,$(ALIAS.FUNCS) $(addprefix _,$(ALIAS._FUNCS)))) 36 38 @$(call RM,$(addprefix $., \ 37 strcasecmp.o strncasecmp.o \39 strcasecmp.o strncasecmp.o itoa.o _itoa.o \ 38 40 $(addsuffix .o,$(ALIAS.FUNCS) $(addprefix _,$(ALIAS._FUNCS))))) 39 41 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/conv/atod.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r493 r494 1 1 /* atod.c (emx+gcc) -- Copyright (c) 1996-1998 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS 3 4 #include "libc-alias.h" 4 5 #include <stdlib.h> … … 11 12 #include <emx/bigint.h> 12 13 #include <emx/float.h> 13 #include < emx/locale.h>14 #include <sys/locale.h> 14 15 15 16 #define BBITS (LDBL_MAX_EXP + LDBL_MANT_DIG - LDBL_MAX_10_EXP \ … … 21 22 #define MAX2 (_BI_WORDMAX - 10 * MAX1) 22 23 23 #define DOT (unsigned char)_ cur_lconv.decimal_point[0]24 #define DOT (unsigned char)__locale_lconv.decimal_point[0] 24 25 25 26 const char * __atod (long double *p_result, const char *string, -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/conv/dtoa.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r493 r494 7 7 #include <assert.h> 8 8 #include <sys/builtin.h> 9 #include <sys/param.h> 9 10 #include <emx/float.h> 10 11 #include <emx/bigint.h> … … 12 13 #define BWORDS _BI_WORDS (LDBL_MAX_EXP) 13 14 #define BIAS 16383 14 15 #define MIN(a,b) ((a) < (b) ? (a) : (b))16 15 17 16 struct long_double_bits -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/conv/gcvt.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r493 r494 1 1 /* gcvt.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS 3 4 #include "libc-alias.h" 4 5 #include <stdlib.h> … … 8 9 #include <locale.h> 9 10 #include <emx/float.h> 10 #include < emx/locale.h>11 #include <sys/locale.h> 11 12 12 13 char *_STD(gcvt) (double x, int digits, char *buffer) … … 81 82 *dst++ = str[0]; 82 83 if (str[1] != 0) 83 *dst++ = _ cur_lconv.decimal_point[0];84 *dst++ = __locale_lconv.decimal_point[0]; 84 85 for (src = str+1; *src != 0; ++src) 85 86 *dst++ = *src; … … 111 112 { 112 113 if (i == xp + 1) 113 *dst++ = _ cur_lconv.decimal_point[0];114 *dst++ = __locale_lconv.decimal_point[0]; 114 115 *dst++ = str[i]; 115 116 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/conv/lltoa.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r493 r494 1 /* lltoa.c (emx+gcc) -- Copyright (c) 1990-1995 by Eberhard Mattes */ 1 /* 2 Integer to ASCII conversion routines. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 4 5 For conditions of distribution and use, see the file COPYING. 6 7 long long -> ascii conversion routine. 8 */ 2 9 3 10 #include "libc-alias.h" 4 11 #include <stdlib.h> 12 #include <386/builtin.h> 5 13 6 char *_lltoa (long long value, char *string, int radix) 14 extern const char *__digits; 15 16 char *_STD(lltoa) (long long value, char *string, int radix) 7 17 { 8 18 char *dst; 9 19 char digits[64]; 10 20 unsigned long long x; 11 int i, n; 12 21 int i; 22 long rem; 23 13 24 dst = string; 14 25 if (radix < 2 || radix > 36) 15 16 17 18 19 if ( radix == 10 && value < 0)20 21 22 23 26 { 27 *dst = 0; 28 return string; 29 } 30 if ((value < 0) && (radix == 10)) 31 { 32 *dst++ = '-'; 33 x = -value; 34 } 24 35 else 25 36 x = value; 37 26 38 i = 0; 27 39 do 28 29 n = x % radix;30 digits[i++] = (n < 10 ? (char)n+'0' : (char)n-10+'a');31 x /= radix;32 } while (x != 0); 40 { 41 x = __ulldivmod (x, radix, &rem); 42 digits [i++] = __digits [rem]; 43 } while (x != 0); 44 33 45 while (i > 0) 34 46 *dst++ = digits[--i]; 47 35 48 *dst = 0; 36 49 return string; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/conv/ltoa.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r493 r494 1 /* ltoa.c (emx+gcc) -- Copyright (c) 1990-1995 by Eberhard Mattes */ 1 /* 2 Integer to ASCII conversion routines. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 4 5 For conditions of distribution and use, see the file COPYING. 6 7 long (AKA int) -> ascii conversion routine. 8 */ 2 9 3 10 #include "libc-alias.h" 4 11 #include <stdlib.h> 12 #include <386/builtin.h> 5 13 6 char *_ltoa (long value, char *string, int radix) 14 extern const char *__digits; 15 16 char *_STD(ltoa) (long value, char *string, int radix) 7 17 { 18 int i; 8 19 char *dst; 9 20 char digits[32]; 10 unsigned long x; 11 int i, n; 12 21 unsigned long rem; 22 13 23 dst = string; 14 24 if (radix < 2 || radix > 36) 15 { 16 *dst = 0; 17 return string; 18 } 19 if (radix == 10 && value < 0) 20 { 21 *dst++ = '-'; 22 x = -value; 23 } 24 else 25 x = value; 25 { 26 *dst = 0; 27 return string; 28 } 29 if ((value < 0) && (radix == 10)) 30 { 31 *dst++ = '-'; 32 value = -value; 33 } 34 26 35 i = 0; 27 36 do 28 29 n = x % radix;30 digits[i++] = (n < 10 ? (char)n+'0' : (char)n-10+'a');31 x /= radix;32 } while (x != 0); 37 { 38 value = __uldivmod (value, radix, &rem); 39 digits [i++] = __digits [rem]; 40 } while (value); 41 33 42 while (i > 0) 34 43 *dst++ = digits[--i]; 44 35 45 *dst = 0; 36 46 return string; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/conv/smalatod.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r493 r494 1 1 /* smalatod.c (emx+gcc) -- Copyright (c) 1990-1996 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS 3 4 #include "libc-alias.h" 4 5 #include <stdlib.h> … … 9 10 #include <errno.h> 10 11 #include <emx/float.h> 11 #include < emx/locale.h>12 #include <sys/locale.h> 12 13 13 14 … … 102 103 for (;;) 103 104 { 104 if (*s == (unsigned char)_ cur_lconv.decimal_point[0] && !dot)105 if (*s == (unsigned char)__locale_lconv.decimal_point[0] && !dot) 105 106 { 106 107 dot = 1; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/conv/ulltoa.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r493 r494 1 /* ulltoa.c (emx+gcc) -- Copyright (c) 1990-1995 by Eberhard Mattes */ 1 /* 2 Integer to ASCII conversion routines. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 4 5 For conditions of distribution and use, see the file COPYING. 6 7 unsigned long long -> ascii conversion routine. 8 */ 2 9 3 10 #include "libc-alias.h" 4 11 #include <stdlib.h> 12 #include <386/builtin.h> 5 13 6 char *_ulltoa (unsigned long long value, char *string, int radix) 14 extern const char *__digits; 15 16 char *_STD(ulltoa) (unsigned long long value, char *string, int radix) 7 17 { 8 18 char *dst; 9 19 char digits[64]; 10 int i, n; 11 20 int i; 21 unsigned long rem; 22 12 23 dst = string; 13 24 if (radix < 2 || radix > 36) 14 { 15 *dst = 0; 16 return string; 17 } 25 { 26 *dst = 0; 27 return string; 28 } 29 18 30 i = 0; 19 31 do 20 21 n = value % radix;22 digits[i++] = (n < 10 ? (char)n+'0' : (char)n-10+'a');23 value /= radix;24 } while (value != 0); 32 { 33 value = __ulldivmod (value, radix, &rem); 34 digits [i++] = __digits [rem]; 35 } while (value != 0); 36 25 37 while (i > 0) 26 38 *dst++ = digits[--i]; 39 27 40 *dst = 0; 28 41 return string; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/conv/ultoa.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r493 r494 1 /* ultoa.c (emx+gcc) -- Copyright (c) 1990-1995 by Eberhard Mattes */ 1 /* 2 Integer to ASCII conversion routines. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 4 5 For conditions of distribution and use, see the file COPYING. 6 7 unsigned long (AKA unsigned int) -> ascii conversion routine. 8 */ 2 9 3 10 #include "libc-alias.h" 4 11 #include <stdlib.h> 12 #include <386/builtin.h> 5 13 6 char *_ultoa (unsigned long value, char *string, int radix) 14 extern const char *__digits; 15 16 char *_STD(ultoa) (unsigned long value, char *string, int radix) 7 17 { 18 int i; 8 19 char *dst; 9 20 char digits[32]; 10 int i, n;11 21 unsigned long rem; 22 12 23 dst = string; 13 24 if (radix < 2 || radix > 36) 14 { 15 *dst = 0; 16 return string; 17 } 25 { 26 *dst = 0; 27 return string; 28 } 29 18 30 i = 0; 19 31 do 20 21 n = value % radix;22 digits[i++] = (n < 10 ? (char)n+'0' : (char)n-10+'a');23 value /= radix;24 } while (value != 0); 32 { 33 value = __uldivmod (value, radix, &rem); 34 digits [i++] = __digits [rem]; 35 } while (value); 36 25 37 while (i > 0) 26 38 *dst++ = digits[--i]; 39 27 40 *dst = 0; 28 41 return string; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_input.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r493 r494 1 1 /* _input.c (emx+gcc) -- Copyright (c) 1990-2000 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS 3 4 #include "libc-alias.h" 4 5 #include <stdio.h> … … 9 10 #include <limits.h> 10 11 #include <locale.h> 11 #include < emx/locale.h>12 #include <sys/locale.h> 12 13 #include <emx/io.h> 13 14 #include "getputc.h" … … 476 477 c = get (v); 477 478 } 478 if (c == (unsigned char)_ cur_lconv.decimal_point[0])479 if (c == (unsigned char)__locale_lconv.decimal_point[0]) 479 480 { 480 481 COLLECT (c); … … 594 595 differs from one comprising the directive, the directive 595 596 fails, and the differing and subsequent characters remain 596 unread." 597 598 Avoid the overhead of calling mblen(). */ 599 600 if (f <= 127 || _cur_mbyte.mode == _MB_8BITS) 597 unread." */ 598 599 if (!CHK_MBCS_PREFIX (__locale_ctype, f, mbn)) 601 600 mbn = 1; 602 else603 {604 mbn = _mbtowc (NULL, format, MB_LEN_MAX, &shift);605 if (mbn < 1)606 mbn = 1; /* Treat an invalid character as is */607 }608 601 for (mbi = 0; mbi < mbn; ++mbi) 609 602 { -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_output.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r493 r494 1 1 /* _output.c (emx+gcc) -- Copyright (c) 1990-2000 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS 3 4 #include "libc-alias.h" 4 5 #include <stdio.h> … … 12 13 #include <emx/io.h> 13 14 #include <emx/float.h> 14 #include < emx/locale.h>15 #include <sys/locale.h> 15 16 #include "getputc.h" 16 17 … … 395 396 /* Cases (1) through (4). We print "0." followed by 396 397 397 min(-xp - 1, v->prec)398 MIN (-xp - 1, v->prec) 398 399 399 400 zeros and the string of digit. */ … … 703 704 v.stream = stream; 704 705 v.count = 0; 705 zdot[1] = _ cur_lconv.decimal_point[0];706 zdot[1] = __locale_lconv.decimal_point[0]; 706 707 707 708 /* ANSI X3.159-1989, 4.9.6.1: "The format shall be a multibyte … … 722 723 Avoid the overhead of calling mblen(). */ 723 724 724 if (c <= 127 || _cur_mbyte.mode == _MB_8BITS) 725 if (!CHK_MBCS_PREFIX (__locale_ctype, c, mbn)) 726 mbn = 1; 727 while (mbn > 0) 725 728 { 726 PUTC (&v, c); 727 ++format; 728 } 729 else 730 { 731 mbn = _mbtowc (NULL, format, MB_LEN_MAX, &shift); 732 if (mbn < 1) 733 mbn = 1; /* Output an invalid character as is */ 734 while (mbn > 0) 735 { 736 PUTC (&v, *format); 737 ++format; --mbn; 738 } 729 PUTC (&v, *format); 730 ++format; --mbn; 739 731 } 740 732 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/_trslash.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r493 r494 1 1 /* _trslash.c (emx+gcc) -- Copyright (c) 1996 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS 3 4 #include "libc-alias.h" 4 #include <sys/nls.h>5 5 #include <emx/io.h> 6 #include <sys/locale.h> 6 7 7 8 /* Detect trailing slash or backslash for stat(), access(), and … … 17 18 int _trslash (const char *name, size_t len, int mode) 18 19 { 19 size_t i ;20 size_t i, mbcl; 20 21 21 22 switch (mode) … … 59 60 for (;;) 60 61 { 61 if ( _nls_is_dbcs_lead ((unsigned char)name[i]))62 if (CHK_MBCS_PREFIX (__locale_ctype, name[i], mbcl)) 62 63 { 63 if (i == len - 3)64 if (i == len - 1 - mbcl) 64 65 { 65 66 /* Case (c) -- a DBCS character precedes the trailing … … 67 68 return 1; 68 69 } 69 else if (i == len - 2)70 else if (i == len - mbcl) 70 71 { 71 72 /* Case (d) -- the last byte is the 2nd byte of a DBCS … … 74 75 } 75 76 else 76 i += 2;77 i += mbcl; 77 78 } 78 79 else if (i == len - 2) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/fread.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r493 r494 5 5 #include <sys/fmutex.h> /* For <sys/rmutex.h> */ 6 6 #include <sys/rmutex.h> 7 #include <sys/param.h> 7 8 #include <stdio.h> 8 9 #include <stdlib.h> … … 11 12 #include <errno.h> 12 13 #include <emx/io.h> 13 14 #define min(a,b) (((a) < (b)) ? (a) : (b))15 14 16 15 size_t _STD(fread) (void *buffer, size_t size, size_t count, FILE *stream) … … 42 41 if (stream->_rcount > 0) 43 42 { 44 n = min((size_t)stream->_rcount, left);43 n = MIN ((size_t)stream->_rcount, left); 45 44 memcpy (dst, stream->_ptr, n); 46 45 stream->_ptr += n; … … 83 82 if (stream->_rcount > 0) 84 83 { 85 n = min((size_t)stream->_rcount, left);84 n = MIN ((size_t)stream->_rcount, left); 86 85 memcpy (dst, stream->_ptr, n); 87 86 stream->_ptr += n; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/io/select.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r493 r494 9 9 #include <emx/io.h> 10 10 #include <emx/syscalls.h> 11 12 #define MIN(a,b) (((a) < (b)) ? (a) : (b))13 11 14 12 int _STD(select) (int nfds, fd_set *readfds, fd_set *writefds, -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/libc.def
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r493 r494 30 30 "__lookahead" @10 31 31 "__mb_cur_max" @11 32 "__nls_ctype_tab" @1233 "__nls_tolower_tab" @1334 "__nls_toupper_tab" @1435 32 "__org_environ" @15 36 33 "__osmajor" @16 … … 225 222 "___fmutex_release_internal" @249 226 223 "___fmutex_request_internal" @250 227 "__fncmp" @251228 224 "__fnexplode" @252 229 225 "__fnexplodefree" @253 … … 334 330 "___newthread" @358 335 331 "__nfiles" @359 336 "___nls_ctype" @360337 "__nls_ctype_init" @361338 "__nls_init" @362339 "___nls_memupr" @363340 "__nls_strlwr" @364341 "__nls_strupr" @365342 "__nls_tolower_init" @366343 "__nls_toupper_init" @367344 332 "___open" @368 345 333 "__openstream" @369 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/libc.smak
-
Property cvs2svn:cvs-rev
changed from
1.16
to1.17
r493 r494 153 153 $(call CP,$^,$(dir $@)) 154 154 155 156 155 # How libc-std.h can be auto-generated. 157 156 # Unfortunately, we cannot use c.a to find out all _std_ names since -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/mbyte/mbcurmax.c
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r493 r494 1 /* mbcurmax.c (emx+gcc) -- Copyright (c) 1994 by Eberhard Mattes */ 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 4 5 For conditions of distribution and use, see the file COPYING. 6 7 This file contains the _mb_cur_max variable which is the maximal 8 length of a multibyte character (depends on LC_CTYPE locale setting). 9 Accessed through MB_CUR_MAX macro defined in <stdlib.h>. 10 */ 2 11 3 12 #include <stdlib.h> -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/mbyte/mblen.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r493 r494 1 /* mblen.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 2 4 5 For conditions of distribution and use, see the file COPYING. 6 7 Compute the number of bytes comprising the multibyte character pointed 8 to by s. If s is NULL, the shift state is reset to the initial state. 9 At most n bytes at s are examined; a multibyte character consisting of 10 more than n bytes is deemed invalid. 11 12 If s is NULL, mblen() returns a non-zero value (if state-dependent encoding 13 is used) or a zero value (if state-dependent encoding is not used). 14 If s is not NULL, mblen() returns 0 (if s points to the null character), 15 the number of bytes comprising the multibyte character pointed to by s 16 (if there is a valid multibyte character), or -1 (if there is not a valid 17 multibyte character). 18 19 Affected by LC_CTYPE locale setting. 20 21 BUGS: Currently shift states between calls to multibyte/widechar 22 functions are lost. 23 */ 24 25 #define __INTERNAL_DEFS 3 26 #include "libc-alias.h" 4 #include <stdlib.h> 5 #include <emx/thread.h> 6 #include <emx/locale.h> 27 #include <sys/locale.h> 7 28 8 29 int _STD(mblen) (const char *s, size_t n) 9 30 { 10 struct _thread *tp = _thread (); 11 12 if (s == NULL) 13 { 14 if (_cur_mbyte.mode == _MB_SHIFT) 15 { 16 tp->_th_mblen_shift = 0; 17 return 1; /* State dependency */ 18 } 19 else 20 return 0; /* No state dependency */ 21 } 22 return _mbtowc (NULL, s, n, &tp->_th_mblen_shift); 31 int pl; 32 if (!n) 33 return -1; 34 CHK_MBCS_PREFIX (__locale_ctype, *s, pl); 35 return pl ? pl : -1; 23 36 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/mbyte/mbstowcs.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r493 r494 1 /* mbstowcs.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 2 4 5 For conditions of distribution and use, see the file COPYING. 6 7 Convert the null-terminated sequence of multibyte character pointed to 8 by s to a sequence of wchar_t codes pointed to by pwcs. The multibyte 9 character sequence starts in the initial shift state. At most n codes 10 are stored to pwcs. pwcs will be terminated with a code of value zero 11 if n is big enough. 12 13 The shift state of mbtowc() and mblen() is not affected. 14 15 mbstowcs() returns the number of codes stored to pwcs (excluding the 16 terminating zero code) or (size_t)-1 if an invalid multibyte character 17 is encountered. 18 19 Affected by LC_CTYPE locale setting. 20 21 BUGS: Currently shift states between calls to multibyte/widechar 22 functions are lost. 23 */ 24 25 #define __INTERNAL_DEFS 3 26 #include "libc-alias.h" 4 #include <stdlib.h> 5 #include <limits.h> 6 #include <emx/locale.h> 27 #include <sys/locale.h> 28 #include <string.h> 7 29 8 30 size_t _STD(mbstowcs) (wchar_t *pwcs, const char *s, size_t n) 9 31 { 10 int shift, i; 11 size_t result; 32 size_t nonid, sl = strlen (s) + 1, nw = n; 12 33 13 shift = 0; result = 0; 14 switch (_cur_mbyte.mode) 15 { 16 case _MB_8BITS: 17 while (*s != 0 && n != 0) 18 { 19 pwcs[result++] = (unsigned char)*s++; 20 --n; 21 } 22 break; 34 if (UniUconvToUcs (__locale_ctype.uconv, (void *)&s, &sl, &pwcs, 35 &nw, &nonid)) 36 return -1; 23 37 24 default: 25 while (*s != 0 && n != 0) 26 { 27 i = _mbtowc (pwcs + result, s, MB_LEN_MAX, &shift); 28 if (i < 1) 29 return (size_t)-1; 30 s += i; ++result; --n; 31 } 32 break; 33 } 34 35 if (n != 0) 36 pwcs[result] = 0; 37 return result; 38 return n - nw - 1; 38 39 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/mbyte/mbtowc.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r493 r494 1 /* mbtowc.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 2 4 5 For conditions of distribution and use, see the file COPYING. 6 7 Convert the multibyte character pointed to by s to a wchar_t code and 8 store it to pwc. If s is NULL, the shift state is reset to the initial 9 state. At most n bytes at s are examined; a multibyte character consisting 10 of more than n bytes is deemed invalid. 11 12 The shift state of mblen() is not affected. 13 14 If s is NULL, mbtowc() returns a non-zero value (if state-dependent 15 encoding is used) or a zero value (if state-dependent encoding is not used). 16 If s is not NULL, mbtowc() returns 0 (if s points to the null character), 17 the number of bytes comprising the multibyte character pointed to by s 18 (if there is a valid multibyte character), or -1 (if there is not a valid 19 multibyte character). 20 21 Affected by LC_CTYPE locale setting. 22 23 BUGS: Currently shift states between calls to multibyte/widechar 24 functions are lost. 25 */ 26 27 #define __INTERNAL_DEFS 3 28 #include "libc-alias.h" 4 #include <stdlib.h> 5 #include <emx/thread.h> 6 #include <emx/locale.h> 29 #include <sys/locale.h> 30 #include <string.h> 7 31 8 32 int _STD(mbtowc) (wchar_t *pwc, const char *s, size_t n) 9 33 { 10 struct _thread *tp = _thread (); 34 size_t nonid, ni = n, no = 1; 35 int rc; 11 36 12 if (s == NULL) 13 { 14 if (_cur_mbyte.mode == _MB_SHIFT) 15 { 16 tp->_th_mbtowc_shift = 0; 17 return 1; /* State dependency */ 18 } 19 else 20 return 0; /* No state dependency */ 21 } 22 return _mbtowc (pwc, s, n, &tp->_th_mbtowc_shift); 37 if (!s) 38 return 0; /* No state dependency */ 39 40 rc = UniUconvToUcs (__locale_ctype.uconv, (void *)&s, &ni, &pwc, &no, &nonid); 41 42 if ((rc == 0) || (rc == UCONV_E2BIG)) 43 return n - ni; 44 45 return -1; 23 46 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/mbyte/wcstombs.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r493 r494 1 /* wcstombs.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 2 4 5 For conditions of distribution and use, see the file COPYING. 6 7 Convert the zero-terminated sequence of wchar_t codes at pwcs to a 8 multibyte character sequence beginning at s. The multibyte character 9 sequence starts in the initial shift state. At most n bytes are stored. 10 s will be terminated with a null character if n is big enough. 11 12 The shift state of wctomb() is not affected. 13 14 wcstombs() returns the number of bytes stored to s (excluding the 15 terminating null character) or (size_t_t)-1 if a code could not be 16 counverted. 17 18 Affected by LC_CTYPE locale setting. 19 20 BUGS: Currently shift states between calls to multibyte/widechar 21 functions are lost. 22 */ 23 24 #define __INTERNAL_DEFS 3 25 #include "libc-alias.h" 4 #include <stdlib.h> 5 #include <ctype.h> 6 #include <emx/locale.h> 26 #include <sys/locale.h> 27 #include <string.h> 7 28 8 29 size_t _STD(wcstombs) (char *s, const wchar_t *pwcs, size_t n) 9 30 { 10 size_t result; 11 wchar_t wc; 12 int shift, i; 31 size_t nonid, sl = UniStrlen (pwcs) + 1, nw = n; 13 32 14 shift = 0; result = 0; 15 switch (_cur_mbyte.mode) 16 { 17 case _MB_8BITS: 18 while (n != 0 && *pwcs != 0) 19 { 20 wc = *pwcs++; 21 if (wc > 255) /* wchar_t is unsigned */ 22 return (size_t)-1; 23 s[result++] = (char)wc; 24 --n; 25 } 26 break; 33 if (UniUconvFromUcs (__locale_ctype.uconv, (UniChar **)&pwcs, &sl, 34 (void *)&s, &nw, &nonid)) 35 return -1; 27 36 28 default: 29 while (n != 0 && *pwcs != 0) 30 { 31 i = _wctomb (s + result, *pwcs++, n, &shift); 32 if (i < 1) 33 return (size_t)-1; 34 result += i; n -= i; 35 } 36 break; 37 } 38 39 /* ANSI X3.159-1989, 4.10.8.2: "Otherwise, the wcstombs function 40 returns the number of bytes modified, not including a terminating 41 null character, if any." */ 42 43 if (n != 0) 44 s[result] = 0; 45 return result; 37 return n - nw - 1; 46 38 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/mbyte/wctomb.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r493 r494 1 /* wctomb.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */ 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 2 4 5 For conditions of distribution and use, see the file COPYING. 6 7 Convert the wchar_t code wchar to a multibyte character sequence pointed 8 to by s.At most MB_CUR_MAX bytes are stored. If s is NULL, the shift state 9 is reset to the initial state. If wchar is zero, the shift state is the 10 initial state after return from wctomb(). 11 12 If s is NULL, wctomb() returns a non-zero value (if state-dependent 13 encoding is used) or a zero value (if state-dependent encoding is not used). 14 If s is not NULL, wctomb() returns 0 (if wchar is zero), the number of 15 bytes comprising the multibyte character stored to s (if conversion is 16 successful), or -1 (if wchar could not be converted). 17 */ 18 19 #define __INTERNAL_DEFS 3 20 #include "libc-alias.h" 21 #include <sys/locale.h> 4 22 #include <stdlib.h> 5 #include <limits.h>6 #include <emx/thread.h>7 #include <emx/locale.h>8 23 9 24 int _STD(wctomb) (char *s, wchar_t wchar) 10 25 { 11 struct _thread *tp = _thread (); 26 UniChar *ucs = &wchar; 27 size_t nonid, ni = 1, no = MB_CUR_MAX; 12 28 13 if (s == NULL) 14 { 15 if (_cur_mbyte.mode == _MB_SHIFT) 16 { 17 tp->_th_wctomb_shift = 0; 18 return 1; /* State dependency */ 19 } 20 else 21 return 0; /* No state dependency */ 22 } 23 return _wctomb (s, wchar, MB_LEN_MAX, &tp->_th_wctomb_shift); 29 if (!s) 30 return 0; /* No state dependency */ 31 32 if (UniUconvFromUcs (__locale_ctype.uconv, &ucs, &ni, (void **)&s, &no, &nonid)) 33 return -1; 34 35 return MB_CUR_MAX - no; 24 36 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/abspath.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r493 r494 1 1 /* abspath.c (emx+gcc) -- Copyright (c) 1992-1998 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS 3 4 #include "libc-alias.h" 4 5 #include <stdlib.h> … … 7 8 #include <errno.h> 8 9 #include <sys/param.h> 9 #include <sys/nls.h>10 10 #include <emx/syscalls.h> 11 #include <sys/locale.h> 11 12 12 13 #define FALSE 0 … … 17 18 { 18 19 char drive, dir[MAXPATHLEN+1], src_drive, *s, *p; 19 int i, j, rel, server, trail ;20 int i, j, rel, server, trail, mbcl; 20 21 21 22 s = alloca (strlen (src) + 1); … … 71 72 while (*s != 0) 72 73 { 73 if ( _nls_is_dbcs_lead ((unsigned char)*s) && s[1] != 0)74 if (CHK_MBCS_PREFIX (__locale_ctype, *s, mbcl) && s[1] != 0) 74 75 { 75 if (i < sizeof (dir) - 2)76 if (i < sizeof (dir) - mbcl) 76 77 { 77 dir[i++] = s[0];78 dir[i++] = s[1];78 memcpy (dir + i, s, mbcl); 79 i += mbcl; 79 80 } 80 s += 2;81 s += mbcl; 81 82 } 82 83 else if (IS_PATH_DELIM (*s)) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/defext.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r493 r494 1 1 /* defext.c (emx+gcc) -- Copyright (c) 1990-1996 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS 3 4 #include "libc-alias.h" 4 5 #include <stdlib.h> 5 6 #include <string.h> 6 #include <sys/nls.h> 7 8 /* Note that _nls_is_dbcs_lead() returns false for all characters if 9 _nls_init() has not been called. In consequence, this function 10 works properly for SBCS strings even if _nls_init() has not been 11 called. */ 12 13 /* Note: This function is used by emx.dll. */ 7 #include <sys/locale.h> 14 8 15 9 #define FALSE 0 … … 18 12 void _defext (char *dst, const char *ext) 19 13 { 20 int dot, sep ;14 int dot, sep, mbcl; 21 15 22 16 dot = FALSE; sep = TRUE; 23 17 while (*dst != 0) 24 if ( _nls_is_dbcs_lead ((unsigned char)*dst))18 if (CHK_MBCS_PREFIX (__locale_ctype, *dst, mbcl)) 25 19 { 26 20 if (dst[1] == 0) /* Invalid DBCS character */ 27 21 return; 28 dst += 2;22 dst += mbcl; 29 23 sep = FALSE; 30 24 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/dtsort.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r493 r494 7 7 #include <sys/dirent.h> 8 8 #include <sys/dirtree.h> 9 #include <sys/nls.h>10 9 11 10 … … 73 72 if (ext2 == NULL && ext1 != NULL) 74 73 return 1; 75 d = _fncmp (ext1, ext2);74 d = strcasecmp (ext1, ext2); 76 75 if (d == 0) 77 76 d = strcmp (ext1, ext2); … … 85 84 int d; 86 85 87 d = _fncmp (n1->name, n2->name);86 d = strcasecmp (n1->name, n2->name); 88 87 if (d == 0) 89 88 d = strcmp (n1->name, n2->name); -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/fnmatch.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r493 r494 1 1 /* fnmatch.c (emx+gcc) -- Copyright (c) 1994-1998 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS 3 4 #include "libc-alias.h" 4 5 #include <string.h> 5 6 #include <ctype.h> 6 7 #include <emx/fnmatch.h> 7 #include <sys/ nls.h>8 #include <sys/locale.h> 8 9 9 10 /* In OS/2 and DOS styles, both / and \ separate components of a path. … … 25 26 static const unsigned char *skip_comp_os2 (const unsigned char *src) 26 27 { 28 /* Correct reading: em-be-ce-el :-) */ 29 int mbcl; 27 30 /* Skip characters until hitting a separator or the end of the 28 31 string. */ 29 32 30 33 while (!IS_OS2_COMP_END (*src)) 31 if ( _nls_is_dbcs_lead (*src) && src[1] != 0)32 src += 2;34 if (CHK_MBCS_PREFIX (__locale_ctype, *src, mbcl) && src[1] != 0) 35 src += mbcl; 33 36 else 34 37 ++src; … … 46 49 static int has_colon (const unsigned char *p) 47 50 { 51 int mbcl; 52 48 53 while (*p != 0) 49 54 if (*p == ':') 50 55 return 1; 51 else if ( _nls_is_dbcs_lead (p[0]) && p[1] != 0)52 p += 2;56 else if (CHK_MBCS_PREFIX (__locale_ctype, p[0], mbcl) && p[1] != 0) 57 p += mbcl; 53 58 else 54 59 ++p; … … 70 75 unsigned flags, int has_dot) 71 76 { 72 int rc ;77 int rc, mbcl; 73 78 74 79 for (;;) 75 if ( _nls_is_dbcs_lead (*mask) && mask[1] != 0)80 if (CHK_MBCS_PREFIX (__locale_ctype, *mask, mbcl) && mask[1] != 0) 76 81 { 77 /* DBCS characters match themselves. */ 78 79 if (mask[0] != name[0] || mask[1] != name[1]) 82 if (memicmp (mask, name, mbcl)) 80 83 return FNM_NOMATCH; 81 mask += 2; name += 2;84 mask += mbcl; name += mbcl; 82 85 } 83 86 else … … 122 125 if (*name != '.' && !IS_OS2_COMP_END (*name)) 123 126 { 124 if ( _nls_is_dbcs_lead (name[0]) && name[1] != 0)125 name += 2;127 if (CHK_MBCS_PREFIX (__locale_ctype, name[0], mbcl) && name[1] != 0) 128 name += mbcl; 126 129 else 127 130 ++name; … … 148 151 if (*name == '.' && (flags & _FNM_STYLE_MASK) == _FNM_DOS) 149 152 return FNM_NOMATCH; 150 if ( _nls_is_dbcs_lead (name[0]) && name[1] != 0)151 name += 2;153 if (CHK_MBCS_PREFIX (__locale_ctype, name[0], mbcl) && name[1] != 0) 154 name += mbcl; 152 155 else 153 156 ++name; … … 172 175 if (flags & _FNM_IGNORECASE) 173 176 { 174 if ( _nls_tolower (*mask) != _nls_tolower (*name))177 if (tolower (*mask) != tolower (*name)) 175 178 return FNM_NOMATCH; 176 179 } … … 197 200 { 198 201 const unsigned char *s; 202 int mbcl; 199 203 200 204 switch (flags & _FNM_STYLE_MASK) … … 208 212 s = name; 209 213 while (!IS_OS2_COMP_END (*s) && *s != '.') 210 if ( _nls_is_dbcs_lead (s[0]) && s[1] != 0)211 s += 2;214 if (CHK_MBCS_PREFIX (__locale_ctype, s[0], mbcl) && s[1] != 0) 215 s += mbcl; 212 216 else 213 217 ++s; … … 245 249 char invert, matched; 246 250 const unsigned char *start; 247 int rc ;251 int rc, mbcl; 248 252 249 253 for (;;) 250 if ( _nls_is_dbcs_lead (*mask))254 if (CHK_MBCS_PREFIX (__locale_ctype, *mask, mbcl)) 251 255 { 252 /* DBCS characters match themselves. */ 253 254 if (mask[0] != name[0] || mask[1] != name[1]) 256 if (memicmp (mask, name, mbcl)) 255 257 return FNM_NOMATCH; 256 mask += 2; name += 2;258 mask += mbcl; name += mbcl; 257 259 } 258 260 else … … 285 287 return FNM_NOMATCH; 286 288 ++mask; 287 if ( _nls_is_dbcs_lead (name[0]) && name[1] != 0)288 name += 2;289 if (CHK_MBCS_PREFIX (__locale_ctype, name[0], mbcl) && name[1] != 0) 290 name += mbcl; 289 291 else 290 292 ++name; … … 313 315 if ((flags & FNM_PATHNAME) && IS_UNIX_COMP_SEP (*name)) 314 316 return FNM_NOMATCH; 315 if ( _nls_is_dbcs_lead (name[0]) && name[1] != 0)316 name += 2;317 if (CHK_MBCS_PREFIX (__locale_ctype, name[0], mbcl) && name[1] != 0) 318 name += mbcl; 317 319 else 318 320 ++name; … … 363 365 ++mask; invert = 1; 364 366 } 365 else if ( _nls_is_dbcs_lead (*name))367 else if (IS_MBCS_PREFIX (__locale_ctype, *name)) 366 368 { 367 369 /* DBCS characters can only match inverted sets. */ … … 382 384 383 385 c1 = *mask++; 384 if ( _nls_is_dbcs_lead (c1))386 if (IS_MBCS_PREFIX (__locale_ctype, c1)) 385 387 return _FNM_ERR; /* DBCS characters not supported in sets */ 386 388 if (!(flags & FNM_NOESCAPE) && c1 == '\\') … … 404 406 break; 405 407 c2 = *mask++; 406 if ( _nls_is_dbcs_lead (c2))408 if (IS_MBCS_PREFIX (__locale_ctype, c2)) 407 409 return _FNM_ERR; /* DBCS chars not supported in sets */ 408 410 } … … 437 439 if (*name != 0) 438 440 { 439 if ( _nls_is_dbcs_lead (name[0]) && name[1] != 0)440 name += 2;441 if (CHK_MBCS_PREFIX (__locale_ctype, name[0], mbcl) && name[1] != 0) 442 name += mbcl; 441 443 else 442 444 ++name; … … 467 469 if (flags & _FNM_IGNORECASE) 468 470 { 469 if ( _nls_tolower (*mask) != _nls_tolower (*name))471 if (tolower (*mask) != tolower (*name)) 470 472 return FNM_NOMATCH; 471 473 } … … 504 506 if (!(flags & _FNM_IGNORECASE)) 505 507 return FNM_NOMATCH; 506 if ( _nls_tolower (m_drive) != _nls_tolower (n_drive))508 if (tolower (m_drive) != tolower (n_drive)) 507 509 return FNM_NOMATCH; 508 510 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/fnslashi.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r493 r494 1 1 /* fnslashi.c (emx+gcc) -- Copyright (c) 1996 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS 3 4 #include "libc-alias.h" 4 5 #include <stdlib.h> 5 #include <sys/ nls.h>6 #include <sys/locale.h> 6 7 7 8 char *_fnslashify (char *name) 8 9 { 9 10 char *p; 11 int mbcl; 10 12 11 13 p = name; 12 14 while (*p != 0) 13 if ( _nls_is_dbcs_lead ((unsigned char)*p) && p[1] != 0)14 p += 2;15 if (CHK_MBCS_PREFIX (__locale_ctype, *p, mbcl) && p[1] != 0) 16 p += mbcl; 15 17 else if (*p == '\\') 16 18 *p++ = '/'; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/getext.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r493 r494 1 1 /* getext.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS 3 4 #include "libc-alias.h" 4 5 #include <stdlib.h> 5 6 #include <string.h> 6 #include <sys/nls.h> 7 8 /* Note that _nls_is_dbcs_lead() returns false for all characters if 9 _nls_init() has not been called. In consequence, this function 10 works properly for SBCS strings even if _nls_init() has not been 11 called. */ 7 #include <sys/locale.h> 12 8 13 9 #define FALSE 0 … … 16 12 char *_getext (const char *path) 17 13 { 18 int sep ;14 int sep, mbcl; 19 15 const char *dotp; 20 16 21 17 sep = TRUE; dotp = NULL; 22 18 while (*path != 0) 23 if ( _nls_is_dbcs_lead ((unsigned char)*path))19 if (CHK_MBCS_PREFIX (__locale_ctype, *path, mbcl)) 24 20 { 25 21 if (path[1] == 0) /* Invalid DBCS character */ 26 22 break; 27 path += 2;23 path += mbcl; 28 24 sep = FALSE; 29 25 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/getname.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r493 r494 1 1 /* getname.c (emx+gcc) -- Copyright (c) 1993-1996 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS 3 4 #include "libc-alias.h" 4 5 #include <stdlib.h> 5 6 #include <string.h> 6 #include <sys/nls.h> 7 8 /* Note that _nls_is_dbcs_lead() returns false for all characters if 9 _nls_init() has not been called. In consequence, this function 10 works properly for SBCS strings even if _nls_init() has not been 11 called. */ 12 13 /* Note: This function is used by emx.dll. */ 7 #include <sys/locale.h> 14 8 15 9 char *_getname (const char *path) 16 10 { 17 11 const char *p; 12 int mbcl; 18 13 19 14 p = path; 20 15 while (*path != 0) 21 if ( _nls_is_dbcs_lead ((unsigned char)*path))16 if (CHK_MBCS_PREFIX (__locale_ctype, *path, mbcl)) 22 17 { 23 18 if (path[1] == 0) /* Invalid DBCS character */ 24 19 break; 25 path += 2;20 path += mbcl; 26 21 } 27 22 else -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/makepath.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r493 r494 1 1 /* makepath.c (emx+gcc) -- Copyright (c) 1993-1996 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS 3 4 #include "libc-alias.h" 4 5 #include <stdlib.h> 5 #include <sys/nls.h> 6 #include <sys/locale.h> 7 #include <string.h> 6 8 7 9 void _makepath (char *dst, const char *drive, const char *dir, 8 10 const char *fname, const char *ext) 9 11 { 10 int n ;12 int n, mbcl; 11 13 char slash, last; 12 14 … … 22 24 while (n < _MAX_PATH - 1 && *dir != 0) 23 25 { 24 if ( _nls_is_dbcs_lead ((unsigned char)*dir))26 if (CHK_MBCS_PREFIX (__locale_ctype, *dir, mbcl)) 25 27 { 26 28 if (dir[1] == 0) 27 29 ++dir; /* Invalid DBCS character */ 28 else if (n + 1 < _MAX_PATH - 1)30 else if (n + mbcl < _MAX_PATH) 29 31 { 30 dst[n++] = *dir++;31 dst [n++] = *dir++;32 memcpy (dst, dir, mbcl); 33 dst += mbcl; dir += mbcl; 32 34 } 33 35 last = 0; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/perror.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r493 r494 4 4 #include <stdio.h> 5 5 #include <stdlib.h> 6 #include <sys/errno.h> 6 7 7 8 void _STD(perror) (const char *string) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/remext.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r493 r494 1 1 /* remext.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS 3 4 #include "libc-alias.h" 4 5 #include <stdlib.h> 5 6 #include <string.h> 6 #include <sys/nls.h> 7 8 /* Note that _nls_is_dbcs_lead() returns false for all characters if 9 _nls_init() has not been called. In consequence, this function 10 works properly for SBCS strings even if _nls_init() has not been 11 called. */ 7 #include <sys/locale.h> 12 8 13 9 #define FALSE 0 … … 16 12 void _remext (char *path) 17 13 { 18 int dot, sep ;14 int dot, sep, mbcl; 19 15 char *dotp; 20 16 21 17 dot = FALSE; sep = TRUE; dotp = NULL; 22 18 while (*path != 0) 23 if ( _nls_is_dbcs_lead ((unsigned char)*path))19 if (CHK_MBCS_PREFIX (__locale_ctype, *path, mbcl)) 24 20 { 25 21 if (path[1] == 0) /* Invalid DBCS character */ 26 22 break; 27 path += 2;23 path += mbcl; 28 24 sep = FALSE; 29 25 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/splitpat.c
-
Property cvs2svn:cvs-rev
changed from
1.2
to1.3
r493 r494 1 1 /* splitpath.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */ 2 2 3 #define __INTERNAL_DEFS 3 4 #include "libc-alias.h" 4 5 #include <stdlib.h> 5 6 #include <string.h> 6 #include <sys/nls.h> 7 8 #define min(a,b) (((a) < (b)) ? (a) : (b)) 7 #include <sys/param.h> 8 #include <sys/locale.h> 9 9 10 10 void _splitpath (const char *src, char *drive, char *dir, char *fname, 11 11 char *ext) 12 12 { 13 int i, j ;13 int i, j, mbcl; 14 14 15 15 i = 0; 16 16 while (src[i] != 0) 17 if ( _nls_is_dbcs_lead ((unsigned char)src[i]))17 if (CHK_MBCS_PREFIX (__locale_ctype, src[i], mbcl)) 18 18 { 19 19 if (src[i+1] == 0) /* Invalid DBCS character */ 20 20 break; 21 i += 2;21 i += mbcl; 22 22 } 23 23 else if (src[i] == ':') … … 29 29 { 30 30 if (drive != NULL) 31 _strncpy (drive, src, min(i+2, _MAX_DRIVE));31 _strncpy (drive, src, MIN (i+2, _MAX_DRIVE)); 32 32 src += i + 1; 33 33 } … … 37 37 i = 0; j = 0; 38 38 while (src[j] != 0) 39 if ( _nls_is_dbcs_lead ((unsigned char)src[j]))39 if (CHK_MBCS_PREFIX (__locale_ctype, src[j], mbcl)) 40 40 { 41 41 if (src[j+1] == 0) /* Invalid DBCS character */ 42 42 break; 43 j += 2;43 j += mbcl; 44 44 } 45 45 else if (src[j] == '/' || src[j] == '\\') … … 49 49 50 50 if (dir != NULL) 51 _strncpy (dir, src, min(_MAX_DIR, i + 1));51 _strncpy (dir, src, MIN (_MAX_DIR, i + 1)); 52 52 src += i; 53 53 54 54 i = 0; j = 0; 55 55 while (src[j] != 0) 56 if ( _nls_is_dbcs_lead ((unsigned char)src[j]))56 if (CHK_MBCS_PREFIX (__locale_ctype, src[j], mbcl)) 57 57 { 58 58 if (src[j+1] == 0) /* Invalid DBCS character */ 59 59 break; 60 j += 2;60 j += mbcl; 61 61 } 62 62 else if (src[j] == '.') … … 68 68 i = j; 69 69 if (fname != NULL) 70 _strncpy (fname, src, min(_MAX_FNAME, i + 1));70 _strncpy (fname, src, MIN (_MAX_FNAME, i + 1)); 71 71 src += i; 72 72 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/process/beginthr.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r493 r494 25 25 1, /* _th_rand */ 26 26 NULL, /* _th_store */ 27 0, /* _th_mblen_shift */28 0, /* _th_mbtowc_shift */29 0, /* _th_wctomb_shift */30 27 "", /* _th_vollabel */ 31 28 "", /* _th_error */ -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/str/memicmp.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r493 r494 1 /* memicmp.c (emx+gcc) -- Copyright (c) 1990-1995 by Eberhard Mattes */ 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 2 4 5 For conditions of distribution and use, see the file COPYING. 6 7 Compare two memory areas case-insensitively. 8 */ 9 10 #define __INTERNAL_DEFS 3 11 #include "libc-alias.h" 4 #include <s tring.h>5 #include < ctype.h>12 #include <sys/locale.h> 13 #include <stddef.h> 6 14 7 int _STD(memicmp) (const void * s1, const void *s2, size_tn)15 int _STD(memicmp) (const void *m1, const void *m2, size_t len) 8 16 { 9 size_t i; 10 int d; 17 unsigned char c1; 18 unsigned char c2; 19 const unsigned char *s1 = (const unsigned char *)m1; 20 const unsigned char *s2 = (const unsigned char *)m2; 11 21 12 for (i = 0; i < n; ++i) 22 if (!len) 23 return 0; 24 25 c1 = *s1; c2 = *s2; 26 27 if (__locale_ctype.mbcs) 28 /* MBCS case. One additional memory lookup per character. */ 29 for (;;) 13 30 { 14 d = tolower (((unsigned char *)s1)[i]) 15 - tolower (((unsigned char *)s2)[i]); 16 if (d != 0) 17 { 18 if (d > 0) 19 return 1; 20 else 21 return -1; 22 } 23 } 24 return 0; 31 int d; 32 33 if (IS_MBCS_PREFIX (__locale_ctype, c1) 34 || IS_MBCS_PREFIX (__locale_ctype, c2)) 35 { 36 /* Translate unknown characters to Unicode, and compare them... 37 We perhaps should convert them back to MBCS, but anyway it is 38 not defined how memicmp should work on multi-byte characters... */ 39 UniChar uc1, uc2; 40 int c1l, c2l; 41 if (!(c1l = __to_ucs (__locale_ctype.uconv, s1, len, &uc1))) 42 uc1 = c1, c1l = 1; 43 else 44 uc1 = UniTransLower (__locale_ctype.locale, uc1); 45 if (!(c2l = __to_ucs (__locale_ctype.uconv, s2, len, &uc2))) 46 uc2 = c2, c2l = 1; 47 else 48 uc2 = UniTransLower (__locale_ctype.locale, uc2); 49 d = uc1 - uc2; 50 c1l--; c2l--; 51 s1 += c1l; s2 += c2l; 52 len -= c1l; 53 } 54 else 55 d = __locale_ctype.locase [c1] - __locale_ctype.locase [c2]; 56 if (d) 57 return d; 58 if (!--len) 59 return 0; 60 c1 = *++s1; 61 c2 = *++s2; 62 } /* endfor */ 63 else 64 /* SBCS case (faster). */ 65 for (;;) 66 { 67 int d = __locale_ctype.locase [c1] - __locale_ctype.locase [c2]; 68 if (d) 69 return d; 70 if (!--len) 71 return 0; 72 c1 = *++s1; 73 c2 = *++s2; 74 } /* endfor */ 75 76 /* This point never reached */ 25 77 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/str/strcoll.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r493 r494 1 /* strcoll.c (emx+gcc) -- Copyright (c) 1994-1995 by Eberhard Mattes */ 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 2 4 5 For conditions of distribution and use, see the file COPYING. 6 7 Compare two strings, interpreting every character as appropiate 8 to the LC_COLLATE category of the locale. The result of the comparison 9 is always in alphabetical order of selected language. 10 */ 11 12 #define __INTERNAL_DEFS 3 13 #include "libc-alias.h" 14 #include <sys/locale.h> 15 #include <alloca.h> 4 16 #include <string.h> 5 17 6 /* Ignore the current locale for now. */ 18 int _STD(strcoll) (const char *s1, const char *s2) 19 { 20 int i, d; 21 unsigned char c1 = *s1; 22 unsigned char c2 = *s2; 7 23 8 int _STD(strcoll) (const char *string1, const char *string2) 9 { 10 return strcmp (string1, string2); 24 if (__locale_collate.mbcs) 25 /* MBCS case. We compare the strings as usual, but as soon as we 26 encounter a MBCS character we translate the rests of the strings 27 to Unicode and continue comparation in Unicode. */ 28 for (;;) 29 { 30 if (IS_MBCS_PREFIX (__locale_collate, c1) 31 || IS_MBCS_PREFIX (__locale_collate, c2)) 32 { 33 /* Allright, we found a MBCS character. */ 34 UniChar *ucs [2]; 35 const char *sbcs [2] = { s1, s2 }; 36 37 /* I can't imagine X bytes to convert into more 38 than X unicode characters... */ 39 for (i = 0; i < 2; i++) 40 { 41 void *inbuf = (void *)sbcs [i]; 42 size_t sl = strlen (sbcs [i]) + 1; 43 size_t nonid, in_left = sl, out_left = sl; 44 UniChar *outbuf = ucs [i] = alloca (sl * sizeof (UniChar)); 45 46 if (UniUconvToUcs (__locale_collate.uconv, &inbuf, &in_left, &outbuf, 47 &out_left, &nonid)) 48 { 49 /* Oops, something bad happened (invalid character code). Suppose 50 the string that caused the fault is "less" than the other */ 51 return i * 2 - 1; 52 } 53 } 54 55 /* Okay, now we have two Unicode strings. Compare them. */ 56 return UniStrcoll (__locale_collate.locale, ucs [0], ucs [1]); 57 } 58 59 d = __locale_collate.weight [c1] - __locale_collate.weight [c2]; 60 if (d || !c1 || !c2) 61 return d; 62 c1 = *++s1; 63 c2 = *++s2; 64 } /* endfor */ 65 else 66 /* SBCS case (faster). */ 67 for (;;) 68 { 69 d = __locale_collate.weight [c1] - __locale_collate.weight [c2]; 70 if (d || !c1 || !c2) 71 return d; 72 c1 = *++s1; 73 c2 = *++s2; 74 } /* endfor */ 75 76 /* This point never achieved */ 11 77 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/str/strerror.c
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r493 r494 5 5 #include <string.h> 6 6 #include <emx/thread.h> 7 #include <sys/errno.h> 7 8 8 9 char *_STD(strerror) (int errnum) -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/str/stricmp.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r493 r494 1 /* stricmp.c (emx+gcc) -- Copyright (c) 1990-1995 by Eberhard Mattes */ 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 2 4 5 For conditions of distribution and use, see the file COPYING. 6 7 Compare two strings case-insensitively. 8 */ 9 10 #define __INTERNAL_DEFS 3 11 #include "libc-alias.h" 12 #include <sys/locale.h> 13 #include <alloca.h> 4 14 #include <string.h> 5 #include <ctype.h>6 15 7 int _STD(stricmp) (const char *string1, const char *string2)16 static int __strnlen (const char *s, int maxlen) 8 17 { 9 int d; 18 int sl = 0; 19 while (*s++ && maxlen--) 20 sl++; 21 return sl; 22 } 10 23 11 for (;;) 24 int _STD(stricmp) (__const__ char *s1, __const__ char *s2) 25 { 26 unsigned char c1 = *s1; 27 unsigned char c2 = *s2; 28 29 if (__locale_ctype.mbcs) 30 /* MBCS case. One additional memory lookup per character. */ 31 for (;;) 12 32 { 13 d = tolower ((unsigned char)*string1) 14 - tolower ((unsigned char)*string2); 15 if (d != 0 || *string1 == 0 || *string2 == 0) 33 int d; 34 35 if (IS_MBCS_PREFIX (__locale_ctype, c1) 36 || IS_MBCS_PREFIX (__locale_ctype, c2)) 37 { 38 /* Translate unknown characters to Unicode, and compare them... 39 We perhaps should convert them back to MBCS, but anyway it is 40 not defined how memicmp should work on multi-byte characters... */ 41 UniChar uc1, uc2; 42 int c1l, c2l; 43 if (!(c1l = __to_ucs (__locale_ctype.uconv, s1, __strnlen (s1, 3), &uc1))) 44 uc1 = c1, c1l = 1; 45 else 46 uc1 = UniTransLower (__locale_ctype.locale, uc1); 47 if (!(c2l = __to_ucs (__locale_ctype.uconv, s2, __strnlen (s2, 3), &uc2))) 48 uc2 = c2, c2l = 1; 49 else 50 uc2 = UniTransLower (__locale_ctype.locale, uc2); 51 d = uc1 - uc2; 52 s1 += c1l - 1; 53 s2 += c2l - 1; 54 } 55 else 56 d = __locale_ctype.locase [c1] - __locale_ctype.locase [c2]; 57 58 if (d || !c1 || !c2) 16 59 return d; 17 ++string1; ++string2; 18 } 60 c1 = *++s1; 61 c2 = *++s2; 62 } /* endfor */ 63 else 64 /* SBCS case (faster). */ 65 for (;;) 66 { 67 int d = __locale_ctype.locase [c1] - __locale_ctype.locase [c2]; 68 if (d || !c1 || !c2) 69 return d; 70 c1 = *++s1; 71 c2 = *++s2; 72 } /* endfor */ 73 74 /* This point never reached */ 19 75 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/str/strlwr.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r493 r494 1 /* strlwr.c (emx+gcc) -- Copyright (c) 1990-1995 by Eberhard Mattes */ 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 2 4 5 For conditions of distribution and use, see the file COPYING. 6 7 Lowercase an ASCIIZ string. 8 */ 9 10 #define __INTERNAL_DEFS 3 11 #include "libc-alias.h" 4 #include <string.h> 5 #include <ctype.h> 12 #include <sys/locale.h> 13 14 static int __uni_strlwr (UniChar *ucs, void *arg) 15 { 16 UniChar *c; 17 (void)arg; 18 for (c = ucs; *c; c++) 19 *c = UniTransLower (__locale_ctype.locale, *c); 20 return 1; 21 } 6 22 7 23 char *_STD(strlwr) (char *string) 8 24 { 9 unsigned char *p; 25 unsigned char c; 26 unsigned char *s = (unsigned char *)string; 10 27 11 for (p = (unsigned char *)string; *p != 0; ++p) 12 *p = (unsigned char)tolower (*p); 28 if (__locale_ctype.mbcs) 29 { 30 while ((c = *s)) 31 { 32 if (IS_MBCS_PREFIX (__locale_ctype, c)) 33 { 34 /* Allright, we encountered a MBCS character. Convert everything 35 until the end to Unicode, do the work in Unicode and then 36 convert back to MBCS. */ 37 __do_Unicode (__locale_ctype.uconv, s, s, __uni_strlwr); 38 break; 39 } 40 *s++ = __locale_ctype.locase [c]; 41 } 42 } 43 else 44 while ((c = *s)) 45 *s++ = __locale_ctype.locase [c]; 46 13 47 return string; 14 48 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/str/strnicmp.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r493 r494 1 /* strnicmp.c (emx+gcc) -- Copyright (c) 1990-1995 by Eberhard Mattes */ 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 2 4 5 For conditions of distribution and use, see the file COPYING. 6 7 Compare at most 'len' characters from two zero-terminated strings 8 case-insensitively. 9 */ 10 11 #define __INTERNAL_DEFS 3 12 #include "libc-alias.h" 4 #include <st ring.h>5 #include < ctype.h>13 #include <stddef.h> 14 #include <sys/locale.h> 6 15 7 int _STD(strnicmp) ( const char *string1, const char *string2, size_t count)16 int _STD(strnicmp) (__const__ char *s1, __const__ char *s2, size_t len) 8 17 { 9 int d; 18 unsigned char c1; 19 unsigned char c2; 10 20 11 while (count != 0) 21 if (!len) 22 return 0; 23 24 c1 = *s1; c2 = *s2; 25 26 if (__locale_ctype.mbcs) 27 /* MBCS case. One additional memory lookup per character. */ 28 for (;;) 12 29 { 13 d = tolower ((unsigned char)*string1) 14 - tolower ((unsigned char)*string2); 15 if (d != 0 || *string1 == 0 || *string2 == 0) 30 int d; 31 32 if (IS_MBCS_PREFIX (__locale_ctype, c1) 33 || IS_MBCS_PREFIX (__locale_ctype, c2)) 34 { 35 /* Translate unknown characters to Unicode, and compare them... 36 We perhaps should convert them back to MBCS, but anyway it is 37 not defined how memicmp should work on multi-byte characters... */ 38 UniChar uc1, uc2; 39 int c1l, c2l; 40 if (!(c1l = __to_ucs (__locale_ctype.uconv, s1, len, &uc1))) 41 uc1 = c1, c1l = 1; 42 else 43 uc1 = UniTransLower (__locale_ctype.locale, uc1); 44 if (!(c2l = __to_ucs (__locale_ctype.uconv, s2, len, &uc2))) 45 uc2 = c2, c2l = 1; 46 else 47 uc2 = UniTransLower (__locale_ctype.locale, uc2); 48 d = uc1 - uc2; 49 c1l--; c2l--; 50 s1 += c1l; s2 += c2l; 51 len -= c1l; 52 } 53 else 54 d = __locale_ctype.locase [c1] - __locale_ctype.locase [c2]; 55 if (d || !c1 || !c2) 16 56 return d; 17 ++string1; ++string2; 18 --count; 19 } 20 return 0; 57 if (!--len) 58 return 0; 59 c1 = *++s1; 60 c2 = *++s2; 61 } /* endfor */ 62 else 63 /* SBCS case (faster). */ 64 for (;;) 65 { 66 int d = __locale_ctype.locase [c1] - __locale_ctype.locase [c2]; 67 if (d || !c1 || !c2) 68 return d; 69 if (!--len) 70 return 0; 71 c1 = *++s1; 72 c2 = *++s2; 73 } /* endfor */ 74 75 /* This point never achieved */ 21 76 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/str/strupr.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r493 r494 1 /* strupr.c (emx+gcc) -- Copyright (c) 1990-1995 by Eberhard Mattes */ 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 2 4 5 For conditions of distribution and use, see the file COPYING. 6 7 Uppercase an ASCIIZ string. 8 */ 9 10 #define __INTERNAL_DEFS 3 11 #include "libc-alias.h" 4 #include <string.h> 5 #include <ctype.h> 12 #include <sys/locale.h> 13 14 static int __uni_strupr (UniChar *ucs, void *arg) 15 { 16 UniChar *c; 17 (void)arg; 18 for (c = ucs; *c; c++) 19 *c = UniTransUpper (__locale_ctype.locale, *c); 20 return 1; 21 } 6 22 7 23 char *_STD(strupr) (char *string) 8 24 { 9 unsigned char *p; 25 unsigned char c; 26 unsigned char *s = (unsigned char *)string; 10 27 11 for (p = (unsigned char *)string; *p != 0; ++p) 12 *p = (unsigned char)toupper (*p); 28 if (__locale_ctype.mbcs) 29 { 30 while ((c = *s)) 31 { 32 if (IS_MBCS_PREFIX (__locale_ctype, c)) 33 { 34 /* Allright, we encountered a MBCS character. Convert everything 35 until the end to Unicode, do the work in Unicode and then 36 convert back to MBCS. */ 37 __do_Unicode (__locale_ctype.uconv, s, s, __uni_strupr); 38 break; 39 } 40 *s++ = __locale_ctype.upcase [c]; 41 } 42 } 43 else 44 while ((c = *s)) 45 *s++ = __locale_ctype.upcase [c]; 46 13 47 return string; 14 48 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/str/strxfrm.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r493 r494 1 /* strxfrm.c (emx+gcc) -- Copyright (c) 1994-1995 by Eberhard Mattes */ 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 2003 InnoTek Systemberatung GmbH 2 4 5 For conditions of distribution and use, see the file COPYING. 6 7 Transform a string so that the resulting string is suitable for 8 comparison with strcmp() and the comparison results will use the 9 alphabetic order in conformance to currently selected locale. 10 */ 11 12 #define __INTERNAL_DEFS 3 13 #include "libc-alias.h" 4 #include <string.h> 14 #include <sys/locale.h> 15 #include <stddef.h> 5 16 6 /* Ignore the current locale for now. */ 17 struct __strxfrm_arg 18 { 19 char *out; 20 size_t size; 21 }; 7 22 8 s ize_t _STD(strxfrm) (char *string1, const char *string2, size_t count)23 static int __uni_strxfrm (UniChar *ucs, void *arg) 9 24 { 10 s ize_t result;25 struct __strxfrm_arg *x = (struct __strxfrm_arg *)arg; 11 26 12 result = 0; 13 while (*string2 != 0) 27 /* BUG WARNING! 28 * As far as I've observed Unicode DLL has a bug that UniStrxfrm returns 29 * one character less than it really fills in the buffer. I haven't 30 * implemented any workaround for that first because it can be fixed 31 * in the future and second because the information at the end of the 32 * buffer seems very seldom really needed. UniStrxfrm generates a lot 33 * of output, and every character in the input buffer generates three 34 * characters in the output buffer: one wchar_t and two bytes that 35 * seems to be related to character type (e.g. similar to character 36 * flags isXXX() works with). 37 */ 38 39 size_t rs = UniStrxfrm (__locale_collate.locale, (UniChar *)x->out, 40 ucs, x->size); 41 /* rs is in UniChar's without trailing zero */ 42 rs *= sizeof (UniChar); 43 if (rs < x->size) 44 { 45 /* The string returned by Unicode API often contain zero characters 46 (in the top or bottom 8 bits of a Unicode character). 47 This is inappropiate for MBCS strings, so we increment all 48 character codes by one except code 0xff (which is very seldom 49 encountered). There is no other way to represent a Unicode 50 xfrm'ed string as a MBCS string, alas. */ 51 52 int i; 53 for (i = 0; i < rs; i++) 54 if (x->out [i] != -1) 55 x->out [i]++; 56 x->out [rs] = 0; 57 } 58 x->size = rs + 1; /* We need space for trailing zero too */ 59 return 0; 60 } 61 62 /* Copy s2 to s1, applying the collate transform. */ 63 size_t _STD(strxfrm) (char *s1, const char *s2, size_t size) 64 { 65 unsigned char c; 66 size_t ret = 1; /* We need at least space for trailing zero */ 67 68 if (__locale_collate.mbcs) 69 { 70 /* When using MBCS codepaes, we will convert the entire string to 71 Unicode and then apply the UniStrxfrm() function. The output strings 72 can be much longer than the original in this case, but if user program 73 is correctly written, it will work since strxfrm will return the 74 required output string length. */ 75 struct __strxfrm_arg x; 76 x.out = s1; 77 x.size = size / sizeof (UniChar); 78 __do_Unicode (__locale_collate.uconv, (char *)s2, &x, __uni_strxfrm); 79 return x.size; 80 } 81 82 while ((c = *s2++)) 83 { 84 if (size) 14 85 { 15 if (count != 0) 16 { 17 *string1++ = *string2; 18 --count; 19 } 20 ++result; 21 ++string2; 86 *s1++ = __locale_collate.weight [c]; 87 size--; 22 88 } 23 if (count != 0) 24 *string1 = 0; 25 return result; 89 ret++; 90 } 91 92 /* Append trailing zero, if there is space. */ 93 if (size) 94 *s1 = 0; 95 96 return ret; 26 97 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/time/gmtime.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r493 r494 6 6 #include <emx/thread.h> 7 7 #include <emx/time.h> 8 9 struct tm *_STD(gmtime) (const time_t *t)10 {11 struct _thread *tp = _thread ();12 return _gmtime (&tp->_th_gmtime_buf, t);13 }14 8 15 9 struct tm *_gmtime (struct tm *dst, const time_t *t) … … 60 54 return dst; 61 55 } 56 57 struct tm *_STD(gmtime) (const time_t *t) 58 { 59 struct _thread *tp = _thread (); 60 return _gmtime (&tp->_th_gmtime_buf, t); 61 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/time/strftime.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r493 r494 1 /* strftime.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */ 2 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 1992-1996 by Eberhard Mattes 4 Copyright (c) 2003 InnoTek Systemberatung GmbH 5 6 For conditions of distribution and use, see the file COPYING. 7 8 Format time. The output string is written to the array of size characters 9 pointed to by string, including the terminating null character. Like 10 sprintf(), strftime() copies the string pointed to by format to the 11 array pointed to by string, replacing format specifications with formatted 12 data from t. Ordinary characters are copied unmodified. 13 14 On success, strftime() returns the number of characters copied to the 15 array pointed to by string, excluding the terminating null character. 16 On failure (size exceeded), strftime() returns 0. 17 */ 18 19 #define __INTERNAL_DEFS 3 20 #include "libc-alias.h" 4 21 #include <stdlib.h> … … 6 23 #include <time.h> 7 24 #include <limits.h> 8 #include < emx/locale.h>25 #include <sys/locale.h> 9 26 #include <emx/time.h> 10 11 static int ins (char *string, size_t *n, size_t size, const char *s, 12 size_t len); 13 static int num2 (char *string, size_t *n, size_t size, int x); 14 static int num3 (char *string, size_t *n, size_t size, int x); 15 static int week (const struct tm *t, int first); 16 17 #define INS(STR,LEN) if (!ins (string, &n, size, (STR), (LEN))) return 0; 18 #define NUM2(X) if (!num2 (string, &n, size, (X))) return 0; 19 #define NUM3(X) if (!num3 (string, &n, size, (X))) return 0; 27 #include <sys/builtin.h> 28 29 #define INS(STR) \ 30 if (!(i = ins (string, size, STR))) \ 31 return 0; \ 32 else \ 33 string += i, size -= i 34 #define NUM2(X) \ 35 if (!(i = num2 (string, size, X, minlen))) \ 36 return 0; \ 37 else \ 38 string += i, size -= i 39 #define NUM3(X) \ 40 if (!(i = num3 (string, size, X, minlen))) \ 41 return 0; \ 42 else \ 43 string += i, size -= i 20 44 #define FMT(F) \ 21 i = strftime (string + n, size - n, (F), t); \ 22 if (i == 0) \ 23 return 0; \ 24 else \ 25 n += i; 45 if (!(i = strftime (string, size, F, t))) \ 46 return 0; \ 47 else \ 48 string += i, size -= i 26 49 #define CHR(C) \ 27 if (n < size) \ 28 string[n++] = C; \ 29 else \ 30 return 0; 31 32 33 static int ins (char *string, size_t *n, size_t size, const char *s, 34 size_t len) 35 { 36 size_t i; 37 38 i = *n; 39 if (len < size - i) 40 { 41 memcpy (string + i, s, len); 42 *n += len; 43 return 1; 44 } 45 else 50 if (!size) \ 51 return 0; \ 52 else \ 53 *string++ = C, size-- 54 55 static size_t ins (char *string, size_t size, const char *s) 56 { 57 size_t len = strlen (s); 58 59 if (len >= size) 46 60 return 0; 47 } 48 49 50 static int num2 (char *string, size_t *n, size_t size, int x) 51 { 52 int i; 53 54 i = *n; 55 if (2 < size - i) 56 { 57 string[i++] = (char)('0' + (x / 10) % 10); 58 string[i++] = (char)('0' + (x % 10)); 59 *n = i; 60 return 1; 61 } 62 else 61 62 memcpy (string, s, len); 63 return len; 64 } 65 66 static size_t num2 (char *string, size_t size, int x, unsigned char minlen) 67 { 68 char *orgstring = string; 69 long r; 70 71 if (size < 2) 63 72 return 0; 64 } 65 66 67 static int num3 (char *string, size_t *n, size_t size, int x) 68 { 69 int i; 70 71 i = *n; 72 if (3 < size - i) 73 { 74 string[i++] = (char)('0' + (x / 100) % 10); 75 string[i++] = (char)('0' + (x / 10) % 10); 76 string[i++] = (char)('0' + (x % 10)); 77 *n = i; 78 return 1; 79 } 80 else 73 74 if (x < 0) 75 x = 0; 76 77 x = __ldivmod (x, 10, &r); 78 if (x > 9) 79 x = x % 10; 80 81 if (minlen > 1 || x > 0) 82 *string++ = x + '0'; 83 *string++ = r + '0'; 84 return string - orgstring; 85 } 86 87 static size_t num3 (char *string, size_t size, int x, unsigned char minlen) 88 { 89 char *orgstring = string; 90 long r1, r2; 91 92 if (size < 3) 81 93 return 0; 82 } 83 94 95 if (x < 0) 96 x = 0; 97 98 x = __ldivmod (x, 10, &r1); 99 x = __ldivmod (x, 10, &r2); 100 if (x > 9) 101 x = x % 10; 102 103 if (minlen >= 3 || x > 0) 104 *string++ = x + '0', minlen = 2; 105 if (minlen >= 2 || r2 > 0) 106 *string++ = r2 + '0'; 107 *string++ = r1 + '0'; 108 return string - orgstring; 109 } 84 110 85 111 static int week (const struct tm *t, int first) … … 94 120 } 95 121 96 97 122 size_t _STD(strftime) (char *string, size_t size, const char *format, 98 123 const struct tm *t) 99 124 { 100 size_t i, n; 101 char *p, tmp[40]; 102 unsigned char c; 103 int mbn, shift; 125 size_t i; 126 unsigned char c, minlen; 127 char *orgstring = string; 104 128 105 129 if (!_tzset_flag) tzset (); 106 shift = 0; n = 0; 130 107 131 while ((c = *format) != 0) 132 { 133 if (c == '%') 108 134 { 109 if (c == '%') 110 { 111 ++format; p = NULL; 112 switch (*format) 113 { 114 case 0: 115 case '%': 116 CHR ('%'); 117 if (*format == 0) 118 --format; 119 break; 120 case 'a': 121 p = _cur_lcf_time.wdays1[t->tm_wday]; 122 INS (p, strlen (p)); 123 break; 124 case 'A': 125 p = _cur_lcf_time.wdays2[t->tm_wday]; 126 INS (p, strlen (p)); 127 break; 128 case 'b': 129 case 'h': 130 p = _cur_lcf_time.months1[t->tm_mon]; 131 INS (p, strlen (p)); 132 break; 133 case 'B': 134 p = _cur_lcf_time.months2[t->tm_mon]; 135 INS (p, strlen (p)); 136 break; 137 case 'c': 138 FMT (_cur_lcf_time.date_time_fmt); 139 break; 140 case 'd': 141 NUM2 (t->tm_mday); 142 break; 143 case 'D': 144 FMT ("%m/%d/%y"); 145 break; 146 case 'e': 147 NUM2 (t->tm_mday); 148 if (string[n-2] == '0') 149 string[n-2] = ' '; 150 break; 151 case 'H': 152 NUM2 (t->tm_hour); 153 break; 154 case 'I': 155 NUM2 ((t->tm_hour + 11) % 12 + 1); 156 break; 157 case 'j': 158 NUM3 (t->tm_yday + 1); 159 break; 160 case 'm': 161 NUM2 (t->tm_mon + 1); 162 break; 163 case 'M': 164 NUM2 (t->tm_min); 165 break; 166 case 'n': 167 CHR ('\n'); 168 break; 169 case 'p': 170 p = (t->tm_hour >= 12 ? _cur_lcf_time.pm : _cur_lcf_time.am); 171 INS (p, strlen (p)); 172 break; 173 case 'r': 174 FMT ("%I:%M:%S %p"); 175 break; 176 case 'S': 177 NUM2 (t->tm_sec); 178 break; 179 case 't': 180 CHR ('\t'); 181 break; 182 case 'T': 183 FMT ("%H:%M:%S"); 184 break; 185 case 'U': 186 NUM2 (week (t, 0)); 187 break; 188 case 'w': 189 NUM2 (t->tm_wday); 190 break; 191 case 'W': 192 NUM2 (week (t, 1)); 193 break; 194 case 'x': 195 FMT (_cur_lcf_time.date_fmt); 196 break; 197 case 'X': 198 FMT (_cur_lcf_time.time_fmt); 199 break; 200 case 'y': 201 NUM2 (t->tm_year % 100); 202 break; 203 case 'Y': 204 p = _itoa (t->tm_year + 1900, tmp, 10); 205 INS (p, strlen (p)); 206 break; 207 case 'Z': 208 if (t->tm_isdst >= 0) 209 { 210 p = _tzname[(t->tm_isdst ? 1 : 0)]; 211 INS (p, strlen (p)); 212 } 213 break; 214 default: 215 break; 216 } 217 } 218 else if (c <= 127 || _cur_mbyte.mode == _MB_8BITS) 219 { 220 if (n < size) 221 string[n++] = c; 222 else 223 return 0; 224 } 225 else 226 { 227 mbn = _mbtowc (NULL, format, MB_LEN_MAX, &shift); 228 if (mbn < 1) 229 mbn = 1; 230 if (n + mbn > size) 231 return 0; 232 while (mbn > 0) 233 { 234 string[n++] = *format++; 235 --mbn; 236 } 237 --format; 238 } 135 minlen = 9; 136 nextformat: 239 137 ++format; 138 switch (*format) 139 { 140 case 0: 141 case '%': 142 CHR ('%'); 143 if (*format == 0) 144 --format; 145 break; 146 147 /* Handle prefixes first */ 148 case 'E': 149 /* Alternative date/time formats not supported for now */ 150 case 'O': 151 /* Alternative numeric formats not supported for now */ 152 goto nextformat; 153 154 case '1': 155 /* Undocumented in Unicode API reference, encountered in Russian 156 locale. I think it should mean that the next number should occupy 157 such much characters how it should (e.g. %1H:%M = 1:20 or 23:00). */ 158 minlen = 1; 159 goto nextformat; 160 161 case 'a': 162 INS (__locale_time.swdays [t->tm_wday]); 163 break; 164 case 'A': 165 INS (__locale_time.lwdays [t->tm_wday]); 166 break; 167 case 'b': 168 case 'h': 169 INS (__locale_time.smonths [t->tm_mon]); 170 break; 171 case 'B': 172 INS (__locale_time.lmonths [t->tm_mon]); 173 break; 174 case 'c': 175 FMT (__locale_time.date_time_fmt); 176 break; 177 case 'C': 178 /* 2000 A.D. is still 20th century (not 21st) */ 179 NUM2 (1 + (t->tm_year - 1) / 100); 180 break; 181 case 'd': 182 NUM2 (t->tm_mday); 183 break; 184 case 'D': 185 FMT ("%m/%d/%y"); 186 break; 187 case 'e': 188 NUM2 (t->tm_mday); 189 if (string [-2] == '0') 190 string [-2] = ' '; 191 break; 192 case 'H': 193 NUM2 (t->tm_hour); 194 break; 195 case 'I': 196 NUM2 ((t->tm_hour + 11) % 12 + 1); 197 break; 198 case 'j': 199 NUM3 (t->tm_yday + 1); 200 break; 201 case 'm': 202 NUM2 (t->tm_mon + 1); 203 break; 204 case 'M': 205 NUM2 (t->tm_min); 206 break; 207 case 'n': 208 CHR ('\n'); 209 break; 210 case 'p': 211 INS (t->tm_hour >= 12 ? __locale_time.pm : __locale_time.am); 212 break; 213 case 'r': 214 FMT ("%I:%M:%S %p"); 215 break; 216 case 'S': 217 NUM2 (t->tm_sec); 218 break; 219 case 't': 220 CHR ('\t'); 221 break; 222 case 'T': 223 FMT ("%H:%M:%S"); 224 break; 225 case 'U': 226 NUM2 (week (t, 0)); 227 break; 228 case 'w': 229 NUM2 (t->tm_wday); 230 break; 231 case 'W': 232 NUM2 (week (t, 1)); 233 break; 234 case 'x': 235 FMT (__locale_time.date_fmt); 236 break; 237 case 'X': 238 FMT (__locale_time.time_fmt); 239 break; 240 case 'y': 241 NUM2 (t->tm_year % 100); 242 break; 243 case 'Y': 244 CHR ('0' + (1900 + t->tm_year) / 1000); 245 NUM3 ((t->tm_year + 1900) % 1000); 246 break; 247 case 'Z': 248 if (t->tm_isdst >= 0) 249 { 250 INS (_tzname [(t->tm_isdst ? 1 : 0)]); 251 } 252 break; 253 } 240 254 } 241 if (n < size) 255 else if (!CHK_MBCS_PREFIX (__locale_ctype, c, i)) 256 CHR (c); 257 else 242 258 { 243 string[n] = 0; 244 return n; 259 if (i > size) 260 return 0; 261 memcpy (string, format, i); 262 string += i; 263 format += i - 1; 245 264 } 246 else 247 return 0; 248 } 265 ++format; 266 } 267 268 if (size) 269 { 270 *string = 0; 271 return string - orgstring; 272 } 273 274 return 0; 275 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/time/strptime.c
-
Property cvs2svn:cvs-rev
changed from
1.4
to1.5
r493 r494 1 /* strptime.c (emx+gcc) -- Copyright (c) 1994-1998 by Eberhard Mattes */ 2 1 /* 2 Locale support implementation through OS/2 Unicode API. 3 Copyright (c) 1992-1996 by Eberhard Mattes 4 Copyright (c) 2003 InnoTek Systemberatung GmbH 5 6 For conditions of distribution and use, see the file COPYING. 7 8 Parse a time specification in the input string pointed to by buffer 9 according to the format string pointed to by format, updating the 10 structure pointed to by t. 11 12 Whitespace (any number of spaces) in the format string matches whitespace 13 (any number of spaces, including zero) in the input string. All other 14 characters except for % are compared to the input. Parsing ends (with an 15 error being indicated) when a mismatch is encountered. %% in the format 16 string matches % in the input string. A % which is not followed by another 17 % or the end of the string starts a field specification. The field in the 18 input is interpreted according to the field specification. For all field 19 types, whitespace is ignored at the start of a field. Field specifications 20 matching numbers skip leading zeros. Case is ignored when comparing strings. 21 The field width is not restricted, that is, as many characters as possible 22 are matched. 23 24 If successful, strptime() returns a pointer to the character following the 25 last character parsed. On error, strptime() returns NULL. 26 */ 27 28 #define __INTERNAL_DEFS 3 29 #include "libc-alias.h" 4 30 #include <stdlib.h> … … 6 32 #include <time.h> 7 33 #include <ctype.h> 8 #include <emx/locale.h> 9 10 #define RECURSE(FMT) parse_fmt (s, FMT, tm) 11 #define NUMBER(DST,MIN,MAX,ADD) parse_number (s, DST, MIN, MAX, ADD) 12 #define STRING(STR) parse_string (s, STR) 13 #define TABLE(DST,TAB,N) parse_table (s, DST, TAB, N) 34 #include <sys/locale.h> 35 #include <emx/time.h> 36 37 #define RECURSE(FMT) \ 38 if (!(s = parse_fmt (s, FMT, tm, &mask))) \ 39 return NULL; 40 #define NUMBER(DST,MIN,MAX,ADD) \ 41 if (!(s = parse_number (s, DST, MIN, MAX, ADD))) \ 42 return NULL; 43 #define STRING(STR) \ 44 if (!(s = parse_string (s, STR))) \ 45 return NULL; 46 #define TABLE(DST,TAB,N) \ 47 if (!(s = parse_table (s, DST, TAB, N))) \ 48 return NULL; 14 49 15 50 static const unsigned char *parse_number (const unsigned char *s, int *dst, 16 51 int min, int max, int add) 17 52 { 18 53 int n; … … 31 66 } 32 67 33 34 68 static const unsigned char *parse_string (const unsigned char *s, 35 69 const char *str) 36 70 { 37 71 size_t len; … … 40 74 ++s; 41 75 len = strlen (str); 42 if (len == 0 || _strnicmp (s, str, len) != 0)76 if (len == 0 || strnicmp (s, str, len) != 0) 43 77 return NULL; 44 78 return s + len; 45 79 } 46 80 47 48 81 static const unsigned char *parse_table (const unsigned char *s, int *dst, 49 82 char **tab, int n) 50 83 { 51 84 int i; … … 55 88 ++s; 56 89 for (i = 0; i < n; ++i) 57 58 59 if (_strnicmp (s, tab[i], len) == 0)60 61 62 63 64 90 { 91 len = strlen (tab[i]); 92 if (strnicmp (s, tab[i], len) == 0) 93 { 94 *dst = i; 95 return s + len; 96 } 97 } 65 98 return NULL; 66 99 } 67 100 68 69 101 static const unsigned char *parse_fmt (const unsigned char *s, 70 const unsigned char *f, struct tm *tm)102 const unsigned char *f, struct tm *tm, unsigned *retmask) 71 103 { 72 104 const unsigned char *t; 73 105 int week = -1; 106 int century = -1; 107 /* The mask of found fields */ 108 unsigned mask = 0; 109 110 #define MASK_CENTURY 0x00000001 111 #define MASK_YEAR2 0x00000002 112 #define MASK_YEAR4 0x00000004 113 #define MASK_YEAR (MASK_YEAR2 | MASK_YEAR4) 114 #define MASK_YEARDAY 0x00000008 115 #define MASK_MONTH 0x00000010 116 #define MASK_MONTHDAY 0x00000020 117 #define MASK_WEEKS 0x00000040 118 #define MASK_WEEKM 0x00000080 119 #define MASK_WEEK (MASK_WEEKM | MASK_WEEKS) 120 #define MASK_WEEKDAY 0x00000100 121 #define MASK_HOUR 0x00000200 122 #define MASK_MINUTE 0x00000400 123 #define MASK_SECOND 0x00000800 74 124 75 125 while (*f != 0) 76 { 77 if (isspace (*f)) 78 { 79 while (*s != 0 && isspace (*s)) 80 ++s; 81 ++f; 82 } 83 else if (*f != '%') 84 { 85 if (*s != *f) 86 return NULL; 87 ++s; ++f; 88 } 89 else 90 { 91 ++f; 92 switch (*f++) 93 { 94 case 0: 95 if (*s != '%') 96 return NULL; 97 return s + 1; 98 break; 99 100 case '%': 101 if (*s != '%') 102 return NULL; 103 ++s; 104 break; 105 106 case 'a': 107 s = TABLE (&tm->tm_wday, _cur_lcf_time.wdays1, 7); 108 if (s == NULL) return NULL; 109 break; 110 111 case 'A': 112 s = TABLE (&tm->tm_wday, _cur_lcf_time.wdays2, 7); 113 if (s == NULL) return NULL; 114 break; 115 116 case 'b': 117 case 'h': 118 s = TABLE (&tm->tm_mon, _cur_lcf_time.months1, 12); 119 if (s == NULL) return NULL; 120 break; 121 122 case 'B': 123 s = TABLE (&tm->tm_mon, _cur_lcf_time.months2, 12); 124 if (s == NULL) return NULL; 125 break; 126 127 case 'c': 128 s = RECURSE (_cur_lcf_time.date_time_fmt); 129 if (s == NULL) return NULL; 130 break; 131 132 case 'C': 133 s = RECURSE ("%x %X"); 134 if (s == NULL) return NULL; 135 break; 136 137 case 'd': 138 case 'e': 139 s = NUMBER (&tm->tm_mday, 1, 31, 0); 140 if (s == NULL) return NULL; 141 break; 142 143 case 'D': 144 s = RECURSE ("%m/%d/%y"); 145 if (s == NULL) return NULL; 146 break; 147 148 case 'H': 149 case 'k': 150 s = NUMBER (&tm->tm_hour, 0, 23, 0); 151 if (s == NULL) return NULL; 152 break; 153 154 case 'I': 155 case 'l': 156 s = NUMBER (&tm->tm_hour, 1, 12, 0); 157 if (s == NULL) return NULL; 158 break; 159 160 case 'j': 161 s = NUMBER (&tm->tm_yday, 1, 366, -1); 162 if (s == NULL) return NULL; 163 break; 164 165 case 'm': 166 s = NUMBER (&tm->tm_mon, 1, 12, -1); 167 if (s == NULL) return NULL; 168 break; 169 170 case 'M': 171 s = NUMBER (&tm->tm_min, 0, 59, 0); 172 if (s == NULL) return NULL; 173 break; 174 175 case 'n': 176 if (*s != '\n') 177 return NULL; 178 ++s; 179 break; 180 181 case 'p': 182 if (tm->tm_hour < 1 || tm->tm_hour > 12) 183 return NULL; 184 if ((t = STRING (_cur_lcf_time.am)) != NULL) 185 { 186 if (tm->tm_hour == 12) 187 tm->tm_hour = 0; 188 } 189 else if ((t = STRING (_cur_lcf_time.pm)) != NULL) 190 { 191 if (tm->tm_hour != 12) 192 tm->tm_hour += 12; 193 } 194 else 195 return NULL; 196 s = t; 197 break; 198 199 case 'r': 200 s = RECURSE ("%I:%M:%S %p"); 201 if (s == NULL) return NULL; 202 break; 203 204 case 'R': 205 s = RECURSE ("%H:%M"); 206 if (s == NULL) return NULL; 207 break; 208 209 case 'S': 210 s = NUMBER (&tm->tm_sec, 0, 61, 0); 211 if (s == NULL) return NULL; 212 break; 213 214 case 't': 215 if (*s != '\t') 216 return NULL; 217 ++s; 218 break; 219 220 case 'T': 221 s = RECURSE ("%H:%M:%S"); 222 if (s == NULL) return NULL; 223 break; 224 225 case 'w': 226 s = NUMBER (&tm->tm_wday, 0, 6, 0); 227 if (s == NULL) return NULL; 228 break; 229 230 case 'U': 231 case 'W': 232 /* %U and %W are currently ignored. */ 233 s = NUMBER (&week, 0, 53, 0); 234 if (s == NULL) return NULL; 235 break; 236 237 case 'x': 238 s = RECURSE (_cur_lcf_time.date_fmt); 239 if (s == NULL) return NULL; 240 break; 241 242 case 'X': 243 s = RECURSE (_cur_lcf_time.time_fmt); 244 if (s == NULL) return NULL; 245 break; 246 247 case 'y': 248 s = NUMBER (&tm->tm_year, 0, 99, 0); 249 if (s == NULL) return NULL; 250 if (tm->tm_year < 69) 251 tm->tm_year += 100; 252 break; 253 254 case 'Y': 255 s = NUMBER (&tm->tm_year, 1900, -1, -1900); 256 if (s == NULL) return NULL; 257 break; 258 259 default: 260 return NULL; 261 } 262 } 263 } 126 { 127 if (isspace (*f)) 128 { 129 while (*s != 0 && isspace (*s)) 130 ++s; 131 ++f; 132 } 133 else if (*f != '%') 134 { 135 if (*s != *f) 136 return NULL; 137 ++s; ++f; 138 } 139 else 140 { 141 ++f; 142 nextformat: 143 switch (*f++) 144 { 145 case 0: 146 if (*s != '%') 147 return NULL; 148 return s + 1; 149 break; 150 151 case '%': /* A percent is just a percent */ 152 if (*s != '%') 153 return NULL; 154 ++s; 155 break; 156 157 /* Handle prefixes first */ 158 case 'E': 159 /* Alternative date/time formats not supported for now */ 160 case 'O': 161 /* Alternative numeric formats not supported for now */ 162 case '1': 163 /* Numeric length does not have sense here */ 164 goto nextformat; 165 166 case 'a': /* Short weekday name */ 167 TABLE (&tm->tm_wday, __locale_time.swdays, 7); 168 mask |= MASK_WEEKDAY; 169 break; 170 171 case 'A': /* Long weekday name */ 172 TABLE (&tm->tm_wday, __locale_time.lwdays, 7); 173 mask |= MASK_WEEKDAY; 174 break; 175 176 case 'b': /* Short month name */ 177 case 'h': 178 TABLE (&tm->tm_mon, __locale_time.smonths, 12); 179 mask |= MASK_MONTH; 180 break; 181 182 case 'B': /* Long month name */ 183 TABLE (&tm->tm_mon, __locale_time.lmonths, 12); 184 mask |= MASK_MONTH; 185 break; 186 187 case 'c': /* Locale's defined time and date format */ 188 RECURSE (__locale_time.date_time_fmt); 189 break; 190 191 case 'C': /* Century number */ 192 NUMBER (¢ury, 0, 99, 0); 193 mask |= MASK_CENTURY; 194 break; 195 196 case 'd': /* Day of the month (1-31) */ 197 case 'e': 198 NUMBER (&tm->tm_mday, 1, 31, 0); 199 mask |= MASK_MONTHDAY; 200 break; 201 202 case 'D': /* MM/DD/YY */ 203 RECURSE ("%m/%d/%y"); 204 break; 205 206 case 'H': /* Hour (00-23) */ 207 case 'k': 208 NUMBER (&tm->tm_hour, 0, 23, 0); 209 mask |= MASK_HOUR; 210 break; 211 212 case 'I': /* Hour (01-12) */ 213 case 'l': 214 NUMBER (&tm->tm_hour, 1, 12, 0); 215 mask |= MASK_HOUR; 216 break; 217 218 case 'j': /* Day of the year (1-366) */ 219 NUMBER (&tm->tm_yday, 1, 366, -1); 220 mask |= MASK_YEARDAY; 221 break; 222 223 case 'm': /* Month (01-12) */ 224 NUMBER (&tm->tm_mon, 1, 12, -1); 225 mask |= MASK_MONTH; 226 break; 227 228 case 'M': /* Minutes (00-59) */ 229 NUMBER (&tm->tm_min, 0, 59, 0); 230 mask |= MASK_MINUTE; 231 break; 232 233 case 'n': /* Newline */ 234 if (*s != '\n') 235 return NULL; 236 ++s; 237 break; 238 239 case 'p': /* am or pm */ 240 if (!(mask & MASK_HOUR) 241 || (tm->tm_hour < 1) 242 || (tm->tm_hour > 12)) 243 return NULL; 244 if ((t = parse_string (s, __locale_time.am)) != NULL) 245 { 246 if (tm->tm_hour == 12) 247 tm->tm_hour = 0; 248 } 249 else if ((t = parse_string (s, __locale_time.pm)) != NULL) 250 { 251 if (tm->tm_hour != 12) 252 tm->tm_hour += 12; 253 } 254 else 255 return NULL; 256 s = t; 257 break; 258 259 case 'r': /* HH:MM:SS am/pm */ 260 RECURSE ("%I:%M:%S %p"); 261 break; 262 263 case 'R': /* HH:MM */ 264 RECURSE ("%H:%M"); 265 break; 266 267 case 'S': /* Seconds (00-61(?)) */ 268 NUMBER (&tm->tm_sec, 0, 61, 0); 269 mask |= MASK_SECOND; 270 break; 271 272 case 't': /* Tabulation */ 273 if (*s != '\t') 274 return NULL; 275 ++s; 276 break; 277 278 case 'T': /* HH:MM:SS */ 279 RECURSE ("%H:%M:%S"); 280 break; 281 282 case 'w': /* Weekday (0-6), 0 = Sunday */ 283 NUMBER (&tm->tm_wday, 0, 6, 0); 284 mask |= MASK_WEEKDAY; 285 break; 286 287 case 'U': /* Week number (0-53), 0 = Sunday */ 288 NUMBER (&week, 0, 53, 0); 289 mask |= MASK_WEEKS; 290 break; 291 292 case 'W': /* Week number (0-53), 0 = Monday */ 293 NUMBER (&week, 0, 53, 0); 294 mask |= MASK_WEEKM; 295 break; 296 297 case 'x': 298 RECURSE (__locale_time.date_fmt); 299 break; 300 301 case 'X': 302 RECURSE (__locale_time.time_fmt); 303 break; 304 305 case 'y': 306 NUMBER (&tm->tm_year, 0, 99, 0); 307 if (tm->tm_year < 69) 308 tm->tm_year += 100; 309 mask |= MASK_YEAR2; 310 break; 311 312 case 'Y': 313 NUMBER (&tm->tm_year, 1900, -1, -1900); 314 mask |= MASK_YEAR4; 315 /* Ignore century since it was explicitely given */ 316 century = -1; mask &= ~MASK_CENTURY; 317 break; 318 319 default: 320 return NULL; 321 } 322 } 323 } 324 325 if (mask & MASK_CENTURY) 326 { 327 if (!(mask & MASK_YEAR)) 328 tm->tm_year = 0; 329 tm->tm_year = (century - 19) * 100 + (tm->tm_year % 100); 330 mask |= MASK_YEAR4; 331 } 332 333 /* We should know which fields are already correctly filled */ 334 if (retmask) 335 mask |= *retmask; 336 337 if ((mask & MASK_YEAR) && (mask & MASK_YEARDAY) 338 && (mask & (MASK_MONTH | MASK_MONTHDAY)) != (MASK_MONTH | MASK_MONTHDAY)) 339 { 340 /* Compute month and day of the month if any of them is not given */ 341 const unsigned short *md = _leap_year (tm->tm_year + 1900) ? 342 _month_day_leap : _month_day_non_leap; 343 for (tm->tm_mon = 0; tm->tm_mon < 12 && tm->tm_yday < md [tm->tm_mon]; 344 tm->tm_mon++) ; 345 tm->tm_mday = 1 + tm->tm_yday - md [tm->tm_mon]; 346 mask |= MASK_MONTH | MASK_MONTHDAY; 347 } 348 349 if (!(mask & MASK_YEARDAY)) 350 { 351 if ((mask & MASK_WEEK) && (mask & MASK_WEEKDAY) && (mask & MASK_YEAR) 352 && (tm->tm_year >= 70) && (tm->tm_year <= 206)) 353 { 354 /* Compute day of the year given week number and weekday */ 355 int dow = (4 + _year_day [tm->tm_year - 70]) % 7; 356 if (mask & MASK_WEEKM) 357 dow--; 358 dow = (tm->tm_wday - dow) % 7; 359 if (dow < 0) dow += 7; 360 tm->tm_yday = week * 7 + dow; 361 mask |= MASK_YEARDAY; 362 } 363 else if ((mask & MASK_YEAR) && (mask & MASK_MONTH) && (mask & MASK_MONTHDAY)) 364 { 365 /* Compute year day from month and day of the month */ 366 const unsigned short *md = _leap_year (tm->tm_year + 1900) ? 367 _month_day_leap : _month_day_non_leap; 368 tm->tm_yday = tm->tm_mday - 1 + md [tm->tm_mon]; 369 mask |= MASK_YEARDAY; 370 } 371 } 372 373 if (!(mask & MASK_WEEKDAY) && (mask & MASK_YEAR) && (mask & MASK_YEARDAY)) 374 { 375 /* Compute day of the week if it was not given */ 376 if ((tm->tm_year < 70) || (tm->tm_year > 206)) 377 tm->tm_wday = 0; /* Unknown */ 378 else 379 { 380 int absday = _year_day [tm->tm_year - 70] + tm->tm_yday; 381 /* 1st January 1970 was Thursday (4) */ 382 tm->tm_wday = ((4 + absday) % 7); 383 mask |= MASK_WEEKDAY; 384 } 385 } 386 387 if (((mask & (MASK_WEEK | MASK_WEEKDAY | MASK_YEAR)) == (MASK_WEEK | MASK_WEEKDAY | MASK_YEAR)) 388 && ((mask & (MASK_MONTH | MASK_MONTHDAY)) != (MASK_MONTH | MASK_MONTHDAY))) 389 { 390 /* Compute month and day of the month given weekday and week number */ 391 const unsigned short *md = _leap_year (tm->tm_year + 1900) ? 392 _month_day_leap : _month_day_non_leap; 393 int days; 394 395 for (days = tm->tm_yday, tm->tm_mon = 0; days >= md [tm->tm_mon]; 396 days -= md [tm->tm_mon], tm->tm_mon++) 397 ; 398 tm->tm_mday = 1 + days; 399 mask |= MASK_MONTH | MASK_MONTHDAY; 400 } 401 402 /* Communicate to the caller which fields are filled, except fields 403 that are not located inside the tm structure. */ 404 if (retmask) 405 *retmask |= mask & ~(MASK_WEEK | MASK_CENTURY); 406 264 407 return s; 265 408 } 266 267 409 268 410 char *_STD(strptime) (const char *buf, const char *format, struct tm *tm) 269 411 { 270 412 return (char *)parse_fmt ((const unsigned char *)buf, 271 (const unsigned char *)format, tm );413 (const unsigned char *)format, tm, NULL); 272 414 } -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/pmgdb/breakpoi.cc
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r493 r494 344 344 for (const brkpt_node *p = list; p != NULL; p = p->next) 345 345 if (!p->source.is_null () && p->lineno == lineno 346 && _fncmp ((const unsigned char *)p->source,347 (const unsigned char *)fname) == 0)346 && strcasecmp ((const unsigned char *)p->source, 347 (const unsigned char *)fname) == 0) 348 348 return p; 349 349 return NULL; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/pmgdb/command.cc
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r493 r494 343 343 p = p->next) 344 344 if (p->get_source () != NULL 345 && _fncmp ((const unsigned char *)p->get_source (),346 (const unsigned char *)name) == 0)345 && strcasecmp ((const unsigned char *)p->get_source (), 346 (const unsigned char *)name) == 0) 347 347 src->set_breakpoint (p->get_lineno (), true, paint); 348 348 } … … 358 358 { 359 359 for (src_node *node = src_list; node != NULL; node = node->next) 360 if ( _fncmp ((const unsigned char *)node->src->get_short_filename (),361 (const unsigned char *)fname) == 0)360 if (strcasecmp ((const unsigned char *)node->src->get_short_filename (), 361 (const unsigned char *)fname) == 0) 362 362 return node->src; 363 363 return NULL; … … 368 368 { 369 369 for (src_node *node = src_list; node != NULL; node = node->next) 370 if ( _fncmp ((const unsigned char *)node->src->get_long_filename (),371 (const unsigned char *)fname) == 0)370 if (strcasecmp ((const unsigned char *)node->src->get_long_filename (), 371 (const unsigned char *)fname) == 0) 372 372 return node->src; 373 373 return NULL; -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/pmgdb/srcfiles.cc
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r493 r494 136 136 const source_files_window::srcs_node *n2 137 137 = *((source_files_window::srcs_node **)p2); 138 return _fncmp ((const unsigned char *)_getname (n1->fname),139 (const unsigned char *)_getname (n2->fname));138 return strcasecmp ((const unsigned char *)_getname (n1->fname), 139 (const unsigned char *)_getname (n2->fname)); 140 140 } 141 141 -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.