You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/* after the options there must not be anything but filenames */
45
-
for (fnr=optind; fnr<argc; fnr++)
45
+
if (optind >= argc) /* no files specified */
46
+
usage(argv[0]);
47
+
else
46
48
{
47
-
char*filename,
48
-
*ptr2ext;
49
-
50
-
filename=malloc(strlen(argv[fnr]) +2);
51
-
if (filename==NULL)
49
+
/* after the options there must not be anything but filenames */
50
+
for (fnr=optind; fnr<argc; fnr++)
52
51
{
53
-
perror("malloc");
54
-
continue;
55
-
}
52
+
char*filename, *ptr2ext;
56
53
57
-
strcpy(filename, argv[fnr]);
54
+
filename=malloc(strlen(argv[fnr]) +2);
55
+
if (filename==NULL)
56
+
{
57
+
perror("malloc");
58
+
continue;
59
+
}
58
60
59
-
ptr2ext=strrchr(filename, '.');
60
-
/* no extension or extension not equal .pgc */
61
-
if (ptr2ext==NULL||strcmp(ptr2ext, ".pgc") !=0)
62
-
{
63
-
ptr2ext=filename+strlen(filename);
64
-
ptr2ext[0] ='.';
65
-
}
61
+
strcpy(filename, argv[fnr]);
66
62
67
-
/* make extension = .c */
68
-
ptr2ext[1] ='c';
69
-
ptr2ext[2] ='\0';
63
+
ptr2ext=strrchr(filename, '.');
64
+
/* no extension or extension not equal .pgc */
65
+
if (ptr2ext==NULL||strcmp(ptr2ext, ".pgc") !=0)
66
+
{
67
+
ptr2ext=filename+strlen(filename);
68
+
ptr2ext[0] ='.';
69
+
}
70
70
71
-
if (out_option==0) /* calculate the output name */
72
-
{
73
-
yyout=fopen(filename, "w");
74
-
if (yyout==NULL)
71
+
/* make extension = .c */
72
+
ptr2ext[1] ='c';
73
+
ptr2ext[2] ='\0';
74
+
75
+
if (out_option==0) /* calculate the output name */
75
76
{
76
-
perror(filename);
77
-
free(filename);
78
-
continue;
77
+
yyout=fopen(filename, "w");
78
+
if (yyout==NULL)
79
+
{
80
+
perror(filename);
81
+
free(filename);
82
+
continue;
83
+
}
79
84
}
80
-
}
81
85
82
-
yyin=fopen(input_filename=argv[fnr], "r");
83
-
if (yyin==NULL)
84
-
{
85
-
perror(argv[fnr]);
86
-
}
87
-
else
88
-
{
89
-
/* initialize lex */
90
-
lex_init();
86
+
yyin=fopen(input_filename=argv[fnr], "r");
87
+
if (yyin==NULL)
88
+
perror(argv[fnr]);
89
+
else
90
+
{
91
+
/* initialize lex */
92
+
lex_init();
91
93
92
-
/* we need two includes everytime */
93
-
fprintf(yyout, "/* These two include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n");
94
+
/* we need two includes */
95
+
fprintf(yyout, "/* Processed by ecpg (%d.%d.%d) */\n/*These two include files are added by the preprocessor */\n#include <ecpgtype.h>\n#include <ecpglib.h>\n", MAJOR_VERSION, MINOR_VERSION, PATCHLEVEL);
0 commit comments