Skip to content

Commit 5a50531

Browse files
committed
Formatting improvements.
1 parent 4db634f commit 5a50531

File tree

3 files changed

+54
-25
lines changed

3 files changed

+54
-25
lines changed

po/de/subnetcalc.po

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: \"subnetcalc\" \"2.5.2~rc0\"\n"
1010
"Report-Msgid-Bugs-To: \"https://github.com/dreibh/system-tools/issues\"\n"
11-
"POT-Creation-Date: 2024-10-19 20:53+0200\n"
11+
"POT-Creation-Date: 2024-10-20 17:56+0200\n"
1212
"PO-Revision-Date: 2024-10-19 18:40+0200\n"
1313
"Last-Translator: Thomas Dreibholz <[email protected]>\n"
1414
"Language-Team:\n"
@@ -42,6 +42,12 @@ msgstr "FEHLER: Lesen von %s nicht möglich!"
4242
msgid "ERROR: Unable to open %s!"
4343
msgstr "FEHLER: %s konnte nicht geöffnet werden!"
4444

45+
#: src/subnetcalc.cc:427 src/subnetcalc.cc:435 src/subnetcalc.cc:451
46+
#: src/subnetcalc.cc:464 src/subnetcalc.cc:474
47+
#, c-format
48+
msgid "%-32s"
49+
msgstr "%-32s"
50+
4551
#: src/subnetcalc.cc:427
4652
msgid "Global ID"
4753
msgstr "Globale ID"
@@ -62,6 +68,14 @@ msgstr "MAC-Adresse"
6268
msgid "Solicited Node Multicast Address"
6369
msgstr "Solicited Node Multicastadresse"
6470

71+
#: src/subnetcalc.cc:491 src/subnetcalc.cc:876 src/subnetcalc.cc:879
72+
#: src/subnetcalc.cc:881 src/subnetcalc.cc:884 src/subnetcalc.cc:893
73+
#: src/subnetcalc.cc:898 src/subnetcalc.cc:901 src/subnetcalc.cc:913
74+
#: src/subnetcalc.cc:915
75+
#, c-format
76+
msgid "%-14s"
77+
msgstr "%-14s"
78+
6579
#: src/subnetcalc.cc:491
6680
msgid "Properties"
6781
msgstr "Eigenschaften"

po/nb/subnetcalc.po

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: \"subnetcalc\" \"2.5.2~rc0\"\n"
1010
"Report-Msgid-Bugs-To: \"https://github.com/dreibh/system-tools/issues\"\n"
11-
"POT-Creation-Date: 2024-10-19 20:53+0200\n"
11+
"POT-Creation-Date: 2024-10-20 17:56+0200\n"
1212
"PO-Revision-Date: 2024-10-19 18:40+0200\n"
1313
"Last-Translator: Thomas Dreibholz <[email protected]>\n"
1414
"Language-Team:\n"
@@ -40,6 +40,12 @@ msgstr "FEIL: Kan ikke lese fra %s!"
4040
msgid "ERROR: Unable to open %s!"
4141
msgstr "FEIL: Kan ikke åpne %s!"
4242

43+
#: src/subnetcalc.cc:427 src/subnetcalc.cc:435 src/subnetcalc.cc:451
44+
#: src/subnetcalc.cc:464 src/subnetcalc.cc:474
45+
#, c-format
46+
msgid "%-32s"
47+
msgstr "%-32s"
48+
4349
#: src/subnetcalc.cc:427
4450
msgid "Global ID"
4551
msgstr "Global-ID"
@@ -60,6 +66,14 @@ msgstr "MAC-adresse"
6066
msgid "Solicited Node Multicast Address"
6167
msgstr "Solicited Node Multicast-adresse"
6268

69+
#: src/subnetcalc.cc:491 src/subnetcalc.cc:876 src/subnetcalc.cc:879
70+
#: src/subnetcalc.cc:881 src/subnetcalc.cc:884 src/subnetcalc.cc:893
71+
#: src/subnetcalc.cc:898 src/subnetcalc.cc:901 src/subnetcalc.cc:913
72+
#: src/subnetcalc.cc:915
73+
#, c-format
74+
msgid "%-14s"
75+
msgstr "%-14s"
76+
6377
#: src/subnetcalc.cc:491
6478
msgid "Properties"
6579
msgstr "Egenskaper"

src/subnetcalc.cc

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -424,15 +424,15 @@ void printUnicastProperties(std::ostream& os,
424424
ntohs(ipv6address.s6_addr16[0]) & 0xff,
425425
ntohs(ipv6address.s6_addr16[1]),
426426
ntohs(ipv6address.s6_addr16[2]));
427-
os << " + " << format("%-32s = %s", gettext("Global ID"), globalIDString) << "\n";
427+
os << " + " << format(gettext("%-32s"), gettext("Global ID")) << " = " << globalIDString << "\n";
428428
}
429429

