summaryrefslogtreecommitdiffstats
path: root/src/CLI
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-10-21 15:49:01 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-10-21 15:49:01 +0200
commitf824969d3a8e77a41dac30997b47a0268cc01cbd (patch)
treec697007457916aa99f20954a4cbb0add5d6d1b82 /src/CLI
parent6c8c8f960302d9e94a820c82eeb41b3f19af2ec1 (diff)
downloadabrt-f824969d3a8e77a41dac30997b47a0268cc01cbd.tar.gz
abrt-f824969d3a8e77a41dac30997b47a0268cc01cbd.tar.xz
abrt-f824969d3a8e77a41dac30997b47a0268cc01cbd.zip
fix warning and whitespace damage
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'src/CLI')
-rw-r--r--src/CLI/CLI.cpp3
-rw-r--r--src/CLI/abrt-cli.110
-rw-r--r--src/CLI/abrt-cli.bash2
-rw-r--r--src/CLI/dbus.cpp2
-rw-r--r--src/CLI/report.cpp78
-rw-r--r--src/CLI/run-command.cpp22
6 files changed, 58 insertions, 59 deletions
diff --git a/src/CLI/CLI.cpp b/src/CLI/CLI.cpp
index a782a59a..18e99dcf 100644
--- a/src/CLI/CLI.cpp
+++ b/src/CLI/CLI.cpp
@@ -65,7 +65,7 @@ static void print_crash_infos(vector_crash_infos_t& pCrashInfos, int pMode)
int success = strftime(timeloc, 128, "%c", localtime(&time));
if (!success)
error_msg_and_die("Error while converting time to string.");
-
+
printf(_("%u.\n"
"\tUID : %s\n"
"\tUUID : %s\n"
@@ -132,7 +132,6 @@ int main(int argc, char** argv)
{
char* uuid = NULL;
int op = -1;
- char *name;
setlocale(LC_ALL,"");
#if ENABLE_NLS
diff --git a/src/CLI/abrt-cli.1 b/src/CLI/abrt-cli.1
index 9ccc6159..4fe4bb42 100644
--- a/src/CLI/abrt-cli.1
+++ b/src/CLI/abrt-cli.1
@@ -24,16 +24,16 @@ Prints list of crashes which are not reported yet.
.IP "\-\-get-list-full"
Prints list of all crashes.
.IP "\-\-report \fIUUID\fR"
-Creates a crash report and then the text editor is invoked on that
-report. When you are done with editing the report just exit the editor
-and then you will be asked if you want to send the report.
+Creates a crash report and then the text editor is invoked on that
+report. When you are done with editing the report just exit the editor
+and then you will be asked if you want to send the report.
.IP "\-\-report-always \fIUUID\fR"
Creates and sends the crash report without asking.
.IP "\-\-delete \fIUUID\fR"
Removes data about particular crash.
.SH ENVIRONMENT VARIABLES
-The editor used to edit the crash report is chosen from the ABRT_EDITOR
-environment variable, the VISUAL environment variable, or the EDITOR
+The editor used to edit the crash report is chosen from the ABRT_EDITOR
+environment variable, the VISUAL environment variable, or the EDITOR
environment variable, in that order.
.SH "SEE ALSO"
.IR abrtd (8),
diff --git a/src/CLI/abrt-cli.bash b/src/CLI/abrt-cli.bash
index 089d5a3f..10b086ae 100644
--- a/src/CLI/abrt-cli.bash
+++ b/src/CLI/abrt-cli.bash
@@ -1,7 +1,7 @@
# bash-completion add-on for abrt-cli(1)
# http://bash-completion.alioth.debian.org/
-_abrt_cli()
+_abrt_cli()
{
local cur prev opts
COMPREPLY=()
diff --git a/src/CLI/dbus.cpp b/src/CLI/dbus.cpp
index 64dac094..420fe703 100644
--- a/src/CLI/dbus.cpp
+++ b/src/CLI/dbus.cpp
@@ -38,7 +38,7 @@ static DBusMessage* send_get_reply_and_unref(DBusMessage* msg)
DBusError err;
dbus_error_init(&err);
DBusMessage *reply;
- reply = dbus_connection_send_with_reply_and_block(s_dbus_conn,
+ reply = dbus_connection_send_with_reply_and_block(s_dbus_conn,
msg, /*timeout*/ -1, &err);
if (reply == NULL)
{
diff --git a/src/CLI/report.cpp b/src/CLI/report.cpp
index 8dedf036..b9a13914 100644
--- a/src/CLI/report.cpp
+++ b/src/CLI/report.cpp
@@ -33,15 +33,15 @@
/* Field separator for the crash report file that is edited by user. */
#define FIELD_SEP "%----"
-/*
- * Trims whitespace characters both from left and right side of a string.
+/*
+ * Trims whitespace characters both from left and right side of a string.
* Modifies the string in-place. Returns the trimmed string.
*/
char *trim(char *str)
{
if (!str)
return NULL;
-
+
// Remove leading spaces.
char *ibuf;
for (ibuf = str; *ibuf && isspace(*ibuf); ++ibuf)
@@ -60,9 +60,9 @@ char *trim(char *str)
return str;
}
-/*
- * Escapes the field content string to avoid confusion with file comments.
- * Returned field must be free()d by caller.
+/*
+ * Escapes the field content string to avoid confusion with file comments.
+ * Returned field must be free()d by caller.
*/
static char *escape(const char *str)
{
@@ -87,12 +87,12 @@ static char *escape(const char *str)
++ptr;
}
- // Copy the input string to the resultant string, and escape all
+ // Copy the input string to the resultant string, and escape all
// occurences of \# and #.
char *result = (char*)malloc(strlen(str) + 1 + count);
if (!result)
error_msg_and_die("Memory error while escaping a field.");
-
+
const char *src = str;
char *dest = result;
newline = true;
@@ -109,15 +109,15 @@ static char *escape(const char *str)
newline = (*src == '\n');
*dest++ = *src++;
}
- *dest = '\0';
+ *dest = '\0';
return result;
}
/*
- * Removes all comment lines, and unescapes the string previously escaped
- * by escape(). Works in-place.
+ * Removes all comment lines, and unescapes the string previously escaped
+ * by escape(). Works in-place.
*/
-static char *remove_comments_and_unescape(char *str)
+static void remove_comments_and_unescape(char *str)
{
char *src = str, *dest = str;
bool newline = true;
@@ -125,7 +125,7 @@ static char *remove_comments_and_unescape(char *str)
{
if (newline)
{
- if (*src == '#')
+ if (*src == '#')
{ // Skip the comment line!
while (*src && *src != '\n')
++src;
@@ -136,25 +136,25 @@ static char *remove_comments_and_unescape(char *str)
++src;
continue;
}
- else if (*src == '\\' &&
- (*(src + 1) == '#' ||
+ else if (*src == '\\' &&
+ (*(src + 1) == '#' ||
(*(src + 1) == '\\' && *(src + 2) == '#')))
{
++src; // Unescape escaped char.
}
}
-
+
newline = (*src == '\n');
*dest++ = *src++;
}
*dest = '\0';
}
-/*
+/*
* Writes a field of crash report to a file.
* Field must be writable.
*/
-static void write_crash_report_field(FILE *fp, const map_crash_report_t &report,
+static void write_crash_report_field(FILE *fp, const map_crash_report_t &report,
const char *field, const char *description)
{
const map_crash_report_t::const_iterator it = report.find(field);
@@ -168,9 +168,9 @@ static void write_crash_report_field(FILE *fp, const map_crash_report_t &report,
if (it->second[CD_TYPE] == CD_SYS)
{
error_msg("Cannot write field %s because it is a system value\n", field);
- return;
+ return;
}
-
+
fprintf(fp, "%s%s\n", FIELD_SEP, it->first.c_str());
fprintf(fp, "%s\n", description);
@@ -182,8 +182,8 @@ static void write_crash_report_field(FILE *fp, const map_crash_report_t &report,
free(escaped_content);
}
-/*
- * Saves the crash report to a file.
+/*
+ * Saves the crash report to a file.
* Parameter 'fp' must be opened before write_crash_report is called.
* Returned value:
* If the report is successfully stored to the file, a zero value is returned.
@@ -194,7 +194,7 @@ static int write_crash_report(const map_crash_report_t &report, FILE *fp)
fprintf(fp, "# Please check this report. Lines starting with '#' will be ignored.\n"
"# Lines starting with '%%----' separate fields, please do not delete them.\n\n");
- write_crash_report_field(fp, report, CD_COMMENT,
+ write_crash_report_field(fp, report, CD_COMMENT,
_("# Describe the circumstances of this crash below."));
write_crash_report_field(fp, report, CD_REPRODUCE,
_("# How to reproduce the crash?"));
@@ -210,19 +210,19 @@ static int write_crash_report(const map_crash_report_t &report, FILE *fp)
write_crash_report_field(fp, report, FILENAME_PACKAGE, _("# Package"));
write_crash_report_field(fp, report, FILENAME_REASON, _("# Reason of crash"));
write_crash_report_field(fp, report, FILENAME_RELEASE, _("# Release string of the operating system"));
-
+
return 0;
}
-/*
+/*
* Updates appropriate field in the report from the text. The text can
- * contain multiple fields.
+ * contain multiple fields.
* Returns:
* 0 if no change to the field was detected.
* 1 if the field was changed.
* Changes to read-only fields are ignored.
*/
-static int read_crash_report_field(const char *text, map_crash_report_t &report,
+static int read_crash_report_field(const char *text, map_crash_report_t &report,
const char *field)
{
char separator[strlen("\n" FIELD_SEP) + strlen(field) + 2]; // 2 = '\n\0'
@@ -236,9 +236,9 @@ static int read_crash_report_field(const char *text, map_crash_report_t &report,
const char *end = strstr(textfield, "\n" FIELD_SEP);
if (!end)
length = strlen(textfield);
- else
+ else
length = end - textfield;
-
+
const map_crash_report_t::iterator it = report.find(field);
if (it == report.end())
{
@@ -249,7 +249,7 @@ static int read_crash_report_field(const char *text, map_crash_report_t &report,
if (it->second[CD_TYPE] == CD_SYS)
{
error_msg("Cannot update field %s because it is a system value.\n", field);
- return 0;
+ return 0;
}
// Do not change noneditable fields.
@@ -275,12 +275,12 @@ static int read_crash_report_field(const char *text, map_crash_report_t &report,
return 1;
}
-/*
- * Updates the crash report 'report' from the text. The text must not contain
- * any comments.
+/*
+ * Updates the crash report 'report' from the text. The text must not contain
+ * any comments.
* Returns:
* 0 if no field was changed.
- * 1 if any field was changed.
+ * 1 if any field was changed.
* Changes to read-only fields are ignored.
*/
static int read_crash_report(map_crash_report_t &report, const char *text)
@@ -306,20 +306,20 @@ static int read_crash_report(map_crash_report_t &report, const char *text)
int launch_editor(const char *path)
{
const char *editor, *terminal;
-
+
editor = getenv("ABRT_EDITOR");
if (!editor)
editor = getenv("VISUAL");
if (!editor)
editor = getenv("EDITOR");
-
+
terminal = getenv("TERM");
if (!editor && (!terminal || !strcmp(terminal, "dumb")))
{
error_msg(_("Terminal is dumb but no VISUAL nor EDITOR defined."));
return 1;
}
-
+
if (!editor)
editor = "vi";
@@ -367,7 +367,7 @@ int report(const char *uuid, bool always)
error_msg("could not close '%s'", filename);
return 2;
}
-
+
// Start a text editor on the temporary file.
launch_editor(filename);
@@ -394,7 +394,7 @@ int report(const char *uuid, bool always)
remove_comments_and_unescape(text);
// Updates the crash report from the file text.
- int report_changed = read_crash_report(cr, text);
+ int report_changed = read_crash_report(cr, text);
if (report_changed)
puts(_("\nThe report has been updated."));
else
diff --git a/src/CLI/run-command.cpp b/src/CLI/run-command.cpp
index df29b0e1..80184cfa 100644
--- a/src/CLI/run-command.cpp
+++ b/src/CLI/run-command.cpp
@@ -23,7 +23,7 @@
http://git.kernel.org/?p=git/git.git;a=blob;f=run-command.c;hb=HEAD
*/
-struct child_process
+struct child_process
{
const char **argv;
pid_t pid;
@@ -51,28 +51,28 @@ static int finish_command(struct child_process *cmd)
int status, code = -1;
while ((waiting = waitpid(cmd->pid, &status, 0)) < 0 && errno == EINTR)
; /* nothing */
-
- if (waiting < 0)
+
+ if (waiting < 0)
error_msg_and_die("waitpid for %s failed: %s", cmd->argv[0], strerror(errno));
- else if (waiting != cmd->pid)
+ else if (waiting != cmd->pid)
error_msg_and_die("waitpid is confused (%s)", cmd->argv[0]);
- else if (WIFSIGNALED(status))
+ else if (WIFSIGNALED(status))
{
code = WTERMSIG(status);
error_msg("%s died of signal %d", cmd->argv[0], code);
- }
- else if (WIFEXITED(status))
+ }
+ else if (WIFEXITED(status))
{
code = WEXITSTATUS(status);
- if (code == 127)
+ if (code == 127)
{
code = -1;
error_msg_and_die("cannot run %s: %s", cmd->argv[0], strerror(ENOENT));
}
- }
- else
+ }
+ else
error_msg_and_die("waitpid is confused (%s)", cmd->argv[0]);
-
+
return code;
}