mirror of
https://github.com/LIV2/libnix.git
synced 2025-12-06 00:23:08 +00:00
make nix13/library work with c++
This commit is contained in:
parent
90cc6be056
commit
5633c334f8
4
preplib
4
preplib
@ -94,8 +94,10 @@ rm -f tainted2.txt
|
||||
|
||||
echo ".data ___sF" >>libnix.def
|
||||
echo ".data ___errno" >>libnix.def
|
||||
echo ".data __ctype_ptr" >>libnix.def
|
||||
echo ".data __ctype_" >>libnix.def
|
||||
echo ".data _environ_ptr" >>libnix.def
|
||||
echo ".data ___timezone" >>libnix.def
|
||||
echo ".data ___daylight" >>libnix.def
|
||||
echo ".data ___tzname" >>libnix.def
|
||||
echo ".data ___decimalpoint" >>libnix.def
|
||||
echo ".data __impure_ptr" >>libnix.def
|
||||
@ -71,12 +71,12 @@ extern __stdargs int toascii_l (int __c, locale_t __l);
|
||||
#define _B 0200
|
||||
|
||||
#ifdef __HAVE_LOCALE_INFO__
|
||||
__stdargs const char *__locale_ctype_ptr (void);
|
||||
__stdargs const char *__locale_ctype_ (void);
|
||||
#else
|
||||
#define __locale_ctype_ptr() _ctype_ptr
|
||||
#define __locale_ctype_() _ctype_
|
||||
#endif
|
||||
|
||||
# define __CTYPE_PTR (__locale_ctype_ptr ())
|
||||
# define __CTYPE_PTR (__locale_ctype_ ())
|
||||
|
||||
#ifndef __cplusplus
|
||||
/* These macros are intentionally written in a manner that will trigger
|
||||
@ -114,7 +114,7 @@ __stdargs const char *__locale_ctype_ptr (void);
|
||||
#ifdef __HAVE_LOCALE_INFO__
|
||||
__stdargs const char *__locale_ctype_ptr_l (locale_t);
|
||||
#else
|
||||
#define __locale_ctype_ptr_l(l) _ctype_ptr
|
||||
#define __locale_ctype_ptr_l(l) _ctype_
|
||||
#endif
|
||||
#define __ctype_lookup_l(__c,__l) ((__locale_ctype_ptr_l(__l)+sizeof(""[__c]))[(int)(__c)])
|
||||
|
||||
@ -177,7 +177,7 @@ __stdargs const char *__locale_ctype_ptr_l (locale_t);
|
||||
#endif /* !__cplusplus */
|
||||
|
||||
/* For C++ backward-compatibility only. */
|
||||
extern const char * _ctype_ptr;
|
||||
extern const char * _ctype_;
|
||||
|
||||
_END_STD_C
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
#include <stddef.h>
|
||||
|
||||
const unsigned char _ctype_ptr__data[]=
|
||||
const unsigned char _ctype___data[]=
|
||||
{ 0x00,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x28,0x28,0x28,0x28,0x28,0x20,0x20,
|
||||
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
|
||||
@ -22,10 +22,10 @@ const unsigned char _ctype_ptr__data[]=
|
||||
};
|
||||
|
||||
__near
|
||||
const unsigned char * _ctype_ptr = _ctype_ptr__data;
|
||||
const unsigned char * _ctype_ = _ctype___data;
|
||||
|
||||
const unsigned char *
|
||||
__locale_ctype_ptr (void)
|
||||
__locale_ctype_ (void)
|
||||
{
|
||||
return _ctype_ptr__data;
|
||||
return _ctype___data;
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
extern const unsigned char * _ctype_ptr;
|
||||
extern const unsigned char * _ctype_;
|
||||
|
||||
int isalnum(int c)
|
||||
{ return _ctype_ptr[1+c]&7; }
|
||||
{ return _ctype_[1+c]&7; }
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
extern const unsigned char * _ctype_ptr;
|
||||
extern const unsigned char * _ctype_;
|
||||
|
||||
int isalpha(int c)
|
||||
{ return _ctype_ptr[1+c]&3; }
|
||||
{ return _ctype_[1+c]&3; }
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
extern const unsigned char * _ctype_ptr;
|
||||
extern const unsigned char * _ctype_;
|
||||
|
||||
int iscntrl(int c)
|
||||
{ return _ctype_ptr[1+c]&32; }
|
||||
{ return _ctype_[1+c]&32; }
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
extern const unsigned char * _ctype_ptr;
|
||||
extern const unsigned char * _ctype_;
|
||||
|
||||
int isdigit(int c)
|
||||
{ return _ctype_ptr[1+c]&4; }
|
||||
{ return _ctype_[1+c]&4; }
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
extern const unsigned char * _ctype_ptr;
|
||||
extern const unsigned char * _ctype_;
|
||||
|
||||
int isgraph(int c)
|
||||
{ return _ctype_ptr[1+c]&23; }
|
||||
{ return _ctype_[1+c]&23; }
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
extern const unsigned char * _ctype_ptr;
|
||||
extern const unsigned char * _ctype_;
|
||||
|
||||
int islower(int c)
|
||||
{ return _ctype_ptr[1+c]&2; }
|
||||
{ return _ctype_[1+c]&2; }
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
extern const unsigned char * _ctype_ptr;
|
||||
extern const unsigned char * _ctype_;
|
||||
|
||||
int isprint(int c)
|
||||
{ return _ctype_ptr[1+c]&151; }
|
||||
{ return _ctype_[1+c]&151; }
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
extern const unsigned char * _ctype_ptr;
|
||||
extern const unsigned char * _ctype_;
|
||||
|
||||
int ispunct(int c)
|
||||
{ return _ctype_ptr[1+c]&16; }
|
||||
{ return _ctype_[1+c]&16; }
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
extern const unsigned char * _ctype_ptr;
|
||||
extern const unsigned char * _ctype_;
|
||||
|
||||
int isspace(int c)
|
||||
{ return _ctype_ptr[1+c]&8; }
|
||||
{ return _ctype_[1+c]&8; }
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
extern const unsigned char * _ctype_ptr;
|
||||
extern const unsigned char * _ctype_;
|
||||
|
||||
int isupper(int c)
|
||||
{ return _ctype_ptr[1+c]&1; }
|
||||
{ return _ctype_[1+c]&1; }
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
extern const unsigned char * _ctype_ptr;
|
||||
extern const unsigned char * _ctype_;
|
||||
|
||||
int isxdigit(int c)
|
||||
{ return _ctype_ptr[1+c]&68; }
|
||||
{ return _ctype_[1+c]&68; }
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
extern const unsigned char * _ctype_ptr;
|
||||
extern const unsigned char * _ctype_;
|
||||
|
||||
int tolower(int c)
|
||||
{ return _ctype_ptr[1+c]&1?c+'a'-'A':c; }
|
||||
{ return _ctype_[1+c]&1?c+'a'-'A':c; }
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
extern const unsigned char * _ctype_ptr;
|
||||
extern const unsigned char * _ctype_;
|
||||
|
||||
int toupper(int c)
|
||||
{ return _ctype_ptr[1+c]&2?c+'A'-'a':c; }
|
||||
{ return _ctype_[1+c]&2?c+'A'-'a':c; }
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
extern const unsigned char * _ctype_ptr;
|
||||
extern const unsigned char * _ctype_;
|
||||
|
||||
int towlower(int c)
|
||||
{ return _ctype_ptr[1+c]&1?c+L'a'-L'A':c; }
|
||||
{ return _ctype_[1+c]&1?c+L'a'-L'A':c; }
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
extern const unsigned char * _ctype_ptr;
|
||||
extern const unsigned char * _ctype_;
|
||||
|
||||
int towupper(int c)
|
||||
{ return _ctype_ptr[1+c]&2?c+L'A'-L'a':c; }
|
||||
{ return _ctype_[1+c]&2?c+L'A'-L'a':c; }
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
char __decimalpoint_data = '.';
|
||||
char * __decimalpoint = &__decimalpoint_data;
|
||||
char __decimalpoint__data = '.';
|
||||
char * __decimalpoint = &__decimalpoint__data;
|
||||
|
||||
@ -14,6 +14,7 @@ int strcoll(const char *s1, const char *s2) {
|
||||
return StrnCmp(__localevec[LC_COLLATE-1], (STRPTR )s1, (STRPTR )s2, LONG_MAX, SC_COLLATE1);
|
||||
}
|
||||
#else
|
||||
#include <stabs.h>
|
||||
ALIAS(strcoll,strcmp);
|
||||
int strcoll(const char *s1, const char *s2) {
|
||||
return strcmp(s1, s2);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -14,6 +14,8 @@ size_t strxfrm(char *buffer, const char *s, size_t n) {
|
||||
return StrConvert(__localevec[LC_COLLATE-1], (STRPTR )s, (STRPTR )buffer, n, SC_COLLATE1);
|
||||
}
|
||||
#else
|
||||
#include <stabs.h>
|
||||
ALIAS(strxfrm,strncpy);
|
||||
size_t strxfrm(char *buffer, const char *s, size_t n) {
|
||||
strncpy(buffer, s, n);
|
||||
return strlen(s);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -15,9 +15,9 @@ extern struct LocaleBase *LocaleBase;
|
||||
extern struct Locale *__localevec[];
|
||||
|
||||
/* for LC_CTYPE */
|
||||
extern const unsigned char _ctype_ptr__data[];
|
||||
extern const unsigned char _ctype___data[];
|
||||
__near
|
||||
extern const unsigned char * _ctype_ptr;
|
||||
extern const unsigned char * _ctype_;
|
||||
static unsigned char *ctype;
|
||||
|
||||
/* for LC_NUMERIC */
|
||||
@ -127,10 +127,10 @@ char *setlocale(int category, const char *name) {
|
||||
for (i = 0; i < 256; i++)
|
||||
ctype[i + 1] = ((IsPrint(locale,i) && !IsGraph(locale, i)) ? 128 : 0) | (IsXDigit(locale,i) ? 64 : 0) | (IsCntrl(locale,i) ? 32 : 0) | (IsPunct(locale,i) ? 16 : 0)
|
||||
| (IsSpace(locale,i) ? 8 : 0) | (IsDigit(locale,i) ? 4 : 0) | (IsLower(locale,i) ? 2 : 0) | (IsUpper(locale,i) ? 1 : 0);
|
||||
_ctype_ptr = ctype;
|
||||
_ctype_ = ctype;
|
||||
} else
|
||||
#endif
|
||||
_ctype_ptr = _ctype_ptr__data;
|
||||
_ctype_ = _ctype___data;
|
||||
|
||||
#ifndef __KICK13__
|
||||
if (__localevec[LC_MONETARY - 1] != NULL) {
|
||||
@ -203,10 +203,12 @@ void __initlocale(void) {
|
||||
}
|
||||
|
||||
void __exitlocale(void) {
|
||||
#ifndef __KICK13__
|
||||
int i;
|
||||
for (i = 0; i < 5; i++)
|
||||
if (__localevec[i] != NULL)
|
||||
CloseLocale(__localevec[i]);
|
||||
#endif
|
||||
}
|
||||
|
||||
ADD2INIT(__initlocale, -10);
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
asm("\t.bss");
|
||||
asm("____stdin: .globl ____stdin");
|
||||
asm("___errno__data: .globl ___errno__data");
|
||||
asm("__impure_ptr__data: .globl __impure_ptr__data");
|
||||
asm("\t.long 0");
|
||||
asm("___sF__data: .globl ___sF__data");
|
||||
asm("\t.long 0");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user