本文整理汇总了C++中search_path::open_file_cautious方法的典型用法代码示例。如果您正苦于以下问题:C++ search_path::open_file_cautious方法的具体用法?C++ search_path::open_file_cautious怎么用?C++ search_path::open_file_cautious使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类search_path
的用法示例。
在下文中一共展示了search_path::open_file_cautious方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_file
int do_file(const char *filename)
{
char *file_name_in_path = 0;
FILE *fp = include_search_path.open_file_cautious(filename,
&file_name_in_path);
int err = errno;
string whole_filename(file_name_in_path ? file_name_in_path : filename);
whole_filename += '\0';
a_delete file_name_in_path;
if (fp == 0) {
error("can't open `%1': %2", whole_filename.contents(), strerror(err));
return 0;
}
current_filename = whole_filename.contents();
current_lineno = 1;
set_location();
enum { START, MIDDLE, HAD_DOT, HAD_s, HAD_so, HAD_l, HAD_lf } state = START;
for (;;) {
int c = getc(fp);
if (c == EOF)
break;
switch (state) {
case START:
if (c == '.')
state = HAD_DOT;
else {
putchar(c);
if (c == '\n') {
current_lineno++;
state = START;
}
else
state = MIDDLE;
}
break;
case MIDDLE:
putchar(c);
if (c == '\n') {
current_lineno++;
state = START;
}
break;
case HAD_DOT:
if (c == 's')
state = HAD_s;
else if (c == 'l')
state = HAD_l;
else {
putchar('.');
putchar(c);
if (c == '\n') {
current_lineno++;
state = START;
}
else
state = MIDDLE;
}
break;
case HAD_s:
if (c == 'o')
state = HAD_so;
else {
putchar('.');
putchar('s');
putchar(c);
if (c == '\n') {
current_lineno++;
state = START;
}
else
state = MIDDLE;
}
break;
case HAD_so:
if (c == ' ' || c == '\n' || compatible_flag) {
string line;
for (; c != EOF && c != '\n'; c = getc(fp))
line += c;
current_lineno++;
line += '\n';
line += '\0';
do_so(line.contents());
state = START;
}
else {
fputs(".so", stdout);
putchar(c);
state = MIDDLE;
}
break;
case HAD_l:
if (c == 'f')
state = HAD_lf;
else {
putchar('.');
putchar('l');
putchar(c);
if (c == '\n') {
current_lineno++;
state = START;
//.........这里部分代码省略.........