430430
// ====== Subnet ID ======================================================
431431
if(hasSubnetID) {
432432
char subnetIDString[16];
433433
const uint16_t subnetID = ntohs(ipv6address.s6_addr16[3]);
434434
snprintf((char*)&subnetIDString, sizeof(subnetIDString), "%04x", subnetID);
435-
os << " + " << format("%-32s = %s", gettext("Subnet ID"), subnetIDString) << "\n";
435+
os << " + " << format(gettext("%-32s"), gettext("Subnet ID")) << " = " << subnetIDString << "\n";
436436
}
437437

438438
// ====== Interface ID ===================================================
@@ -448,7 +448,7 @@ void printUnicastProperties(std::ostream& os,
448448
(interfaceID[1] & 0xff00) >> 8, (interfaceID[1] & 0x00ff),
449449
(interfaceID[2] & 0xff00) >> 8, (interfaceID[2] & 0x00ff),
450450
interfaceID[3]);
451-
os << " + " << format("%-32s = %s", gettext("Interface ID"), interfaceIDString) << "\n";
451+
os << " + " << format(gettext("%-32s"), gettext("Interface ID")) << " = " << interfaceIDString << "\n";
452452

453453
if( ((interfaceID[1] & 0x00ff) == 0x00ff) &&
454454
((interfaceID[2] & 0xff00) == 0xfe00) ) {
@@ -461,7 +461,7 @@ void printUnicastProperties(std::ostream& os,
461461
ipv6address.s6_addr[13],
462462
ipv6address.s6_addr[14],
463463
ipv6address.s6_addr[15]);
464-
os << " + " << format("%-32s = %s", gettext("MAC Address"), interfaceIDString) << "\n";
464+
os << " + " << format(gettext("%-32s"), gettext("MAC Address")) << " = " << interfaceIDString << "\n";
465465
}
466466

467467
// ====== Solicited Node Multicast Address ===============================
@@ -471,7 +471,7 @@ void printUnicastProperties(std::ostream& os,
471471
"ff02::1:ff%02x:%04x"),
472472
ntohs(ipv6address.s6_addr16[6]) & 0xff,
473473
ntohs(ipv6address.s6_addr16[7]));
474-
os << " + " << format("%-32s = %s", gettext("Solicited Node Multicast Address"), snmcAddressString) << "\n";
474+
os << " + " << format(gettext("%-32s"), gettext("Solicited Node Multicast Address")) << " = " << snmcAddressString << "\n";
475475
}
476476

477477

@@ -488,7 +488,7 @@ void printAddressProperties(std::ostream& os,
488488
address2string(&address.sa, addressString, sizeof(addressString), false, false);
489489

490490
// ====== Common properties ==============================================
491-
os << format("%-16s", gettext("Properties")) << " = \n";
491+
os << format(gettext("%-14s"), gettext("Properties")) << " = \n";
492492
os << " - ";
493493
if(isMulticast(address)) {
494494
os << format(gettext("%s is a MULTICAST address"), addressString);
@@ -873,15 +873,16 @@ int main(int argc, char** argv)
873873

874874

875875
// ====== Print results ==================================================
876-
std::cout << format("%-16s", gettext("Address")) << " = "
876+
std::cout << format(gettext("%-14s"), gettext("Address")) << " = "
877877
<< address << "\n";
878-
printAddressBinary(std::cout, address, prefix, colourMode, " ");
879-
std::cout << format("%-16s", gettext("Network")) << " = "
878+
printAddressBinary(std::cout, address, prefix, colourMode,
879+
(format(gettext("%-14s"), " ") + " ").c_str());
880+
std::cout << format(gettext("%-14s"), gettext("Network")) << " = "
880881
<< network << " / " << prefix << "\n"
881-
<< format("%-16s", gettext("Netmask")) << " = "
882+
<< format(gettext("%-14s"), gettext("Netmask")) << " = "
882883
<< netmask << "\n";
883884
if(isIPv4(address)) {
884-
std::cout << format("%-16s", gettext("Broadcast")) << " = ";
885+
std::cout << format(gettext("%-14s"), gettext("Broadcast")) << " = ";
885886
if(reservedHosts == 2) {
886887
std::cout << broadcast;
887888
}
@@ -890,15 +891,15 @@ int main(int argc, char** argv)
890891
}
891892
std::cout << "\n";
892893
}
893-
std::cout << format("%-16s", gettext("Wildcard Mask"))
894+
std::cout << format(gettext("%-14s"), gettext("Wildcard Mask"))
894895
<< " = " << wildcard << "\n";
895896
if(isIPv4(address)) {
896897
char hex[16];
897898
snprintf((char*)&hex, sizeof(hex), "%08X", ntohl(address.in.sin_addr.s_addr));
898-
std::cout << format("%-16s", gettext("Hex. Address"))
899+
std::cout << format(gettext("%-14s"), gettext("Hex. Address"))
899900
<< " = " << hex << "\n";
900901
}
901-
std::cout << format("%-16s", gettext("Hosts Bits")) << " = "
902+
std::cout << format(gettext("%-14s"), gettext("Hosts Bits")) << " = "
902903
<< hostBits << "\n";
903904
if(!isMulticast(address)) {
904905
char maxHostsString[128];
@@ -910,9 +911,9 @@ int main(int argc, char** argv)
910911
snprintf((char*)&maxHostsString, sizeof(maxHostsString),
911912
"2^%u - %u", hostBits, reservedHosts);
912913
}
913-
std::cout << format("%-16s", gettext("Max. Hosts")) << " = "
914+
std::cout << format(gettext("%-14s"), gettext("Max. Hosts")) << " = "
914915
<< maxHostsString << "\n"
915-
<< format("%-16s", gettext("Host Range")) << " = { "
916+
<< format(gettext("%-14s"), gettext("Host Range")) << " = { "
916917
<< host1 << " - " << host2 << " }" << "\n";
917918
}
918919

