Skip to content

Commit 7e28ab9

Browse files
committed
Merge branch 'master' of github.com:holzschu/ios_system
2 parents f2565ef + 6f46f90 commit 7e28ab9

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

ios_system.m

+20-4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,22 @@
5151
__thread FILE* thread_stderr;
5252
__thread void* thread_context;
5353

54+
FILE* ios_stdin(void) {
55+
return thread_stdin;
56+
}
57+
58+
FILE* ios_stdout(void) {
59+
return thread_stdout;
60+
}
61+
62+
FILE* ios_stderr(void) {
63+
return thread_stderr;
64+
}
65+
66+
void* ios_context(void) {
67+
return thread_context;
68+
}
69+
5470
// Parameters for each session. We can have multiple sessions running in parallel.
5571
typedef struct _sessionParameters {
5672
bool isMainThread; // are we on the first command?
@@ -67,8 +83,8 @@
6783
void* context;
6884
int global_errno;
6985
char commandName[NAME_MAX];
70-
char columns[4];
71-
char lines[4];
86+
char columns[5];
87+
char lines[5];
7288
bool activePager;
7389
} sessionParameters;
7490

@@ -239,8 +255,8 @@ void ios_setWindowSize(int width, int height, const void* sessionId) {
239255
return;
240256
}
241257

242-
sprintf(resizedSession->columns, "%d", width);
243-
sprintf(resizedSession->lines, "%d",height);
258+
sprintf(resizedSession->columns, "%d", MIN(width, 9999));
259+
sprintf(resizedSession->lines, "%d", MIN(height, 9999));
244260
// Also send SIGWINCH to the main thread of resizedSession:
245261
if (resizedSession->current_command_root_thread != NULL) {
246262
pthread_kill(resizedSession->current_command_root_thread, SIGWINCH);

ios_system/ios_system.h

+9
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ extern __thread FILE* thread_stdin;
2020
extern __thread FILE* thread_stdout;
2121
extern __thread FILE* thread_stderr;
2222
extern __thread void* thread_context;
23+
24+
// rust doesn't support extern __thread vars yet
25+
// see https://github.com/rust-lang/rust/issues/30795
26+
// so we provide function accessors for them.
27+
extern FILE* ios_stdin(void);
28+
extern FILE* ios_stdout(void);
29+
extern FILE* ios_stderr(void);
30+
extern void* ios_context(void);
31+
2332
// set to true to have more commands available, more debugging information.
2433
extern bool sideLoading;
2534
// set to false to have the main thread run in detached mode (non blocking)

0 commit comments

Comments
 (0)