summaryrefslogtreecommitdiff
path: root/user/gnucobol/big-endian.patch
blob: 65e5243d28dce5709742e84ae71dae656de5a04b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
From 99cfa96676db1fcb6e4a5db89110c4991782eab6 Mon Sep 17 00:00:00 2001
From: sf-mensch <sf-mensch@ed166372-6744-4ac0-a67f-bb1ae9efa102>
Date: Mon, 25 Mar 2019 21:34:35 +0000
Subject: [PATCH] testsuite.src/run_misc.at: fixed test that expected
 little-endian values in dump to not check the dump content *FIXME: still
 expecting ASCII*

git-svn-id: https://svn.code.sf.net/p/open-cobol/code/trunk@3054 ed166372-6744-4ac0-a67f-bb1ae9efa102
---
 tests/testsuite.src/run_misc.at | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/tests/testsuite.src/run_misc.at b/tests/testsuite.src/run_misc.at
index 2ef4a86..173ac48 100644
--- a/tests/testsuite.src/run_misc.at
+++ b/tests/testsuite.src/run_misc.at
@@ -5918,6 +5918,10 @@ AT_CLEANUP
 AT_SETUP([MF FIGURATIVE to NUMERIC])
 AT_KEYWORDS([MOVE])
 
+# FIXME: This test will NOT work on EBCDIC machines,
+#        either add it explicit here and split into two or add
+#        a pre-test and check the expected "native" result
+
 AT_DATA([prog.cob], [
        IDENTIFICATION   DIVISION.
        PROGRAM-ID. prog.
@@ -5963,12 +5967,16 @@ AT_DATA([prog.cob], [
            DISPLAY "MOVE HIGH-VALUES TO BIGFLT"
            MOVE HIGH-VALUES TO BIGFLT.
            PERFORM SHOW-BIG.
+           CALL "dump" USING BIGFLT.
            DISPLAY "MOVE QUOTE TO BIGFLT"
            MOVE QUOTE TO BIGFLT.
            PERFORM SHOW-BIG.
+           CALL "dump" USING BIGFLT.
            DISPLAY "MOVE ALL * TO BIGFLT"
            MOVE ALL '*' TO BIGFLT.
            PERFORM SHOW-BIG.
+      *>   Note: the next results are dependant on endianess
+      *>         therefore no dump here
            DISPLAY "MOVE ALL '21' TO BIGFLT"
            MOVE ALL '21' TO BIGFLT.
            PERFORM SHOW-BIG.
@@ -5977,7 +5985,6 @@ AT_DATA([prog.cob], [
            CALL "dump" USING MYFLD.
        SHOW-BIG.
            DISPLAY "BIGFLT is " BIGFLT.
-           CALL "dump" USING BIGFLT.
 ])
 
 AT_DATA([cmod.c], [[
@@ -6033,10 +6040,8 @@ BIGFLT is 2.1973164E-18
 22222222 .
 MOVE ALL * TO BIGFLT
 BIGFLT is 5.4312347E+12
-DA119E54 .
 MOVE ALL '21' TO BIGFLT
 BIGFLT is 2.1212121E+37
-E5547F7D .
 ], [])
 
 AT_CLEANUP
-- 
2.15.3

From e0d02d05d50804d6fefe3f01d7eee8c943cb07e4 Mon Sep 17 00:00:00 2001
From: sf-mensch <sf-mensch@ed166372-6744-4ac0-a67f-bb1ae9efa102>
Date: Mon, 25 Mar 2019 21:41:12 +0000
Subject: [PATCH] testsuite.src/run_misc.at: fixed test that expected
 little-endian values in dump to not check the dump content *FIXME: still
 expecting ASCII*

git-svn-id: https://svn.code.sf.net/p/open-cobol/code/trunk@3055 ed166372-6744-4ac0-a67f-bb1ae9efa102

diff --git a/tests/testsuite.src/run_misc.at b/tests/testsuite.src/run_misc.at
index 173ac48..51f4b84 100644
--- a/tests/testsuite.src/run_misc.at
+++ b/tests/testsuite.src/run_misc.at
@@ -6005,7 +6005,7 @@ prog.cob:28: warning: numeric value is expected
 prog.cob:6: warning: 'MYFLD' defined here as PIC 9(4)
 prog.cob:34: warning: numeric value is expected
 prog.cob:6: warning: 'MYFLD' defined here as PIC 9(4)
-prog.cob:50: warning: numeric value is expected
+prog.cob:52: warning: numeric value is expected
 prog.cob:7: warning: 'BIGFLT' defined here as USAGE FLOAT
 ])
 
-- 
2.15.3

From 71b65c9fe2c6997e33c56457977d79fd10c3a8f2 Mon Sep 17 00:00:00 2001
From: sf-mensch <sf-mensch@ed166372-6744-4ac0-a67f-bb1ae9efa102>
Date: Mon, 15 Apr 2019 21:29:54 +0000
Subject: [PATCH] Partially merged r525 from branches/reportwriter and r3106
 from branches/pangaea: libcob/common.c (cob_sys_getopt_long_long): fix ENDIAN
 problem with CBL_GC_GETOPT

also applied minor reformatting to keep the function formatted consistently


git-svn-id: https://svn.code.sf.net/p/open-cobol/code/trunk@3115 ed166372-6744-4ac0-a67f-bb1ae9efa102

diff --git a/libcob/common.c b/libcob/common.c
index 5262282..d99c533 100644
--- a/libcob/common.c
+++ b/libcob/common.c
@@ -5138,9 +5138,7 @@ cob_sys_getopt_long_long (void *so, void *lo, void *idx, const int long_only, vo
 
 	COB_CHK_PARMS (CBL_GC_GETOPT, 6);
 
-	/*
-	 * Read in sizes of some parameters
-	 */
+	/* read in sizes of some parameters */
 	if (COB_MODULE_PTR->cob_procedure_params[1]) {
 		lo_size = COB_MODULE_PTR->cob_procedure_params[1]->size;
 	}
@@ -5151,9 +5149,7 @@ cob_sys_getopt_long_long (void *so, void *lo, void *idx, const int long_only, vo
 		opt_val_size = COB_MODULE_PTR->cob_procedure_params[5]->size;
 	}
 
-	/*
-	 * Buffering longoptions (COBOL), target format (struct option)
-	 */
+	/* buffering longoptions (COBOL), target format (struct option) */
 	if (lo_size % sizeof (longoption_def) == 0) {
 		lo_amount = (int)lo_size / sizeof (longoption_def);
 		longoptions_root = (struct option*) cob_malloc (sizeof (struct option) * (lo_amount + 1U));
@@ -5168,9 +5164,7 @@ cob_sys_getopt_long_long (void *so, void *lo, void *idx, const int long_only, vo
 	}
 	longind = cob_get_int (COB_MODULE_PTR->cob_procedure_params[2]);
 
-	/*
-	 * Add 0-termination to strings.
-	 */
+	/* add 0-termination to strings */
 	shortoptions = cob_malloc (so_size + 1U);
 	if (COB_MODULE_PTR->cob_procedure_params[0]) {
 		cob_field_to_string (COB_MODULE_PTR->cob_procedure_params[0], shortoptions, so_size);
@@ -5196,9 +5190,7 @@ cob_sys_getopt_long_long (void *so, void *lo, void *idx, const int long_only, vo
 		longoptions = longoptions + 1;
 	}
 
-	/*
-	 * Appending final record, so getopt can spot the end of longoptions
-	 */
+	/* appending final record, so getopt can spot the end of longoptions */
 	longoptions->name = NULL;
 	longoptions->has_arg = 0;
 	longoptions->flag = NULL;
@@ -5211,17 +5203,42 @@ cob_sys_getopt_long_long (void *so, void *lo, void *idx, const int long_only, vo
 	return_value = cob_getopt_long_long (cob_argc, cob_argv, shortoptions, longoptions, &longind, long_only);
 	temp = (char *) &return_value;
 
-	/*
-	 * Write data back to COBOL
-	 */
-	if (temp[0] == '?' || temp[0] == ':' || temp[0] == 'W'
-		|| temp[0] == -1 || temp[0] == 0) exit_status = return_value;
-	else exit_status = 3;
+	/* write data back to COBOL */
+#ifdef	WORDS_BIGENDIAN
+	if (temp[3] == '?'
+	 || temp[3] == ':'
+	 || temp[3] == 'W'
+	 || temp[3] == 0) {
+		exit_status = temp[3] & 0xFF;
+	} else if (return_value == -1) {
+		exit_status = -1;
+	} else {
+		exit_status = 3;
+	}
+	 /* cob_getopt_long_long sometimes returns and 'int' value and sometimes a 'x   ' in the int */
+	if (temp[0] == 0
+	 && temp[1] == 0
+	 && temp[2] == 0) {
+		/* Move option value to 1st byte and SPACE fill the 'int' */
+		temp[0] = temp[3];
+		temp[1] = temp[2] = temp[3] = ' ';
+	}
+#else
+	if (temp[0] == '?'
+	 || temp[0] == ':'
+	 || temp[0] == 'W'
+	 || temp[0] == -1
+	 || temp[0] == 0) {
+		exit_status = return_value;
+	} else {
+		exit_status = 3;
+	}
 
 	for (i = 3; i > 0; i--) {
-		if (temp[i] == 0x00) temp[i] = 0x20;
+		if (temp[i] == 0) temp[i] = ' ';
 		else break;
 	}
+#endif
 
 	cob_set_int (COB_MODULE_PTR->cob_procedure_params[2], longind);
 	memcpy (return_char, &return_value, 4);
-- 
2.15.3

From 9151800276cff454f11d250cb19d267def883978 Mon Sep 17 00:00:00 2001
From: sf-mensch <sf-mensch@ed166372-6744-4ac0-a67f-bb1ae9efa102>
Date: Mon, 15 Apr 2019 21:38:53 +0000
Subject: [PATCH] Partially merged r525 from branches/reportwriter:
 libcob/fileio.c (cob_sys_create_file, cob_sys_open_file): fix ENDIAN problem
 with CBL_CREATE_FILE, CBL_OPEN_FILE

also applied minor reformatting to keep the function formatted consistently


git-svn-id: https://svn.code.sf.net/p/open-cobol/code/trunk@3116 ed166372-6744-4ac0-a67f-bb1ae9efa102

diff --git a/libcob/fileio.c b/libcob/fileio.c
index 885cd48..521e245 100644
--- a/libcob/fileio.c
+++ b/libcob/fileio.c
@@ -5559,6 +5559,22 @@ cob_sys_open_file (unsigned char *file_name, unsigned char *file_access,
 
 	COB_CHK_PARMS (CBL_OPEN_FILE, 5);
 
+#ifdef	WORDS_BIGENDIAN
+	/* if value is passed as numeric literal, it becomes an 'int' so value is in 4th byte */
+	if (file_access[0] == 0
+	 && file_access[1] == 0
+	 && file_access[2] == 0)
+		file_access += 3;
+	if (file_lock[0] == 0
+	 && file_lock[1] == 0
+	 && file_lock[2] == 0)
+		file_lock += 3;
+	if (file_dev[0] == 0
+	 && file_dev[1] == 0
+	 && file_dev[2] == 0)
+		file_dev += 3;
+#endif
+
 	return open_cbl_file (file_name, file_access, file_handle, 0);
 }
 
@@ -5573,6 +5589,24 @@ cob_sys_create_file (unsigned char *file_name, unsigned char *file_access,
 	 * @param: file_dev : not implemented, set 0
 	 */
 
+	COB_CHK_PARMS (CBL_CREATE_FILE, 5);
+
+#ifdef	WORDS_BIGENDIAN
+	/* if value is passed as numeric literal, it becomes an 'int' so value is in 4th byte */
+	if (file_access[0] == 0
+	 && file_access[1] == 0
+	 && file_access[2] == 0)
+		file_access += 3;
+	if (file_lock[0] == 0
+	 && file_lock[1] == 0
+	 && file_lock[2] == 0)
+		file_lock += 3;
+	if (file_dev[0] == 0
+	 && file_dev[1] == 0
+	 && file_dev[2] == 0)
+		file_dev += 3;
+#endif
+
 	if (*file_lock != 0) {
 		cob_runtime_warning (_("call to CBL_CREATE_FILE with wrong file_lock: %d"), *file_lock);
 	}
@@ -5580,8 +5614,6 @@ cob_sys_create_file (unsigned char *file_name, unsigned char *file_access,
 		cob_runtime_warning (_("call to CBL_CREATE_FILE with wrong file_dev: %d"), *file_dev);
 	}
 
-	COB_CHK_PARMS (CBL_CREATE_FILE, 5);
-
 	return open_cbl_file (file_name, file_access, file_handle, O_CREAT | O_TRUNC);
 }
 
-- 
2.15.3

From f6ff480b71da490476abc84699558bddef6b9a56 Mon Sep 17 00:00:00 2001
From: sf-mensch <sf-mensch@ed166372-6744-4ac0-a67f-bb1ae9efa102>
Date: Tue, 18 Jun 2019 20:09:46 +0000
Subject: [PATCH] tests: * atlocal.in explicit disable BDB internal locking by
 unsetting DB_HOME to work around issues in different environments and to not
 pollute the users's general BDB locking files * skip UDF recursion test
 previously marked as expected fail as the current implementation may or may
 not work depending on the underlying C compiler/library in use (including the
 exact version...)

git-svn-id: https://svn.code.sf.net/p/open-cobol/code/trunk@3194 ed166372-6744-4ac0-a67f-bb1ae9efa102

diff --git a/tests/testsuite.src/run_functions.at b/tests/testsuite.src/run_functions.at
index 7c3c660..5ddbd58 100644
--- a/tests/testsuite.src/run_functions.at
+++ b/tests/testsuite.src/run_functions.at
@@ -1,4 +1,4 @@
-## Copyright (C) 2003-2012, 2014-2018 Free Software Foundation, Inc.
+## Copyright (C) 2003-2012, 2014-2019 Free Software Foundation, Inc.
 ## Written by Keisuke Nishida, Roger While, Simon Sobisch, Edward Hart
 ##
 ## This file is part of GnuCOBOL.
@@ -4145,7 +4145,7 @@ AT_CLEANUP
 AT_SETUP([UDF with recursion])
 AT_KEYWORDS([functions LOCAL-STORAGE])
 
-AT_XFAIL_IF(true)	# see bug #222 and r2291 - postponed
+AT_SKIP_IF(true)	# see bug #222 and r2291 - postponed
 
 AT_DATA([prog.cob], [
        IDENTIFICATION DIVISION.
-- 
2.15.3