app.c 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482
  1. /* This is the Assembler Pre-Processor
  2. Copyright (C) 1987-2015 Free Software Foundation, Inc.
  3. This file is part of GAS, the GNU Assembler.
  4. GAS is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3, or (at your option)
  7. any later version.
  8. GAS is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  10. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  11. License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GAS; see the file COPYING. If not, write to the Free
  14. Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
  15. 02110-1301, USA. */
  16. /* Modified by Allen Wirfs-Brock, Instantiations Inc 2/90. */
  17. /* App, the assembler pre-processor. This pre-processor strips out
  18. excess spaces, turns single-quoted characters into a decimal
  19. constant, and turns the # in # <number> <filename> <garbage> into a
  20. .linefile. This needs better error-handling. */
  21. #include "as.h"
  22. #if (__STDC__ != 1)
  23. #ifndef const
  24. #define const /* empty */
  25. #endif
  26. #endif
  27. #ifdef H_TICK_HEX
  28. int enable_h_tick_hex = 0;
  29. #endif
  30. #ifdef TC_M68K
  31. /* Whether we are scrubbing in m68k MRI mode. This is different from
  32. flag_m68k_mri, because the two flags will be affected by the .mri
  33. pseudo-op at different times. */
  34. static int scrub_m68k_mri;
  35. /* The pseudo-op which switches in and out of MRI mode. See the
  36. comment in do_scrub_chars. */
  37. static const char mri_pseudo[] = ".mri 0";
  38. #else
  39. #define scrub_m68k_mri 0
  40. #endif
  41. #if defined TC_ARM && defined OBJ_ELF
  42. /* The pseudo-op for which we need to special-case `@' characters.
  43. See the comment in do_scrub_chars. */
  44. static const char symver_pseudo[] = ".symver";
  45. static const char * symver_state;
  46. #endif
  47. static char lex[256];
  48. static const char symbol_chars[] =
  49. "$._ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  50. #define LEX_IS_SYMBOL_COMPONENT 1
  51. #define LEX_IS_WHITESPACE 2
  52. #define LEX_IS_LINE_SEPARATOR 3
  53. #define LEX_IS_COMMENT_START 4
  54. #define LEX_IS_LINE_COMMENT_START 5
  55. #define LEX_IS_TWOCHAR_COMMENT_1ST 6
  56. #define LEX_IS_STRINGQUOTE 8
  57. #define LEX_IS_COLON 9
  58. #define LEX_IS_NEWLINE 10
  59. #define LEX_IS_ONECHAR_QUOTE 11
  60. #ifdef TC_V850
  61. #define LEX_IS_DOUBLEDASH_1ST 12
  62. #endif
  63. #ifdef TC_M32R
  64. #define DOUBLEBAR_PARALLEL
  65. #endif
  66. #ifdef DOUBLEBAR_PARALLEL
  67. #define LEX_IS_DOUBLEBAR_1ST 13
  68. #endif
  69. #define LEX_IS_PARALLEL_SEPARATOR 14
  70. #ifdef H_TICK_HEX
  71. #define LEX_IS_H 15
  72. #endif
  73. #define IS_SYMBOL_COMPONENT(c) (lex[c] == LEX_IS_SYMBOL_COMPONENT)
  74. #define IS_WHITESPACE(c) (lex[c] == LEX_IS_WHITESPACE)
  75. #define IS_LINE_SEPARATOR(c) (lex[c] == LEX_IS_LINE_SEPARATOR)
  76. #define IS_PARALLEL_SEPARATOR(c) (lex[c] == LEX_IS_PARALLEL_SEPARATOR)
  77. #define IS_COMMENT(c) (lex[c] == LEX_IS_COMMENT_START)
  78. #define IS_LINE_COMMENT(c) (lex[c] == LEX_IS_LINE_COMMENT_START)
  79. #define IS_NEWLINE(c) (lex[c] == LEX_IS_NEWLINE)
  80. static int process_escape (int);
  81. /* FIXME-soon: The entire lexer/parser thingy should be
  82. built statically at compile time rather than dynamically
  83. each and every time the assembler is run. xoxorich. */
  84. void
  85. do_scrub_begin (int m68k_mri ATTRIBUTE_UNUSED)
  86. {
  87. const char *p;
  88. int c;
  89. lex[' '] = LEX_IS_WHITESPACE;
  90. lex['\t'] = LEX_IS_WHITESPACE;
  91. lex['\r'] = LEX_IS_WHITESPACE;
  92. lex['\n'] = LEX_IS_NEWLINE;
  93. lex[':'] = LEX_IS_COLON;
  94. #ifdef TC_M68K
  95. scrub_m68k_mri = m68k_mri;
  96. if (! m68k_mri)
  97. #endif
  98. {
  99. lex['"'] = LEX_IS_STRINGQUOTE;
  100. #if ! defined (TC_HPPA) && ! defined (TC_I370)
  101. /* I370 uses single-quotes to delimit integer, float constants. */
  102. lex['\''] = LEX_IS_ONECHAR_QUOTE;
  103. #endif
  104. #ifdef SINGLE_QUOTE_STRINGS
  105. lex['\''] = LEX_IS_STRINGQUOTE;
  106. #endif
  107. }
  108. /* Note: if any other character can be LEX_IS_STRINGQUOTE, the loop
  109. in state 5 of do_scrub_chars must be changed. */
  110. /* Note that these override the previous defaults, e.g. if ';' is a
  111. comment char, then it isn't a line separator. */
  112. for (p = symbol_chars; *p; ++p)
  113. lex[(unsigned char) *p] = LEX_IS_SYMBOL_COMPONENT;
  114. for (c = 128; c < 256; ++c)
  115. lex[c] = LEX_IS_SYMBOL_COMPONENT;
  116. #ifdef tc_symbol_chars
  117. /* This macro permits the processor to specify all characters which
  118. may appears in an operand. This will prevent the scrubber from
  119. discarding meaningful whitespace in certain cases. The i386
  120. backend uses this to support prefixes, which can confuse the
  121. scrubber as to whether it is parsing operands or opcodes. */
  122. for (p = tc_symbol_chars; *p; ++p)
  123. lex[(unsigned char) *p] = LEX_IS_SYMBOL_COMPONENT;
  124. #endif
  125. /* The m68k backend wants to be able to change comment_chars. */
  126. #ifndef tc_comment_chars
  127. #define tc_comment_chars comment_chars
  128. #endif
  129. for (p = tc_comment_chars; *p; p++)
  130. lex[(unsigned char) *p] = LEX_IS_COMMENT_START;
  131. for (p = line_comment_chars; *p; p++)
  132. lex[(unsigned char) *p] = LEX_IS_LINE_COMMENT_START;
  133. #ifndef tc_line_separator_chars
  134. #define tc_line_separator_chars line_separator_chars
  135. #endif
  136. for (p = tc_line_separator_chars; *p; p++)
  137. lex[(unsigned char) *p] = LEX_IS_LINE_SEPARATOR;
  138. #ifdef tc_parallel_separator_chars
  139. /* This macro permits the processor to specify all characters which
  140. separate parallel insns on the same line. */
  141. for (p = tc_parallel_separator_chars; *p; p++)
  142. lex[(unsigned char) *p] = LEX_IS_PARALLEL_SEPARATOR;
  143. #endif
  144. /* Only allow slash-star comments if slash is not in use.
  145. FIXME: This isn't right. We should always permit them. */
  146. if (lex['/'] == 0)
  147. lex['/'] = LEX_IS_TWOCHAR_COMMENT_1ST;
  148. #ifdef TC_M68K
  149. if (m68k_mri)
  150. {
  151. lex['\''] = LEX_IS_STRINGQUOTE;
  152. lex[';'] = LEX_IS_COMMENT_START;
  153. lex['*'] = LEX_IS_LINE_COMMENT_START;
  154. /* The MRI documentation says '!' is LEX_IS_COMMENT_START, but
  155. then it can't be used in an expression. */
  156. lex['!'] = LEX_IS_LINE_COMMENT_START;
  157. }
  158. #endif
  159. #ifdef TC_V850
  160. lex['-'] = LEX_IS_DOUBLEDASH_1ST;
  161. #endif
  162. #ifdef DOUBLEBAR_PARALLEL
  163. lex['|'] = LEX_IS_DOUBLEBAR_1ST;
  164. #endif
  165. #ifdef TC_D30V
  166. /* Must do this is we want VLIW instruction with "->" or "<-". */
  167. lex['-'] = LEX_IS_SYMBOL_COMPONENT;
  168. #endif
  169. #ifdef H_TICK_HEX
  170. if (enable_h_tick_hex)
  171. {
  172. lex['h'] = LEX_IS_H;
  173. lex['H'] = LEX_IS_H;
  174. }
  175. #endif
  176. }
  177. /* Saved state of the scrubber. */
  178. static int state;
  179. static int old_state;
  180. static char *out_string;
  181. static char out_buf[20];
  182. static int add_newlines;
  183. static char *saved_input;
  184. static size_t saved_input_len;
  185. static char input_buffer[32 * 1024];
  186. static const char *mri_state;
  187. static char mri_last_ch;
  188. /* Data structure for saving the state of app across #include's. Note that
  189. app is called asynchronously to the parsing of the .include's, so our
  190. state at the time .include is interpreted is completely unrelated.
  191. That's why we have to save it all. */
  192. struct app_save
  193. {
  194. int state;
  195. int old_state;
  196. char * out_string;
  197. char out_buf[sizeof (out_buf)];
  198. int add_newlines;
  199. char * saved_input;
  200. size_t saved_input_len;
  201. #ifdef TC_M68K
  202. int scrub_m68k_mri;
  203. #endif
  204. const char * mri_state;
  205. char mri_last_ch;
  206. #if defined TC_ARM && defined OBJ_ELF
  207. const char * symver_state;
  208. #endif
  209. };
  210. char *
  211. app_push (void)
  212. {
  213. struct app_save *saved;
  214. saved = (struct app_save *) xmalloc (sizeof (*saved));
  215. saved->state = state;
  216. saved->old_state = old_state;
  217. saved->out_string = out_string;
  218. memcpy (saved->out_buf, out_buf, sizeof (out_buf));
  219. saved->add_newlines = add_newlines;
  220. if (saved_input == NULL)
  221. saved->saved_input = NULL;
  222. else
  223. {
  224. saved->saved_input = (char *) xmalloc (saved_input_len);
  225. memcpy (saved->saved_input, saved_input, saved_input_len);
  226. saved->saved_input_len = saved_input_len;
  227. }
  228. #ifdef TC_M68K
  229. saved->scrub_m68k_mri = scrub_m68k_mri;
  230. #endif
  231. saved->mri_state = mri_state;
  232. saved->mri_last_ch = mri_last_ch;
  233. #if defined TC_ARM && defined OBJ_ELF
  234. saved->symver_state = symver_state;
  235. #endif
  236. /* do_scrub_begin() is not useful, just wastes time. */
  237. state = 0;
  238. saved_input = NULL;
  239. add_newlines = 0;
  240. return (char *) saved;
  241. }
  242. void
  243. app_pop (char *arg)
  244. {
  245. struct app_save *saved = (struct app_save *) arg;
  246. /* There is no do_scrub_end (). */
  247. state = saved->state;
  248. old_state = saved->old_state;
  249. out_string = saved->out_string;
  250. memcpy (out_buf, saved->out_buf, sizeof (out_buf));
  251. add_newlines = saved->add_newlines;
  252. if (saved->saved_input == NULL)
  253. saved_input = NULL;
  254. else
  255. {
  256. gas_assert (saved->saved_input_len <= sizeof (input_buffer));
  257. memcpy (input_buffer, saved->saved_input, saved->saved_input_len);
  258. saved_input = input_buffer;
  259. saved_input_len = saved->saved_input_len;
  260. free (saved->saved_input);
  261. }
  262. #ifdef TC_M68K
  263. scrub_m68k_mri = saved->scrub_m68k_mri;
  264. #endif
  265. mri_state = saved->mri_state;
  266. mri_last_ch = saved->mri_last_ch;
  267. #if defined TC_ARM && defined OBJ_ELF
  268. symver_state = saved->symver_state;
  269. #endif
  270. free (arg);
  271. }
  272. /* @@ This assumes that \n &c are the same on host and target. This is not
  273. necessarily true. */
  274. static int
  275. process_escape (int ch)
  276. {
  277. switch (ch)
  278. {
  279. case 'b':
  280. return '\b';
  281. case 'f':
  282. return '\f';
  283. case 'n':
  284. return '\n';
  285. case 'r':
  286. return '\r';
  287. case 't':
  288. return '\t';
  289. case '\'':
  290. return '\'';
  291. case '"':
  292. return '\"';
  293. default:
  294. return ch;
  295. }
  296. }
  297. /* This function is called to process input characters. The GET
  298. parameter is used to retrieve more input characters. GET should
  299. set its parameter to point to a buffer, and return the length of
  300. the buffer; it should return 0 at end of file. The scrubbed output
  301. characters are put into the buffer starting at TOSTART; the TOSTART
  302. buffer is TOLEN bytes in length. The function returns the number
  303. of scrubbed characters put into TOSTART. This will be TOLEN unless
  304. end of file was seen. This function is arranged as a state
  305. machine, and saves its state so that it may return at any point.
  306. This is the way the old code used to work. */
  307. size_t
  308. do_scrub_chars (size_t (*get) (char *, size_t), char *tostart, size_t tolen)
  309. {
  310. char *to = tostart;
  311. char *toend = tostart + tolen;
  312. char *from;
  313. char *fromend;
  314. size_t fromlen;
  315. int ch, ch2 = 0;
  316. /* Character that started the string we're working on. */
  317. static char quotechar;
  318. /*State 0: beginning of normal line
  319. 1: After first whitespace on line (flush more white)
  320. 2: After first non-white (opcode) on line (keep 1white)
  321. 3: after second white on line (into operands) (flush white)
  322. 4: after putting out a .linefile, put out digits
  323. 5: parsing a string, then go to old-state
  324. 6: putting out \ escape in a "d string.
  325. 7: no longer used
  326. 8: no longer used
  327. 9: After seeing symbol char in state 3 (keep 1white after symchar)
  328. 10: After seeing whitespace in state 9 (keep white before symchar)
  329. 11: After seeing a symbol character in state 0 (eg a label definition)
  330. -1: output string in out_string and go to the state in old_state
  331. -2: flush text until a '*' '/' is seen, then go to state old_state
  332. #ifdef TC_V850
  333. 12: After seeing a dash, looking for a second dash as a start
  334. of comment.
  335. #endif
  336. #ifdef DOUBLEBAR_PARALLEL
  337. 13: After seeing a vertical bar, looking for a second
  338. vertical bar as a parallel expression separator.
  339. #endif
  340. #ifdef TC_PREDICATE_START_CHAR
  341. 14: After seeing a predicate start character at state 0, looking
  342. for a predicate end character as predicate.
  343. 15: After seeing a predicate start character at state 1, looking
  344. for a predicate end character as predicate.
  345. #endif
  346. #ifdef TC_Z80
  347. 16: After seeing an 'a' or an 'A' at the start of a symbol
  348. 17: After seeing an 'f' or an 'F' in state 16
  349. #endif
  350. */
  351. /* I added states 9 and 10 because the MIPS ECOFF assembler uses
  352. constructs like ``.loc 1 20''. This was turning into ``.loc
  353. 120''. States 9 and 10 ensure that a space is never dropped in
  354. between characters which could appear in an identifier. Ian
  355. Taylor, ian@cygnus.com.
  356. I added state 11 so that something like "Lfoo add %r25,%r26,%r27" works
  357. correctly on the PA (and any other target where colons are optional).
  358. Jeff Law, law@cs.utah.edu.
  359. I added state 13 so that something like "cmp r1, r2 || trap #1" does not
  360. get squashed into "cmp r1,r2||trap#1", with the all important space
  361. between the 'trap' and the '#1' being eliminated. nickc@cygnus.com */
  362. /* This macro gets the next input character. */
  363. #define GET() \
  364. (from < fromend \
  365. ? * (unsigned char *) (from++) \
  366. : (saved_input = NULL, \
  367. fromlen = (*get) (input_buffer, sizeof input_buffer), \
  368. from = input_buffer, \
  369. fromend = from + fromlen, \
  370. (fromlen == 0 \
  371. ? EOF \
  372. : * (unsigned char *) (from++))))
  373. /* This macro pushes a character back on the input stream. */
  374. #define UNGET(uch) (*--from = (uch))
  375. /* This macro puts a character into the output buffer. If this
  376. character fills the output buffer, this macro jumps to the label
  377. TOFULL. We use this rather ugly approach because we need to
  378. handle two different termination conditions: EOF on the input
  379. stream, and a full output buffer. It would be simpler if we
  380. always read in the entire input stream before processing it, but
  381. I don't want to make such a significant change to the assembler's
  382. memory usage. */
  383. #define PUT(pch) \
  384. do \
  385. { \
  386. *to++ = (pch); \
  387. if (to >= toend) \
  388. goto tofull; \
  389. } \
  390. while (0)
  391. if (saved_input != NULL)
  392. {
  393. from = saved_input;
  394. fromend = from + saved_input_len;
  395. }
  396. else
  397. {
  398. fromlen = (*get) (input_buffer, sizeof input_buffer);
  399. if (fromlen == 0)
  400. return 0;
  401. from = input_buffer;
  402. fromend = from + fromlen;
  403. }
  404. while (1)
  405. {
  406. /* The cases in this switch end with continue, in order to
  407. branch back to the top of this while loop and generate the
  408. next output character in the appropriate state. */
  409. switch (state)
  410. {
  411. case -1:
  412. ch = *out_string++;
  413. if (*out_string == '\0')
  414. {
  415. state = old_state;
  416. old_state = 3;
  417. }
  418. PUT (ch);
  419. continue;
  420. case -2:
  421. for (;;)
  422. {
  423. do
  424. {
  425. ch = GET ();
  426. if (ch == EOF)
  427. {
  428. as_warn (_("end of file in comment"));
  429. goto fromeof;
  430. }
  431. if (ch == '\n')
  432. PUT ('\n');
  433. }
  434. while (ch != '*');
  435. while ((ch = GET ()) == '*')
  436. ;
  437. if (ch == EOF)
  438. {
  439. as_warn (_("end of file in comment"));
  440. goto fromeof;
  441. }
  442. if (ch == '/')
  443. break;
  444. UNGET (ch);
  445. }
  446. state = old_state;
  447. UNGET (' ');
  448. continue;
  449. case 4:
  450. ch = GET ();
  451. if (ch == EOF)
  452. goto fromeof;
  453. else if (ch >= '0' && ch <= '9')
  454. PUT (ch);
  455. else
  456. {
  457. while (ch != EOF && IS_WHITESPACE (ch))
  458. ch = GET ();
  459. if (ch == '"')
  460. {
  461. quotechar = ch;
  462. state = 5;
  463. old_state = 3;
  464. PUT (ch);
  465. }
  466. else
  467. {
  468. while (ch != EOF && ch != '\n')
  469. ch = GET ();
  470. state = 0;
  471. PUT (ch);
  472. }
  473. }
  474. continue;
  475. case 5:
  476. /* We are going to copy everything up to a quote character,
  477. with special handling for a backslash. We try to
  478. optimize the copying in the simple case without using the
  479. GET and PUT macros. */
  480. {
  481. char *s;
  482. ptrdiff_t len;
  483. for (s = from; s < fromend; s++)
  484. {
  485. ch = *s;
  486. if (ch == '\\'
  487. || ch == quotechar
  488. || ch == '\n')
  489. break;
  490. }
  491. len = s - from;
  492. if (len > toend - to)
  493. len = toend - to;
  494. if (len > 0)
  495. {
  496. memcpy (to, from, len);
  497. to += len;
  498. from += len;
  499. if (to >= toend)
  500. goto tofull;
  501. }
  502. }
  503. ch = GET ();
  504. if (ch == EOF)
  505. {
  506. /* This buffer is here specifically so
  507. that the UNGET below will work. */
  508. static char one_char_buf[1];
  509. as_warn (_("end of file in string; '%c' inserted"), quotechar);
  510. state = old_state;
  511. from = fromend = one_char_buf + 1;
  512. fromlen = 1;
  513. UNGET ('\n');
  514. PUT (quotechar);
  515. }
  516. else if (ch == quotechar)
  517. {
  518. state = old_state;
  519. PUT (ch);
  520. }
  521. #ifndef NO_STRING_ESCAPES
  522. else if (ch == '\\')
  523. {
  524. state = 6;
  525. PUT (ch);
  526. }
  527. #endif
  528. else if (scrub_m68k_mri && ch == '\n')
  529. {
  530. /* Just quietly terminate the string. This permits lines like
  531. bne label loop if we haven't reach end yet. */
  532. state = old_state;
  533. UNGET (ch);
  534. PUT ('\'');
  535. }
  536. else
  537. {
  538. PUT (ch);
  539. }
  540. continue;
  541. case 6:
  542. state = 5;
  543. ch = GET ();
  544. switch (ch)
  545. {
  546. /* Handle strings broken across lines, by turning '\n' into
  547. '\\' and 'n'. */
  548. case '\n':
  549. UNGET ('n');
  550. add_newlines++;
  551. PUT ('\\');
  552. continue;
  553. case EOF:
  554. as_warn (_("end of file in string; '%c' inserted"), quotechar);
  555. PUT (quotechar);
  556. continue;
  557. case '"':
  558. case '\\':
  559. case 'b':
  560. case 'f':
  561. case 'n':
  562. case 'r':
  563. case 't':
  564. case 'v':
  565. case 'x':
  566. case 'X':
  567. case '0':
  568. case '1':
  569. case '2':
  570. case '3':
  571. case '4':
  572. case '5':
  573. case '6':
  574. case '7':
  575. break;
  576. default:
  577. #ifdef ONLY_STANDARD_ESCAPES
  578. as_warn (_("unknown escape '\\%c' in string; ignored"), ch);
  579. #endif
  580. break;
  581. }
  582. PUT (ch);
  583. continue;
  584. #ifdef DOUBLEBAR_PARALLEL
  585. case 13:
  586. ch = GET ();
  587. if (ch != '|')
  588. abort ();
  589. /* Reset back to state 1 and pretend that we are parsing a
  590. line from just after the first white space. */
  591. state = 1;
  592. PUT ('|');
  593. #ifdef TC_TIC6X
  594. /* "||^" is used for SPMASKed instructions. */
  595. ch = GET ();
  596. if (ch == EOF)
  597. goto fromeof;
  598. else if (ch == '^')
  599. PUT ('^');
  600. else
  601. UNGET (ch);
  602. #endif
  603. continue;
  604. #endif
  605. #ifdef TC_Z80
  606. case 16:
  607. /* We have seen an 'a' at the start of a symbol, look for an 'f'. */
  608. ch = GET ();
  609. if (ch == 'f' || ch == 'F')
  610. {
  611. state = 17;
  612. PUT (ch);
  613. }
  614. else
  615. {
  616. state = 9;
  617. break;
  618. }
  619. case 17:
  620. /* We have seen "af" at the start of a symbol,
  621. a ' here is a part of that symbol. */
  622. ch = GET ();
  623. state = 9;
  624. if (ch == '\'')
  625. /* Change to avoid warning about unclosed string. */
  626. PUT ('`');
  627. else if (ch != EOF)
  628. UNGET (ch);
  629. break;
  630. #endif
  631. }
  632. /* OK, we are somewhere in states 0 through 4 or 9 through 11. */
  633. /* flushchar: */
  634. ch = GET ();
  635. #ifdef TC_PREDICATE_START_CHAR
  636. if (ch == TC_PREDICATE_START_CHAR && (state == 0 || state == 1))
  637. {
  638. state += 14;
  639. PUT (ch);
  640. continue;
  641. }
  642. else if (state == 14 || state == 15)
  643. {
  644. if (ch == TC_PREDICATE_END_CHAR)
  645. {
  646. state -= 14;
  647. PUT (ch);
  648. ch = GET ();
  649. }
  650. else
  651. {
  652. PUT (ch);
  653. continue;
  654. }
  655. }
  656. #endif
  657. recycle:
  658. #if defined TC_ARM && defined OBJ_ELF
  659. /* We need to watch out for .symver directives. See the comment later
  660. in this function. */
  661. if (symver_state == NULL)
  662. {
  663. if ((state == 0 || state == 1) && ch == symver_pseudo[0])
  664. symver_state = symver_pseudo + 1;
  665. }
  666. else
  667. {
  668. /* We advance to the next state if we find the right
  669. character. */
  670. if (ch != '\0' && (*symver_state == ch))
  671. ++symver_state;
  672. else if (*symver_state != '\0')
  673. /* We did not get the expected character, or we didn't
  674. get a valid terminating character after seeing the
  675. entire pseudo-op, so we must go back to the beginning. */
  676. symver_state = NULL;
  677. else
  678. {
  679. /* We've read the entire pseudo-op. If this is the end
  680. of the line, go back to the beginning. */
  681. if (IS_NEWLINE (ch))
  682. symver_state = NULL;
  683. }
  684. }
  685. #endif /* TC_ARM && OBJ_ELF */
  686. #ifdef TC_M68K
  687. /* We want to have pseudo-ops which control whether we are in
  688. MRI mode or not. Unfortunately, since m68k MRI mode affects
  689. the scrubber, that means that we need a special purpose
  690. recognizer here. */
  691. if (mri_state == NULL)
  692. {
  693. if ((state == 0 || state == 1)
  694. && ch == mri_pseudo[0])
  695. mri_state = mri_pseudo + 1;
  696. }
  697. else
  698. {
  699. /* We advance to the next state if we find the right
  700. character, or if we need a space character and we get any
  701. whitespace character, or if we need a '0' and we get a
  702. '1' (this is so that we only need one state to handle
  703. ``.mri 0'' and ``.mri 1''). */
  704. if (ch != '\0'
  705. && (*mri_state == ch
  706. || (*mri_state == ' '
  707. && lex[ch] == LEX_IS_WHITESPACE)
  708. || (*mri_state == '0'
  709. && ch == '1')))
  710. {
  711. mri_last_ch = ch;
  712. ++mri_state;
  713. }
  714. else if (*mri_state != '\0'
  715. || (lex[ch] != LEX_IS_WHITESPACE
  716. && lex[ch] != LEX_IS_NEWLINE))
  717. {
  718. /* We did not get the expected character, or we didn't
  719. get a valid terminating character after seeing the
  720. entire pseudo-op, so we must go back to the
  721. beginning. */
  722. mri_state = NULL;
  723. }
  724. else
  725. {
  726. /* We've read the entire pseudo-op. mips_last_ch is
  727. either '0' or '1' indicating whether to enter or
  728. leave MRI mode. */
  729. do_scrub_begin (mri_last_ch == '1');
  730. mri_state = NULL;
  731. /* We continue handling the character as usual. The
  732. main gas reader must also handle the .mri pseudo-op
  733. to control expression parsing and the like. */
  734. }
  735. }
  736. #endif
  737. if (ch == EOF)
  738. {
  739. if (state != 0)
  740. {
  741. as_warn (_("end of file not at end of a line; newline inserted"));
  742. state = 0;
  743. PUT ('\n');
  744. }
  745. goto fromeof;
  746. }
  747. switch (lex[ch])
  748. {
  749. case LEX_IS_WHITESPACE:
  750. do
  751. {
  752. ch = GET ();
  753. }
  754. while (ch != EOF && IS_WHITESPACE (ch));
  755. if (ch == EOF)
  756. goto fromeof;
  757. if (state == 0)
  758. {
  759. /* Preserve a single whitespace character at the
  760. beginning of a line. */
  761. state = 1;
  762. UNGET (ch);
  763. PUT (' ');
  764. break;
  765. }
  766. #ifdef KEEP_WHITE_AROUND_COLON
  767. if (lex[ch] == LEX_IS_COLON)
  768. {
  769. /* Only keep this white if there's no white *after* the
  770. colon. */
  771. ch2 = GET ();
  772. if (ch2 != EOF)
  773. UNGET (ch2);
  774. if (!IS_WHITESPACE (ch2))
  775. {
  776. state = 9;
  777. UNGET (ch);
  778. PUT (' ');
  779. break;
  780. }
  781. }
  782. #endif
  783. if (IS_COMMENT (ch)
  784. || ch == '/'
  785. || IS_LINE_SEPARATOR (ch)
  786. || IS_PARALLEL_SEPARATOR (ch))
  787. {
  788. if (scrub_m68k_mri)
  789. {
  790. /* In MRI mode, we keep these spaces. */
  791. UNGET (ch);
  792. PUT (' ');
  793. break;
  794. }
  795. goto recycle;
  796. }
  797. /* If we're in state 2 or 11, we've seen a non-white
  798. character followed by whitespace. If the next character
  799. is ':', this is whitespace after a label name which we
  800. normally must ignore. In MRI mode, though, spaces are
  801. not permitted between the label and the colon. */
  802. if ((state == 2 || state == 11)
  803. && lex[ch] == LEX_IS_COLON
  804. && ! scrub_m68k_mri)
  805. {
  806. state = 1;
  807. PUT (ch);
  808. break;
  809. }
  810. switch (state)
  811. {
  812. case 1:
  813. /* We can arrive here if we leave a leading whitespace
  814. character at the beginning of a line. */
  815. goto recycle;
  816. case 2:
  817. state = 3;
  818. if (to + 1 < toend)
  819. {
  820. /* Optimize common case by skipping UNGET/GET. */
  821. PUT (' '); /* Sp after opco */
  822. goto recycle;
  823. }
  824. UNGET (ch);
  825. PUT (' ');
  826. break;
  827. case 3:
  828. #ifndef TC_KEEP_OPERAND_SPACES
  829. /* For TI C6X, we keep these spaces as they may separate
  830. functional unit specifiers from operands. */
  831. if (scrub_m68k_mri)
  832. #endif
  833. {
  834. /* In MRI mode, we keep these spaces. */
  835. UNGET (ch);
  836. PUT (' ');
  837. break;
  838. }
  839. goto recycle; /* Sp in operands */
  840. case 9:
  841. case 10:
  842. #ifndef TC_KEEP_OPERAND_SPACES
  843. if (scrub_m68k_mri)
  844. #endif
  845. {
  846. /* In MRI mode, we keep these spaces. */
  847. state = 3;
  848. UNGET (ch);
  849. PUT (' ');
  850. break;
  851. }
  852. state = 10; /* Sp after symbol char */
  853. goto recycle;
  854. case 11:
  855. if (LABELS_WITHOUT_COLONS || flag_m68k_mri)
  856. state = 1;
  857. else
  858. {
  859. /* We know that ch is not ':', since we tested that
  860. case above. Therefore this is not a label, so it
  861. must be the opcode, and we've just seen the
  862. whitespace after it. */
  863. state = 3;
  864. }
  865. UNGET (ch);
  866. PUT (' '); /* Sp after label definition. */
  867. break;
  868. default:
  869. BAD_CASE (state);
  870. }
  871. break;
  872. case LEX_IS_TWOCHAR_COMMENT_1ST:
  873. ch2 = GET ();
  874. if (ch2 == '*')
  875. {
  876. for (;;)
  877. {
  878. do
  879. {
  880. ch2 = GET ();
  881. if (ch2 != EOF && IS_NEWLINE (ch2))
  882. add_newlines++;
  883. }
  884. while (ch2 != EOF && ch2 != '*');
  885. while (ch2 == '*')
  886. ch2 = GET ();
  887. if (ch2 == EOF || ch2 == '/')
  888. break;
  889. /* This UNGET will ensure that we count newlines
  890. correctly. */
  891. UNGET (ch2);
  892. }
  893. if (ch2 == EOF)
  894. as_warn (_("end of file in multiline comment"));
  895. ch = ' ';
  896. goto recycle;
  897. }
  898. #ifdef DOUBLESLASH_LINE_COMMENTS
  899. else if (ch2 == '/')
  900. {
  901. do
  902. {
  903. ch = GET ();
  904. }
  905. while (ch != EOF && !IS_NEWLINE (ch));
  906. if (ch == EOF)
  907. as_warn ("end of file in comment; newline inserted");
  908. state = 0;
  909. PUT ('\n');
  910. break;
  911. }
  912. #endif
  913. else
  914. {
  915. if (ch2 != EOF)
  916. UNGET (ch2);
  917. if (state == 9 || state == 10)
  918. state = 3;
  919. PUT (ch);
  920. }
  921. break;
  922. case LEX_IS_STRINGQUOTE:
  923. quotechar = ch;
  924. if (state == 10)
  925. {
  926. /* Preserve the whitespace in foo "bar". */
  927. UNGET (ch);
  928. state = 3;
  929. PUT (' ');
  930. /* PUT didn't jump out. We could just break, but we
  931. know what will happen, so optimize a bit. */
  932. ch = GET ();
  933. old_state = 3;
  934. }
  935. else if (state == 9)
  936. old_state = 3;
  937. else
  938. old_state = state;
  939. state = 5;
  940. PUT (ch);
  941. break;
  942. #ifndef IEEE_STYLE
  943. case LEX_IS_ONECHAR_QUOTE:
  944. #ifdef H_TICK_HEX
  945. if (state == 9 && enable_h_tick_hex)
  946. {
  947. char c;
  948. c = GET ();
  949. as_warn ("'%c found after symbol", c);
  950. UNGET (c);
  951. }
  952. #endif
  953. if (state == 10)
  954. {
  955. /* Preserve the whitespace in foo 'b'. */
  956. UNGET (ch);
  957. state = 3;
  958. PUT (' ');
  959. break;
  960. }
  961. ch = GET ();
  962. if (ch == EOF)
  963. {
  964. as_warn (_("end of file after a one-character quote; \\0 inserted"));
  965. ch = 0;
  966. }
  967. if (ch == '\\')
  968. {
  969. ch = GET ();
  970. if (ch == EOF)
  971. {
  972. as_warn (_("end of file in escape character"));
  973. ch = '\\';
  974. }
  975. else
  976. ch = process_escape (ch);
  977. }
  978. sprintf (out_buf, "%d", (int) (unsigned char) ch);
  979. /* None of these 'x constants for us. We want 'x'. */
  980. if ((ch = GET ()) != '\'')
  981. {
  982. #ifdef REQUIRE_CHAR_CLOSE_QUOTE
  983. as_warn (_("missing close quote; (assumed)"));
  984. #else
  985. if (ch != EOF)
  986. UNGET (ch);
  987. #endif
  988. }
  989. if (strlen (out_buf) == 1)
  990. {
  991. PUT (out_buf[0]);
  992. break;
  993. }
  994. if (state == 9)
  995. old_state = 3;
  996. else
  997. old_state = state;
  998. state = -1;
  999. out_string = out_buf;
  1000. PUT (*out_string++);
  1001. break;
  1002. #endif
  1003. case LEX_IS_COLON:
  1004. #ifdef KEEP_WHITE_AROUND_COLON
  1005. state = 9;
  1006. #else
  1007. if (state == 9 || state == 10)
  1008. state = 3;
  1009. else if (state != 3)
  1010. state = 1;
  1011. #endif
  1012. PUT (ch);
  1013. break;
  1014. case LEX_IS_NEWLINE:
  1015. /* Roll out a bunch of newlines from inside comments, etc. */
  1016. if (add_newlines)
  1017. {
  1018. --add_newlines;
  1019. UNGET (ch);
  1020. }
  1021. /* Fall through. */
  1022. case LEX_IS_LINE_SEPARATOR:
  1023. state = 0;
  1024. PUT (ch);
  1025. break;
  1026. case LEX_IS_PARALLEL_SEPARATOR:
  1027. state = 1;
  1028. PUT (ch);
  1029. break;
  1030. #ifdef TC_V850
  1031. case LEX_IS_DOUBLEDASH_1ST:
  1032. ch2 = GET ();
  1033. if (ch2 != '-')
  1034. {
  1035. if (ch2 != EOF)
  1036. UNGET (ch2);
  1037. goto de_fault;
  1038. }
  1039. /* Read and skip to end of line. */
  1040. do
  1041. {
  1042. ch = GET ();
  1043. }
  1044. while (ch != EOF && ch != '\n');
  1045. if (ch == EOF)
  1046. as_warn (_("end of file in comment; newline inserted"));
  1047. state = 0;
  1048. PUT ('\n');
  1049. break;
  1050. #endif
  1051. #ifdef DOUBLEBAR_PARALLEL
  1052. case LEX_IS_DOUBLEBAR_1ST:
  1053. ch2 = GET ();
  1054. if (ch2 != EOF)
  1055. UNGET (ch2);
  1056. if (ch2 != '|')
  1057. goto de_fault;
  1058. /* Handle '||' in two states as invoking PUT twice might
  1059. result in the first one jumping out of this loop. We'd
  1060. then lose track of the state and one '|' char. */
  1061. state = 13;
  1062. PUT ('|');
  1063. break;
  1064. #endif
  1065. case LEX_IS_LINE_COMMENT_START:
  1066. /* FIXME-someday: The two character comment stuff was badly
  1067. thought out. On i386, we want '/' as line comment start
  1068. AND we want C style comments. hence this hack. The
  1069. whole lexical process should be reworked. xoxorich. */
  1070. if (ch == '/')
  1071. {
  1072. ch2 = GET ();
  1073. if (ch2 == '*')
  1074. {
  1075. old_state = 3;
  1076. state = -2;
  1077. break;
  1078. }
  1079. else
  1080. {
  1081. UNGET (ch2);
  1082. }
  1083. }
  1084. if (state == 0 || state == 1) /* Only comment at start of line. */
  1085. {
  1086. int startch;
  1087. startch = ch;
  1088. do
  1089. {
  1090. ch = GET ();
  1091. }
  1092. while (ch != EOF && IS_WHITESPACE (ch));
  1093. if (ch == EOF)
  1094. {
  1095. as_warn (_("end of file in comment; newline inserted"));
  1096. PUT ('\n');
  1097. break;
  1098. }
  1099. if (ch < '0' || ch > '9' || state != 0 || startch != '#')
  1100. {
  1101. /* Not a cpp line. */
  1102. while (ch != EOF && !IS_NEWLINE (ch))
  1103. ch = GET ();
  1104. if (ch == EOF)
  1105. {
  1106. as_warn (_("end of file in comment; newline inserted"));
  1107. PUT ('\n');
  1108. }
  1109. else /* IS_NEWLINE (ch) */
  1110. {
  1111. /* To process non-zero add_newlines. */
  1112. UNGET (ch);
  1113. }
  1114. state = 0;
  1115. break;
  1116. }
  1117. /* Looks like `# 123 "filename"' from cpp. */
  1118. UNGET (ch);
  1119. old_state = 4;
  1120. state = -1;
  1121. if (scrub_m68k_mri)
  1122. out_string = "\tlinefile ";
  1123. else
  1124. out_string = "\t.linefile ";
  1125. PUT (*out_string++);
  1126. break;
  1127. }
  1128. #ifdef TC_D10V
  1129. /* All insns end in a char for which LEX_IS_SYMBOL_COMPONENT is true.
  1130. Trap is the only short insn that has a first operand that is
  1131. neither register nor label.
  1132. We must prevent exef0f ||trap #1 to degenerate to exef0f ||trap#1 .
  1133. We can't make '#' LEX_IS_SYMBOL_COMPONENT because it is
  1134. already LEX_IS_LINE_COMMENT_START. However, it is the
  1135. only character in line_comment_chars for d10v, hence we
  1136. can recognize it as such. */
  1137. /* An alternative approach would be to reset the state to 1 when
  1138. we see '||', '<'- or '->', but that seems to be overkill. */
  1139. if (state == 10)
  1140. PUT (' ');
  1141. #endif
  1142. /* We have a line comment character which is not at the
  1143. start of a line. If this is also a normal comment
  1144. character, fall through. Otherwise treat it as a default
  1145. character. */
  1146. if (strchr (tc_comment_chars, ch) == NULL
  1147. && (! scrub_m68k_mri
  1148. || (ch != '!' && ch != '*')))
  1149. goto de_fault;
  1150. if (scrub_m68k_mri
  1151. && (ch == '!' || ch == '*' || ch == '#')
  1152. && state != 1
  1153. && state != 10)
  1154. goto de_fault;
  1155. /* Fall through. */
  1156. case LEX_IS_COMMENT_START:
  1157. #if defined TC_ARM && defined OBJ_ELF
  1158. /* On the ARM, `@' is the comment character.
  1159. Unfortunately this is also a special character in ELF .symver
  1160. directives (and .type, though we deal with those another way).
  1161. So we check if this line is such a directive, and treat
  1162. the character as default if so. This is a hack. */
  1163. if ((symver_state != NULL) && (*symver_state == 0))
  1164. goto de_fault;
  1165. #endif
  1166. #ifdef TC_ARM
  1167. /* For the ARM, care is needed not to damage occurrences of \@
  1168. by stripping the @ onwards. Yuck. */
  1169. if (to > tostart && *(to - 1) == '\\')
  1170. /* Do not treat the @ as a start-of-comment. */
  1171. goto de_fault;
  1172. #endif
  1173. #ifdef WARN_COMMENTS
  1174. if (!found_comment)
  1175. as_where (&found_comment_file, &found_comment);
  1176. #endif
  1177. do
  1178. {
  1179. ch = GET ();
  1180. }
  1181. while (ch != EOF && !IS_NEWLINE (ch));
  1182. if (ch == EOF)
  1183. as_warn (_("end of file in comment; newline inserted"));
  1184. state = 0;
  1185. PUT ('\n');
  1186. break;
  1187. #ifdef H_TICK_HEX
  1188. case LEX_IS_H:
  1189. /* Look for strings like H'[0-9A-Fa-f] and if found, replace
  1190. the H' with 0x to make them gas-style hex characters. */
  1191. if (enable_h_tick_hex)
  1192. {
  1193. char quot;
  1194. quot = GET ();
  1195. if (quot == '\'')
  1196. {
  1197. UNGET ('x');
  1198. ch = '0';
  1199. }
  1200. else
  1201. UNGET (quot);
  1202. }
  1203. /* FALL THROUGH */
  1204. #endif
  1205. case LEX_IS_SYMBOL_COMPONENT:
  1206. if (state == 10)
  1207. {
  1208. /* This is a symbol character following another symbol
  1209. character, with whitespace in between. We skipped
  1210. the whitespace earlier, so output it now. */
  1211. UNGET (ch);
  1212. state = 3;
  1213. PUT (' ');
  1214. break;
  1215. }
  1216. #ifdef TC_Z80
  1217. /* "af'" is a symbol containing '\''. */
  1218. if (state == 3 && (ch == 'a' || ch == 'A'))
  1219. {
  1220. state = 16;
  1221. PUT (ch);
  1222. ch = GET ();
  1223. if (ch == 'f' || ch == 'F')
  1224. {
  1225. state = 17;
  1226. PUT (ch);
  1227. break;
  1228. }
  1229. else
  1230. {
  1231. state = 9;
  1232. if (ch == EOF || !IS_SYMBOL_COMPONENT (ch))
  1233. {
  1234. if (ch != EOF)
  1235. UNGET (ch);
  1236. break;
  1237. }
  1238. }
  1239. }
  1240. #endif
  1241. if (state == 3)
  1242. state = 9;
  1243. /* This is a common case. Quickly copy CH and all the
  1244. following symbol component or normal characters. */
  1245. if (to + 1 < toend
  1246. && mri_state == NULL
  1247. #if defined TC_ARM && defined OBJ_ELF
  1248. && symver_state == NULL
  1249. #endif
  1250. )
  1251. {
  1252. char *s;
  1253. ptrdiff_t len;
  1254. for (s = from; s < fromend; s++)
  1255. {
  1256. int type;
  1257. ch2 = *(unsigned char *) s;
  1258. type = lex[ch2];
  1259. if (type != 0
  1260. && type != LEX_IS_SYMBOL_COMPONENT)
  1261. break;
  1262. }
  1263. if (s > from)
  1264. /* Handle the last character normally, for
  1265. simplicity. */
  1266. --s;
  1267. len = s - from;
  1268. if (len > (toend - to) - 1)
  1269. len = (toend - to) - 1;
  1270. if (len > 0)
  1271. {
  1272. PUT (ch);
  1273. memcpy (to, from, len);
  1274. to += len;
  1275. from += len;
  1276. if (to >= toend)
  1277. goto tofull;
  1278. ch = GET ();
  1279. }
  1280. }
  1281. /* Fall through. */
  1282. default:
  1283. de_fault:
  1284. /* Some relatively `normal' character. */
  1285. if (state == 0)
  1286. {
  1287. state = 11; /* Now seeing label definition. */
  1288. }
  1289. else if (state == 1)
  1290. {
  1291. state = 2; /* Ditto. */
  1292. }
  1293. else if (state == 9)
  1294. {
  1295. if (!IS_SYMBOL_COMPONENT (ch))
  1296. state = 3;
  1297. }
  1298. else if (state == 10)
  1299. {
  1300. if (ch == '\\')
  1301. {
  1302. /* Special handling for backslash: a backslash may
  1303. be the beginning of a formal parameter (of a
  1304. macro) following another symbol character, with
  1305. whitespace in between. If that is the case, we
  1306. output a space before the parameter. Strictly
  1307. speaking, correct handling depends upon what the
  1308. macro parameter expands into; if the parameter
  1309. expands into something which does not start with
  1310. an operand character, then we don't want to keep
  1311. the space. We don't have enough information to
  1312. make the right choice, so here we are making the
  1313. choice which is more likely to be correct. */
  1314. if (to + 1 >= toend)
  1315. {
  1316. /* If we're near the end of the buffer, save the
  1317. character for the next time round. Otherwise
  1318. we'll lose our state. */
  1319. UNGET (ch);
  1320. goto tofull;
  1321. }
  1322. *to++ = ' ';
  1323. }
  1324. state = 3;
  1325. }
  1326. PUT (ch);
  1327. break;
  1328. }
  1329. }
  1330. /*NOTREACHED*/
  1331. fromeof:
  1332. /* We have reached the end of the input. */
  1333. return to - tostart;
  1334. tofull:
  1335. /* The output buffer is full. Save any input we have not yet
  1336. processed. */
  1337. if (fromend > from)
  1338. {
  1339. saved_input = from;
  1340. saved_input_len = fromend - from;
  1341. }
  1342. else
  1343. saved_input = NULL;
  1344. return to - tostart;
  1345. }