Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
2.5 KiB

  1. // Copyright (c) 1993-1999 Microsoft Corporation
  2. /* Edits:
  3. * 06-Dec-80 Original code broken out of y1.c.
  4. * 18-Dec-80 Add conditional code for Decus for tempfile deletion.
  5. */
  6. #include "y1.h"
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. FILE *pfopen(const char *path, char *search, const char *type);
  11. void
  12. others( void )
  13. {
  14. /* put out other arrays, copy the parsers */
  15. register c, i, j;
  16. char *psz;
  17. extern char *infile;
  18. finput = NULL;
  19. if ((psz = strrchr(infile, '\\')) || (psz = strrchr(infile, ':'))) {
  20. char tmp[FNAMESIZE];
  21. char c = *++psz;
  22. *psz = '\0';
  23. strcpy(tmp, infile);
  24. *psz = c;
  25. strcat(tmp, PARSER);
  26. finput = fopen(tmp, "r");
  27. }
  28. if ( !finput && !(finput = fopen(PARSER, "r"))) {
  29. if (!(finput = pfopen(PARSER, getenv(LIBENV), "r"))) {
  30. error( "cannot find parser %s", PARSER );
  31. }
  32. }
  33. warray( "yyr1", levprd, nprod );
  34. aryfil( temp1, nprod, 0 );
  35. PLOOP(1,i)temp1[i] = prdptr[i+1]-prdptr[i]-2;
  36. warray( "yyr2", temp1, nprod );
  37. aryfil( temp1, nstate, -1000 );
  38. TLOOP(i)
  39. {
  40. for( j=tstates[i]; j!=0; j=mstates[j] )
  41. {
  42. temp1[j] = tokset[i].value;
  43. }
  44. }
  45. NTLOOP(i)
  46. {
  47. for( j=ntstates[i]; j!=0; j=mstates[j] )
  48. {
  49. temp1[j] = -i;
  50. }
  51. }
  52. warray( "yychk", temp1, nstate );
  53. warray( "yydef", defact, nstate );
  54. /* copy parser text */
  55. while( (c=unix_getc(finput) ) != EOF )
  56. {
  57. if( c == '$' ) {
  58. switch (c=unix_getc(finput)) {
  59. case 'A':
  60. faction = fopen( ACTNAME, "r" );
  61. if( faction == NULL ) error( "cannot reopen action tempfile" );
  62. while( (c=unix_getc(faction) ) != EOF ) putc( c, ftable );
  63. fclose(faction);
  64. ZAPFILE(ACTNAME);
  65. c = unix_getc(finput);
  66. break;
  67. case 'T':
  68. if (pszPrefix) {
  69. fprintf(ftable, "%s", pszPrefix);
  70. }
  71. c = unix_getc(finput);
  72. break;
  73. default:
  74. putc( '$', ftable );
  75. break;
  76. }
  77. }
  78. putc( c, ftable );
  79. }
  80. fclose( ftable );
  81. }
  82. static char getbuf[30], *getbufptr = getbuf;
  83. unix_getc(iop)
  84. FILE *iop;
  85. {
  86. if(getbufptr == getbuf)
  87. return(getc(iop));
  88. else
  89. return(*--getbufptr);
  90. }
  91. void
  92. yungetc(c, iop)
  93. SSIZE_T c;
  94. FILE *iop; /* WARNING: iop ignored ... ungetc's are multiplexed!!! */
  95. {
  96. *getbufptr++ = (char) c;
  97. }