Forgot to commit the updated "rc" to make AddRevisionToResources work:
* "rc" now accepts stdin as input file when "-" is used as a file name. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16225 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -79,10 +79,17 @@ class AddIncludeDir {
|
|||||||
|
|
||||||
|
|
||||||
AddIncludeDir::AddIncludeDir(const char *file)
|
AddIncludeDir::AddIncludeDir(const char *file)
|
||||||
:
|
|
||||||
fPath(file)
|
|
||||||
{
|
{
|
||||||
if (fPath.GetParent(&fPath) == B_OK)
|
// ignore the special stdin file
|
||||||
|
if (!strcmp(file, "-"))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (fPath.SetTo(file) != B_OK
|
||||||
|
|| fPath.GetParent(&fPath) != B_OK) {
|
||||||
|
fPath.Unset();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
rdef_add_include_dir(fPath.Path(), false);
|
rdef_add_include_dir(fPath.Path(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +194,12 @@ compile_file(char *file)
|
|||||||
{
|
{
|
||||||
strcpy(lexfile, file);
|
strcpy(lexfile, file);
|
||||||
|
|
||||||
|
// "-" means reading from stdin
|
||||||
|
if (strcmp(file, "-"))
|
||||||
yyin = fopen(lexfile, "r");
|
yyin = fopen(lexfile, "r");
|
||||||
|
else
|
||||||
|
yyin = stdin;
|
||||||
|
|
||||||
if (yyin == NULL) {
|
if (yyin == NULL) {
|
||||||
strcpy(rdef_err_file, lexfile);
|
strcpy(rdef_err_file, lexfile);
|
||||||
rdef_err = RDEF_FILE_NOT_FOUND;
|
rdef_err = RDEF_FILE_NOT_FOUND;
|
||||||
|
|||||||
+18
-26
@@ -50,8 +50,7 @@ static void addbuf(uint8); // appends byte to lexbuf
|
|||||||
// When we encounter an #include directive, we push the current
|
// When we encounter an #include directive, we push the current
|
||||||
// buffer, filename, and line number on the include stack, so we
|
// buffer, filename, and line number on the include stack, so we
|
||||||
// can resume lexing that file when we're done with the include.
|
// can resume lexing that file when we're done with the include.
|
||||||
struct include_t
|
struct include_t {
|
||||||
{
|
|
||||||
YY_BUFFER_STATE buffer;
|
YY_BUFFER_STATE buffer;
|
||||||
char* filename;
|
char* filename;
|
||||||
int lineno;
|
int lineno;
|
||||||
@@ -188,24 +187,22 @@ $\" BEGIN(RAWDATA); resetbuf();
|
|||||||
%%
|
%%
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
void resetbuf()
|
void
|
||||||
|
resetbuf()
|
||||||
{
|
{
|
||||||
lexptr = lexbuf;
|
lexptr = lexbuf;
|
||||||
lexcnt = 0;
|
lexcnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void addbuf(uint8 b)
|
void
|
||||||
{
|
addbuf(uint8 b)
|
||||||
if (lexcnt == lexsize)
|
|
||||||
{
|
{
|
||||||
|
if (lexcnt == lexsize) {
|
||||||
lexsize += LEX_BUF_SIZE;
|
lexsize += LEX_BUF_SIZE;
|
||||||
lexbuf = (uint8*) realloc(lexbuf, lexsize);
|
lexbuf = (uint8*) realloc(lexbuf, lexsize);
|
||||||
if (lexbuf == NULL)
|
if (lexbuf == NULL)
|
||||||
{
|
|
||||||
abort_compile(B_NO_MEMORY, "out of memory");
|
abort_compile(B_NO_MEMORY, "out of memory");
|
||||||
}
|
|
||||||
|
|
||||||
lexptr = lexbuf + lexcnt;
|
lexptr = lexbuf + lexcnt;
|
||||||
}
|
}
|
||||||
@@ -214,18 +211,16 @@ void addbuf(uint8 b)
|
|||||||
++lexcnt;
|
++lexcnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void open_include()
|
void
|
||||||
|
open_include()
|
||||||
{
|
{
|
||||||
yytext[yyleng - 1] = '\0'; // remove trailing " quote
|
yytext[yyleng - 1] = '\0'; // remove trailing " quote
|
||||||
|
|
||||||
char tmpname[B_PATH_NAME_LENGTH];
|
char tmpname[B_PATH_NAME_LENGTH];
|
||||||
if (open_file_from_include_dir(yytext, tmpname))
|
if (open_file_from_include_dir(yytext, tmpname)) {
|
||||||
{
|
|
||||||
yyin = fopen(tmpname, "r");
|
yyin = fopen(tmpname, "r");
|
||||||
if (yyin != NULL)
|
if (yyin != NULL) {
|
||||||
{
|
|
||||||
include_t incl;
|
include_t incl;
|
||||||
incl.buffer = YY_CURRENT_BUFFER;
|
incl.buffer = YY_CURRENT_BUFFER;
|
||||||
incl.lineno = yylineno;
|
incl.lineno = yylineno;
|
||||||
@@ -244,9 +239,9 @@ void open_include()
|
|||||||
abort_compile(RDEF_COMPILE_ERR, "cannot open include %s", yytext);
|
abort_compile(RDEF_COMPILE_ERR, "cannot open include %s", yytext);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void close_include()
|
void
|
||||||
|
close_include()
|
||||||
{
|
{
|
||||||
fclose(yyin);
|
fclose(yyin);
|
||||||
yy_delete_buffer(YY_CURRENT_BUFFER);
|
yy_delete_buffer(YY_CURRENT_BUFFER);
|
||||||
@@ -261,34 +256,31 @@ void close_include()
|
|||||||
free(incl.filename);
|
free(incl.filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void init_lexer()
|
void
|
||||||
|
init_lexer()
|
||||||
{
|
{
|
||||||
lexsize = LEX_BUF_SIZE;
|
lexsize = LEX_BUF_SIZE;
|
||||||
lexbuf = (uint8*) malloc(lexsize);
|
lexbuf = (uint8*) malloc(lexsize);
|
||||||
if (lexbuf == NULL)
|
if (lexbuf == NULL)
|
||||||
{
|
|
||||||
abort_compile(B_NO_MEMORY, "out of memory");
|
abort_compile(B_NO_MEMORY, "out of memory");
|
||||||
}
|
|
||||||
|
|
||||||
yyrestart(yyin); // necessary for multiple input files
|
yyrestart(yyin); // necessary for multiple input files
|
||||||
yylineno = 1;
|
yylineno = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void clean_up_lexer()
|
void
|
||||||
{
|
clean_up_lexer()
|
||||||
while (!include_stack.empty())
|
|
||||||
{
|
{
|
||||||
|
while (!include_stack.empty()) {
|
||||||
close_include();
|
close_include();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stdin != yyin)
|
||||||
fclose(yyin);
|
fclose(yyin);
|
||||||
yy_delete_buffer(YY_CURRENT_BUFFER);
|
yy_delete_buffer(YY_CURRENT_BUFFER);
|
||||||
|
|
||||||
free(lexbuf);
|
free(lexbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
|
|||||||
@@ -210,6 +210,9 @@ parse_options(int argc, char *argv[])
|
|||||||
} else if (strcmp(argv[i], "-V") == 0
|
} else if (strcmp(argv[i], "-V") == 0
|
||||||
|| strcmp(argv[i], "--version") == 0) {
|
|| strcmp(argv[i], "--version") == 0) {
|
||||||
version();
|
version();
|
||||||
|
} else if (!strcmp(argv[i], "-")) {
|
||||||
|
// stdin input file
|
||||||
|
break;
|
||||||
} else if (argv[i][0] == '-') {
|
} else if (argv[i][0] == '-') {
|
||||||
error("unknown option %s", argv[i]);
|
error("unknown option %s", argv[i]);
|
||||||
argv[i] = NULL;
|
argv[i] = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user