machdep.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* Copyright (c) 1991 by the Vrije Universiteit, Amsterdam, the Netherlands.
  2. * For full copyright amd restrictions on use see the file COPYING in the top
  3. * level of the LLgen tree.
  4. */
  5. /*
  6. * L L G E N
  7. *
  8. * An Extended LL(1) Parser Generator
  9. *
  10. * Author : Ceriel J.H. Jacobs
  11. */
  12. /*
  13. * machdep.c
  14. * Machine dependant things
  15. */
  16. # include "types.h"
  17. # ifndef NORCSID
  18. static string rcsid5 = "$Id$";
  19. # endif
  20. /* In this file the following routines are defined: */
  21. extern UNLINK();
  22. extern RENAME();
  23. extern string libpath();
  24. UNLINK(x) string x; {
  25. /* Must remove the file "x" */
  26. #ifdef USE_SYS
  27. sys_remove(x); /* systemcall to remove file */
  28. #else
  29. unlink(x);
  30. #endif
  31. }
  32. RENAME(x,y) string x,y; {
  33. /* Must move the file "x" to the file "y" */
  34. #ifdef USE_SYS
  35. if(! sys_rename(x,y)) fatal(1,"Cannot rename to %s",y);
  36. #else
  37. unlink(y);
  38. if (link(x,y) != 0) fatal(1,"Cannot rename to %s",y);
  39. unlink(x);
  40. #endif
  41. }
  42. /* to make it easier to patch ... */
  43. char libdir[256] = LIBDIR;
  44. string
  45. libpath(s) string s; {
  46. /* Must deliver a full pathname to the library file "s" */
  47. register string p;
  48. register length;
  49. p_mem alloc();
  50. string strcpy(), strcat();
  51. length = strlen(libdir) + strlen(s) + 2;
  52. p = (string) alloc((unsigned) length);
  53. strcpy(p,libdir);
  54. strcat(p,"/");
  55. strcat(p,s);
  56. return p;
  57. }