Skip to content
This repository has been archived by the owner on Sep 24, 2019. It is now read-only.

Commit

Permalink
Use uint16_t instead of uint for better POSIX compliance
Browse files Browse the repository at this point in the history
uint works with glibc, but not with musl
  • Loading branch information
lutter committed Jun 26, 2017
1 parent e4b899a commit 3ae80e2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 5 additions & 2 deletions exe/ralsh.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <libral/emitter/json_emitter.hpp>
#include <libral/emitter/quiet_emitter.hpp>

#include <stdint.h>

#include <iomanip>

#include <config.hpp>
Expand All @@ -17,6 +19,7 @@
// cause problems before including the headers, then re-enable the warnings.
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattributes"
#pragma GCC diagnostic ignored "-Wsuggest-override"
#include <boost/program_options.hpp>
#pragma GCC diagnostic pop

Expand Down Expand Up @@ -81,7 +84,7 @@ R"txt(Exit status:

static void print_attr_explanation(const std::string& name,
const lib::attr::spec& attr,
uint maxlen) {
uint16_t maxlen) {
cout << " " << color::green << left << setw(maxlen)
<< name << color::reset
<< " : " << attr.desc() << endl;
Expand All @@ -102,7 +105,7 @@ static void print_explanation(lib::type& type) {
return;
}

uint maxlen = 0;
uint16_t maxlen = 0;
for (auto a = spec->attr_begin(); a != spec->attr_end(); ++a) {
if (a->first.length() > maxlen) maxlen = a->first.length();
}
Expand Down
4 changes: 3 additions & 1 deletion lib/inc/libral/emitter/puppet_emitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

#include <libral/emitter/emitter.hpp>

#include <stdint.h>

namespace libral {
class puppet_emitter : public emitter {
public:
Expand All @@ -21,6 +23,6 @@ namespace libral {
void print_resource(const type &type, const resource &resource);
void print_resource_attr(const std::string& name,
const value& v,
uint maxlen);
uint16_t maxlen);
};
}
4 changes: 2 additions & 2 deletions lib/src/emitter/puppet_emitter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ namespace libral {
void puppet_emitter::print_resource(const type &type, const resource &res) {
std::cout << color::blue << type.qname() << color::reset << " { '"
<< color::blue << res.name() << color::reset << "':" << std::endl;
uint maxlen = 0;
uint16_t maxlen = 0;
for (const auto& a : res.attrs()) {
if (a.first.length() > maxlen) maxlen = a.first.length();
}
Expand All @@ -97,7 +97,7 @@ namespace libral {

void puppet_emitter::print_resource_attr(const std::string& name,
const value& v,
uint maxlen) {
uint16_t maxlen) {
std::cout << " " << color::green << std::left << std::setw(maxlen)
<< name << color::reset
<< " => " << v << "," << std::endl;
Expand Down

0 comments on commit 3ae80e2

Please sign in to comment.