File: import_diff.patch

package info (click to toggle)
bwbasic 2.20pl2-13
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 1,764 kB
  • sloc: ansic: 21,002; makefile: 80
file content (444 lines) | stat: -rw-r--r-- 14,101 bytes parent folder | download | duplicates (2)
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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
Description: Import old diff in patch format

---

--- bwbasic-2.20pl2.orig/Makefile.in
+++ bwbasic-2.20pl2/Makefile.in
@@ -10,10 +10,6 @@ VPATH = @srcdir@
 
 CC = @CC@
 
-INSTALL = @INSTALL@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_DATA = @INSTALL_DATA@
-
 DEFS = @DEFS@
 
 # Revised by JBV
@@ -23,9 +19,8 @@ CFLAGS = -g -ansi
 # Revised by JBV
 #LDFLAGS = -s
 
-prefix = /usr/local
-exec_prefix = $(prefix)
-bindir = $(exec_prefix)/bin
+# Modified by Vince Mulhollon
+BIN = $(DESTDIR)/usr/bin/
 
 SHELL = /bin/sh
 
@@ -59,8 +54,8 @@ TESTFILES=	\
 DISTFILES=	$(CFILES) $(HFILES) $(MISCFILES)
 
 # Revised by JBV
-#all: bwbasic
-all: bwbasic renum
+# Vince Mulhollon added bwbasic.1
+all: bwbasic bwbasic.1 renum
 
 bwbasic:	$(OFILES)
 		$(CC) $(OFILES) -lm -o $@ $(LDFLAGS)
@@ -69,16 +64,29 @@ bwbasic:	$(OFILES)
 renum:
 	$(CC) renum.c -o renum
 
+# Added by Vince Mulhollon
+bwbasic.1: bwbasic.doc
+	set -e; \
+	exec > $@; \
+	echo '.TH BWBASIC 1 "October 11, 1993"'; \
+	echo '.SH NAME'; \
+	echo 'bwbasic \- Bywater BASIC interpreter/shell'; \
+	echo '.RE'; \
+	echo '.nf'; \
+	expand $<
+
 $(OFILES):      $(HFILES)
 
 .c.o:
 	$(CC) -c $(CPPFLAGS) -I$(srcdir) $(DEFS) $(CFLAGS) $<
 
-install: all
-	$(INSTALL_PROGRAM) bwbasic $(bindir)/bwbasic
+install: ${ALL}
+	mkdir -p ${BIN}
+	install bwbasic ${BIN}
+	install renum ${BIN}
 
 uninstall:
-	rm -f $(bindir)/bwbasic
+	rm -f $(bindir)/bwbasic $(bindir)/renum
 
 Makefile: Makefile.in config.status
 	$(SHELL) config.status
@@ -90,8 +98,9 @@ configure: configure.in
 TAGS:	$(CFILES)
 	etags $(CFILES)
 
+# Vince Mulhollon added bwbasic.1
 clean:
-	rm -f *.o bwbasic core
+	rm -f *.o bwbasic bwbasic.1 renum core
 
 mostlyclean: clean
 
--- bwbasic-2.20pl2.orig/bwb_cmd.c
+++ bwbasic-2.20pl2/bwb_cmd.c
@@ -552,7 +552,7 @@ bwb_on( l )
    struct bwb_line *oline, *x;
    char varname[ MAXVARNAMESIZE + 1 ];
    char tbuf[ MAXSTRINGSIZE + 1 ];
-   static int p;
+   static int startpos;
    struct exp_ese *rvar;
    int v;
    int loop;
@@ -579,6 +579,10 @@ bwb_on( l )
          break;
       }
 
+   /* save starting position if this doesn't turn out to be ON ERROR */
+
+   startpos = l->position;
+
    /* get the variable name or numerical constant */
 
    adv_element( l->buffer, &( l->position ), varname );
@@ -598,10 +602,10 @@ bwb_on( l )
       }
 #endif	/* COMMON_CMDS */
 
-   /* evaluate the variable name or constant */
+   /* evaluate expression from the start */
 
-   p = 0;
-   rvar = bwb_exp( varname, FALSE, &p );
+   l->position = startpos;
+   rvar = bwb_exp( l->buffer, FALSE, &l->position );
    v = (int) exp_getnval( rvar );
 
 #if INTENSIVE_DEBUG
