Skip to content

Commit bd3de8b

Browse files
author
markisch
committed
include file cleanup
1 parent f48a153 commit bd3de8b

File tree

9 files changed

+30
-53
lines changed

9 files changed

+30
-53
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
functions to write to screen.
66
Bug #1361
77

8+
* src/command.c src/command.h src/plot.c src/stdfn.h src/syscfg.h
9+
src/win/wgraph.c src/win/winmain.c src/win/wprinter.c: Include file
10+
cleanup.
11+
12+
* src/win/screenbuf.c: Avoid crashes on memory allocation errors.
13+
814
* src/makefile.all src/makefile.awc: Recreate to include multiplot.c.
915

1016
* demo/lines_arrows.dem: UTF-8 encoding.

src/command.c

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#ifndef lint
2-
static char *RCSid() { return RCSid("$Id: command.c,v 1.283 2014/03/25 01:50:01 sfeam Exp $"); }
2+
static char *RCSid() { return RCSid("$Id: command.c,v 1.284 2014/03/30 18:33:21 markisch Exp $"); }
33
#endif
44

55
/* GNUPLOT - command.c */
@@ -131,9 +131,6 @@ static int winsystem __PROTO((const char *));
131131
# include <direct.h> /* getcwd() */
132132
# else
133133
# include <alloc.h>
134-
# ifndef __WATCOMC__
135-
# include <dir.h> /* setdisk() */
136-
# endif
137134
# endif /* !MSC */
138135
# include <htmlhelp.h>
139136
# include "win/winmain.h"
@@ -1650,7 +1647,7 @@ print_command()
16501647
{
16511648
struct value a;
16521649
/* space printed between two expressions only */
1653-
int need_space = 0;
1650+
TBOOLEAN need_space = FALSE;
16541651
char *dataline = NULL;
16551652
size_t size = 256;
16561653

@@ -1676,32 +1673,30 @@ print_command()
16761673
}
16771674
const_express(&a);
16781675
if (a.type == STRING) {
1679-
if (dataline)
1676+
if (dataline != NULL)
16801677
strappend(&dataline, &size, a.v.string_val);
16811678
else
16821679
fputs(a.v.string_val, print_out);
16831680
gpfree_string(&a);
1684-
need_space = 0;
1681+
need_space = FALSE;
16851682
} else {
16861683
if (need_space) {
1687-
if (dataline)
1684+
if (dataline != NULL)
16881685
strappend(&dataline, &size, " ");
16891686
else
16901687
putc(' ', print_out);
16911688
}
1692-
if (dataline) {
1693-
char * val = value_to_str(&a, FALSE);
1694-
strappend(&dataline, &size, val);
1695-
} else {
1689+
if (dataline != NULL)
1690+
strappend(&dataline, &size, value_to_str(&a, FALSE));
1691+
else
16961692
disp_value(print_out, &a, FALSE);
1697-
}
1698-
need_space = 1;
1693+
need_space = TRUE;
16991694
}
17001695
} while (!END_OF_COMMAND && equals(c_token, ","));
17011696

