File: userinit.lex

package info (click to toggle)
flex 2.6.4-8.2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 7,168 kB
  • sloc: ansic: 12,044; sh: 5,363; lex: 3,699; yacc: 990; makefile: 717; perl: 238; awk: 72; cpp: 25; sed: 16
file content (30 lines) | stat: -rw-r--r-- 514 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
%{
#define YY_USER_INIT open_input_file()

extern FILE *yyin;

void open_input_file(void)
{
  char *file_name,buffer[1024];

  yyin      = NULL; 

  while(yyin == NULL){
    printf("Input file: ");
    file_name = fgets(buffer,1024,stdin);
    if(file_name){
      file_name[strlen(file_name)-1] = '\0';
      yyin = fopen(file_name,"r");
      if(yyin == NULL){
        printf("Unable to open \"%s\"\n",file_name);
      }
    } else {
      printf("stdin\n");
      yyin = stdin;
      break;
    }
  }
}

%}
%%