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

if_match compare fails if locale uses "," as decimal mark #20

Closed
twwn opened this issue Jul 15, 2013 · 19 comments
Closed

if_match compare fails if locale uses "," as decimal mark #20

twwn opened this issue Jul 15, 2013 · 19 comments
Labels
bug Bug report or bug fix PR

Comments

@twwn
Copy link

twwn commented Jul 15, 2013

From my log:

conky: Bad arguments: '0,0 ' and ' 10.0'
conky: compare failed for expression '0,0 < 10.0'

These compares are all similar to this one:

${if_match ${downspeedf enp2s0} < 100.0}

The compare still fails if the argument is written with ",". Explicitly setting conky's locale to en_US.UTF-8 works for now.

(This didn't happen in 1.9.0.)

@ghost
Copy link

ghost commented Jul 26, 2015

I have the same problem.

@thhart
Copy link

thhart commented Sep 5, 2017

Same here, can you tell please how to set a specific LOCALE for conky?

@twwn
Copy link
Author

twwn commented Sep 6, 2017

You preface the command with eg.

LC_ALL=C conky

@thhart
Copy link

thhart commented Sep 7, 2017

Thanks, however it turns out comparing is failing in general with fraction numbers:

conky: compare failed for expression ' 12,61 >= 10 '

${if_match ${top cpu 1} >= 10 }${color red}\
${else}${color}\
${endif}\

@thhart
Copy link

thhart commented Sep 7, 2017

Sorry my fault, the locale was not set it worked now. I use following startup script now:

#!/bin/bash

export LANG=en_US.UTF-8
export LC_ALL=C

sleep 5 && conky

Side note: It looks like it is in algebra.cc: enum arg_type get_arg_type. I recommend to use a locale aware number parser.

@mswanson-me
Copy link
Collaborator

Is this issue still outstanding in the current version of Conky? If so, please update the issue. Otherwise, the issue will be closed in 2 weeks.

@su8
Copy link
Collaborator

su8 commented Aug 3, 2018

@lasers Can you have a look ?

@lasers
Copy link
Contributor

lasers commented Aug 3, 2018

@su8 I tried. Not familiar with locale. Tried Italy. Didn't get commas to display. Maybe I did it wrong.

@lasers
Copy link
Contributor

lasers commented Aug 5, 2018

@su8 I tried git bisect here to 1.9.0. Earlier tags does not contain cmake stuffs. :-(

US.

0B // False
56.9K // True
16.9K // False
544B // False
74.9K // True
88.4K // True
13.9K // False

DK.

conky: Bad arguments: '0,0' and '50.0'
conky: compare failed for expression '0,0>50.0'
0B // True
conky: Bad arguments: '0,0' and '50.0'
conky: compare failed for expression '0,3>50.0'
307B // True
^Cconky: Bad arguments: '0,3' and '50.0'
conky: compare failed for expression '0,3>50.0'
350B // True

@lasers lasers added the bug Bug report or bug fix PR label Aug 5, 2018
brndnmtthws pushed a commit that referenced this issue Aug 7, 2018
Using the Intel® Power Gadget API (https://software.intel.com/en-us/blogs/2012/12/13/using-the-intel-power-gadget-api-on-mac-os-x) we can now get actual Core frequency and not the constant factory one.

Though, for some weird reason the API gives the same freq for all Cores, thus the |cpu| arg becomes useless.
brndnmtthws pushed a commit that referenced this issue Aug 7, 2018
Using the Intel® Power Gadget API (https://software.intel.com/en-us/blogs/2012/12/13/using-the-intel-power-gadget-api-on-mac-os-x) we can now get actual Core frequency and not the constant factory one.

Though, for some weird reason the API gives the same freq for all Cores, thus the |cpu| arg becomes useless.
brndnmtthws pushed a commit that referenced this issue Aug 7, 2018
Using the Intel® Power Gadget API (https://software.intel.com/en-us/blogs/2012/12/13/using-the-intel-power-gadget-api-on-mac-os-x) we can now get actual Core frequency and not the constant factory one.

Though, for some weird reason the API gives the same freq for all Cores, thus the |cpu| arg becomes useless.
brndnmtthws added a commit that referenced this issue Aug 7, 2018
* Try to amend #31

* BUILD_WLAN should be available for all OS.

Keep BUILD_WLAN OFF by default for compatibility reasons.

* WLAN-related variables should be available for every OS.

There are some problems (probably null-dereference)

* Fix $wireless_essid crashing conky if no argument provided.

Conky wasn't parsing the argument of the variable as it should, thus wasn't allocating the `dev` member variable.

Also fix some documentation stuff.

* Improve `get_freq` #20

Using the Intel® Power Gadget API (https://software.intel.com/en-us/blogs/2012/12/13/using-the-intel-power-gadget-api-on-mac-os-x) we can now get actual Core frequency and not the constant factory one.

Though, for some weird reason the API gives the same freq for all Cores, thus the |cpu| arg becomes useless.

* Oops, this accidently slipped in

* Introduce BUILD_IPGFREQ build option

This build option has been introduced for one particular reason:

On macOS getting current core-frequency is not supported by the APIs.  A solution is to install Intel's ® Power Gadget which comes with an .app, a Framework and a kernel-extension.  Though, this may trouble some alot, thus introduce BUILD_IPGFREQ.

* Forgot static here.

* Some improvements for get_freq again.

Fix frequency not printing correctly (I wasn't using the divisor)
Add more guards.

* Setup cmake files and project code for Objective-C code #17

We want to use CoreWLAN framework.

* update_cpu_usage() now supports multiple cores

Also, some cleanup.

* Updated default conky config to monitor Mac Networking

* Made Mac Friendly BuildOptions and generic default conky configs

* Undid Xdamage config and cleaned up previous IF statements

* Re-Added XDamage fix

* Finish up the algorithm. I think its now correct. Closes: #33

* Cleanup macro and introduce a no-op free_cpu() function for ALL cpu-related variables

free_cpu() must be implemented for every OS and on all except macOS its a no-op function.

* Reformat, add empty comment.
@lasers
Copy link
Contributor

lasers commented Aug 7, 2018

@su8 Just in case you missed the latest comment, I can test this now.

@su8
Copy link
Collaborator

su8 commented Aug 7, 2018

This line is skipped when using locales that use ','

if (*p == '.') {

and returns

return ARG_BAD;

which causes the "bad argument" to be printed

if (type1 == ARG_BAD || type2 == ARG_BAD) {

NORM_ERR("Bad arguments: '%s' and '%s'", expr_dup, (expr_dup + idx + 1));

@su8
Copy link
Collaborator

su8 commented Aug 7, 2018

Can you test this:

diff --git a/src/algebra.cc b/src/algebra.cc
index 66dfd2d6..4e1d36e2 100644
--- a/src/algebra.cc
+++ b/src/algebra.cc
@@ -155,7 +155,7 @@ enum arg_type get_arg_type(const char *arg) {
   if (p == e + 1) {
     return ARG_LONG;
   }
-  if (*p == '.') {
+  if (*p == '.' || *p == ',') {
     p++;
     while (p <= e) {
       if (isdigit((unsigned char)*p) == 0) {

@lasers
Copy link
Contributor

lasers commented Aug 7, 2018

It works. The numbers get printed with comma too. Lazy copied the example above.

56,9K // True
16,9K // False
544B // False
74,9K // True
88,4K // True
13,9K // False

@lasers
Copy link
Contributor

lasers commented Aug 7, 2018

This happens in the master too. Hmm. Actually, I think this is okay as-is. Duh.

@su8
Copy link
Collaborator

su8 commented Aug 7, 2018

Open up a pull request with this change as I'm lazy to do it 🍔

@lasers
Copy link
Contributor

lasers commented Aug 7, 2018

You're not lazy. I'm lasers lazier. I'm wondering about something. If this contains a comma, should you not swap characters around first?

  • If comma detected...
    • Replace period with uniq char
    • Replace comma with a period
    • Replace uniq char with comma
  • Compare

Does that make sense or am I thinking too much?

@su8
Copy link
Collaborator

su8 commented Aug 7, 2018

That's the current country standard, why changing it to other ?

@lasers
Copy link
Contributor

lasers commented Aug 7, 2018

Idk. Noob here. I'll make a pull request at your request. What is if (*p == '.') { for?

brndnmtthws added a commit that referenced this issue Aug 7, 2018
brndnmtthws pushed a commit that referenced this issue Aug 7, 2018
@lasers
Copy link
Contributor

lasers commented Aug 7, 2018

Closed via #585 👋

@lasers lasers closed this as completed Aug 7, 2018
lasers pushed a commit that referenced this issue Aug 12, 2018
* Try to amend #31

* BUILD_WLAN should be available for all OS.

Keep BUILD_WLAN OFF by default for compatibility reasons.

* WLAN-related variables should be available for every OS.

There are some problems (probably null-dereference)

* Fix $wireless_essid crashing conky if no argument provided.

Conky wasn't parsing the argument of the variable as it should, thus wasn't allocating the `dev` member variable.

Also fix some documentation stuff.

* Improve `get_freq` #20

Using the Intel® Power Gadget API (https://software.intel.com/en-us/blogs/2012/12/13/using-the-intel-power-gadget-api-on-mac-os-x) we can now get actual Core frequency and not the constant factory one.

Though, for some weird reason the API gives the same freq for all Cores, thus the |cpu| arg becomes useless.

* Oops, this accidently slipped in

* Introduce BUILD_IPGFREQ build option

This build option has been introduced for one particular reason:

On macOS getting current core-frequency is not supported by the APIs.  A solution is to install Intel's ® Power Gadget which comes with an .app, a Framework and a kernel-extension.  Though, this may trouble some alot, thus introduce BUILD_IPGFREQ.

* Forgot static here.

* Some improvements for get_freq again.

Fix frequency not printing correctly (I wasn't using the divisor)
Add more guards.

* Setup cmake files and project code for Objective-C code #17

We want to use CoreWLAN framework.

* update_cpu_usage() now supports multiple cores

Also, some cleanup.

* Updated default conky config to monitor Mac Networking

* Made Mac Friendly BuildOptions and generic default conky configs

* Undid Xdamage config and cleaned up previous IF statements

* Re-Added XDamage fix

* Finish up the algorithm. I think its now correct. Closes: #33

* Cleanup macro and introduce a no-op free_cpu() function for ALL cpu-related variables

free_cpu() must be implemented for every OS and on all except macOS its a no-op function.

* Reformat, add empty comment.
lasers pushed a commit that referenced this issue Aug 12, 2018
iiey added a commit to iiey/dotfiles that referenced this issue Jul 2, 2019
Need to do it manually.
New version not completely backward compatible with old format. E.g.:
double_buffer = yes --> crash!

Using /usr/share/doc/conky-all/convert.lua
New format from release 1.10.x

Known issues in conky 1.10.x (2016):
+ if_match fail with locale:
brndnmtthws/conky#20

+ exec not work at first iteration:
brndnmtthws/conky#112
iiey added a commit to iiey/dotfiles that referenced this issue Jul 2, 2019
Need to do it manually.
New version not completely backward compatible with old format. E.g.:
double_buffer = yes --> crash!

Using /usr/share/doc/conky-all/convert.lua
New format from release 1.10.x

Known issues in conky 1.10.x (2016):
+ if_match fail with locale:
brndnmtthws/conky#20

+ exec not work at first iteration:
brndnmtthws/conky#112
iiey added a commit to iiey/dotfiles that referenced this issue Jul 3, 2019
Need to do it manually.
New version not completely backward compatible with old format. E.g.:
double_buffer = yes --> crash!

Using /usr/share/doc/conky-all/convert.lua
New format from release 1.10.x

Known issues in conky 1.10.x (2016):
+ if_match fail with locale:
brndnmtthws/conky#20

+ exec not work at first iteration:
brndnmtthws/conky#112
iiey added a commit to iiey/dotfiles that referenced this issue Jul 11, 2019
Need to do it manually.
New version not completely backward compatible with old format. E.g.:
double_buffer = yes --> crash!

Using /usr/share/doc/conky-all/convert.lua
New format from release 1.10.x

Known issues in conky 1.10.x (2016):
+ if_match fail with locale:
brndnmtthws/conky#20

+ exec not work at first iteration:
brndnmtthws/conky#112
iiey added a commit to iiey/dotfiles that referenced this issue Jul 29, 2019
Need to do it manually.
New version not completely backward compatible with old format. E.g.:
double_buffer = yes --> crash!

Using /usr/share/doc/conky-all/convert.lua
New format from release 1.10.x

Known issues in conky 1.10.x (2016):
+ if_match fail with locale:
brndnmtthws/conky#20

+ exec not work at first iteration:
brndnmtthws/conky#112
iiey added a commit to iiey/dotfiles that referenced this issue May 2, 2020
Need to do it manually.
New version not completely backward compatible with old format. E.g.:
double_buffer = yes --> crash!

Using /usr/share/doc/conky-all/convert.lua
New format from release 1.10.x

Known issues in conky 1.10.x (2016):
+ if_match fail with locale:
brndnmtthws/conky#20

+ exec not work at first iteration:
brndnmtthws/conky#112
iiey added a commit to iiey/dotfiles that referenced this issue May 2, 2020
Need to do it manually.
New version not completely backward compatible with old format. E.g.:
double_buffer = yes --> crash!

Using /usr/share/doc/conky-all/convert.lua
New format from release 1.10.x

Known issues in conky 1.10.x (2016):
+ if_match fail with locale:
brndnmtthws/conky#20

+ exec not work at first iteration:
brndnmtthws/conky#112
iiey added a commit to iiey/dotfiles that referenced this issue Jun 17, 2021
Need to do it manually.
New version not completely backward compatible with old format. E.g.:
double_buffer = yes --> crash!

Using /usr/share/doc/conky-all/convert.lua
New format from release 1.10.x

Known issues in conky 1.10.x (2016):
+ if_match fail with locale:
brndnmtthws/conky#20

+ exec not work at first iteration:
brndnmtthws/conky#112
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report or bug fix PR
Projects
None yet
Development

No branches or pull requests

5 participants