Skip to content

Commit 8826b05

Browse files
authored
Removed nullptr definition. (#715)
* Removed nullptr definition. * comment formatting in ansi_files.c
1 parent b98978e commit 8826b05

File tree

11 files changed

+245
-220
lines changed

11 files changed

+245
-220
lines changed

include/types.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ typedef wchar_t wint_t;
8383
#define TRUE 1
8484
#define FALSE 0
8585

86-
#define nullptr 0
8786
#define null 0
8887

8988
#ifndef NULL

src/PowerPC_EABI_Support/src/MSL_C/MSL_Common/FILE_POS.C

Lines changed: 102 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,29 @@
1515

1616
int _ftell(FILE* file)
1717
{
18-
int charsInUndoBuffer = 0;
19-
int position;
18+
int charsInUndoBuffer = 0;
19+
int position;
2020

21-
u8 tmp_kind = file->mMode.file_kind;
22-
if (!(tmp_kind == __disk_file || tmp_kind == __console_file) || file->mState.error) {
23-
errno = 0x28;
24-
return -1;
25-
}
21+
u8 tmp_kind = file->mMode.file_kind;
22+
if (!(tmp_kind == __disk_file || tmp_kind == __console_file) || file->mState.error)
23+
{
24+
errno = 0x28;
25+
return -1;
26+
}
2627

27-
if (file->mState.io_state == __neutral)
28-
return (file->mPosition);
28+
if (file->mState.io_state == __neutral)
29+
return (file->mPosition);
2930

30-
position = file->mBufferPosition + (file->mBufferPtr - file->mBuffer);
31+
position = file->mBufferPosition + (file->mBufferPtr - file->mBuffer);
3132

32-
if (file->mState.io_state >= __rereading) {
33-
charsInUndoBuffer = file->mState.io_state - __rereading + 1;
34-
position -= charsInUndoBuffer;
35-
}
33+
if (file->mState.io_state >= __rereading)
34+
{
35+
charsInUndoBuffer = file->mState.io_state - __rereading + 1;
36+
position -= charsInUndoBuffer;
37+
}
3638

37-
// got added in later it seems?
38-
/*if (!file->mMode.binary_io) {
39+
// got added in later it seems?
40+
/*if (!file->mMode.binary_io) {
3941
int n = file->mBufferPtr - file->mBuffer - charsInUndoBuffer;
4042
u8* p = (u8*)file->mBuffer;
4143
@@ -44,87 +46,99 @@ int _ftell(FILE* file)
4446
position++;
4547
}*/
4648

47-
return (position);
49+
return (position);
4850
}
4951

5052
int ftell(FILE* stream)
5153
{
52-
int retval;
54+
int retval;
5355

54-
__begin_critical_region(stdin_access);
55-
retval = (long)_ftell(stream);
56-
__end_critical_region(stdin_access);
57-
return retval;
56+
__begin_critical_region(stdin_access);
57+
retval = (long)_ftell(stream);
58+
__end_critical_region(stdin_access);
59+
return retval;
5860
}
5961

60-
int _fseek(FILE *file, fpos_t offset, int whence)
62+
int _fseek(FILE* file, fpos_t offset, int whence)
6163
{
62-
fpos_t pos;
63-
__pos_proc func;
64-
65-
unsigned char fileKind = file->mMode.file_kind;
66-
if (fileKind != 1 || file->mState.error != 0) {
67-
errno = 0x28;
68-
return -1;
69-
}
70-
71-
if (file->mState.io_state == 1) {
72-
if (__flush_buffer(file, nullptr) != 0) {
73-
file->mState.error = 1;
74-
file->mBufferLength = 0;
75-
errno = 0x28;
76-
return -1;
77-
}
78-
}
79-
80-
if (whence == SEEK_CUR) {
81-
whence = SEEK_SET;
82-
83-
if ((pos = _ftell(file)) < 0)
84-
pos = 0;
85-
86-
offset += pos;
87-
}
88-
89-
if ((whence != SEEK_END) && (file->mMode.io_mode != 3) && (file->mState.io_state == 2 || file->mState.io_state == 3)) {
90-
if ((offset >= file->mPosition) || !(offset >= file->mBufferPosition)) {
91-
file->mState.io_state = 0;
92-
} else {
93-
file->mBufferPtr = file->mBuffer + (offset - file->mBufferPosition);
94-
file->mBufferLength = file->mPosition - offset;
95-
file->mState.io_state = 2;
96-
}
97-
} else {
98-
file->mState.io_state = 0;
99-
}
100-
101-
if (file->mState.io_state == 0) {
102-
103-
if ((func = file->positionFunc) != nullptr && func(file->mHandle, &offset, whence, file->ref_con) != 0)
104-
{
105-
file->mState.error = 1;
106-
file->mBufferLength = 0;
107-
errno = 0x28;
108-
return -1;
109-
}
110-
else
111-
{
112-
file->mState.eof = 0;
113-
file->mPosition = offset;
114-
file->mBufferLength = 0;
115-
}
116-
}
117-
118-
return 0;
64+
fpos_t pos;
65+
__pos_proc func;
66+
67+
unsigned char fileKind = file->mMode.file_kind;
68+
if (fileKind != 1 || file->mState.error != 0)
69+
{
70+
errno = 0x28;
71+
return -1;
72+
}
73+
74+
if (file->mState.io_state == 1)
75+
{
76+
if (__flush_buffer(file, NULL) != 0)
77+
{
78+
file->mState.error = 1;
79+
file->mBufferLength = 0;
80+
errno = 0x28;
81+
return -1;
82+
}
83+
}
84+
85+
if (whence == SEEK_CUR)
86+
{
87+
whence = SEEK_SET;
88+
89+
if ((pos = _ftell(file)) < 0)
90+
pos = 0;
91+
92+
offset += pos;
93+
}
94+
95+
if ((whence != SEEK_END) && (file->mMode.io_mode != 3) &&
96+
(file->mState.io_state == 2 || file->mState.io_state == 3))
97+
{
98+
if ((offset >= file->mPosition) || !(offset >= file->mBufferPosition))
99+
{
100+
file->mState.io_state = 0;
101+
}
102+
else
103+
{
104+
file->mBufferPtr = file->mBuffer + (offset - file->mBufferPosition);
105+
file->mBufferLength = file->mPosition - offset;
106+
file->mState.io_state = 2;
107+
}
108+
}
109+
else
110+
{
111+
file->mState.io_state = 0;
112+
}
113+
114+
if (file->mState.io_state == 0)
115+
{
116+
if ((func = file->positionFunc) != NULL &&
117+
func(file->mHandle, &offset, whence, file->ref_con) != 0)
118+
{
119+
file->mState.error = 1;
120+
file->mBufferLength = 0;
121+
errno = 0x28;
122+
return -1;
123+
}
124+
else
125+
{
126+
file->mState.eof = 0;
127+
file->mPosition = offset;
128+
file->mBufferLength = 0;
129+
}
130+
}
131+
132+
return 0;
119133
}
120134

121-
int fseek(FILE *stream, fpos_t offset, int whence)
135+
int fseek(FILE* stream, fpos_t offset, int whence)
122136
{
123-
fpos_t start;
124-
int code;
125-
start = offset;
126-
__begin_critical_region(stdin_access);
127-
code = _fseek(stream, start, whence); // 0 if successful, -1 if error
128-
__end_critical_region(stdin_access);
129-
return code;
137+
fpos_t start;
138+
int code;
139+
start = offset;
140+
__begin_critical_region(stdin_access);
141+
code = _fseek(stream, start, whence); // 0 if successful, -1 if error
142+
__end_critical_region(stdin_access);
143+
return code;
130144
}

src/PowerPC_EABI_Support/src/MSL_C/MSL_Common/ansi_files.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern int __close_console(u32);
1414
// clang-format off
1515
FILE __files[4] =
1616
{
17-
{ 0, // _00
17+
{ 0, // _00
1818
0, // _04, open_mode
1919
1, // _04, io_mode
2020
1, // _04, buffer_mode
@@ -31,22 +31,22 @@ FILE __files[4] =
3131
0, // _10
3232
0, // _12
3333
0, // _14
34-
0, // _18
34+
0, // _18
3535
stdin_buff, // _1C
3636
sizeof(stdin_buff), // _20
3737
stdin_buff, // _24
3838
0, // _28
3939
0, // _2C
4040
0, // _30
4141
0, // _34
42-
nullptr, // _38
42+
NULL, // _38
4343
&__read_console, // _3C
4444
&__write_console, // _40
4545
&__close_console, // _44
4646
0, // _48
4747
&__files[1] // _4C
4848
},
49-
{ 1, // _00
49+
{ 1, // _00
5050
0, // _04, open_mode
5151
2, // _04, io_mode
5252
1, // _04, buffer_mode
@@ -63,22 +63,22 @@ FILE __files[4] =
6363
0, // _10
6464
0, // _12
6565
0, // _14
66-
0, // _18
66+
0, // _18
6767
stdout_buff, // _1C
6868
sizeof(stdout_buff), // _20
6969
stdout_buff, // _24
7070
0, // _28
7171
0, // _2C
7272
0, // _30
7373
0, // _34
74-
nullptr, // _38
74+
NULL, // _38
7575
&__read_console, // _3C
7676
&__write_console, // _40
7777
&__close_console, // _44
7878
0, // _48
7979
&__files[2] // _4C
8080
},
81-
{ 2, // _00
81+
{ 2, // _00
8282
0, // _04, open_mode
8383
2, // _04, io_mode
8484
0, // _04, buffer_mode
@@ -95,15 +95,15 @@ FILE __files[4] =
9595
0, // _10
9696
0, // _12
9797
0, // _14
98-
0, // _18
98+
0, // _18
9999
stderr_buff, // _1C
100100
sizeof(stderr_buff), // _20
101101
stderr_buff, // _24
102102
0, // _28
103103
0, // _2C
104104
0, // _30
105105
0, // _34
106-
nullptr, // _38
106+
NULL, // _38
107107
&__read_console, // _3C
108108
&__write_console, // _40
109109
&__close_console, // _44
@@ -135,7 +135,7 @@ void __close_all()
135135
{
136136
plast->mMode.file_kind = __unavailable_file;
137137
if ((p != NULL) && p->mIsDynamicallyAllocated)
138-
plast->mNextFile = nullptr;
138+
plast->mNextFile = NULL;
139139
}
140140
}
141141

0 commit comments

Comments
 (0)