open: style fixes

This commit is contained in:
John Scipione
2014-06-25 19:33:18 -04:00
parent 807a7aa09a
commit ade169709b
+28 -28
View File
@@ -18,7 +18,6 @@
#include <Mime.h> #include <Mime.h>
#include <Roster.h> #include <Roster.h>
#include <String.h> #include <String.h>
#include <Url.h> #include <Url.h>
@@ -26,14 +25,14 @@ const char *kTrackerSignature = "application/x-vnd.Be-TRAK";
status_t status_t
open_file(const char* openWith, BEntry &entry, int32 line = -1, int32 col = -1) open_file(const char* openWith, BEntry& entry, int32 line = -1, int32 col = -1)
{ {
entry_ref ref; entry_ref ref;
status_t status = entry.GetRef(&ref); status_t result = entry.GetRef(&ref);
if (status < B_OK) if (result != B_OK)
return status; return result;
BMessenger target(openWith ? openWith : kTrackerSignature); BMessenger target(openWith != NULL ? openWith : kTrackerSignature);
if (!target.IsValid()) if (!target.IsValid())
return be_roster->Launch(&ref); return be_roster->Launch(&ref);
@@ -41,6 +40,7 @@ open_file(const char* openWith, BEntry &entry, int32 line = -1, int32 col = -1)
message.AddRef("refs", &ref); message.AddRef("refs", &ref);
if (line > -1) if (line > -1)
message.AddInt32("be:line", line); message.AddInt32("be:line", line);
if (col > -1) if (col > -1)
message.AddInt32("be:column", col); message.AddInt32("be:column", col);
@@ -50,12 +50,12 @@ open_file(const char* openWith, BEntry &entry, int32 line = -1, int32 col = -1)
int int
main(int argc, char **argv) main(int argc, char** argv)
{ {
int exitcode = EXIT_SUCCESS; int exitCode = EXIT_SUCCESS;
const char *openWith = NULL; const char* openWith = NULL;
char *progName = argv[0]; char* progName = argv[0];
if (strrchr(progName, '/')) if (strrchr(progName, '/'))
progName = strrchr(progName, '/') + 1; progName = strrchr(progName, '/') + 1;
@@ -65,12 +65,12 @@ main(int argc, char **argv)
} }
while (*++argv) { while (*++argv) {
status_t status = B_OK; status_t result = B_OK;
argc--; argc--;
BEntry entry(*argv); BEntry entry(*argv);
if ((status = entry.InitCheck()) == B_OK && entry.Exists()) { if ((result = entry.InitCheck()) == B_OK && entry.Exists()) {
status = open_file(openWith, entry); result = open_file(openWith, entry);
} else if (!strncasecmp("application/", *argv, 12)) { } else if (!strncasecmp("application/", *argv, 12)) {
// maybe it's an application-mimetype? // maybe it's an application-mimetype?
@@ -84,9 +84,9 @@ main(int argc, char **argv)
be_roster->GetAppList(*argv, &teams); be_roster->GetAppList(*argv, &teams);
if (teams.IsEmpty()) if (teams.IsEmpty())
status = be_roster->Launch(*argv); result = be_roster->Launch(*argv);
else else
status = B_OK; result = B_OK;
} else if (strchr(*argv, ':')) { } else if (strchr(*argv, ':')) {
// try to open it as an URI // try to open it as an URI
BPrivate::Support::BUrl url(*argv); BPrivate::Support::BUrl url(*argv);
@@ -95,7 +95,7 @@ main(int argc, char **argv)
// maybe it's "file:line" or "file:line:col" // maybe it's "file:line" or "file:line:col"
int line = 0, col = 0, i; int line = 0, col = 0, i;
status = B_ENTRY_NOT_FOUND; result = B_ENTRY_NOT_FOUND;
// remove gcc error's last : // remove gcc error's last :
BString arg(*argv); BString arg(*argv);
if (arg[arg.Length() - 1] == ':') if (arg[arg.Length() - 1] == ':')
@@ -106,10 +106,10 @@ main(int argc, char **argv)
line = atoi(arg.String() + i + 1); line = atoi(arg.String() + i + 1);
arg.Truncate(i); arg.Truncate(i);
status = entry.SetTo(arg.String()); result = entry.SetTo(arg.String());
if (status == B_OK && entry.Exists()) { if (result == B_OK && entry.Exists()) {
status = open_file(openWith, entry, line); result = open_file(openWith, entry, line);
if (status == B_OK) if (result == B_OK)
continue; continue;
} }
@@ -119,20 +119,20 @@ main(int argc, char **argv)
line = atoi(arg.String() + i + 1); line = atoi(arg.String() + i + 1);
arg.Truncate(i); arg.Truncate(i);
status = entry.SetTo(arg.String()); result = entry.SetTo(arg.String());
if (status == B_OK && entry.Exists()) if (result == B_OK && entry.Exists())
status = open_file(openWith, entry, line, col); result = open_file(openWith, entry, line, col);
} }
} else } else
status = B_ENTRY_NOT_FOUND; result = B_ENTRY_NOT_FOUND;
if (status != B_OK && status != B_ALREADY_RUNNING) { if (result != B_OK && result != B_ALREADY_RUNNING) {
fprintf(stderr, "%s: \"%s\": %s\n", progName, *argv, fprintf(stderr, "%s: \"%s\": %s\n", progName, *argv,
strerror(status)); strerror(result));
// make sure the shell knows this // make sure the shell knows this
exitcode = EXIT_FAILURE; exitCode = EXIT_FAILURE;
} }
} }
return exitcode; return exitCode;
} }