summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorZejun Wu <watashi@fb.com>2018-12-11 13:15:13 -0500
committerBen Gamari <ben@smart-cactus.org>2018-12-11 13:15:20 -0500
commit0ff5ecfbc543d80d1668fec460df90b98d563898 (patch)
tree92b9aa1292b6bedee40640c841790eae406e4167 /utils
parentd7cb230ad8784ff9cacc6f7734ae71e8da72c93b (diff)
downloadhaskell-0ff5ecfbc543d80d1668fec460df90b98d563898.tar.gz
cosmetic change: expandtab in utils/hp2ps/HpFile.c
rGHCbba2b9bf2d69700dc114118658507aaac34c5e62 expand tabs in utils/hp2ps/HpFile.c with tabwidth 2, but the code was written as tabwidth 8. This change simply retabs the code with tabwidth 8 and removes trailing spaces. Test Plan: Tested in stacked diff: {D5388} Reviewers: simonmar, bgamari, afarmer, tdammers Reviewed By: simonmar Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5407
Diffstat (limited to 'utils')
-rw-r--r--utils/hp2ps/HpFile.c404
1 files changed, 202 insertions, 202 deletions
diff --git a/utils/hp2ps/HpFile.c b/utils/hp2ps/HpFile.c
index 02223ed783..a64a74a254 100644
--- a/utils/hp2ps/HpFile.c
+++ b/utils/hp2ps/HpFile.c
@@ -14,34 +14,34 @@ double atof PROTO((const char *));
/* own stuff already included */
-#define N_MARKS 50 /* start size of the mark table */
-#define N_SAMPLES 500 /* start size of the sample table */
+#define N_MARKS 50 /* start size of the mark table */
+#define N_SAMPLES 500 /* start size of the sample table */
char *theident;
static char *thestring;
int theinteger;
floatish thefloatish;
-int ch; /* last character read */
-token thetok; /* last token */
-int linenum; /* current line number */
-int endfile; /* true at end of file */
+int ch; /* last character read */
+token thetok; /* last token */
+int linenum; /* current line number */
+int endfile; /* true at end of file */
-static boolish gotjob = 0; /* "JOB" read */
-static boolish gotdate = 0; /* "DATE" read */
-static boolish gotvalueunit = 0; /* "VALUE_UNIT" read */
-static boolish gotsampleunit = 0; /* "SAMPLE_UNIT" read */
-static boolish insample = 0; /* true when in sample */
+static boolish gotjob = 0; /* "JOB" read */
+static boolish gotdate = 0; /* "DATE" read */
+static boolish gotvalueunit = 0; /* "VALUE_UNIT" read */
+static boolish gotsampleunit = 0; /* "SAMPLE_UNIT" read */
+static boolish insample = 0; /* true when in sample */
-static floatish lastsample; /* the last sample time */
+static floatish lastsample; /* the last sample time */
-static void GetHpLine PROTO((FILE *)); /* forward */
-static void GetHpTok PROTO((FILE *, int)); /* forward */
+static void GetHpLine PROTO((FILE *)); /* forward */
+static void GetHpTok PROTO((FILE *, int)); /* forward */
-static struct entry *GetEntry PROTO((char *)); /* forward */
+static struct entry *GetEntry PROTO((char *)); /* forward */
-static void GetString PROTO((FILE *)); /* forward */
+static void GetString PROTO((FILE *)); /* forward */
-static void MakeIdentTable PROTO((void)); /* forward */
+static void MakeIdentTable PROTO((void)); /* forward */
char *jobstring;
char *datestring;
@@ -49,21 +49,21 @@ char *datestring;
char *sampleunitstring;
char *valueunitstring;
-floatish *samplemap; /* sample intervals */
-floatish *markmap; /* sample marks */
+floatish *samplemap; /* sample intervals */
+floatish *markmap; /* sample marks */
/*
- * An extremely simple parser. The input is organised into lines of
- * the form
+ * An extremely simple parser. The input is organised into lines of
+ * the form
*
* JOB s -- job identifier string
- * DATE s -- date string
- * SAMPLE_UNIT s -- sample unit eg "seconds"
- * VALUE_UNIT s -- value unit eg "bytes"
- * MARK i -- sample mark
- * BEGIN_SAMPLE i -- start of ith sample
- * identifier i -- there are i identifiers in this sample
- * END_SAMPLE i -- end of ith sample
+ * DATE s -- date string
+ * SAMPLE_UNIT s -- sample unit eg "seconds"
+ * VALUE_UNIT s -- value unit eg "bytes"
+ * MARK i -- sample mark
+ * BEGIN_SAMPLE i -- start of ith sample
+ * identifier i -- there are i identifiers in this sample
+ * END_SAMPLE i -- end of ith sample
*
*/
@@ -82,27 +82,27 @@ GetHpFile(FILE *infp)
GetHpTok(infp, 1);
while (endfile == 0) {
- GetHpLine(infp);
+ GetHpLine(infp);
}
if (!gotjob) {
- Error("%s: JOB missing", hpfile);
+ Error("%s: JOB missing", hpfile);
}
if (!gotdate) {
- Error("%s: DATE missing", hpfile);
+ Error("%s: DATE missing", hpfile);
}
if (!gotvalueunit) {
- Error("%s: VALUE_UNIT missing", hpfile);
+ Error("%s: VALUE_UNIT missing", hpfile);
}
if (!gotsampleunit) {
- Error("%s: SAMPLE_UNIT missing", hpfile);
+ Error("%s: SAMPLE_UNIT missing", hpfile);
}
if (nsamples == 0) {
- Error("%s: contains no samples", hpfile);
+ Error("%s: contains no samples", hpfile);
}
@@ -114,7 +114,7 @@ GetHpFile(FILE *infp)
/*
* Read the next line from the input, check the syntax, and perform
- * the appropriate action.
+ * the appropriate action.
*/
static void
@@ -124,123 +124,123 @@ GetHpLine(FILE *infp)
switch (thetok) {
case JOB_TOK:
- GetHpTok(infp, 0);
- if (thetok != STRING_TOK) {
- Error("%s, line %d: string must follow JOB", hpfile, linenum);
+ GetHpTok(infp, 0);
+ if (thetok != STRING_TOK) {
+ Error("%s, line %d: string must follow JOB", hpfile, linenum);
}
- jobstring = thestring;
- gotjob = 1;
+ jobstring = thestring;
+ gotjob = 1;
GetHpTok(infp, 1);
- break;
+ break;
case DATE_TOK:
- GetHpTok(infp, 0);
- if (thetok != STRING_TOK) {
- Error("%s, line %d: string must follow DATE", hpfile, linenum);
+ GetHpTok(infp, 0);
+ if (thetok != STRING_TOK) {
+ Error("%s, line %d: string must follow DATE", hpfile, linenum);
}
- datestring = thestring;
- gotdate = 1;
+ datestring = thestring;
+ gotdate = 1;
GetHpTok(infp, 1);
- break;
+ break;
case SAMPLE_UNIT_TOK:
- GetHpTok(infp, 0);
- if (thetok != STRING_TOK) {
- Error("%s, line %d: string must follow SAMPLE_UNIT", hpfile,
- linenum);
+ GetHpTok(infp, 0);
+ if (thetok != STRING_TOK) {
+ Error("%s, line %d: string must follow SAMPLE_UNIT", hpfile,
+ linenum);
}
- sampleunitstring = thestring;
- gotsampleunit = 1;
+ sampleunitstring = thestring;
+ gotsampleunit = 1;
GetHpTok(infp, 1);
- break;
+ break;
case VALUE_UNIT_TOK:
GetHpTok(infp, 0);
- if (thetok != STRING_TOK) {
- Error("%s, line %d: string must follow VALUE_UNIT", hpfile,
- linenum);
+ if (thetok != STRING_TOK) {
+ Error("%s, line %d: string must follow VALUE_UNIT", hpfile,
+ linenum);
}
- valueunitstring = thestring;
- gotvalueunit = 1;
+ valueunitstring = thestring;
+ gotvalueunit = 1;
GetHpTok(infp, 1);
- break;
+ break;
case MARK_TOK:
- GetHpTok(infp, 0);
+ GetHpTok(infp, 0);
if (thetok != FLOAT_TOK) {
Error("%s, line %d, floating point number must follow MARK",
- hpfile, linenum);
+ hpfile, linenum);
+ }
+ if (insample) {
+ Error("%s, line %d, MARK occurs within sample", hpfile, linenum);
+ }
+ if (nmarks >= nmarkmax) {
+ if (!markmap) {
+ nmarkmax = N_MARKS;
+ markmap = (floatish*) xmalloc(nmarkmax * sizeof(floatish));
+ } else {
+ nmarkmax *= 2;
+ markmap = (floatish*) xrealloc(markmap, nmarkmax * sizeof(floatish));
+ }
}
- if (insample) {
- Error("%s, line %d, MARK occurs within sample", hpfile, linenum);
- }
- if (nmarks >= nmarkmax) {
- if (!markmap) {
- nmarkmax = N_MARKS;
- markmap = (floatish*) xmalloc(nmarkmax * sizeof(floatish));
- } else {
- nmarkmax *= 2;
- markmap = (floatish*) xrealloc(markmap, nmarkmax * sizeof(floatish));
- }
- }
- markmap[ nmarks++ ] = thefloatish;
+ markmap[ nmarks++ ] = thefloatish;
GetHpTok(infp, 1);
break;
case BEGIN_SAMPLE_TOK:
- insample = 1;
- GetHpTok(infp, 0);
- if (thetok != FLOAT_TOK) {
- Error("%s, line %d, floating point number must follow BEGIN_SAMPLE", hpfile, linenum);
- }
- if (thefloatish < lastsample) {
- Error("%s, line %d, samples out of sequence", hpfile, linenum);
- } else {
- lastsample = thefloatish;
+ insample = 1;
+ GetHpTok(infp, 0);
+ if (thetok != FLOAT_TOK) {
+ Error("%s, line %d, floating point number must follow BEGIN_SAMPLE", hpfile, linenum);
+ }
+ if (thefloatish < lastsample) {
+ Error("%s, line %d, samples out of sequence", hpfile, linenum);
+ } else {
+ lastsample = thefloatish;
+ }
+ if (nsamples >= nsamplemax) {
+ if (!samplemap) {
+ nsamplemax = N_SAMPLES;
+ samplemap = (floatish*) xmalloc(nsamplemax * sizeof(floatish));
+ } else {
+ nsamplemax *= 2;
+ samplemap = (floatish*) xrealloc(samplemap,
+ nsamplemax * sizeof(floatish));
+ }
}
- if (nsamples >= nsamplemax) {
- if (!samplemap) {
- nsamplemax = N_SAMPLES;
- samplemap = (floatish*) xmalloc(nsamplemax * sizeof(floatish));
- } else {
- nsamplemax *= 2;
- samplemap = (floatish*) xrealloc(samplemap,
- nsamplemax * sizeof(floatish));
- }
- }
- samplemap[ nsamples ] = thefloatish;
- GetHpTok(infp, 1);
- break;
+ samplemap[ nsamples ] = thefloatish;
+ GetHpTok(infp, 1);
+ break;
case END_SAMPLE_TOK:
- insample = 0;
- GetHpTok(infp, 0);
- if (thetok != FLOAT_TOK) {
- Error("%s, line %d: floating point number must follow END_SAMPLE",
+ insample = 0;
+ GetHpTok(infp, 0);
+ if (thetok != FLOAT_TOK) {
+ Error("%s, line %d: floating point number must follow END_SAMPLE",
hpfile, linenum);
- }
+ }
nsamples++;
- GetHpTok(infp, 1);
- break;
+ GetHpTok(infp, 1);
+ break;
case IDENTIFIER_TOK:
- GetHpTok(infp, 0);
- if (thetok != INTEGER_TOK) {
- Error("%s, line %d: integer must follow identifier", hpfile,
+ GetHpTok(infp, 0);
+ if (thetok != INTEGER_TOK) {
+ Error("%s, line %d: integer must follow identifier", hpfile,
linenum);
- }
+ }
StoreSample(GetEntry(theident), nsamples, thefloatish);
- GetHpTok(infp, 1);
+ GetHpTok(infp, 1);
break;
case EOF_TOK:
endfile = 1;
- break;
+ break;
default:
- Error("%s, line %d: %s unexpected", hpfile, linenum,
- TokenToString(thetok));
- break;
+ Error("%s, line %d: %s unexpected", hpfile, linenum,
+ TokenToString(thetok));
+ break;
}
}
@@ -249,91 +249,91 @@ char *
TokenToString(token t)
{
switch (t) {
- case EOF_TOK: return "EOF";
- case INTEGER_TOK: return "integer";
- case FLOAT_TOK: return "floating point number";
- case IDENTIFIER_TOK: return "identifier";
- case STRING_TOK: return "string";
- case BEGIN_SAMPLE_TOK: return "BEGIN_SAMPLE";
- case END_SAMPLE_TOK: return "END_SAMPLE";
- case JOB_TOK: return "JOB";
- case DATE_TOK: return "DATE";
- case SAMPLE_UNIT_TOK: return "SAMPLE_UNIT";
- case VALUE_UNIT_TOK: return "VALUE_UNIT";
- case MARK_TOK: return "MARK";
-
- case X_RANGE_TOK: return "X_RANGE";
- case Y_RANGE_TOK: return "Y_RANGE";
- case ORDER_TOK: return "ORDER";
- case SHADE_TOK: return "SHADE";
- default: return "(strange token)";
+ case EOF_TOK: return "EOF";
+ case INTEGER_TOK: return "integer";
+ case FLOAT_TOK: return "floating point number";
+ case IDENTIFIER_TOK: return "identifier";
+ case STRING_TOK: return "string";
+ case BEGIN_SAMPLE_TOK: return "BEGIN_SAMPLE";
+ case END_SAMPLE_TOK: return "END_SAMPLE";
+ case JOB_TOK: return "JOB";
+ case DATE_TOK: return "DATE";
+ case SAMPLE_UNIT_TOK: return "SAMPLE_UNIT";
+ case VALUE_UNIT_TOK: return "VALUE_UNIT";
+ case MARK_TOK: return "MARK";
+
+ case X_RANGE_TOK: return "X_RANGE";
+ case Y_RANGE_TOK: return "Y_RANGE";
+ case ORDER_TOK: return "ORDER";
+ case SHADE_TOK: return "SHADE";
+ default: return "(strange token)";
}
}
/*
- * Read the next token from the input and assign its value
- * to the global variable "thetok". In the case of numbers,
- * the corresponding value is also assigned to "theinteger"
- * or "thefloatish" as appropriate; in the case of identifiers
- * it is assigned to "theident".
+ * Read the next token from the input and assign its value
+ * to the global variable "thetok". In the case of numbers,
+ * the corresponding value is also assigned to "theinteger"
+ * or "thefloatish" as appropriate; in the case of identifiers
+ * it is assigned to "theident".
*
- * startline argument should be true for the first token on a line
+ * startline argument should be true for the first token on a line
*/
static void
GetHpTok(FILE *infp, int startline)
{
- while (isspace(ch)) { /* skip whitespace */
- if (ch == '\n') linenum++;
- ch = getc(infp);
+ while (isspace(ch)) { /* skip whitespace */
+ if (ch == '\n') linenum++;
+ ch = getc(infp);
}
if (ch == EOF) {
- thetok = EOF_TOK;
- return;
+ thetok = EOF_TOK;
+ return;
}
if (isdigit(ch) && !startline) {
- /* there should not be numbers at start of line */
- thetok = GetNumber(infp);
- return;
+ /* there should not be numbers at start of line */
+ thetok = GetNumber(infp);
+ return;
} else if (ch == '\"') {
- GetString(infp);
- thetok = STRING_TOK;
- return;
+ GetString(infp);
+ thetok = STRING_TOK;
+ return;
} else if (IsIdChar(ch)) {
- GetIdent(infp);
- if (!isupper((int)theident[0])) {
- thetok = IDENTIFIER_TOK;
- } else if (strcmp(theident, "BEGIN_SAMPLE") == 0) {
+ GetIdent(infp);
+ if (!isupper((int)theident[0])) {
+ thetok = IDENTIFIER_TOK;
+ } else if (strcmp(theident, "BEGIN_SAMPLE") == 0) {
thetok = BEGIN_SAMPLE_TOK;
- } else if (strcmp(theident, "END_SAMPLE") == 0) {
+ } else if (strcmp(theident, "END_SAMPLE") == 0) {
thetok = END_SAMPLE_TOK;
- } else if (strcmp(theident, "JOB") == 0) {
- thetok = JOB_TOK;
- } else if (strcmp(theident, "DATE") == 0) {
- thetok = DATE_TOK;
- } else if (strcmp(theident, "SAMPLE_UNIT") == 0) {
- thetok = SAMPLE_UNIT_TOK;
- } else if (strcmp(theident, "VALUE_UNIT") == 0) {
- thetok = VALUE_UNIT_TOK;
- } else if (strcmp(theident, "MARK") == 0) {
- thetok = MARK_TOK;
- } else {
+ } else if (strcmp(theident, "JOB") == 0) {
+ thetok = JOB_TOK;
+ } else if (strcmp(theident, "DATE") == 0) {
+ thetok = DATE_TOK;
+ } else if (strcmp(theident, "SAMPLE_UNIT") == 0) {
+ thetok = SAMPLE_UNIT_TOK;
+ } else if (strcmp(theident, "VALUE_UNIT") == 0) {
+ thetok = VALUE_UNIT_TOK;
+ } else if (strcmp(theident, "MARK") == 0) {
+ thetok = MARK_TOK;
+ } else {
thetok = IDENTIFIER_TOK;
- }
- return;
+ }
+ return;
} else {
- Error("%s, line %d: strange character (%c)", hpfile, linenum, ch);
+ Error("%s, line %d: strange character (%c)", hpfile, linenum, ch);
}
}
/*
- * Read a sequence of digits and convert the result to an integer
- * or floating point value (assigned to the "theinteger" or
- * "thefloatish").
+ * Read a sequence of digits and convert the result to an integer
+ * or floating point value (assigned to the "theinteger" or
+ * "thefloatish").
*/
static char numberstring[ NUMBER_LENGTH + 1 ];
@@ -360,7 +360,7 @@ GetNumber(FILE *infp)
if (containsdot) {
thefloatish = (floatish) atof(numberstring);
- return FLOAT_TOK;
+ return FLOAT_TOK;
} else {
theinteger = atoi(numberstring);
/* Set thefloatish too.
@@ -373,8 +373,8 @@ GetNumber(FILE *infp)
}
/*
- * Read a sequence of identifier characters and assign the result
- * to the string "theident".
+ * Read a sequence of identifier characters and assign the result
+ * to the string "theident".
*/
void
@@ -384,22 +384,22 @@ GetIdent(FILE *infp)
char idbuffer[5000];
for (i = 0; i < (sizeof idbuffer)-1 && IsIdChar(ch); i++) {
- idbuffer[ i ] = ch;
- ch = getc(infp);
+ idbuffer[ i ] = ch;
+ ch = getc(infp);
}
idbuffer[ i ] = '\0';
if (theident)
- free(theident);
+ free(theident);
theident = copystring(idbuffer);
}
/*
- * Read a sequence of characters that make up a string and
- * assign the result to "thestring".
+ * Read a sequence of characters that make up a string and
+ * assign the result to "thestring".
*/
void
@@ -414,12 +414,12 @@ GetString(FILE *infp)
stringbuffersize = 5000;
stringbuffer = xmalloc(stringbuffersize);
- ch = getc(infp); /* skip the '\"' that begins the string */
+ ch = getc(infp); /* skip the '\"' that begins the string */
i = 0;
while (ch != '\"') {
if (ch == EOF) {
- Error("%s, line %d: EOF when expecting \"", hpfile, linenum, ch);
+ Error("%s, line %d: EOF when expecting \"", hpfile, linenum, ch);
}
else if (i == stringbuffersize - 1) {
stringbuffersize = 2 * stringbuffersize;
@@ -448,11 +448,11 @@ IsIdChar(int ch)
/*
* The information associated with each identifier is stored
- * in a linked list of chunks. The table below allows the list
- * of chunks to be retrieved given an identifier name.
+ * in a linked list of chunks. The table below allows the list
+ * of chunks to be retrieved given an identifier name.
*/
-#define N_HASH 513
+#define N_HASH 513
static struct entry* hashtable[ N_HASH ];
@@ -472,7 +472,7 @@ Hash(char *s)
/*
* Get space for a new chunk. Initialise it, and return a pointer
- * to the new chunk.
+ * to the new chunk.
*/
static struct chunk*
@@ -494,7 +494,7 @@ MakeChunk(void)
/*
* Get space for a new entry. Initialise it, and return a pointer
- * to the new entry.
+ * to the new entry.
*/
struct entry *
@@ -509,8 +509,8 @@ MakeEntry(char *name)
}
/*
- * Get the entry associated with "name", creating a new entry if
- * necessary.
+ * Get the entry associated with "name", creating a new entry if
+ * necessary.
*/
static struct entry *
@@ -528,7 +528,7 @@ GetEntry(char *name)
}
if (e) {
- return (e);
+ return (e);
} else {
nidents++;
e = MakeEntry(name);
@@ -549,18 +549,18 @@ StoreSample(struct entry *en, intish bucket, floatish value)
struct chunk* chk;
for (chk = en->chk; chk->next != 0; chk = chk->next)
- ;
+ ;
if (chk->nd < N_CHUNK) {
- chk->d[ chk->nd ].bucket = bucket;
- chk->d[ chk->nd ].value = value;
- chk->nd += 1;
+ chk->d[ chk->nd ].bucket = bucket;
+ chk->d[ chk->nd ].value = value;
+ chk->nd += 1;
} else {
- struct chunk* t;
- t = chk->next = MakeChunk();
- t->d[ 0 ].bucket = bucket;
- t->d[ 0 ].value = value;
- t->nd += 1;
+ struct chunk* t;
+ t = chk->next = MakeChunk();
+ t->d[ 0 ].bucket = bucket;
+ t->d[ 0 ].value = value;
+ t->nd += 1;
}
}
@@ -568,9 +568,9 @@ StoreSample(struct entry *en, intish bucket, floatish value)
struct entry** identtable;
/*
- * The hash table is useful while reading the input, but it
- * becomes a liability thereafter. The code below converts
- * it to a more easily processed table.
+ * The hash table is useful while reading the input, but it
+ * becomes a liability thereafter. The code below converts
+ * it to a more easily processed table.
*/
static void
@@ -583,7 +583,7 @@ MakeIdentTable(void)
nidents = 0;
for (i = 0; i < N_HASH; i++) {
for (e = hashtable[ i ]; e; e = e->next) {
- nidents++;
+ nidents++;
}
}
@@ -592,7 +592,7 @@ MakeIdentTable(void)
for (i = 0; i < N_HASH; i++) {
for (e = hashtable[ i ]; e; e = e->next, j++) {
- identtable[ j ] = e;
+ identtable[ j ] = e;
}
}
}