lf.cc 958 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // -*- C++ -*-
  2. /* Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
  3. Written by James Clark (jjc@jclark.com) */
  4. #include <string.h>
  5. #include <ctype.h>
  6. #include "cset.h"
  7. #include "stringclass.h"
  8. extern void change_filename(const char *);
  9. extern void change_lineno(int);
  10. int
  11. interpret_lf_args(const char *p)
  12. {
  13. while (*p == ' ')
  14. p++;
  15. if (!csdigit(*p))
  16. return 0;
  17. int ln = 0;
  18. do
  19. {
  20. ln *= 10;
  21. ln += *p++ - '0';
  22. } while (csdigit(*p));
  23. if (*p != ' ' && *p != '\n' && *p != '\0')
  24. return 0;
  25. while (*p == ' ')
  26. p++;
  27. if (*p == '\0' || *p == '\n')
  28. {
  29. change_lineno(ln);
  30. return 1;
  31. }
  32. const char *q;
  33. for (q = p;
  34. *q != '\0' && *q != ' ' && *q != '\n' && *q != '\\';
  35. q++)
  36. ;
  37. string tem(p, q - p);
  38. while (*q == ' ')
  39. q++;
  40. if (*q != '\n' && *q != '\0')
  41. return 0;
  42. tem += '\0';
  43. change_filename(tem.contents());
  44. change_lineno(ln);
  45. return 1;
  46. }