1702-
if (dataline)
1697+
if (dataline != NULL) {
17031698
append_to_datablock(&print_out_var->udv_value, dataline);
1704-
else {
1699+
} else {
17051700
(void) putc('\n', print_out);
17061701
fflush(print_out);
17071702
}
@@ -2271,11 +2266,9 @@ changedir(char *path)
22712266
if (isalpha(path[0]) && (path[1] == ':')) {
22722267
int driveno = toupper(path[0]) - 'A'; /* 0=A, 1=B, ... */
22732268

2274-
# if (defined(MSDOS) && defined(__EMX__)) || defined(__MSC__)
2269+
# if defined(__EMX__)
22752270
(void) _chdrive(driveno + 1);
2276-
# endif
2277-
2278-
# ifdef DJGPP
2271+
# elif defined(__DJGPP__)
22792272
(void) setdisk(driveno);
22802273
# endif
22812274
path += 2; /* move past drive letter */

src/command.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $Id: command.h,v 1.65 2014/03/23 13:27:27 markisch Exp $
2+
* $Id: command.h,v 1.66 2014/03/30 18:33:21 markisch Exp $
33
*/
44

55
/* GNUPLOT - command.h */
@@ -89,10 +89,8 @@ extern struct udft_entry *dummy_func;
8989
# define STDOUT 1
9090
#endif
9191

92-
#if defined(MSDOS)
93-
# ifdef DJGPP
92+
#if defined(MSDOS) && defined(DJGPP)
9493
extern char HelpFile[]; /* patch for do_help - AP */
95-
# endif /* DJGPP */
9694
#endif /* MSDOS */
9795

9896
#ifdef _Windows

src/plot.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#ifndef lint
2-
static char *RCSid() { return RCSid("$Id: plot.c,v 1.161 2014/03/22 23:09:06 sfeam Exp $"); }
2+
static char *RCSid() { return RCSid("$Id: plot.c,v 1.162 2014/03/30 18:33:21 markisch Exp $"); }
33
#endif
44

55
/* GNUPLOT - plot.c */
@@ -90,9 +90,6 @@ extern smg$create_key_table();
9090

9191
#ifdef _Windows
9292
# include <windows.h>
93-
# ifndef SIGINT
94-
# define SIGINT 2 /* for MSC */
95-
# endif
9693
# include "win/winmain.h"
9794
# include "win/wcommon.h"
9895
#endif /* _Windows */

src/stdfn.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $Id: stdfn.h,v 1.46 2014/03/20 00:58:36 markisch Exp $
2+
* $Id: stdfn.h,v 1.47 2014/03/30 18:33:21 markisch Exp $
33
*/
44

55
/* GNUPLOT - stdfn.h */
@@ -353,10 +353,6 @@ int ms_snprintf(char *str, size_t size, const char * format, ...);
353353
# include <windows.h>
354354
#endif
355355

356-
#if defined(_MSC_VER)
357-
#define strtoll _strtoi64
358-
#endif
359-
360356
/* sleep delay time, where delay is a double value */
361357
#if defined(HAVE_USLEEP)
362358
# define GP_SLEEP(delay) usleep((unsigned int) ((delay)*1e6))

src/syscfg.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $Id: syscfg.h,v 1.52 2013/12/22 20:47:25 sfeam Exp $
2+
* $Id: syscfg.h,v 1.53 2014/03/30 18:33:21 markisch Exp $
33
*/
44

55
/* GNUPLOT - syscfg.h */
@@ -215,18 +215,12 @@
215215

216216
/* DOS/Windows stuff. Moved here from command.c */
217217
#if defined(MSDOS)
218-
219218
# ifdef DJGPP
220219
# include <dos.h>
221220
# include <dir.h> /* HBB: for setdisk() */
222221
# else
223222
# include <process.h>
224223
# endif /* !DJGPP */
225-
226-
# ifdef __MSC__
227-
# include <direct.h> /* for _chdrive() */
228-
# endif /* __MSC__ */
229-
230224
#endif /* MSDOS */
231225

232226
/* Watcom's compiler; this should probably be somewhere

src/win/wgraph.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $Id: wgraph.c,v 1.181 2014/03/23 14:09:02 markisch Exp $
2+
* $Id: wgraph.c,v 1.182 2014/03/30 18:33:21 markisch Exp $
33
*/
44

55
/* GNUPLOT - win/wgraph.c */
@@ -47,9 +47,6 @@
4747
#include <windowsx.h>
4848
#include <commdlg.h>
4949
#include <commctrl.h>
50-
#ifndef __MSC__
51-
# include <mem.h>
52-
#endif
5350
#include <stdio.h>
5451
#include <string.h>
5552
#include "winmain.h"

src/win/winmain.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $Id: winmain.c,v 1.73 2014/03/20 00:58:36 markisch Exp $
2+
* $Id: winmain.c,v 1.74 2014/03/30 18:33:21 markisch Exp $
33
*/
44

55
/* GNUPLOT - win/winmain.c */
@@ -64,9 +64,6 @@
6464
#include <stdarg.h>
6565
#include <ctype.h>
6666
#include <fcntl.h>
67-
#ifdef __MSC__
68-
# include <malloc.h>
69-
#endif
7067
#ifdef __WATCOMC__
7168
# define mktemp _mktemp
7269
#endif

src/win/wprinter.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $Id: wprinter.c,v 1.11 2013/12/27 19:51:22 markisch Exp $
2+
* $Id: wprinter.c,v 1.12 2014/03/30 18:33:21 markisch Exp $
33
*/
44

55
/* GNUPLOT - win/wprinter.c */
@@ -52,10 +52,8 @@
5252
#include <commdlg.h>
5353
#include <stdio.h>
5454
#include <stdlib.h>
55-
#ifdef __MSC__
56-
#include <memory.h>
57-
#else
58-
#include <mem.h>
55+
#ifndef __MSC__
56+
# include <mem.h>
5957
#endif
6058
#include "wgnuplib.h"
6159
#include "wresourc.h"
@@ -237,6 +235,7 @@ PrintDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
237235
return FALSE;
238236
}
239237

238+
240239
BOOL CALLBACK
241240
PrintAbortProc(HDC hdcPrn, int code)
242241
{

0 commit comments

Comments
 (0)