Revision: 41048
http://brlcad.svn.sourceforge.net/brlcad/?rev=41048&view=rev
Author: brlcad
Date: 2010-10-18 17:34:20 +0000 (Mon, 18 Oct 2010)
Log Message:
-----------
remove the inlined sleep(3) declaration since it breaks the build on windows
(there's a sleep() macro for windows that converts to Sleep()). instead,
conditionally include unistd.h like should have been done in the first place.
also reorder args to avoid all forward decls.
Modified Paths:
--------------
brlcad/trunk/src/util/pl-tek.c
Modified: brlcad/trunk/src/util/pl-tek.c
===================================================================
--- brlcad/trunk/src/util/pl-tek.c 2010-10-18 17:24:49 UTC (rev 41047)
+++ brlcad/trunk/src/util/pl-tek.c 2010-10-18 17:34:20 UTC (rev 41048)
@@ -26,17 +26,19 @@
#include "common.h"
+#ifdef HAVE_UNISTD_H
+# include <unistd.h> /* for sleep(3) */
+#endif
+
#include <stdlib.h>
#include <string.h>
#include "bio.h"
-#include "common.h"
-
-
#include "bu.h"
#include "vmath.h"
#include "bn.h"
+
struct uplot {
int targ; /* type of args */
int narg; /* number or args */
@@ -45,18 +47,6 @@
};
-void getstring(void);
-void getargs(struct uplot *up);
-double getieee(void);
-void doscale(void);
-
-static void tekmove(int xi, int yi);
-static void tekcont(int x, int y);
-static void tekerase(void);
-static void teklabel(char *s);
-static void teklinemod(char *s);
-static void tekpoint(int xi, int yi);
-
#define BELL 007
#define FF 014
#define SUB 032 /* Turn on graphics cursor */
@@ -145,184 +135,7 @@
static const char usage[] = "\
Usage: pl-tek [-e] [-v] < file.pl > file.tek\n";
-int
-main(int argc, char **argv)
-{
- int c;
- struct uplot *up;
- while (argc > 1) {
- if (strcmp(argv[1], "-v") == 0) {
- verbose++;
- } else if (strcmp(argv[1], "-e") == 0) {
- expand_it = 1;
- } else {
- fprintf(stderr, "pl-tek: argument '%s' ignored\n", argv[1]);
- break;
- }
-
- argc--;
- argv++;
- }
- /* Stdout may be a genuine Tektronix! */
- if (isatty(fileno(stdin))) {
- bu_exit(1, "%s", usage);
- }
-
- /* Assume default space, in case one is not provided */
- sp[0] = sp[1] = sp[2] = -32767;
- sp[3] = sp[4] = sp[5] = 32767;
- doscale();
-
- /* Initialize the Tektronix */
- (void)putc(ESC, stdout);
- (void)putc(';', stdout); /* Miniature typeface */
- (void)putc(US, stdout);
-
- while ((c = getchar()) != EOF) {
- /* look it up */
- if (c < 'A' || c > 'z') {
- up = &uerror;
- } else {
- up = &letters[ c - 'A' ];
- }
-
- if (up->targ == TBAD) {
- fprintf(stderr, "Bad command '%c' (0x%02x)\n", c, c);
- continue;
- }
-
- if (up->narg > 0)
- getargs(up);
-
- if (verbose) {
- int i;
- fprintf(stderr, "%s", up->desc);
- switch (up->targ) {
- case TCHAR:
- case TSHORT:
- case TIEEE:
- for (i=0; i < up->narg; i++)
- fprintf(stderr, " %g", arg[i]);
- break;
- case TSTRING:
- fprintf(stderr, " '%s'", strarg);
- break;
- }
- fprintf(stderr, "\n");
- }
-
- /* check for space command */
- switch (c) {
- case 's': /* space */
- case 'w': /* d_space */
- sp[0] = arg[0];
- sp[1] = arg[1];
- sp[2] = 0;
- sp[3] = arg[2];
- sp[4] = arg[3];
- sp[5] = 0;
- doscale();
- seenscale++;
- continue;
- case 'S': /* 3space */
- case 'W': /* d_3space */
- sp[0] = arg[0];
- sp[1] = arg[1];
- sp[2] = arg[2];
- sp[3] = arg[3];
- sp[4] = arg[4];
- sp[5] = arg[5];
- doscale();
- seenscale++;
- continue;
- }
-
- /* do it */
- switch (c) {
- case 'm': /* 2-d move */
- case 'M': /* 3move */
- case 'o': /* d_move */
- case 'O': /* d_3move */
- tekmove((int)((arg[0] - sp[0]) * scale),
- (int)((arg[1] - sp[1]) * scale));
- break;
-
- case 'n': /* 2-d continue */
- case 'N': /* 3cont */
- case 'q': /* d_cont */
- case 'Q': /* d_3cont */
- tekcont((int)((arg[0] - sp[0]) * scale),
- (int)((arg[1] - sp[1]) * scale));
- break;
-
- case 'p': /* 2-d point */
- case 'P': /* 3point */
- case 'x': /* d_point */
- case 'X': /* d_3point */
- tekpoint((int)((arg[0] - sp[0]) * scale),
- (int)((arg[1] - sp[1]) * scale));
- break;
-
- case 'l': /* 2-d line */
- case 'v': /* d_line */
- tekmove((int)((arg[0] - sp[0]) * scale),
- (int)((arg[1] - sp[1]) * scale));
- tekcont((int)((arg[2] - sp[0]) * scale),
- (int)((arg[3] - sp[1]) * scale));
- break;
-
- case 'L': /* 3line */
- case 'V': /* d_3line */
- tekmove((int)((arg[0] - sp[0]) * scale),
- (int)((arg[1] - sp[1]) * scale));
- tekcont((int)((arg[3] - sp[0]) * scale),
- (int)((arg[4] - sp[1]) * scale));
- break;
-
- case 'c': /* circle */
- case 'i': /* d_circle */
- fprintf(stderr, "pl-tek: circle unimplemented\n");
- break;
-
- case 'a': /* arc */
- case 'r': /* d_arc */
- fprintf(stderr, "pl-tek: arc unimplemented\n");
- break;
-
- case 'f': /* linmod */
- teklinemod(strarg);
- break;
-
- case 'e': /* erase */
- tekerase();
- break;
-
- case 't': /* text label */
- teklabel(strarg);
- break;
-
- case 'C': /* set color */
- break;
-
- case 'F': /* flush buffer */
- break;
-
- default:
- fprintf(stderr, "pl-tek: unknown command byte x%x\n", c);
- }
- }
-
- if (!seenscale) {
- fprintf(stderr, "pl-tek: WARNING no space command in file, defaulting
to +/-32k\n");
- }
-
- return 0;
-}
-
-
-/*** Input args ***/
-
int
getshort(void)
{
@@ -340,6 +153,31 @@
void
+getstring(void)
+{
+ int c;
+ char *cp;
+
+ cp = strarg;
+ while ((c = getchar()) != '\n' && c != EOF)
+ *cp++ = c;
+ *cp = 0;
+}
+
+
+double
+getieee(void)
+{
+ unsigned char in[8];
+ double d;
+
+ fread(in, 8, 1, stdin);
+ ntohd((unsigned char *)&d, in, 1);
+ return d;
+}
+
+
+void
getargs(struct uplot *up)
{
int i;
@@ -367,31 +205,6 @@
}
-void
-getstring(void)
-{
- int c;
- char *cp;
-
- cp = strarg;
- while ((c = getchar()) != '\n' && c != EOF)
- *cp++ = c;
- *cp = 0;
-}
-
-
-double
-getieee(void)
-{
- unsigned char in[8];
- double d;
-
- fread(in, 8, 1, stdin);
- ntohd((unsigned char *)&d, in, 1);
- return d;
-}
-
-
/*
* Establish display coordinate conversion:
* Input ranges from min=(sp[0], sp[1]) to max=(sp[3], sp[4]).
@@ -496,8 +309,6 @@
static void
tekerase(void)
{
- extern unsigned sleep(unsigned int); /* DAG -- was missing */
-
(void)putc(ESC, stdout);
(void)putc(FF, stdout);
ohix = ohiy = oloy = oextra = -1;
@@ -550,6 +361,182 @@
}
+int
+main(int argc, char **argv)
+{
+ int c;
+ struct uplot *up;
+
+ while (argc > 1) {
+ if (strcmp(argv[1], "-v") == 0) {
+ verbose++;
+ } else if (strcmp(argv[1], "-e") == 0) {
+ expand_it = 1;
+ } else {
+ fprintf(stderr, "pl-tek: argument '%s' ignored\n", argv[1]);
+ break;
+ }
+
+ argc--;
+ argv++;
+ }
+ /* Stdout may be a genuine Tektronix! */
+ if (isatty(fileno(stdin))) {
+ bu_exit(1, "%s", usage);
+ }
+
+ /* Assume default space, in case one is not provided */
+ sp[0] = sp[1] = sp[2] = -32767;
+ sp[3] = sp[4] = sp[5] = 32767;
+ doscale();
+
+ /* Initialize the Tektronix */
+ (void)putc(ESC, stdout);
+ (void)putc(';', stdout); /* Miniature typeface */
+ (void)putc(US, stdout);
+
+ while ((c = getchar()) != EOF) {
+ /* look it up */
+ if (c < 'A' || c > 'z') {
+ up = &uerror;
+ } else {
+ up = &letters[ c - 'A' ];
+ }
+
+ if (up->targ == TBAD) {
+ fprintf(stderr, "Bad command '%c' (0x%02x)\n", c, c);
+ continue;
+ }
+
+ if (up->narg > 0)
+ getargs(up);
+
+ if (verbose) {
+ int i;
+ fprintf(stderr, "%s", up->desc);
+ switch (up->targ) {
+ case TCHAR:
+ case TSHORT:
+ case TIEEE:
+ for (i=0; i < up->narg; i++)
+ fprintf(stderr, " %g", arg[i]);
+ break;
+ case TSTRING:
+ fprintf(stderr, " '%s'", strarg);
+ break;
+ }
+ fprintf(stderr, "\n");
+ }
+
+ /* check for space command */
+ switch (c) {
+ case 's': /* space */
+ case 'w': /* d_space */
+ sp[0] = arg[0];
+ sp[1] = arg[1];
+ sp[2] = 0;
+ sp[3] = arg[2];
+ sp[4] = arg[3];
+ sp[5] = 0;
+ doscale();
+ seenscale++;
+ continue;
+ case 'S': /* 3space */
+ case 'W': /* d_3space */
+ sp[0] = arg[0];
+ sp[1] = arg[1];
+ sp[2] = arg[2];
+ sp[3] = arg[3];
+ sp[4] = arg[4];
+ sp[5] = arg[5];
+ doscale();
+ seenscale++;
+ continue;
+ }
+
+ /* do it */
+ switch (c) {
+ case 'm': /* 2-d move */
+ case 'M': /* 3move */
+ case 'o': /* d_move */
+ case 'O': /* d_3move */
+ tekmove((int)((arg[0] - sp[0]) * scale),
+ (int)((arg[1] - sp[1]) * scale));
+ break;
+
+ case 'n': /* 2-d continue */
+ case 'N': /* 3cont */
+ case 'q': /* d_cont */
+ case 'Q': /* d_3cont */
+ tekcont((int)((arg[0] - sp[0]) * scale),
+ (int)((arg[1] - sp[1]) * scale));
+ break;
+
+ case 'p': /* 2-d point */
+ case 'P': /* 3point */
+ case 'x': /* d_point */
+ case 'X': /* d_3point */
+ tekpoint((int)((arg[0] - sp[0]) * scale),
+ (int)((arg[1] - sp[1]) * scale));
+ break;
+
+ case 'l': /* 2-d line */
+ case 'v': /* d_line */
+ tekmove((int)((arg[0] - sp[0]) * scale),
+ (int)((arg[1] - sp[1]) * scale));
+ tekcont((int)((arg[2] - sp[0]) * scale),
+ (int)((arg[3] - sp[1]) * scale));
+ break;
+
+ case 'L': /* 3line */
+ case 'V': /* d_3line */
+ tekmove((int)((arg[0] - sp[0]) * scale),
+ (int)((arg[1] - sp[1]) * scale));
+ tekcont((int)((arg[3] - sp[0]) * scale),
+ (int)((arg[4] - sp[1]) * scale));
+ break;
+
+ case 'c': /* circle */
+ case 'i': /* d_circle */
+ fprintf(stderr, "pl-tek: circle unimplemented\n");
+ break;
+
+ case 'a': /* arc */
+ case 'r': /* d_arc */
+ fprintf(stderr, "pl-tek: arc unimplemented\n");
+ break;
+
+ case 'f': /* linmod */
+ teklinemod(strarg);
+ break;
+
+ case 'e': /* erase */
+ tekerase();
+ break;
+
+ case 't': /* text label */
+ teklabel(strarg);
+ break;
+
+ case 'C': /* set color */
+ break;
+
+ case 'F': /* flush buffer */
+ break;
+
+ default:
+ fprintf(stderr, "pl-tek: unknown command byte x%x\n", c);
+ }
+ }
+
+ if (!seenscale) {
+ fprintf(stderr, "pl-tek: WARNING no space command in file, defaulting
to +/-32k\n");
+ }
+
+ return 0;
+}
+
+
/*
* Local Variables:
* mode: C
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits