Clipboard: style fixes.

This commit is contained in:
Adrien Destugues
2015-01-05 15:49:52 +01:00
parent 569a7bfc3c
commit a17012ab11
+20 -11
View File
@@ -77,7 +77,8 @@ ClipboardApp::ArgvReceived(int32 argc, char **argv)
}; };
int c; int c;
while ((c = getopt_long(argc, argv, "l:s:o:c:ripdh", kLongOptions, NULL)) != -1) { while ((c = getopt_long(argc, argv, "l:s:o:c:ripdh", kLongOptions, NULL))
!= -1) {
switch (c) { switch (c) {
case 'l': case 'l':
status = Load(optarg); status = Load(optarg);
@@ -118,6 +119,7 @@ ClipboardApp::ArgvReceived(int32 argc, char **argv)
sExitValue = EXIT_FAILURE; sExitValue = EXIT_FAILURE;
} }
void void
ClipboardApp::ReadyToRun(void) ClipboardApp::ReadyToRun(void)
{ {
@@ -156,7 +158,8 @@ ClipboardApp::Load(const char *path)
status = file.SetTo(path, B_READ_ONLY); status = file.SetTo(path, B_READ_ONLY);
if (status != B_OK) { if (status != B_OK) {
fprintf(stderr, "%s: Could not open file: %s\n", kProgramName, strerror(status)); fprintf(stderr, "%s: Could not open file: %s\n", kProgramName,
strerror(status));
return status; return status;
} }
@@ -164,7 +167,8 @@ ClipboardApp::Load(const char *path)
BMessage clipFromFile; BMessage clipFromFile;
status = clipFromFile.Unflatten(&file); status = clipFromFile.Unflatten(&file);
if (status != B_OK) { if (status != B_OK) {
fprintf(stderr, "%s: Could not read clip: %s\n", kProgramName, strerror(status)); fprintf(stderr, "%s: Could not read clip: %s\n", kProgramName,
strerror(status));
return status; return status;
} }
@@ -181,7 +185,8 @@ ClipboardApp::Load(const char *path)
status = be_clipboard->Commit(); status = be_clipboard->Commit();
if (status != B_OK) { if (status != B_OK) {
fprintf(stderr, "%s: could not commit data to clipboard.\n", kProgramName); fprintf(stderr, "%s: could not commit data to clipboard.\n",
kProgramName);
be_clipboard->Unlock(); be_clipboard->Unlock();
return status; return status;
} }
@@ -199,7 +204,8 @@ ClipboardApp::Save(const char *path)
status = file.SetTo(path, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE); status = file.SetTo(path, B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
if (status != B_OK) { if (status != B_OK) {
fprintf(stderr, "%s: Could not create file: %s\n", kProgramName, strerror(status)); fprintf(stderr, "%s: Could not create file: %s\n", kProgramName,
strerror(status));
return status; return status;
} }
@@ -216,7 +222,8 @@ ClipboardApp::Save(const char *path)
// flatten clip to file // flatten clip to file
status = clip->Flatten(&file); status = clip->Flatten(&file);
if (status != B_OK) { if (status != B_OK) {
fprintf(stderr, "%s: Could not write data: %s\n", kProgramName, strerror(status)); fprintf(stderr, "%s: Could not write data: %s\n", kProgramName,
strerror(status));
return status; return status;
} }
@@ -234,7 +241,7 @@ ClipboardApp::Copy(const char *string)
// read from standard input // read from standard input
int c; int c;
while ((c = fgetc(stdin)) != EOF) { while ((c = fgetc(stdin)) != EOF) {
inputString += (char) c; inputString += (char)c;
} }
string = inputString.String(); string = inputString.String();
@@ -252,7 +259,8 @@ ClipboardApp::Copy(const char *string)
status = be_clipboard->Commit(); status = be_clipboard->Commit();
if (status != B_OK) { if (status != B_OK) {
fprintf(stderr, "%s: could not commit data to clipboard.\n", kProgramName); fprintf(stderr, "%s: could not commit data to clipboard.\n",
kProgramName);
be_clipboard->Unlock(); be_clipboard->Unlock();
return status; return status;
} }
@@ -304,12 +312,13 @@ ClipboardApp::Print(bool debug)
BMessage *clip = be_clipboard->Data(); BMessage *clip = be_clipboard->Data();
if (debug) { if (debug)
clip->PrintToStream(); clip->PrintToStream();
} else { else {
const char * textBuffer; const char * textBuffer;
ssize_t textLength; ssize_t textLength;
clip->FindData("text/plain", B_MIME_TYPE, (const void **)&textBuffer, &textLength); clip->FindData("text/plain", B_MIME_TYPE, (const void **)&textBuffer,
&textLength);
if (textBuffer != NULL && textLength > 0) { if (textBuffer != NULL && textLength > 0) {
BString textString(textBuffer, textLength); BString textString(textBuffer, textLength);