Skip to content

Commit

Permalink
Merge pull request openSUSE#871 from aschnell/master
Browse files Browse the repository at this point in the history
- select table style based on codeset
  • Loading branch information
aschnell authored Feb 16, 2024
2 parents aa20cd7 + 1636dc3 commit 6d5b3a8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
6 changes: 3 additions & 3 deletions client/GlobalOptions.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) [2019-2023] SUSE LLC
* Copyright (c) [2019-2024] SUSE LLC
*
* All Rights Reserved.
*
Expand Down Expand Up @@ -122,7 +122,7 @@ namespace snapper
{
ParsedOpts::const_iterator it = opts.find("table-style");
if (it == opts.end())
return TableFormatter::default_style;
return TableFormatter::default_style();

try
{
Expand All @@ -141,7 +141,7 @@ namespace snapper
SN_THROW(OptionsException(error));
}

return TableFormatter::default_style;
return TableFormatter::default_style();
}


Expand Down
11 changes: 9 additions & 2 deletions client/utils/TableFormatter.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) [2019-2020] SUSE LLC
* Copyright (c) [2019-2024] SUSE LLC
*
* All Rights Reserved.
*
Expand All @@ -20,6 +20,9 @@
*/


#include <cstring>
#include <langinfo.h>

#include "client/utils/TableFormatter.h"


Expand All @@ -29,7 +32,11 @@ namespace snapper
using namespace std;


const TableStyle TableFormatter::default_style = Ascii;
TableStyle
TableFormatter::default_style()
{
return strcmp(nl_langinfo(CODESET), "UTF-8") == 0 ? TableStyle::Light : TableStyle::Ascii;
}


ostream&
Expand Down
4 changes: 2 additions & 2 deletions client/utils/TableFormatter.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) [2019-2020] SUSE LLC
* Copyright (c) [2019-2024] SUSE LLC
*
* All Rights Reserved.
*
Expand Down Expand Up @@ -41,7 +41,7 @@ namespace snapper

public:

static const TableStyle default_style;
static TableStyle default_style();

TableFormatter(TableStyle style) : style(style) {}

Expand Down
5 changes: 5 additions & 0 deletions package/snapper.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
-------------------------------------------------------------------
Fri Feb 16 08:26:41 CET 2024 - [email protected]

- select table style based on codeset

-------------------------------------------------------------------
Wed Feb 14 09:14:32 CET 2024 - [email protected]

Expand Down

0 comments on commit 6d5b3a8

Please sign in to comment.