--- bwbasic-2.20pl2.orig/bwb_dio.c
+++ bwbasic-2.20pl2/bwb_dio.c
@@ -90,7 +90,6 @@ bwb_open( l )
    {
    FILE *fp;
    struct exp_ese *e;
-   int previous_buffer;
    char atbuf[ MAXSTRINGSIZE + 1 ];
    char first[ MAXSTRINGSIZE + 1 ];
    char devname[ MAXSTRINGSIZE + 1 ];
@@ -98,7 +97,6 @@ bwb_open( l )
    /* initialize */
 
    mode = req_devnumber = rlen = -1;
-   previous_buffer = FALSE;
 
    /* get the first expression element up to comma or whitespace */
 
@@ -435,7 +433,15 @@ bwb_open( l )
       sprintf( bwb_ebuf, "in bwb_open(): using previously closed file (and buffer)" );
       bwb_debug( bwb_ebuf );
 #endif
-      previous_buffer = TRUE;
+      /*
+       * Previous code assumed that buffer was always valid, and
+       * always the right size.  (MJS)
+       */
+      if (dev_table[ req_devnumber ].buffer != NULL) 
+         {
+         free (dev_table[ req_devnumber ].buffer);
+         dev_table[ req_devnumber ].buffer = NULL;
+         }
       }
 
    if ( ( dev_table[ req_devnumber ].mode != DEVMODE_CLOSED ) &&
@@ -512,7 +518,7 @@ bwb_open( l )
 
    /* allocate a character buffer for random access */
 
-   if (( mode == DEVMODE_RANDOM ) && ( previous_buffer != TRUE ))
+   if ( mode == DEVMODE_RANDOM )
       {
       /* Revised to CALLOC pass-thru call by JBV */
       if ( ( dev_table[ req_devnumber ].buffer = CALLOC( rlen + 1, 1, "bwb_open" )) == NULL )
--- bwbasic-2.20pl2.orig/bwb_elx.c
+++ bwbasic-2.20pl2/bwb_elx.c
@@ -754,7 +754,7 @@ exp_function( expression )
       sizeof( struct bwb_variable ), "exp_function" )) == NULL )
       {
       bwb_error( err_getmem );
-      return NULL;
+      return OP_ERROR;
       }
 
    /* assign pointers to argument stack */
--- bwbasic-2.20pl2.orig/bwb_fnc.c
+++ bwbasic-2.20pl2/bwb_fnc.c
@@ -1437,8 +1437,11 @@ fnc_environ( argc, argv, unique_id )
    /* Added check for getenv return value to prevent segmentation faults */
    /* JBV 3/15/96                                                        */
    /*--------------------------------------------------------------------*/
-   if (getenv( tbuf ) != NULL) strcpy( tmp, getenv( tbuf ));
-   else strcpy( tmp, "" );
+   /* if (getenv( tbuf ) != NULL) strcpy( tmp, getenv( tbuf )); */
+   /* else strcpy( tmp, "" ); */
+
+   /* Patch from Steve Kemp 2007-08-29 */
+   if (getenv( tbuf ) != NULL) strncpy( tmp, getenv( tbuf ), sizeof(tmp)-1);
 
    str_ctob( var_findsval( &nvar, nvar.array_pos ), tmp );
 
--- bwbasic-2.20pl2.orig/bwb_mes.h
+++ bwbasic-2.20pl2/bwb_mes.h
@@ -356,6 +356,7 @@
 #define CMD_REM		"REM"
 #define CMD_LET		"LET"
 #define CMD_PRINT	"PRINT"
+#define CMD_QUESTION	"?"
 #define CMD_INPUT	"INPUT"
 #define CMD_GO          "GO"
 #define CMD_GOTO        "GOTO"
