Mercurial > hg > xemacs-beta
comparison lib-src/make-docfile.c @ 408:501cfd01ee6d r21-2-34
Import from CVS: tag r21-2-34
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:18:11 +0200 |
parents | 74fd4e045ea6 |
children | de805c49cfc1 |
comparison
equal
deleted
inserted
replaced
407:ed6218a7d4d3 | 408:501cfd01ee6d |
---|---|
301 If printflag is positive, output string contents to outfile. | 301 If printflag is positive, output string contents to outfile. |
302 If it is negative, store contents in buf. | 302 If it is negative, store contents in buf. |
303 Convert escape sequences \n and \t to newline and tab; | 303 Convert escape sequences \n and \t to newline and tab; |
304 discard \ followed by newline. */ | 304 discard \ followed by newline. */ |
305 | 305 |
306 #define MDGET do { prevc = c; c = getc (infile); } while (0) | |
306 static int | 307 static int |
307 read_c_string (FILE *infile, int printflag, int c_docstring) | 308 read_c_string (FILE *infile, int printflag, int c_docstring) |
308 { | 309 { |
309 register int c; | 310 register int prevc = 0, c = 0; |
310 char *p = buf; | 311 char *p = buf; |
311 int start = -1; | 312 int start = -1; |
312 | 313 |
313 c = getc (infile); | 314 MDGET; |
314 while (c != EOF) | 315 while (c != EOF) |
315 { | 316 { |
316 while ((c_docstring || c != '"') && c != EOF) | 317 while ((c_docstring || c != '"') && c != EOF) |
317 { | 318 { |
318 if (start) | 319 if (c == '*') |
319 { | 320 { |
320 if (c == '*') | 321 int cc = getc (infile); |
321 { | 322 if (cc == '/') |
322 int cc = getc (infile); | 323 { |
323 if (cc == '/') | 324 if (prevc != '\n') |
324 break; | 325 { |
325 else | 326 if (printflag > 0) |
326 ungetc (cc, infile); | 327 { |
327 } | 328 if (ellcc) |
328 | 329 fprintf (outfile, "\\n\\"); |
329 if (start != -1) | 330 putc ('\n', outfile); |
330 { | 331 } |
331 if (printflag > 0) | 332 else if (printflag < 0) |
332 { | 333 *p++ = '\n'; |
333 if (ellcc) | 334 } |
334 fprintf (outfile, "\\n\\"); | 335 break; |
335 putc ('\n', outfile); | 336 } |
336 } | 337 else |
337 else if (printflag < 0) | 338 ungetc (cc, infile); |
338 *p++ = '\n'; | 339 } |
339 } | 340 |
341 if (start == 1) | |
342 { | |
343 if (printflag > 0) | |
344 { | |
345 if (ellcc) | |
346 fprintf (outfile, "\\n\\"); | |
347 putc ('\n', outfile); | |
348 } | |
349 else if (printflag < 0) | |
350 *p++ = '\n'; | |
340 } | 351 } |
341 | 352 |
342 if (c == '\\') | 353 if (c == '\\') |
343 { | 354 { |
344 c = getc (infile); | 355 MDGET; |
345 if (c == '\n') | 356 if (c == '\n') |
346 { | 357 { |
347 c = getc (infile); | 358 MDGET; |
348 start = 1; | 359 start = 1; |
349 continue; | 360 continue; |
350 } | 361 } |
351 if (!c_docstring && c == 'n') | 362 if (!c_docstring && c == 'n') |
352 c = '\n'; | 363 c = '\n'; |
356 if (c == '\n') | 367 if (c == '\n') |
357 start = 1; | 368 start = 1; |
358 else | 369 else |
359 { | 370 { |
360 start = 0; | 371 start = 0; |
361 if (printflag > 0) { | 372 if (printflag > 0) |
362 if (ellcc && c == '"') | 373 { |
363 putc ('\\', outfile); | 374 if (ellcc && c == '"') |
364 putc (c, outfile); | 375 putc ('\\', outfile); |
365 } | 376 putc (c, outfile); |
377 } | |
366 else if (printflag < 0) | 378 else if (printflag < 0) |
367 *p++ = c; | 379 *p++ = c; |
368 } | 380 } |
369 c = getc (infile); | 381 MDGET; |
370 } | 382 } |
371 /* look for continuation of string */ | 383 /* look for continuation of string */ |
372 if (Current_file_type == c_file) | 384 if (Current_file_type == c_file) |
373 { | 385 { |
374 while (isspace (c = getc (infile))) | 386 do |
375 ; | 387 { |
388 MDGET; | |
389 } | |
390 while (isspace (c)); | |
376 if (c != '"') | 391 if (c != '"') |
377 break; | 392 break; |
378 } | 393 } |
379 else | 394 else |
380 { | 395 { |
381 c = getc (infile); | 396 MDGET; |
382 if (c != '"') | 397 if (c != '"') |
383 break; | 398 break; |
384 /* If we had a "", concatenate the two strings. */ | 399 /* If we had a "", concatenate the two strings. */ |
385 } | 400 } |
386 c = getc (infile); | 401 MDGET; |
387 } | 402 } |
388 | 403 |
389 if (printflag < 0) | 404 if (printflag < 0) |
390 *p = 0; | 405 *p = 0; |
391 | 406 |