Hi all
A clever idea! The problem is to get the parameters right. The above work for text files, but they're a bit unusual (and I wonder why GPC uses them for Input and Output).
So do I. But if I set them to e.g. 256,1 ("large" buffer, type text files), it didn't work. So I just took the values as for Input, Output).
But it seems strange to me in the first place why _p_initfdr() isn't called automatically -- after all, the compiler (util.c, function init_simple() generates code to do so). Could you generate an assembler output of your Pascal program (gpc -S), and check if it contains some calls to _p_initfdr(), and if so, what parameters are pushed before it.
I'm not familiar with assembler listings, but I definitely see _p_initfdr somewhere in there. But don't forget that Input and Output are always initialized with that function. I'll mail you the listing, Frank, no need to send the whole thing to the mailing list I presume...
Could you please check which parameters are pushed before the call to _p_read() in the assembler code of your program (or just send me the assembler file if that's easier to you)?
I'll send it too.
For another test, you could check the value of s_maxlen in the READ_STRING macro in rts-rdinc.c (with some printf) and see if it's already wrong there. (I suppose it is, but one never knows...)
Indeed, s_maxlen is zero as well. Strange:
Also, did you get any warnings (especially of type mismatches and the like) when compiling the RTS? This might indicate some non-portable type conversions in the C files.
These are all the warnings I got during the stage2 build for c and pascal using the stage 1 gcc-2.8.1 compiler (I didn't really worry about them, they did not seem too severe):
---begin--- p/version.c:59: warning: unknown escape sequence `)' include/sys/wait.h:90: warning: `WIFEXITED' redefined module.h:51: warning: this is the location of the previous definition include/sys/wait.h:92: warning: `WEXITSTATUS' redefined module.h:54: warning: this is the location of the previous definition include/sys/wait.h:94: warning: `WIFSIGNALED' redefined module.h:45: warning: this is the location of the previous definition include/sys/wait.h:96: warning: `WTERMSIG' redefined module.h:48: warning: this is the location of the previous definition module.c:1663: warning: comparison is always 0 due to limited range of data type include/sys/wait.h:90: warning: `WIFEXITED' redefined module.h:51: warning: this is the location of the previous definition include/sys/wait.h:92: warning: `WEXITSTATUS' redefined module.h:54: warning: this is the location of the previous definition include/sys/wait.h:94: warning: `WIFSIGNALED' redefined module.h:45: warning: this is the location of the previous definition include/sys/wait.h:96: warning: `WTERMSIG' redefined module.h:48: warning: this is the location of the previous definition include/sys/wait.h:90: warning: `WIFEXITED' redefined module.h:51: warning: this is the location of the previous definition include/sys/wait.h:92: warning: `WEXITSTATUS' redefined module.h:54: warning: this is the location of the previous definition include/sys/wait.h:94: warning: `WIFSIGNALED' redefined module.h:45: warning: this is the location of the previous definition include/sys/wait.h:96: warning: `WTERMSIG' redefined module.h:48: warning: this is the location of the previous definition types.c:197: warning: `this_set_type' might be used uninitialized in this function include/sys/wait.h:90: warning: `WIFEXITED' redefined module.h:51: warning: this is the location of the previous definition include/sys/wait.h:92: warning: `WEXITSTATUS' redefined module.h:54: warning: this is the location of the previous definition include/sys/wait.h:94: warning: `WIFSIGNALED' redefined module.h:45: warning: this is the location of the previous definition include/sys/wait.h:96: warning: `WTERMSIG' redefined module.h:48: warning: this is the location of the previous definition ./enquire.c:1401: warning: comparison is always 0 due to limited range of data type ./enquire.c:2443: warning: comparison is always 0 due to limited range of data type enquire.c:2147: warning: decimal constant is so large that it is unsigned enquire.c:2151: warning: decimal constant is so large that it is unsigned enquire.c:2147: warning: decimal constant is so large that it is unsigned enquire.c:2151: warning: decimal constant is so large that it is unsigned rts-write.c:69: warning: no previous prototype for `_p_write' rts-read.c:69: warning: no previous prototype for `_p_read' rts-read.c:152: warning: `_p_GetByt' was used with no prototype before its definition rts-block.c:33: warning: no previous prototype for `_p_blockread' rts-block.c:67: warning: no previous prototype for `_p_blockwrite' rts-file.c:169: warning: implicit declaration of function `strcasecmp' rts-random.c:85: warning: no previous prototype for `_p_truncate' rts-random.c:143: warning: suggest explicit braces to avoid ambiguous `else' rts-setup.c:28: warning: no previous prototype for `_p_setup' rts-setup.c:33: warning: no previous prototype for `_p_final' choose-temp.c:88: warning: implicit declaration of function `access' choose-temp.c:100: warning: no previous prototype for `choose_temp_base' choose-temp.c:108: warning: implicit declaration of function `getenv' choose-temp.c:129: warning: implicit declaration of function `malloc' choose-temp.c:144: warning: implicit declaration of function `mktemp' rts-error.c:171: warning: no previous prototype for `malloc_warning' rts-error.c:257: warning: no previous prototype for `_p_error' rts-misc.c:89: warning: no previous prototype for `_p_collect' rts-string.c:193: warning: no previous prototype for `_p_string' rts-string.c:396: warning: no previous prototype for `_p_writestr' rts-wrtinc.c:78: warning: implicit declaration of function `bcopy' rts-string.c:403: warning: `long_curlen' might be used uninitialized in this function rts-string.c:404: warning: `short_curlen' might be used uninitialized in this function rts-string.c:509: warning: no previous prototype for `_p_readstr' rts-string.c:614: warning: no previous prototype for `_p_val_byteint_check' rts-string.c:615: warning: no previous prototype for `_p_val_shortint_check' rts-string.c:616: warning: no previous prototype for `_p_val_integer_check' rts-string.c:617: warning: no previous prototype for `_p_val_medint_check' rts-string.c:618: warning: no previous prototype for `_p_val_longint_check' rts-string.c:619: warning: no previous prototype for `_p_val_bytecard_check' rts-string.c:620: warning: no previous prototype for `_p_val_shortcard_check' rts-string.c:621: warning: no previous prototype for `_p_val_cardinal_check' rts-string.c:622: warning: no previous prototype for `_p_val_medcard_check' rts-string.c:623: warning: no previous prototype for `_p_val_longcard_check' rts-string.c:624: warning: no previous prototype for `_p_val_byteint_nocheck' rts-string.c:625: warning: no previous prototype for `_p_val_shortint_nocheck' rts-string.c:626: warning: no previous prototype for `_p_val_integer_nocheck' rts-string.c:627: warning: no previous prototype for `_p_val_medint_nocheck' rts-string.c:628: warning: no previous prototype for `_p_val_longint_nocheck' rts-string.c:629: warning: no previous prototype for `_p_val_bytecard_nocheck' rts-string.c:630: warning: no previous prototype for `_p_val_shortcard_nocheck' rts-string.c:631: warning: no previous prototype for `_p_val_cardinal_nocheck' rts-string.c:632: warning: no previous prototype for `_p_val_medcard_nocheck' rts-string.c:633: warning: no previous prototype for `_p_val_longcard_nocheck' rts-string.c:662: warning: no previous prototype for `_p_val_shortreal' rts-string.c:663: warning: no previous prototype for `_p_val_real' rts-string.c:664: warning: no previous prototype for `_p_val_longreal' rts-bind.c:247: warning: implicit declaration of function `bcopy' rts-base.p:56: warning: no previous prototype for `__init_Rts_base' rts-assign.p:44: warning: no previous prototype for `__init_Rts_assign' rts-str.p:107: warning: passing arg 1 of `Insert_f' discards `const' from pointer target type rts-str.p:135: warning: no previous prototype for `__init_Rts_str' rts-numtodec.p:70: warning: `First_char' might be used uninitialized in this function rts-numtodec.p:204: warning: `Ch' might be used uninitialized in this function rts-numtodec.p:250: warning: no previous prototype for `__init_Rts_numtodec' rts-intfrac.p:72: warning: no previous prototype for `__init_Rts_intfrac' rts-move.p:94: warning: cast increases required alignment of target type rts-move.p:95: warning: cast increases required alignment of target type rts-move.p:99: warning: cast increases required alignment of target type rts-move.p:100: warning: cast increases required alignment of target type rts-move.p:102: warning: cast increases required alignment of target type rts-move.p:103: warning: cast increases required alignment of target type rts-move.p:106: warning: cast increases required alignment of target type rts-move.p:123: warning: cast increases required alignment of target type rts-move.p:124: warning: cast increases required alignment of target type rts-move.p:147: warning: pointer of type `void *' used in arithmetic rts-move.p:166: warning: cast increases required alignment of target type rts-move.p:170: warning: cast increases required alignment of target type rts-move.p:171: warning: cast increases required alignment of target type rts-move.p:172: warning: cast increases required alignment of target type rts-move.p:173: warning: cast increases required alignment of target type rts-move.p:185: warning: cast increases required alignment of target type rts-move.p:186: warning: cast increases required alignment of target type rts-move.p:208: warning: no previous prototype for `__init_Rts_move' vasprintf.c:119: warning: no previous prototype for `vasprintf' asprintf.c:27: warning: no previous prototype for `asprintf' gpc.pas:331: warning: no previous prototype for `__init_Gpc' /backup/gnu/gcc-2.8.1/p/rts/rts-emath.c:73: warning: type mismatch in implicit declaration for built-in function `sqrtl' /backup/gnu/gcc-2.8.1/p/rts/rts-emath.c:141: warning: type mismatch in implicit declaration for built-in function `sinl' /backup/gnu/gcc-2.8.1/p/rts/rts-emath.c:164: warning: type mismatch in implicit declaration for built-in function `cosl' Various warnings and error messages from fixproto are normal ---end---
Perhaps really the varargs are to blame -- I don't know much about their inner workings. I intend to get rid of them, anyway. If they're the problem here, this might be a reason to get rid of them even earlier than planned...
Maybe stdarg is broken in AIX, I don't know...
Nick