preprocessor.cxx

changeset 48
976c57f153b3
parent 36
a8838b5f1213
child 66
4fc1ec88aa41
equal deleted inserted replaced
47:d84d82213137 48:976c57f153b3
49 /* Since the preprocessor is *called* from ReadChar and I don't want 49 /* Since the preprocessor is *called* from ReadChar and I don't want
50 * to worry about recursive preprocessing, the preprocessor uses its 50 * to worry about recursive preprocessing, the preprocessor uses its
51 * own bare-bones variant of the function for file reading. 51 * own bare-bones variant of the function for file reading.
52 */ 52 */
53 char ScriptReader::PPReadChar () { 53 char ScriptReader::PPReadChar () {
54 char* c = (char*)malloc (sizeof (char)); 54 char c;
55 if (!fread (c, sizeof (char), 1, fp[fc])) 55 if (!fread (&c, sizeof (char), 1, fp[fc]))
56 return 0; 56 return 0;
57 curchar[fc]++; 57 curchar[fc]++;
58 return c[0]; 58 return c;
59 } 59 }
60 60
61 void ScriptReader::PPMustChar (char c) { 61 void ScriptReader::PPMustChar (char c) {
62 char d = PPReadChar (); 62 char d = PPReadChar ();
63 if (c != d) { 63 if (c != d)
64 ParserError ("expected `%c`, got `%d`", c, d); 64 ParserError ("expected `%c`, got `%d`", c, d);
65 }
66 } 65 }
67 66
68 // ============================================================================ 67 // ============================================================================
69 // Reads a word until whitespace 68 // Reads a word until whitespace
70 str ScriptReader::PPReadWord (char &term) { 69 str ScriptReader::PPReadWord (char &term) {

mercurial