--- bwbasic-2.20pl2.orig/bwb_tbl.c
+++ bwbasic-2.20pl2/bwb_tbl.c
@@ -147,6 +147,7 @@ struct bwb_command bwb_cmdtable[ COMMAND
       { CMD_ON,           bwb_on },
       { CMD_OPTION,       bwb_option },
       { CMD_PRINT,        bwb_print },
+      { CMD_QUESTION,     bwb_print },
       { CMD_RANDOMIZE,    bwb_randomize },
       { CMD_READ,         bwb_read },
       { CMD_REM,          bwb_rem },
--- bwbasic-2.20pl2.orig/bwb_var.c
+++ bwbasic-2.20pl2/bwb_var.c
@@ -376,7 +376,7 @@ bwb_swap( l )
    lhs->array_pos = rhs->array_pos;
    lhs->dimensions = rhs->dimensions;
 
-   if ( lhs->type = NUMBER )
+   if ( lhs->type == NUMBER )
       {
       rhs->memnum = tmp.memnum;
       }
@@ -1806,7 +1806,7 @@ dim_unit( v, pp )
       {
 #if PROG_ERRORS
       sprintf( bwb_ebuf, "in dim_unit(): unit value <%ld> exceeds array units <%ld>",
-         r, v->array_units );
+         (long) r, (long) v->array_units );
       bwb_error( bwb_ebuf );
 #else
       bwb_error( err_valoorange );
@@ -2507,6 +2507,12 @@ var_islocal( buffer )
    {
    struct bwb_variable *v;
 
+   if ( exsc < 0 )
+      {
+      /* no execution stack yet (e.g. during bwb_init()) */
+      return NULL;
+      }
+
 #if INTENSIVE_DEBUG
    sprintf( bwb_ebuf, "in var_islocal(): check for local variable <%s> EXEC level <%d>",
       buffer, CURTASK exsc );
--- bwbasic-2.20pl2.orig/bwbasic.c
+++ bwbasic-2.20pl2/bwbasic.c
@@ -51,7 +51,7 @@
 char *bwb_ebuf;				/* error buffer */
 static char *read_line;
 int bwb_trace = FALSE;
-FILE *errfdevice = stderr;              /* output device for error messages */
+FILE *errfdevice;              /* output device for error messages */
 
 #if HAVE_LONGJUMP
 jmp_buf mark;
@@ -133,6 +133,7 @@ bwb_init( argc, argv )
    static char end_buf[] = "\0";
 #endif
 
+   errfdevice = stderr;
 #if INTENSIVE_DEBUG
    prn_xprintf( stderr, "Memory Allocation Statistics:\n" );
    prn_xprintf( stderr, "----------------------------\n" );
@@ -1030,6 +1031,7 @@ bwb_mainloop( void )
 bwb_mainloop()
 #endif
    {
+   errfdevice = stderr;
    if ( CURTASK exsc > -1 )
       {
       bwb_execline();			/* execute one line of program */
--- bwbasic-2.20pl2.orig/bwbasic.doc
+++ bwbasic-2.20pl2/bwbasic.doc
@@ -209,7 +209,7 @@ CONTENTS:
    added to the program in memory.
 
    Line numbers are not strictly required, but are useful if the
-   interactive enviroment is used for programming.  For longer
+   interactive environment is used for programming.  For longer
    program entry one might prefer to use an ASCII text editor, and
    in this case lines can be entered without numbers. One can use
    DO NUM and DO UNNUM to number or unnumber lines. See also the
@@ -307,7 +307,7 @@ CONTENTS:
 
 5. EXPANDED REFERENCE FOR COMMANDS AND FUNCTIONS
 
-   The "Dependencies" listed in the folowing reference materials
+   The "Dependencies" listed in the following reference materials
    refers to flags that must be set to TRUE in bwbasic.h for the
    associated command or function to be implemented.  These flags
    are as follows:
@@ -321,7 +321,7 @@ CONTENTS:
    COMMON_CMDS		Commands beyond ANSI Minimal BASIC which are common
    			to Full ANSI BASIC and Microsoft BASICs
 
-   COMMON_FUNCS		Functions beyond the ANSI Mimimal BASIC core, but
+   COMMON_FUNCS		Functions beyond the ANSI Minimal BASIC core, but
    			common to both ANSI Full BASIC and Microsoft-style
    			BASIC varieties
 
@@ -493,7 +493,7 @@ CONTENTS:
                  number (precision is irrelevant in bwBASIC since
                  bwBASIC numbers have only one precision).
 
-   Implenentation-Specific Notes:
+   Implementation-Specific Notes:
 
    CVD(), CVI(), CVS(), MKI$(), MKD$(), MKS$(): These functions
    are implemented, but are dependent on a) the sizes for integer,
@@ -667,7 +667,7 @@ CONTENTS:
    Description:  EDIT is a pseudo-command which calls the text editor
                  specified in the variable BWB.EDITOR$ to edit the
                  program in memory.  After the call to the text editor,
-                 the (edited) prgram is reloaded into memory.  The user
+                 the (edited) program is reloaded into memory.  The user
                  normally must specific a valid path and filename in
                  BWB.EDITOR$ before this command will be useful.
 
@@ -840,7 +840,7 @@ CONTENTS:
 
    Description:  FUNCTION introduces a function definition, normally
                  ending with END FUNCTION.  In bwBASIC, FUNCTION and
-                 DEF are qorking equivalents, so either can be used
+                 DEF are working equivalents, so either can be used
                  with single-line function definitions or with multi-
                  line definitions terminated by END FUNCTION.
 
@@ -861,7 +861,7 @@ CONTENTS:
 
    Command:      GET [#] device-number [, record-number]
 
-   Description:  GET reads the next reacord from a random-access file
+   Description:  GET reads the next record from a random-access file
                  or device into the buffer associated with that file.
                  If record-number is specified, the GET command reads the
                  specified record.
@@ -1406,7 +1406,7 @@ CONTENTS:
    Description:  SELECT CASE introduces a multi-line conditional selection
                  statement.  The expression given as the argument to SELECT
                  CASE will be evaluated by CASE statements following.  The
-                 SELECT CASE statement conclludes with an END SELECT
+                 SELECT CASE statement concludes with an END SELECT
                  statement.
 
                  As currently implemented, CASE statements may be followed
@@ -1618,7 +1618,7 @@ CONTENTS:
 
    Description:  WIDTH sets screen or device output to 'number'
                  columns.  device-number specifies the device
-                 or file for oputput.
+                 or file for output.
 
    Dependencies: COMMON_CMDS
 
@@ -1654,7 +1654,7 @@ CONTENTS:
 
    The preset variable BWB.PROMPT$ can be used to set the prompt
    string for bwBASIC.  Again, it is suggested that a user-
-   selected promptcan be set up in a "profile.bas" to be
+   selected prompt can be set up in a "profile.bas" to be
    initialized each time bwBASIC starts.  Note that special
    characters can be added to the prompt string, e.g.,
 
@@ -1665,7 +1665,7 @@ CONTENTS:
    The preset variable BWB.IMPLEMENTATION$ will return "TTY" for
    the bwx_tty implementation and will return "IQC" for the
    IBM PC or Compatibles with QuickC (bwx_iqc) implementation.
-   This may be useful in determing which commands and functions
+   This may be useful in determining which commands and functions
    (specifically CLS, LOCATE, and INKEY$) may be available. 
 
 
@@ -1754,7 +1754,7 @@ CONTENTS:
 
    XMEM		PC-type computers need to be able to use extended
    		memory.  If we could use extended memory for program
-   		lines, variables, and function defitions, we could
+   		lines, variables, and function definitions, we could
    		write much longer programs.  This would entail,
    		however, a fairly serious rewriting of the program
    		to utilize memory handles for these storage features
--- bwbasic-2.20pl2.orig/bwbasic.h
+++ bwbasic-2.20pl2/bwbasic.h
@@ -342,7 +342,7 @@
 
 /* define number of commands */
 
-#define CMDS_CORE       22              /* number of core commands defined */
+#define CMDS_CORE       23              /* number of core commands defined */
 #if UNIX_CMDS
 #define CMDS_DIR	5
 #else
--- bwbasic-2.20pl2.orig/renum.c
+++ bwbasic-2.20pl2/renum.c
@@ -33,7 +33,9 @@ main(argc, argv)
    else
    {
       printf("Program in file? ");
-      gets(pstr);
+      fgets(pstr, sizeof(pstr), stdin);
+      p = strlen(pstr);
+      if (pstr[p - 1] == '\n') pstr[--p] = '\0';
    }
    if (strlen(pstr) == 0) strcpy(pstr, "0.doc");
 
@@ -117,8 +119,9 @@ main(argc, argv)
       skip = 0;
       bp = 0;
       printf("RENUMBER-");
-      gets(pstr);
+      fgets(pstr, sizeof(pstr), stdin);
       p = strlen(pstr);
+      if (pstr[p - 1] == '\n') pstr[--p] = '\0';
 
       if (g == 0)
       {
@@ -261,7 +264,9 @@ main(argc, argv)
       printf("%d -> %d\n", sidx[r][0], sidx[r][1]); */
 
    printf("VERIFY? ");
-   gets(pstr);
+   fgets(pstr, sizeof(pstr), stdin);
+   p = strlen(pstr);
+   if (pstr[p - 1] == '\n') pstr[--p] = '\0';
    v1 = 0;
    if (strcmp(midstr2(pstr, 1, 1), "N") == 0) v1 = 1;
 
@@ -473,13 +478,12 @@ main(argc, argv)
 int instr(astr, bstr)
    char *astr, *bstr;
 {
-   int p;
+   char *p;
 
    p = strstr(astr, bstr);
-   if (p == NULL) p = (int)(astr) - 1;
-   p = p - (int)(astr) + 1;
+   if (p == NULL) p = astr - 1;
 
-   return p;
+   return p - astr + 1;
 }