@@ -936,15 +937,15 @@ int main(int argc, char** argv)
936937
GeoIP* geoIP = GeoIP_open_type(GEOIP_ASNUM_EDITION, GEOIP_STANDARD);
937938
if(geoIP) {
938939
const char* org = GeoIP_name_by_ipnum(geoIP, ntohl(address.in.sin_addr.s_addr));
939-
std::cout << format("%-16s = ", gettext("GeoIP AS Info"))
940+
std::cout << format("%-14s = ", gettext("GeoIP AS Info"))
940941
<< ((org != nullptr) ? org : "Unknown") << "\n";
941942
GeoIP_delete(geoIP);
942943
}
943944
geoIP = GeoIP_open_type(GEOIP_COUNTRY_EDITION, GEOIP_STANDARD);
944945
if(geoIP) {
945946
country = GeoIP_country_name_by_ipnum(geoIP, ntohl(address.in.sin_addr.s_addr));
946947
code = GeoIP_country_code_by_ipnum(geoIP, ntohl(address.in.sin_addr.s_addr));
947-
std::cout << format("%-16s = ", gettext("GeoIP Country"))
948+
std::cout << format("%-14s = ", gettext("GeoIP Country"))
948949
<< ((country != nullptr) ? country: "Unknown")
949950
<< " (" << ((code != nullptr) ? code : "??") << ")" << "\n";
950951
GeoIP_delete(geoIP);
@@ -955,7 +956,7 @@ int main(int argc, char** argv)
955956
if(gir != nullptr) {
956957
const char* timeZone = GeoIP_time_zone_by_country_and_region(
957958
gir->country_code, gir->region);
958-
std::cout << format("%-16s = ", gettext("GeoIP Region"))
959+
std::cout << format("%-14s = ", gettext("GeoIP Region"))
959960
<< ((gir->postal_code != nullptr) ? gir->postal_code : "")
960961
<< ((gir->postal_code != nullptr) ? " " : "")
961962
<< ((gir->city != nullptr) ? gir->city : "Unknown")
@@ -977,15 +978,15 @@ int main(int argc, char** argv)
977978
GeoIP* geoIP = GeoIP_open_type(GEOIP_ASNUM_EDITION_V6, GEOIP_STANDARD);
978979
if(geoIP) {
979980
const char* org = GeoIP_name_by_ipnum_v6(geoIP, address.in6.sin6_addr);
980-
std::cout << format("%-16s = ", gettext("GeoIP AS Info"))
981+
std::cout << format("%-14s = ", gettext("GeoIP AS Info"))
981982
<< ((org != nullptr) ? org : "Unknown") << "\n";
982983
GeoIP_delete(geoIP);
983984
}
984985
geoIP = GeoIP_open_type(GEOIP_COUNTRY_EDITION_V6, GEOIP_STANDARD);
985986
if(geoIP) {
986987
country = GeoIP_country_name_by_ipnum_v6(geoIP, address.in6.sin6_addr);
987988
code = GeoIP_country_code_by_ipnum_v6(geoIP, address.in6.sin6_addr);
988-
std::cout << format("%-16s = ", gettext("GeoIP Country"))
989+
std::cout << format("%-14s = ", gettext("GeoIP Country"))
989990
<< ((country != nullptr) ? country: "Unknown")
990991
<< " (" << ((code != nullptr) ? code : "??") << ")" << "\n";
991992
GeoIP_delete(geoIP);
@@ -996,7 +997,7 @@ int main(int argc, char** argv)
996997
if(gir != nullptr) {
997998
const char* timeZone = GeoIP_time_zone_by_country_and_region(
998999
gir->country_code, gir->region);
999-
std::cout << format("%-16s = ", gettext("GeoIP Region"))
1000+
std::cout << format("%-14s = ", gettext("GeoIP Region"))
10001001
<< ((gir->postal_code != nullptr) ? gir->postal_code : "")
10011002
<< ((gir->postal_code != nullptr) ? " " : "")
10021003
<< ((gir->city != nullptr) ? gir->city : "Unknown")
@@ -1037,7 +1038,7 @@ int main(int argc, char** argv)
10371038
#endif
10381039
);
10391040
std::cout << "\r\x1b[K"
1040-
<< format("%-16s = ", gettext("DNS Hostname"));
1041+
<< format("%-14s = ", gettext("DNS Hostname"));
10411042
std::cout.flush();
10421043
if(error == 0) {
10431044
std::cout << hostname << "\n";

0 commit comments

Comments
 (0)