Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[496 Battery module incorrectly trims whitespace] #515

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ On debian-based systems, the following line will install all requirements:
apt-get install autoconf libconfuse-dev libyajl-dev libasound2-dev libiw-dev asciidoc libpulse-dev libnl-genl-3-dev meson
```

On arch-based systems, the following line will install all requirements:
```bash
pacman -S base-devel alsa-lib confuse libnl libpulse yajl meson asciidoc
```

## Upstream

i3status is developed at https://github.com/i3/i3status
Expand Down
33 changes: 0 additions & 33 deletions src/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,36 +122,3 @@ void maybe_escape_markup(char *text, char **buffer) {
}
}
}

/*
* remove leading spaces
*/
char *ltrim(const char *s) {
while (isspace(*s))
++s;
return sstrdup(s);
}

/*
* remove trailing spaces
*/
char *rtrim(const char *s) {
char *r = sstrdup(s);
if (r != NULL) {
char *fr = r + strlen(s) - 1;
while ((isspace(*fr) || *fr == 0) && fr >= r)
--fr;
*++fr = 0;
}
return r;
}

/*
* remove leading & trailing spaces
*/
char *trim(const char *s) {
char *r = rtrim(s);
char *f = ltrim(r);
free(r);
return f;
}
12 changes: 5 additions & 7 deletions src/print_battery_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ static bool slurp_battery_info(battery_info_ctx_t *ctx, struct battery_info *bat
batt_info->status = CS_DISCHARGING;
#elif defined(__OpenBSD__)
/*
* We're using apm(4) here, which is the interface to acpi(4) on amd64/i386 and
* the generic interface on macppc/sparc64/zaurus. Machines that have ACPI
* battery sensors gain some extra information.
*/
* We're using apm(4) here, which is the interface to acpi(4) on amd64/i386 and
* the generic interface on macppc/sparc64/zaurus. Machines that have ACPI
* battery sensors gain some extra information.
*/
struct apm_power_info apm_info;
struct sensordev sensordev;
struct sensor sensor;
Expand Down Expand Up @@ -726,11 +726,9 @@ void print_battery_info(battery_info_ctx_t *ctx) {
{.name = "%consumption", .value = string_consumption}};

const size_t num = sizeof(placeholders) / sizeof(placeholder_t);
char *untrimmed = format_placeholders(ctx->format, &placeholders[0], num);
char *formatted = trim(untrimmed);
char *formatted = format_placeholders(ctx->format, &placeholders[0], num);
OUTPUT_FORMATTED;
free(formatted);
free(untrimmed);

if (colorful_output) {
END_COLOR;
Expand Down
8 changes: 4 additions & 4 deletions src/print_eth_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ static int print_eth_speed(char *outwalk, const char *interface) {

for (desc = ifm_subtype_descriptions; desc->ifmt_string != NULL; desc++) {
/*
* Skip these non-informative values and go right ahead to the
* actual speeds.
*/
* Skip these non-informative values and go right ahead to the
* actual speeds.
*/
if (BEGINS_WITH(desc->ifmt_string, "autoselect") ||
BEGINS_WITH(desc->ifmt_string, "auto"))
continue;
Expand Down Expand Up @@ -157,7 +157,7 @@ void print_eth_info(eth_info_ctx_t *ctx) {
/*
* Removing '%' and following characters from IPv6 since the interface identifier is redundant,
* as the output already includes the interface name.
*/
*/
if (ipv6_address != NULL) {
char *prct_ptr = strstr(ipv6_address, "%");
if (prct_ptr != NULL) {
Expand Down
8 changes: 4 additions & 4 deletions src/print_wireless_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,9 @@ static int get_wireless_info(const char *interface, wireless_info_t *info) {
close(s);
if (na.i_len >= sizeof(u.req)) {
/*
* Just use the first BSSID returned even if there are
* multiple APs sharing the same BSSID.
*/
* Just use the first BSSID returned even if there are
* multiple APs sharing the same BSSID.
*/
info->signal_level = u.req.info[0].isi_rssi / 2 +
u.req.info[0].isi_noise;
info->flags |= WIRELESS_INFO_FLAG_HAS_SIGNAL;
Expand Down Expand Up @@ -523,7 +523,7 @@ void print_wireless_info(wireless_info_ctx_t *ctx) {
/*
* Removing '%' and following characters from IPv6 since the interface identifier is redundant,
* as the output already includes the interface name.
*/
*/
if (ipv6_address != NULL) {
char *prct_ptr = strstr(ipv6_address, "%");
if (prct_ptr != NULL) {
Expand Down
2 changes: 1 addition & 1 deletion testcases/014-battery-capacity/expected_output.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Touchpad: 100.00% BAT
Touchpad: 100.00% BAT